idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
25,000 | public function registerServices ( ServiceProviderInterface $ serviceProvider ) { $ services = $ serviceProvider -> getServices ( ) ; foreach ( $ services as $ id => $ service ) { if ( $ this -> has ( $ id ) == false ) { $ this -> set ( $ id , $ service ) ; } } } | Add services to the container |
25,001 | protected function getBestLanguage ( Request $ request , $ default = null ) { foreach ( $ request -> getLanguages ( ) as $ language ) { if ( strpos ( $ language , '_' ) !== false ) { return $ language ; } } return $ default ; } | Finds the best language for a given request . |
25,002 | public static function get ( $ nickname ) { try { $ lang = App :: getLocale ( ) ; $ modelClass = config ( 'sirgrimorum.transarticles.default_articles_model' ) ; $ langColumn = config ( 'sirgrimorum.transarticles.default_lang_column' ) ; $ findArticle = config ( 'sirgrimorum.transarticles.default_findarticle_function_name' ) ; $ article = $ modelClass :: { $ findArticle } ( $ nickname ) -> where ( $ langColumn , "=" , $ lang ) -> first ( ) ; if ( $ article ) { return $ article -> content ; } else { $ article = $ modelClass :: { $ findArticle } ( $ nickname ) -> first ( ) ; if ( $ article ) { return $ article -> content . "<small><span class='label label-warning'>" . $ article -> { $ langColumn } . "</span></small>" ; } else { return $ nickname ; } } } catch ( Exception $ ex ) { return $ nickname . "<pre class='label label-warning'>" . print_r ( [ $ ex -> getMessage ( ) , $ ex -> getTraceAsString ( ) ] , true ) . "</pre>" ; } } | Return the translation for the article |
25,003 | public static function getjs ( $ scope , $ basevar = '' ) { if ( $ basevar == '' ) { $ basevar = config ( 'sirgrimorum.transarticles.default_base_var' ) ; } $ lang = App :: getLocale ( ) ; $ listo = false ; try { $ modelClass = config ( 'sirgrimorum.transarticles.default_articles_model' ) ; $ langColumn = config ( 'sirgrimorum.transarticles.default_lang_column' ) ; $ findArticles = config ( 'sirgrimorum.transarticles.default_findarticles_function_name' ) ; $ findArticle = config ( 'sirgrimorum.transarticles.default_findarticle_function_name' ) ; $ articles = $ modelClass :: { $ findArticles } ( $ scope ) -> where ( $ langColumn , "=" , $ lang ) -> get ( ) ; if ( $ articles ) { $ listo = true ; } else { $ articles = $ modelClass :: { $ findArticles } ( $ scope ) -> get ( ) ; if ( $ articles ) { $ listo = true ; } else { $ articles = $ modelClass :: { $ findArticle } ( $ scope ) -> where ( $ langColumn , "=" , $ lang ) -> first ( ) ; $ listo = false ; if ( $ articles ) { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ articles -> content ) ; } else { $ articles = $ modelClass :: { $ findArticle } ( $ scope ) -> first ( ) ; if ( $ articles ) { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ articles -> content ) ; } else { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ scope ) ; } } } } } catch ( Exception $ ex ) { return $ scope . " - Error:" . print_r ( $ ex -> getMessage ( ) , true ) ; } if ( $ listo ) { if ( $ articles ) { $ trans = [ ] ; foreach ( $ articles as $ article ) { $ trans [ $ article -> nickname ] = $ article -> content ; } $ jsarray = json_encode ( $ trans ) ; return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar}.{$scope} = {$jsarray};</script>" ; } else { $ jsarray = [ ] ; data_fill ( $ jsarray , $ scope , $ scope ) ; } } $ jsarray = json_encode ( $ jsarray ) ; return "<script>window.{$basevar} = window.{$basevar} || {};{$basevar} = {$jsarray};</script>" ; } | return the JavaScript from article table |
25,004 | protected function getThemeConfigurationFiles ( Container $ app ) { $ files = [ ] ; $ config_path = $ app -> make ( 'config' ) -> get ( 'theme.config_path' , realpath ( $ app -> make ( 'wp.theme' ) -> getRoot ( ) ) . '/config' ) ; if ( file_exists ( $ config_path ) && is_dir ( $ config_path ) ) { foreach ( Finder :: create ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ config_path ) as $ file ) { $ nesting = $ this -> getThemeConfigurationNesting ( $ file , $ config_path ) ; $ files [ $ nesting . basename ( $ file -> getRealPath ( ) , '.php' ) ] = $ file -> getRealPath ( ) ; } } return $ files ; } | Get all of the configuration files for the theme . |
25,005 | public function getParameters ( $ page = null , $ limit = null ) { $ params = $ this -> params ; $ params [ $ this -> pageParam ] = null == $ page ? $ this -> getPage ( ) : $ page ; $ params [ $ this -> limitParam ] = null == $ limit ? $ this -> getLimit ( ) : $ limit ; return $ params ; } | Handles parsing through parameters array |
25,006 | public function setApiKey ( $ key ) { $ this -> apiKey = $ key ; return $ this -> apiKey === $ key ? true : false ; } | Set API key |
25,007 | public function setApiEndpoint ( $ url ) { $ this -> apiEndpoint = $ url ; return $ this -> apiEndpoint === $ url ? true : false ; } | Set API URL |
25,008 | public function setApiQueryStringRequestFormat ( $ format ) { $ this -> apiQueryStringRequestFormat = $ format ; return $ this -> apiQueryStringRequestFormat === $ format ? true : false ; } | Set API URL REST format Used as format for sprintf to inject parameters into the URL string . |
25,009 | private function ensureNodeClass ( DOMNode $ node ) { $ class = $ this -> nodeClasses [ 'DOMElement' ] ; if ( true !== ( $ node instanceof $ class ) && $ node instanceof \ DOMElement ) { return $ node -> ownerDocument -> importNode ( $ node , true ) ; } return $ node ; } | Workarround for hhvm issue |
25,010 | private static function uuid4 ( ) { $ bytes = function_exists ( 'openssl_random_pseudo_bytes' ) ? openssl_random_pseudo_bytes ( 16 ) : self :: generateBytes ( 16 ) ; $ hash = bin2hex ( $ bytes ) ; $ timeHi = hexdec ( substr ( $ hash , 12 , 4 ) ) & 0x0fff ; $ timeHi &= ~ ( 0xf000 ) ; $ timeHi |= 4 << 12 ; $ clockSeqHi = hexdec ( substr ( $ hash , 16 , 2 ) ) & 0x3f ; $ clockSeqHi &= ~ ( 0xc0 ) ; $ clockSeqHi |= 0x80 ; $ fields = [ 'time_low' => substr ( $ hash , 0 , 8 ) , 'time_mid' => substr ( $ hash , 8 , 4 ) , 'time_hi_and_version' => sprintf ( '%04x' , $ timeHi ) , 'clock_seq_hi_and_reserved' => sprintf ( '%02x' , $ clockSeqHi ) , 'clock_seq_low' => substr ( $ hash , 18 , 2 ) , 'node' => substr ( $ hash , 20 , 12 ) , ] ; return vsprintf ( '%08s-%04s-%04s-%02s%02s-%012s' , $ fields ) ; } | Returns a version 4 UUID |
25,011 | public function validateApiKeys ( array $ keys ) { if ( empty ( $ keys ) ) { throw new InvalidArgumentException ( 'No API keys specified' , 401 ) ; } foreach ( $ keys as $ key ) { $ this -> validateApiKey ( $ key ) ; } return $ this ; } | Validates the given API keys . |
25,012 | public function validateDeveloperKey ( $ key ) { if ( '' === $ key ) { return $ this ; } if ( ! is_string ( $ key ) || strlen ( $ key ) !== 48 ) { throw new InvalidArgumentException ( 'Developer key must be a string of exactly 48 characters' , 401 ) ; } return $ this ; } | Validates the given developer key . |
25,013 | public function validateApplication ( $ application ) { if ( ! is_string ( $ application ) || strlen ( $ application ) > 256 || strlen ( $ application ) < 1 ) { throw new InvalidArgumentException ( 'Application name must be a non empty string of at most 256 ' . 'characters' , 400 ) ; } return $ this ; } | Validates the given application name . |
25,014 | public function validateEvent ( $ event ) { if ( ! is_string ( $ event ) || strlen ( $ event ) > 1000 || strlen ( $ event ) < 1 ) { throw new InvalidArgumentException ( 'Event name must be a non empty string of at most 1,000 ' . 'characters' , 400 ) ; } return $ this ; } | Validates the given event name . |
25,015 | public function validateDescription ( $ event ) { if ( ! is_string ( $ event ) || strlen ( $ event ) > 10000 || strlen ( $ event ) < 1 ) { throw new InvalidArgumentException ( 'Event description must be a non empty string of at most ' . '10,000 characters' , 400 ) ; } return $ this ; } | Validates the given event description . |
25,016 | public function validateUrl ( $ url ) { if ( '' === $ url ) { return $ this ; } if ( ! is_string ( $ url ) || strlen ( $ url ) > 2000 ) { throw new InvalidArgumentException ( 'URL must be a string of at most 2,000 characters' , 400 ) ; } return $ this ; } | Validates the given URL . |
25,017 | public function load ( $ ofxFile ) { $ content = file_get_contents ( $ ofxFile ) ; $ inicio = stripos ( $ content , '<OFX>' ) ; $ header = trim ( substr ( $ content , 0 , $ inicio ) ) ; $ this -> headers = $ this -> headers ( $ header ) ; $ content = str_replace ( $ header , '' , $ content ) ; $ dom = new \ DOMDocument ( ) ; $ dom -> loadXML ( $ content ) ; $ this -> saldoTotal = $ dom -> getElementsByTagName ( 'BALAMT' ) -> item ( 0 ) -> textContent ; $ this -> dataInicial = $ this -> date ( $ dom -> getElementsByTagName ( 'DTSTART' ) -> item ( 0 ) -> textContent ) ; $ this -> dataFinal = $ this -> date ( $ dom -> getElementsByTagName ( 'DTEND' ) -> item ( 0 ) -> textContent ) ; $ this -> conta -> banco = $ dom -> getElementsByTagName ( 'BANKID' ) -> item ( 0 ) -> textContent ; $ this -> conta -> numConta = substr ( $ dom -> getElementsByTagName ( 'ACCTID' ) -> item ( 0 ) -> textContent , 5 ) ; $ this -> conta -> agencia = substr ( $ dom -> getElementsByTagName ( 'ACCTID' ) -> item ( 0 ) -> textContent , 0 , 5 ) ; foreach ( $ dom -> getElementsByTagName ( 'STMTTRN' ) as $ item ) { $ transacao = new Transacao ( ) ; $ transacao -> tipo = $ item -> getElementsByTagName ( 'TRNTYPE' ) -> item ( 0 ) -> textContent ; $ transacao -> valor = $ item -> getElementsByTagName ( 'TRNAMT' ) -> item ( 0 ) -> textContent ; $ transacao -> descricao = $ item -> getElementsByTagName ( 'MEMO' ) -> item ( 0 ) -> textContent ; $ transacao -> data = $ this -> date ( $ item -> getElementsByTagName ( 'DTPOSTED' ) -> item ( 0 ) -> textContent ) ; $ transacao -> checkNum = $ item -> getElementsByTagName ( 'CHECKNUM' ) -> item ( 0 ) -> textContent ; $ transacao -> transacaoId = $ item -> getElementsByTagName ( 'FITID' ) -> item ( 0 ) -> textContent ; $ this -> transacoes [ ] = $ transacao ; } } | Load an OfxFile . |
25,018 | public static function flatten ( array $ array ) { $ out = [ ] ; foreach ( new RecursiveIteratorIterator ( new RecursiveArrayIterator ( $ array ) ) as $ key => $ item ) { if ( is_int ( $ key ) ) { $ out [ ] = $ item ; } else { $ out [ $ key ] = $ item ; } } return $ out ; } | Flattens a multidimensional array . |
25,019 | public static function pluck ( array $ array , $ key ) { return array_map ( function ( $ item ) use ( $ key ) { return is_object ( $ item ) ? $ item -> $ key : $ item [ $ key ] ; } , $ array ) ; } | Plucks values by key from a list of arrays or objects . |
25,020 | public static function zip ( ) { $ args = func_get_args ( ) ; $ count = count ( $ args ) ; $ out = [ ] ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ out [ $ i ] = self :: pluck ( $ i , $ args ) ; } return $ out ; } | Zips to or more arrays |
25,021 | public static function max ( array $ args ) { uasort ( $ args , function ( $ a , $ b ) { return count ( $ a ) < count ( $ b ) ? 1 : - 1 ; } ) ; return count ( reset ( $ args ) ) ; } | Get the highest value . |
25,022 | public static function min ( array $ args ) { usort ( $ args , function ( $ a , $ b ) { return count ( $ a ) < count ( $ b ) ? 1 : - 1 ; } ) ; return count ( end ( $ args ) ) ; } | Get the lowest value . |
25,023 | public static function get ( array $ array , $ namespace = null , $ separator = '.' ) { if ( ! is_string ( $ namespace ) ) { return $ array ; } $ keys = explode ( $ separator , $ namespace ) ; while ( count ( $ keys ) > 0 and ! is_null ( $ array ) ) { $ key = array_shift ( $ keys ) ; $ array = isset ( $ array [ $ key ] ) ? $ array [ $ key ] : null ; } return $ array ; } | Getter for multidimensional arrays . |
25,024 | public static function set ( array & $ input , $ namespace , $ value , $ separator = '.' ) { $ keys = explode ( $ separator , $ namespace ) ; $ pointer = & $ input ; while ( count ( $ keys ) > 0 ) { $ key = array_shift ( $ keys ) ; $ pointer [ $ key ] = isset ( $ pointer [ $ key ] ) ? $ pointer [ $ key ] : [ ] ; $ pointer = & $ pointer [ $ key ] ; } $ pointer = $ value ; return $ input ; } | Sets a segmented string to an array |
25,025 | public static function unsetKey ( array & $ array , $ namespace , $ separator = '.' ) { if ( ! is_string ( $ namespace ) ) { return $ array ; } $ keys = explode ( $ separator , $ namespace ) ; while ( ( $ count = count ( $ keys ) ) > 0 and ! is_null ( $ array ) ) { $ key = array_shift ( $ keys ) ; if ( isset ( $ array [ $ key ] ) ) { if ( $ count < 2 ) { unset ( $ array [ $ key ] ) ; } else { $ array = & $ array [ $ key ] ; } } } } | Unsets a value from a multidimensional array |
25,026 | public static function compact ( $ array , $ reindex = false ) { $ out = array_filter ( $ array , function ( $ item ) { return false !== ( bool ) $ item ; } ) ; return false !== $ reindex && self :: isList ( $ out ) ? array_values ( $ out ) : $ out ; } | Filters out boolish items that resemble none truthy values . |
25,027 | public function get ( $ name ) { if ( array_key_exists ( $ name , $ this -> properties ) ) { return $ this -> properties [ $ name ] ; } elseif ( array_key_exists ( $ name , $ this -> dynamic ) ) { return $ this -> dynamic [ $ name ] ( ) ; } else { return ; } } | Returns the property value of the questioned keyname . |
25,028 | public function getAllProperties ( ) { $ props = array ( ) ; foreach ( $ this -> dynamic as $ k => $ c ) { $ props [ $ k ] = $ c ( ) ; } return array_replace ( $ props , $ this -> properties ) ; } | returns all the properties in an array . |
25,029 | public function startSection ( $ name , $ content = null ) { $ section = $ this -> getSectionCollection ( ) -> findOrCreate ( $ name ) ; $ content ? $ section -> setContent ( $ content ) : $ section -> setContent ( '' ) -> start ( ) ; return $ this ; } | Starts a section . If content is passed section doesn t not use blocks |
25,030 | public function appendSection ( $ name , $ content = null ) { $ section = $ this -> getSectionCollection ( ) -> findOrCreate ( $ name ) ; $ content ? $ section -> appendContent ( $ content ) : $ section -> start ( ) ; } | Append in a section . If content is passed section doesn t not use blocks |
25,031 | public function getSection ( $ name , $ default = '' ) { if ( $ this -> getSectionCollection ( ) -> has ( $ name ) ) { return $ this -> getSectionCollection ( ) -> get ( $ name ) ; } return $ default ; } | Gives the value of a initialized section |
25,032 | public function includes ( $ view , $ data = [ ] ) { $ factory = $ this -> getFactory ( ) ; $ filename = $ factory -> getFinder ( ) -> find ( $ view ) ; $ context = new static ( $ factory ) ; $ context -> setSectionCollection ( $ this -> getSectionCollection ( ) ) ; return new View ( $ filename , $ data , $ context ) ; } | Create a view in current context . Is useful for create view inside another . |
25,033 | protected function validate ( $ var , $ ruleset = null , $ locale = null , $ lib = '\Enola\Lib\Validation\ValidationFields' , $ dir = null ) { $ validation = new $ lib ( $ locale ) ; if ( $ dir == null ) { $ dir = PATHAPP . 'src/content/messages' ; } $ validation -> dir_content = $ dir ; $ ruleset = $ ruleset != null ? $ ruleset : $ this -> configValidation ( ) ; if ( is_object ( $ var ) ) { $ reflection = new Reflection ( $ var ) ; foreach ( $ ruleset as $ key => $ regla ) { $ validation -> add_rule ( $ key , $ reflection -> getProperty ( $ key ) , $ regla ) ; } } else { foreach ( $ ruleset as $ key => $ regla ) { $ field = isset ( $ var [ $ key ] ) ? $ var [ $ key ] : NULL ; $ validation -> add_rule ( $ key , $ field , $ regla ) ; } } if ( ! $ validation -> validate ( ) ) { $ this -> errors = $ validation -> error_messages ( ) ; return FALSE ; } else { return TRUE ; } } | Valida las variables de un objeto o de un array en base a una definicion de configuracion de validacion Se puede utilizar la libreria que se desee pere debe respetar la inerfaz de la proporcionada por el framework . |
25,034 | protected function injectDependency ( $ propertyName , $ dependencyName ) { EnolaContext :: getInstance ( ) -> app -> dependenciesEngine -> injectDependency ( $ this , $ propertyName , $ dependencyName ) ; } | Carga la dependencias indicada en la instancia actual en la propiedad indicada |
25,035 | public static function instance ( $ name = '_default_' , array $ config = array ( ) ) { if ( ! \ array_key_exists ( $ name , static :: $ instances ) ) { static :: $ instances [ $ name ] = static :: forge ( $ config ) ; } return static :: $ instances [ $ name ] ; } | Acts as a Multiton . Will return the requested instance or will create a new named one if it does not exist . |
25,036 | public function view ( $ view , $ data = array ( ) , $ auto_filter = null ) { if ( $ this -> active [ 'path' ] === null ) { throw new \ ThemeException ( 'You must set an active theme.' ) ; } return \ View :: forge ( $ this -> find_file ( $ view ) , $ data , $ auto_filter ) ; } | Loads a view from the currently active theme the fallback theme or via the standard FuelPHP cascading file system for views |
25,037 | public function viewmodel ( $ view , $ method = 'view' , $ auto_filter = null ) { return \ Viewmodel :: forge ( $ view , $ method , $ auto_filter , $ this -> find_file ( $ view ) ) ; } | Loads a viewmodel and have it use the view from the currently active theme the fallback theme or the standard FuelPHP cascading file system |
25,038 | public function presenter ( $ view , $ method = 'view' , $ auto_filter = null ) { return \ Presenter :: forge ( $ view , $ method , $ auto_filter , $ this -> find_file ( $ view ) ) ; } | Loads a presenter and have it use the view from the currently active theme the fallback theme or the standard FuelPHP cascading file system |
25,039 | public function asset_path ( $ path ) { if ( $ this -> active [ 'path' ] === null ) { throw new \ ThemeException ( 'You must set an active theme.' ) ; } if ( $ this -> active [ 'asset_base' ] ) { return $ this -> active [ 'asset_base' ] . $ path ; } else { return $ this -> active [ 'path' ] . $ path ; } } | Loads an asset from the currently loaded theme . |
25,040 | public function set_template ( $ template ) { if ( is_string ( $ template ) ) { $ this -> template = $ this -> view ( $ template ) ; } else { $ this -> template = $ template ; } return $ this -> template ; } | Sets a template for a theme |
25,041 | public function render ( ) { if ( empty ( $ this -> template ) ) { throw new \ ThemeException ( 'No valid template could be found. Use set_template() to define a page template.' ) ; } $ rendered = array ( ) ; foreach ( $ this -> partials as $ key => $ partials ) { $ output = '' ; foreach ( $ partials as $ index => $ partial ) { $ output .= $ partial -> render ( ) ; } if ( ! empty ( $ output ) and array_key_exists ( $ key , $ this -> chrome ) ) { $ rendered [ $ key ] = $ this -> chrome [ $ key ] [ 'view' ] -> set ( $ this -> chrome [ $ key ] [ 'var' ] , $ output , false ) ; } else { $ rendered [ $ key ] = $ output ; } } $ this -> template -> set ( 'partials' , $ rendered , false ) ; return $ this -> template ; } | Render the partials and the theme template |
25,042 | public function set_partial ( $ section , $ view , $ overwrite = false ) { array_key_exists ( $ section , $ this -> partials ) or $ this -> partials [ $ section ] = array ( ) ; if ( is_string ( $ view ) ) { $ name = $ view ; $ view = $ this -> view ( $ view ) ; } else { $ name = 'partial_' . count ( $ this -> partials [ $ section ] ) ; } if ( $ overwrite ) { $ this -> partials [ $ section ] = array ( $ name => $ view ) ; } else { $ this -> partials [ $ section ] [ $ name ] = $ view ; } return $ this -> partials [ $ section ] [ $ name ] ; } | Sets a partial for the current template |
25,043 | public function get_partial ( $ section , $ view ) { if ( ! array_key_exists ( $ section , $ this -> partials ) or ! array_key_exists ( $ view , $ this -> partials [ $ section ] ) ) { throw new \ ThemeException ( sprintf ( 'No partial named "%s" can be found in the "%s" section.' , $ view , $ section ) ) ; } return $ this -> partials [ $ section ] [ $ view ] ; } | Get a partial so it can be manipulated |
25,044 | public function partial_count ( $ section ) { return array_key_exists ( $ section , $ this -> partials ) ? count ( $ this -> partials [ $ section ] ) : 0 ; } | Returns the number of partials defined for a section |
25,045 | public function set_chrome ( $ section , $ view , $ var = 'content' ) { if ( is_string ( $ view ) ) { $ view = $ this -> view ( $ view ) ; } $ this -> chrome [ $ section ] = array ( 'var' => $ var , 'view' => $ view ) ; return $ view ; } | Sets a chrome for a partial |
25,046 | public function get_chrome ( $ section ) { if ( ! array_key_exists ( $ section , $ this -> chrome ) ) { throw new \ ThemeException ( sprintf ( 'No chrome for a partial named "%s" can be found.' , $ section ) ) ; } return $ this -> chrome [ $ section ] [ 'view' ] ; } | Get a set chrome view |
25,047 | public function find ( $ theme ) { foreach ( $ this -> paths as $ path ) { if ( is_dir ( $ path . $ theme ) ) { return $ path . $ theme . DS ; } } return false ; } | Finds the given theme by searching through all of the theme paths . If found it will return the path else it will return false . |
25,048 | public function all ( ) { $ themes = array ( ) ; foreach ( $ this -> paths as $ path ) { $ iterator = new \ GlobIterator ( $ path . '*' ) ; foreach ( $ iterator as $ theme ) { $ themes [ ] = $ theme -> getFilename ( ) ; } } sort ( $ themes ) ; return $ themes ; } | Gets an array of all themes in all theme paths sorted alphabetically . |
25,049 | public function get_info ( $ var = null , $ default = null , $ theme = null ) { if ( $ theme === null ) { if ( $ var === null ) { return $ this -> active [ 'info' ] ; } if ( ( $ value = \ Arr :: get ( $ this -> active [ 'info' ] , $ var , null ) ) !== null ) { return $ value ; } elseif ( ( $ value = \ Arr :: get ( $ this -> fallback [ 'info' ] , $ var , null ) ) !== null ) { return $ value ; } } else { $ info = $ this -> load_info ( $ theme ) ; return $ var === null ? $ info : \ Arr :: get ( $ info , $ var , $ default ) ; } return $ default ; } | Get a value from the info array |
25,050 | public function set_info ( $ var , $ value = null , $ type = 'active' ) { if ( $ type == 'active' ) { \ Arr :: set ( $ this -> active [ 'info' ] , $ var , $ value ) ; } elseif ( $ type == 'fallback' ) { \ Arr :: set ( $ this -> fallback [ 'info' ] , $ var , $ value ) ; } return $ this ; } | Set a value in the info array |
25,051 | protected function set_theme ( $ theme = null , $ type = 'active' ) { if ( $ theme !== null ) { empty ( $ this -> active [ 'asset_path' ] ) or $ this -> asset -> remove_path ( $ this -> active [ 'asset_path' ] ) ; empty ( $ this -> fallback [ 'asset_path' ] ) or $ this -> asset -> remove_path ( $ this -> fallback [ 'asset_path' ] ) ; $ this -> { $ type } = $ this -> create_theme_array ( $ theme ) ; empty ( $ this -> fallback [ 'asset_path' ] ) or $ this -> asset -> add_path ( $ this -> fallback [ 'asset_path' ] ) ; empty ( $ this -> active [ 'asset_path' ] ) or $ this -> asset -> add_path ( $ this -> active [ 'asset_path' ] ) ; } return $ this -> { $ type } ; } | Sets a theme . |
25,052 | protected function create_theme_array ( $ theme ) { if ( ! is_array ( $ theme ) ) { if ( ! $ path = $ this -> find ( $ theme ) ) { throw new \ ThemeException ( sprintf ( 'Theme "%s" could not be found.' , $ theme ) ) ; } $ theme = array ( 'name' => $ theme , 'path' => $ path , ) ; } else { if ( ! isset ( $ theme [ 'name' ] ) or ! isset ( $ theme [ 'path' ] ) ) { throw new \ ThemeException ( 'Theme name and path must be given in array config.' ) ; } } if ( ! isset ( $ theme [ 'info' ] ) ) { $ theme [ 'info' ] = $ this -> load_info ( $ theme ) ; } if ( ! isset ( $ theme [ 'asset_base' ] ) ) { $ assets_folder = rtrim ( $ this -> config [ 'assets_folder' ] , DS ) . '/' ; if ( strpos ( $ path , DOCROOT ) === 0 and is_dir ( $ path . $ assets_folder ) ) { $ theme [ 'asset_path' ] = $ path . $ assets_folder ; $ theme [ 'asset_base' ] = str_replace ( DOCROOT , '' , $ theme [ 'asset_path' ] ) ; } else { $ theme [ 'asset_base' ] = $ assets_folder . $ theme [ 'name' ] . '/' ; } } if ( ! isset ( $ theme [ 'asset_path' ] ) and strpos ( $ theme [ 'asset_base' ] , '://' ) === false ) { $ theme [ 'asset_path' ] = DOCROOT . $ theme [ 'asset_base' ] ; } $ theme [ 'asset_base' ] = str_replace ( DS , '/' , $ theme [ 'asset_base' ] ) ; return $ theme ; } | Creates a theme array by locating the given theme and setting all of the option . It will throw a \ ThemeException if it cannot locate the theme . |
25,053 | private function linearize ( Throwable $ e ) : array { $ previous = $ e -> getPrevious ( ) ; if ( is_null ( $ previous ) ) return [ $ e ] ; return array_merge ( $ this -> linearize ( $ previous ) , [ $ e ] ) ; } | Return an array containing the given exception and all its previous exceptions . |
25,054 | protected function getAttributes ( array $ attributes ) : array { $ result = [ ] ; foreach ( $ attributes as $ attribute ) { if ( ! ( $ attribute instanceof Descriptor ) ) { continue ; } $ result [ $ attribute -> getName ( ) ] = $ attribute ; } return $ result ; } | Results array of items . |
25,055 | public function add ( Descriptor $ argDescriptor ) : Support { $ this -> _attributes [ $ argDescriptor -> getName ( ) ] = $ argDescriptor ; return $ this ; } | Adds or overwrites a argument descriptor . |
25,056 | public function remove ( string $ argName ) : Support { if ( ! $ this -> has ( $ argName ) ) { return $ this ; } unset ( $ this -> _attributes [ $ argName ] ) ; return $ this ; } | Removes the DSN argument descriptor with defined name |
25,057 | public function getSQLParamNames ( ) : array { $ out = [ ] ; foreach ( $ this -> _attributes as $ attributeName => $ attribute ) { if ( Type :: INIT_SQL === $ attribute -> getType ( ) ) { $ out [ ] = $ attributeName ; } } return $ out ; } | Gets the names of the parameters that should be used as SQL queries called after connection open . |
25,058 | public function validate ( string $ attributeName , $ attributeValue ) : ValidationResult { $ result = new ValidationResult ( ) ; if ( false === $ this -> has ( $ attributeName ) ) { return $ result -> setErrorMessage ( 'Unknown Driver attribute name "' . $ attributeName . '"!' ) ; } if ( $ this -> _attributes [ $ attributeName ] -> validateValue ( $ attributeValue ) ) { return $ result -> setIsKnown ( true ) -> setIsValidValue ( true ) -> setValue ( $ attributeValue ) ; } if ( $ this -> _attributes [ $ attributeName ] -> hasDefaultValue ( ) ) { return $ result -> setIsKnown ( true ) -> setValue ( $ this -> _attributes [ $ attributeName ] -> getDefaultValue ( ) ) ; } return $ result -> setIsKnown ( true ) -> setErrorMessage ( 'Unknown Driver argument "' . $ attributeName . '" value "' . $ attributeValue . '"!' ) ; } | Validates a Driver argument with defined name and value . At least it checks if the Driver knows the argument and if the value is valid . |
25,059 | public function addTable ( $ data ) { if ( $ data instanceof Table ) { $ tbl = $ data ; $ tbl -> setDatabase ( $ this ) ; if ( $ tbl -> getSchema ( ) === null ) $ tbl -> setSchema ( $ this -> getSchema ( ) ) ; if ( isset ( $ this -> tablesByName [ $ tbl -> getName ( ) ] ) ) { return ; } $ this -> tableList [ ] = $ tbl ; $ this -> tablesByName [ $ tbl -> getName ( ) ] = $ tbl ; $ this -> tablesByLowercaseName [ strtolower ( $ tbl -> getName ( ) ) ] = $ tbl ; $ this -> tablesByPhpName [ $ tbl -> getPhpName ( ) ] = $ tbl ; if ( strpos ( $ tbl -> getNamespace ( ) , '\\' ) === 0 ) { $ tbl -> setNamespace ( substr ( $ tbl -> getNamespace ( ) , 1 ) ) ; } elseif ( $ namespace = $ this -> getNamespace ( ) ) { if ( $ tbl -> getNamespace ( ) === null ) { $ tbl -> setNamespace ( $ namespace ) ; } else { $ tbl -> setNamespace ( $ namespace . '\\' . $ tbl -> getNamespace ( ) ) ; } } if ( $ tbl -> getPackage ( ) === null ) { $ tbl -> setPackage ( $ this -> getPackage ( ) ) ; } return $ tbl ; } else { $ tbl = new Table ( ) ; $ tbl -> setDatabase ( $ this ) ; $ tbl -> setSchema ( $ this -> getSchema ( ) ) ; $ tbl -> loadFromXML ( $ data ) ; return $ this -> addTable ( $ tbl ) ; } } | An utility method to add a new table from an xml attribute . |
25,060 | public function actionEvents ( ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; $ result = ( $ post = Yii :: $ app -> request -> post ( 'depdrop_parents' ) ) ? array_flip ( ClassCrawler :: getEventNames ( $ post [ 0 ] ) ) : [ ] ; $ output = [ ] ; foreach ( $ result as $ id => $ name ) { $ output [ ] = compact ( 'id' , 'name' ) ; } echo Json :: encode ( [ 'output' => $ output , 'selected' => '' ] ) ; } | Returns json event list for form DepDrop widget . |
25,061 | public function run ( $ argc , $ argv ) { $ this -> addDefaultCommands ( ) ; if ( $ argc == 1 ) { $ run = $ this -> getDefaultCommand ( ) ; $ argv = [ ] ; } else { $ run = $ argv [ 1 ] ; $ argv = array_slice ( $ argv , 2 ) ; } $ found = false ; foreach ( $ this -> commands as $ command ) { if ( $ command -> getName ( ) == $ run ) { $ command -> run ( [ ] , $ argv ) ; $ found = true ; } } if ( ! $ found ) { echo "command unknown\n" ; exit ( 1 ) ; } $ this -> loop -> run ( ) ; } | execute the actuall run |
25,062 | private function getProxyMethods ( ) : array { if ( null !== $ this -> reflectionProxyMethods ) { return $ this -> reflectionProxyMethods ; } $ proxyMethods = [ ] ; $ methods = $ this -> getClassMethods ( ) ; foreach ( $ methods as $ method ) { $ docComment = $ method -> getDocComment ( ) ; if ( \ strpos ( $ docComment , 'Transactional' ) !== false ) { $ annotation = $ this -> annotationReader -> getMethodAnnotation ( $ method , Transactional :: class ) ; if ( $ annotation ) { $ proxyMethods [ ] = $ method ; } } } $ this -> reflectionProxyMethods = $ proxyMethods ; return $ proxyMethods ; } | Get proxy methods |
25,063 | private function getClassMethods ( ) : array { if ( null !== $ this -> reflectionMethods ) { return $ this -> reflectionMethods ; } $ this -> reflectionMethods = [ ] ; $ class = $ this -> reflectionClass ; do { $ this -> reflectionMethods = \ array_merge ( $ this -> reflectionMethods , $ class -> getMethods ( ) ) ; } while ( $ class = $ class -> getParentClass ( ) ) ; return $ this -> reflectionMethods ; } | Get all methods from class |
25,064 | private function getAllUseStatementsMarkedAsAnnotation ( \ ReflectionClass $ class ) : array { $ tokens = \ token_get_all ( \ file_get_contents ( $ class -> getFileName ( ) ) ) ; $ uses = [ ] ; $ buffer = '' ; $ startUseParse = false ; foreach ( $ tokens as $ token ) { if ( \ is_scalar ( $ token ) ) { if ( $ token == ';' || $ token = ',' ) { if ( $ startUseParse ) { $ uses [ ] = trim ( $ buffer ) ; $ buffer = '' ; if ( $ token == ';' ) { $ startUseParse = false ; } } } continue ; } $ type = $ token [ 0 ] ; $ value = $ token [ 1 ] ; if ( \ in_array ( $ type , [ T_ABSTRACT , T_CLASS , T_INTERFACE , T_TRAIT ] ) ) { break ; } if ( $ type == T_USE ) { $ startUseParse = true ; continue ; } if ( $ startUseParse ) { $ buffer .= $ value ; } } $ useFiltering = function ( $ class , $ searchChild = true ) use ( & $ useFiltering ) { if ( ! $ class ) { return false ; } $ parts = \ explode ( ' as ' , $ class , 2 ) ; $ class = $ parts [ 0 ] ; try { $ reflection = new \ ReflectionClass ( $ class ) ; } catch ( \ ReflectionException $ e ) { if ( $ searchChild ) { foreach ( \ get_declared_classes ( ) as $ declaredClass ) { if ( \ strpos ( $ declaredClass , $ class ) === 0 ) { if ( true === $ useFiltering ( $ declaredClass , false ) ) { return true ; } } } } return false ; } if ( $ reflection -> getName ( ) == Transactional :: class ) { return false ; } return \ strpos ( $ reflection -> getDocComment ( ) , '@Annotation' ) !== false ; } ; $ uses = \ array_filter ( $ uses , $ useFiltering ) ; return $ uses ; } | Get all use statements from class |
25,065 | private function generateProxyClass ( ) : string { $ class = $ this -> reflectionClass ; if ( $ class -> isFinal ( ) ) { throw new \ RuntimeException ( sprintf ( 'Can not generate proxy for final class "%s".' , $ class -> getName ( ) ) ) ; } if ( $ class -> isAbstract ( ) ) { throw new \ RuntimeException ( sprintf ( 'Can not generate proxy for abstract class "%s".' , $ class -> getName ( ) ) ) ; } $ methodCodes = [ ] ; $ uses = $ this -> getAllUseStatementsMarkedAsAnnotation ( $ class ) ; $ uses [ ] = 'FiveLab\Component\Transactional\Proxy\ProxyInterface as FiveLabTransactionalProxyInterface' ; $ uses = \ array_map ( function ( $ use ) { return 'use ' . $ use . ';' ; } , $ uses ) ; $ interfaces = [ 'FiveLabTransactionalProxyInterface' , ] ; foreach ( $ this -> getProxyMethods ( ) as $ method ) { $ methodCodes [ ] = $ this -> generateProxyMethod ( $ method ) ; } $ docComment = $ class -> getDocComment ( ) ; $ templateVariables = [ 'uses' => \ implode ( "\n" , $ uses ) , 'namespace' => $ class -> getNamespaceName ( ) , 'docComment' => $ docComment , 'proxyClassName' => $ class -> getShortName ( ) . 'Proxy' , 'className' => '\\' . $ class -> getName ( ) , 'proxyMethods' => \ implode ( "\n\n" , $ methodCodes ) , 'interfaces' => \ implode ( ', ' , $ interfaces ) , 'realClassName' => $ class -> getName ( ) , ] ; $ template = $ this -> getTemplateForProxyClass ( ) ; $ code = $ this -> replaceVariables ( $ template , $ templateVariables ) ; $ lines = \ explode ( "\n" , $ code ) ; $ lines = \ array_map ( 'rtrim' , $ lines ) ; return \ implode ( "\n" , $ lines ) ; } | Generate proxy class |
25,066 | private function appendTabulationCharacter ( $ text , $ count ) : string { $ lines = \ explode ( "\n" , $ text ) ; foreach ( $ lines as $ index => $ line ) { $ lines [ $ index ] = \ str_repeat ( " " , $ count ) . rtrim ( $ line ) ; } return \ implode ( PHP_EOL , $ lines ) ; } | Append tabulation character for lines |
25,067 | public static function move ( $ source , $ des ) { if ( ! is_file ( $ source ) ) { return false ; } try { @ rename ( $ source , $ des ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } | move the file or dir . |
25,068 | public static function copy ( $ source , $ des ) { if ( ! is_file ( $ source ) ) { return false ; } try { @ copy ( $ source , $ des ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } | copy the file . |
25,069 | public static function remove ( $ source ) { if ( ! is_file ( $ source ) ) { return false ; } try { @ unlink ( $ source ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } | delete the file . |
25,070 | public static function create ( $ source , $ data ) { try { $ file = @ fopen ( $ source , 'w' ) ; @ fwrite ( $ file , $ data ) ; @ fclose ( $ file ) ; return true ; } catch ( \ Exception $ e ) { return false ; } } | create the file . |
25,071 | public static function append ( $ source , $ data ) { try { if ( is_file ( $ source ) ) { $ file = @ fopen ( $ source , 'a' ) ; @ fwrite ( $ file , $ data ) ; @ fclose ( $ file ) ; return true ; } } catch ( \ Exception $ e ) { } return false ; } | append the content to the file . |
25,072 | public static function read ( $ source , $ length = 0 ) { if ( ! is_file ( $ source ) || ! is_readable ( $ source ) ) { return false ; } try { if ( $ length <= 0 || $ length > filesize ( $ source ) ) { return file_get_contents ( $ source ) ; } $ file = @ fopen ( $ source , 'r' ) ; $ content = @ fread ( $ file , $ length ) ; @ fclose ( $ file ) ; return $ content ; } catch ( \ Exception $ e ) { return false ; } } | read the content from the fle . |
25,073 | public static function saveInputAsFile ( $ content , $ tmpDir = '' , $ key = '' ) { if ( ! $ tmpDir ) { $ tmpDir = ini_get ( 'upload_tmp_dir' ) ; } if ( ! is_dir ( $ tmpDir ) ) { return false ; } if ( ! $ key ) { $ key = uniqid ( ) ; } if ( ! $ content ) { return false ; } $ tmp_file = realpath ( $ tmpDir ) . '/' . $ key ; if ( self :: create ( $ tmp_file , $ content ) > 0 ) { return [ 'name' => $ key , 'path' => $ tmp_file ] ; } else { return false ; } } | put the format php input stream into the temporary file . |
25,074 | public function lead ( MinibusInterface $ minibus ) { $ startEvent = $ this -> eventFactory -> createStart ( $ minibus ) ; $ this -> dispatcher -> dispatch ( LineEvents :: START , $ startEvent ) ; $ minibus = $ startEvent -> getMinibus ( ) ; foreach ( $ this -> stations as $ station ) { $ configuration = $ this -> stations [ $ station ] ; $ gateOpenEvent = $ this -> eventFactory -> createGate ( $ minibus , $ station ) ; $ this -> dispatcher -> dispatch ( LineEvents :: GATE_OPEN , $ gateOpenEvent ) ; if ( $ station instanceof Configurable ) { $ configuration = $ this -> configurationProcessor -> processConfiguration ( $ station -> getConfiguration ( ) , [ $ configuration ] ) ; } $ station -> handle ( $ minibus , $ configuration ) ; $ gateCloseEvent = $ this -> eventFactory -> createGate ( $ minibus , $ station ) ; $ this -> dispatcher -> dispatch ( LineEvents :: GATE_CLOSE , $ gateCloseEvent ) ; } if ( null !== $ this -> terminus and $ this -> terminus instanceof Configurable ) { $ this -> configuration = $ this -> configurationProcessor -> processConfiguration ( $ this -> terminus -> getConfiguration ( ) , [ $ this -> configuration ] ) ; } $ terminusEvent = $ this -> eventFactory -> createTerminus ( $ minibus , $ this -> terminus , $ this -> configuration ) ; $ this -> dispatcher -> dispatch ( LineEvents :: TERMINUS , $ terminusEvent ) ; $ terminus = $ terminusEvent -> getTerminus ( ) ; $ configuration = $ terminusEvent -> getConfiguration ( ) ; return null === $ terminus ? $ minibus : $ terminus -> terminate ( $ minibus , $ configuration ) ; } | Lead the minibus thrie all the stations . If you have defined a Terminus then the terminus resolved data should be return else the minibus is return . This method also dispatch events |
25,075 | public function getCookieValue ( string $ name ) : ? string { $ cookie = $ this -> cookies -> get ( $ name ) ; return $ cookie !== null ? $ cookie -> getValue ( ) : null ; } | Returns the cookie value by cookie name if it exists null otherwise . |
25,076 | public function getReferrer ( ) : ? UrlInterface { $ referrerHeader = $ this -> getHeader ( 'Referer' ) ; if ( $ referrerHeader === null ) { return null ; } return Url :: tryParse ( $ referrerHeader ) ; } | Returns the referrer or null if request has no or invalid referrer . |
25,077 | public function setSessionItem ( string $ name , $ value ) : void { $ this -> sessionItems -> set ( $ name , $ value ) ; } | Sets a session item . |
25,078 | protected function buildRouteAction ( Route $ route ) { $ action = $ route -> getAction ( ) ; if ( $ action instanceof \ Closure ) { $ controller = new Controller ( ) ; return $ action -> bindTo ( $ controller , get_class ( $ controller ) ) ; } list ( $ class , $ method ) = $ action ; $ class = new $ class ; return [ $ class , $ method ] ; } | Overwrites buildRouteAction of Trait |
25,079 | private function configureStorage ( array $ config , ContainerBuilder $ container ) { $ container -> register ( 'doctrine.key_value.storage' , 'Doctrine\KeyValueStore\Storage\DoctrineCacheStorage' ) -> setPublic ( false ) -> addArgument ( new Reference ( 'cache.' . $ config [ 'cache_driver' ] ) ) ; } | Configure the data store . |
25,080 | private function configureMetadataDriver ( array $ config , ContainerBuilder $ container ) { $ container -> register ( 'doctrine.key_value.metadata.annotation.reader' , 'Doctrine\Common\Annotations\AnnotationReader' ) -> setPublic ( false ) ; $ container -> register ( 'doctrine.key_value.metadata.annotation' , 'Doctrine\KeyValueStore\Mapping\AnnotationDriver' ) -> setPublic ( false ) -> addArgument ( new Reference ( 'doctrine.key_value.metadata.annotation.reader' ) ) ; } | Configure the metadata driver . |
25,081 | private function configureEntityManager ( array $ config , ContainerBuilder $ container ) { $ container -> register ( 'doctrine.key_value.configuration' , 'Doctrine\KeyValueStore\Configuration' ) -> addMethodCall ( 'setMappingDriverImpl' , array ( new Reference ( 'doctrine.key_value.metadata.annotation' ) ) ) ; $ container -> register ( 'doctrine.key_value.entity_manager' , 'Doctrine\KeyValueStore\EntityManager' ) -> addArgument ( new Reference ( 'doctrine.key_value.storage' ) ) -> addArgument ( new Reference ( 'doctrine.key_value.configuration' ) ) ; } | Configure the entity manager . |
25,082 | protected function http ( ) { if ( ! $ this -> http instanceof Client ) { $ this -> http = new Client ( array_merge ( [ 'base_uri' => $ this -> url ] , $ this -> options ) ) ; } return $ this -> http ; } | Get the http client instance |
25,083 | public function getEvent ( ) { if ( null === $ this -> event ) { $ event = new AuthenticationEvent ( ) ; $ this -> setEvent ( $ event ) ; } return $ this -> event ; } | Get the auth event . |
25,084 | public function setEvent ( EventInterface $ event ) { $ target = $ this ; if ( ! ( $ event instanceof AuthenticationEvent ) ) { $ eventParams = $ event -> getParams ( ) ; $ eventTarget = $ event -> getTarget ( ) ; if ( $ eventTarget ) { $ target = $ eventTarget ; } $ event = new AuthenticationEvent ( ) ; $ event -> setParams ( $ eventParams ) ; } $ event -> setIdentity ( null ) -> setTarget ( $ target ) ; $ this -> event = $ event ; return $ this ; } | Set an event to use during dispatch . By default will re - cast to AdapterChainEvent if another event type is provided . |
25,085 | public function sign ( $ username , $ password , Adapter \ AdapterInterface $ adapter = null , Request $ request = null ) { $ adapter = $ adapter ? : $ this -> getAdapter ( ) ; $ adapter -> setIdentity ( $ username ) ; $ adapter -> setCredential ( $ password ) ; return $ this -> authenticate ( $ adapter , $ request ) ; } | Sign - in and provides an authentication result . |
25,086 | public function logout ( Adapter \ AdapterInterface $ adapter = null , Request $ request = null ) { $ event = $ this -> prepareEvent ( $ adapter , $ request ) ; $ event -> setResult ( $ event -> getAdapter ( ) -> logout ( ) ) ; $ this -> clearIdentity ( ) ; return $ this -> triggerEventResult ( AuthenticationEvent :: AUTH_LOGOUT , $ event ) ; } | Logout and provides an authentication result . |
25,087 | public function getSubmitted ( ) { $ fieldType = $ this -> getType ( ) ; $ data = array_key_exists ( $ this -> getSlug ( ) , $ _POST ) === true ? $ _POST [ $ this -> getSlug ( ) ] : "" ; if ( in_array ( $ fieldType , [ static :: TYPE_CHOICE , static :: TYPE_MULTIPLE_CHOICE ] ) === true ) { $ data = $ this -> parseChoiceSlugs ( $ data ) ; if ( is_array ( $ data ) === true ) { foreach ( $ data as $ index => $ datum ) { $ data [ $ index ] = $ datum -> getValue ( ) ; } } else { $ data = $ data -> getValue ( ) ; } } return $ data ; } | Provides the data that was submitted to this field if applicable . |
25,088 | protected function getChoiceSlugs ( ) { $ choiceSlugs = [ ] ; foreach ( $ this -> choices as $ index => $ choice ) { $ choiceSlugs [ ] = StringUtils :: slugify ( "$index-{$choice->getAlias()}" ) ; } return $ choiceSlugs ; } | Provides the slugs which shall be used to identify valid submissions to this field . |
25,089 | public function setInitial ( $ value ) { if ( $ value instanceof DateTime ) { $ value = new DateTimeWrapper ( $ value -> format ( 'c' ) ) ; } $ this -> initial = $ value ; return $ this ; } | Sets the initial value to be displayed by the field . |
25,090 | public function validate ( ) { $ data = $ this -> wasSubmitted ( ) === true ? $ this -> getSubmitted ( ) : null ; if ( $ data === [ ] ) { $ this -> addError ( "Unrecognized choice." ) ; } if ( $ this -> isRequired ( ) === true && $ data === null ) { $ this -> addError ( "This field is required." ) ; } if ( $ this -> getErrors ( ) === [ ] ) { $ this -> setValidatedData ( $ data ) ; } } | Perform basic validation on the field add any apparent errors and mark valid data . |
25,091 | public function authorize ( ActionDispatchEvent $ event ) { $ callable = $ event -> getCallable ( ) ; if ( ! $ callable -> isMethod ( ) && ! $ callable -> isMethodStatic ( ) ) { return ; } $ class = $ callable -> getReflection ( ) -> getDeclaringClass ( ) -> getName ( ) ; $ method = $ callable -> getReflection ( ) -> getName ( ) ; $ parameters = $ event -> getParameters ( ) ; $ action = $ event -> getAction ( ) ; foreach ( $ action -> getSecurityGroups ( ) as $ group ) { $ authorized = $ this -> authorizationChecker -> isGrantedMethodCall ( $ class , $ method , $ parameters , [ ] , $ group ) ; if ( ! $ authorized ) { throw new AccessDeniedException ( ) ; } } } | Authorize and authenticate on API method |
25,092 | public function updateFromEmbeddedApiResponse ( array $ data , DeliveryInterface $ delivery = null ) : DeliveryInterface { if ( ! $ delivery ) { $ delivery = new Delivery ( ) ; } $ delivery -> setAddress ( $ data [ 'address' ] ) -> setAddress2 ( $ data [ 'address2' ] ) -> setAttention ( $ data [ 'attention' ] ) -> setCity ( $ data [ 'city' ] ) -> setCountry ( $ data [ 'country' ] ) -> setCountryId ( $ data [ 'countryId' ] ) -> setCvr ( $ data [ 'cvr' ] ) -> setEan ( $ data [ 'ean' ] ) -> setEmail ( $ data [ 'email' ] ) -> setFax ( $ data [ 'fax' ] ) -> setName ( $ data [ 'name' ] ) -> setPhone ( $ data [ 'phone' ] ) -> setState ( $ data [ 'state' ] ) -> setZipCode ( $ data [ 'zipCode' ] ) ; return $ delivery ; } | This method is called when a delivery object is embedded in another object i . e . orders . |
25,093 | protected function _getConf ( ) { $ services = $ this -> services ( ) ; $ config = $ services -> get ( '/sapi' ) ; $ orig = $ config = $ config -> config ( ) ; $ config = $ config -> get ( \ Module \ Authorization \ Module :: CONF , array ( ) ) ; if ( ! isset ( $ config [ self :: CONF ] ) && ! is_array ( $ config [ self :: CONF ] ) ) return null ; $ config = $ config [ self :: CONF ] ; return $ config ; } | Get Config Values |
25,094 | public static function activeLanguagesArray ( ) { if ( ! empty ( Yii :: $ app -> langManager ) && ! empty ( Yii :: $ app -> langManager -> langsConfig ) ) { return Yii :: $ app -> langManager -> langsConfig ; } else { return include ( dirname ( __DIR__ ) . '/config/langs-default.php' ) ; } } | Get basic active languages array according to sort criteria . |
25,095 | public static function findLanguageByCode2 ( $ langCode2 ) { $ langList = static :: activeLanguagesArray ( ) ; foreach ( $ langList as $ lang ) { if ( $ lang [ 'code2' ] == $ langCode2 ) return $ lang ; } return false ; } | Find language by 2 - symbols language code |
25,096 | private function build ( $ dest = null , $ plugin = null ) { if ( $ plugin !== null ) { $ builds = file_exists ( $ this -> pluginManifestOfAssets ) ? include $ this -> pluginManifestOfAssets : [ ] ; if ( ! isset ( $ builds [ $ plugin ] ) ) { throw new InvalidArgumentException ( 'Plugin "' . $ plugin . '" has no assets or is not installed.' ) ; } $ build = $ builds [ $ plugin ] ; } else { $ build = require $ this -> buildFile ; } if ( $ dest !== null ) { if ( ! isset ( $ build [ $ dest ] ) ) { throw new InvalidArgumentException ( 'Asset "' . $ dest . '" is not defined.' ) ; } $ build = [ $ dest => $ build [ $ dest ] ] ; } $ basePath = base_path ( ) ; foreach ( $ build as $ asset => $ sources ) { foreach ( $ sources as $ i => $ source ) { if ( ! is_absolute_path ( $ source ) ) { $ build [ $ asset ] [ $ i ] = $ basePath . DIRECTORY_SEPARATOR . $ source ; } } } return $ build ; } | Get the build information array . |
25,097 | private function buildUniqueFile ( $ file ) { $ dir = public_path ( 'build' ) ; if ( ! file_exists ( $ dir ) ) { if ( ! make_dir ( $ dir , 0755 ) ) { throw new RuntimeException ( 'Unable to create directory ' . $ dir ) ; } } $ dir = dirname ( $ this -> manifestFile ) ; if ( ! file_exists ( $ dir ) ) { if ( ! make_dir ( $ dir , 0755 ) ) { throw new RuntimeException ( 'Unable to create directory ' . $ dir ) ; } } $ ext = pathinfo ( $ file , PATHINFO_EXTENSION ) ; $ uniqueFile = 'build/' . basename ( $ file , '.' . $ ext ) . '-' . uniqid ( ) . '.' . $ ext ; copy ( public_path ( $ file ) , public_path ( $ uniqueFile ) ) ; $ oldFile = isset ( $ this -> manifest [ $ file ] ) ? public_path ( $ this -> manifest [ $ file ] ) : null ; $ this -> manifest [ $ file ] = $ uniqueFile ; if ( file_put_contents ( $ this -> manifestFile , '<?php return ' . var_export ( $ this -> manifest , true ) . ';' . PHP_EOL , LOCK_EX ) === false ) { throw new RuntimeException ( sprintf ( 'Asset Manager was not able to save manifest file "%s"' , $ this -> manifestFile ) ) ; } if ( $ oldFile !== null && file_exists ( $ oldFile ) ) { unlink ( $ oldFile ) ; } } | Build an unique file and update the manifest |
25,098 | private function removeUniqueFile ( $ file ) { if ( ! isset ( $ this -> manifest [ $ file ] ) ) { return ; } $ uniqueFile = public_path ( $ this -> manifest [ $ file ] ) ; if ( $ uniqueFile !== null && file_exists ( $ uniqueFile ) ) { unlink ( $ uniqueFile ) ; } unset ( $ this -> manifest [ $ file ] ) ; if ( file_put_contents ( $ this -> manifestFile , '<?php return ' . var_export ( $ this -> manifest , true ) . ';' . PHP_EOL , LOCK_EX ) === false ) { throw new RuntimeException ( sprintf ( 'Asset Manager was not able to save manifest file "%s"' , $ this -> manifestFile ) ) ; } } | Remove unique file and update the manifest |
25,099 | public function listAction ( ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'groups' , 'INDEX' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ groups = $ this -> get ( 'fos_user.group_manager' ) -> findGroups ( ) ; return $ this -> render ( 'FOSUserBundle:Group:list.html.twig' , array ( 'groups' => $ groups ) ) ; } | Show all groups |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.