idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
14,200
public function orWhereColumn ( ... $ arguments ) : self { $ this -> where [ ] = $ this -> whereArgumentsToCriterion ( $ arguments , 'OR' , true ) ; return $ this ; }
The same as whereColumn but the result criterion is appended to the where group with the OR append rule .
14,201
public function whereExists ( $ subQuery , bool $ not = false , string $ appendRule = 'AND' ) : self { $ subQuery = $ this -> checkSubQueryValue ( 'Argument $subQuery' , $ subQuery ) ; $ this -> where [ ] = new ExistsCriterion ( $ subQuery , $ not , $ appendRule ) ; return $ this ; }
Adds a EXISTS criterion to the WHERE section .
14,202
protected function whereArgumentsToCriterion ( array $ arguments , string $ appendRule = 'AND' , bool $ valueIsColumn = false ) : Criterion { switch ( $ argumentsCount = count ( $ arguments ) ) { case 0 : return $ this -> handleException ( new InvalidArgumentException ( 'Too few arguments' ) ) ; case 1 : $ argument = $ arguments [ 0 ] ; if ( $ argument instanceof \ Closure ) { $ groupQuery = $ this -> resolveCriteriaGroupClosure ( $ argument ) ; return new CriteriaCriterion ( $ groupQuery -> where , false , $ appendRule ) ; } if ( is_array ( $ argument ) ) { $ criteria = [ ] ; foreach ( $ argument as $ criterionData ) { $ criteria [ ] = $ this -> whereArgumentsToCriterion ( $ criterionData , 'AND' , $ valueIsColumn ) ; } return new CriteriaCriterion ( $ criteria , false , $ appendRule ) ; } if ( $ argument instanceof StatementInterface ) { return new RawCriterion ( $ argument , $ appendRule ) ; } return $ this -> handleException ( InvalidArgumentException :: create ( 'The argument' , $ argument , [ 'Closure' , 'array' , StatementInterface :: class ] ) ) ; case 2 : case 3 : if ( $ argumentsCount === 2 ) { list ( $ column , $ value ) = $ arguments ; $ rule = '=' ; } else { list ( $ column , $ rule , $ value ) = $ arguments ; if ( ! is_string ( $ rule ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $rule' , $ rule , [ 'string' ] ) ) ; } } if ( $ valueIsColumn ) { $ column1 = $ this -> checkStringValue ( 'Argument $column1' , $ column ) ; $ column2 = $ this -> checkStringValue ( 'Argument $column2' , $ value ) ; return new ColumnsCriterion ( $ column1 , $ rule , $ column2 , $ appendRule ) ; } else { $ column = $ this -> checkStringValue ( 'Argument $column' , $ column ) ; $ value = $ this -> checkScalarOrNullValue ( 'Argument $value' , $ value ) ; return new ValueCriterion ( $ column , $ rule , $ value , $ appendRule ) ; } default : return $ this -> handleException ( new InvalidArgumentException ( 'Too many arguments' ) ) ; } }
Converts where method arguments to a criterion object
14,203
public function match ( Subject $ subject , string $ verb ) : bool { return $ this -> subject -> getType ( ) == $ subject -> getType ( ) && $ this -> subject -> getId ( ) === $ subject -> getId ( ) && ( $ this -> verbs === null || in_array ( $ verb , $ this -> verbs , true ) ) ; }
Gets whether this Rule matches the Subject and verb provided .
14,204
public static function allow ( Subject $ subject , array $ verbs = null ) : Rule { return new self ( $ subject , true , $ verbs ) ; }
Creates an allowing Rule .
14,205
public static function deny ( Subject $ subject , array $ verbs = null ) : Rule { return new self ( $ subject , false , $ verbs ) ; }
Creates an denying Rule .
14,206
public function cmdGetPage ( ) { $ result = $ this -> getListPage ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTablePage ( $ result ) ; $ this -> output ( ) ; }
Callback for page - get command
14,207
public function cmdDeletePage ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; $ blog = $ this -> getParam ( 'blog' ) ; if ( empty ( $ id ) && empty ( $ all ) && empty ( $ blog ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( isset ( $ id ) && ( empty ( $ id ) || ! is_numeric ( $ id ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ options = null ; if ( isset ( $ id ) ) { if ( $ this -> getParam ( 'store' ) ) { $ options = array ( 'store_id' => $ id ) ; } else if ( $ this -> getParam ( 'category' ) ) { $ options = array ( 'category_id' => $ id ) ; } else if ( $ this -> getParam ( 'user' ) ) { $ options = array ( 'user_id' => $ id ) ; } } else if ( $ blog ) { $ options = array ( 'blog_post' => true ) ; } else if ( $ all ) { $ options = array ( ) ; } if ( isset ( $ options ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> page -> getList ( $ options ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> page -> delete ( $ item [ 'page_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } else { $ result = $ this -> page -> delete ( $ id ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for page - delete command
14,208
public function cmdUpdatePage ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this -> setSubmitted ( null , $ params ) ; $ this -> setSubmitted ( 'update' , $ params [ 0 ] ) ; $ this -> validateComponent ( 'page' ) ; $ this -> updatePage ( $ params [ 0 ] ) ; $ this -> output ( ) ; }
Callback for page - update command
14,209
protected function addPage ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> page -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new page
14,210
protected function submitAddPage ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'page' ) ; $ this -> addPage ( ) ; }
Add a new page at once
14,211
protected function wizardAddPage ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'page' ) ; $ this -> validatePrompt ( 'description' , $ this -> text ( 'Description' ) , 'page' ) ; $ this -> validatePrompt ( 'store_id' , $ this -> text ( 'Store ID' ) , 'page' ) ; $ this -> validatePrompt ( 'user_id' , $ this -> text ( 'User ID' ) , 'page' , 0 ) ; $ this -> validatePrompt ( 'meta_title' , $ this -> text ( 'Meta title' ) , 'page' , '' ) ; $ this -> validatePrompt ( 'meta_description' , $ this -> text ( 'Meta description' ) , 'page' , '' ) ; $ this -> validatePrompt ( 'category_id' , $ this -> text ( 'Category ID' ) , 'page' , 0 ) ; $ this -> validatePrompt ( 'blog_post' , $ this -> text ( 'Blog post' ) , 'page' , 0 ) ; $ this -> validatePrompt ( 'status' , $ this -> text ( 'Status' ) , 'page' , 0 ) ; $ this -> validateComponent ( 'page' ) ; $ this -> addPage ( ) ; }
Add a new page step by step
14,212
public static function make ( $ total = 0 , $ message = '' , $ value = 0 , $ startTime = null , $ current = null ) { $ now = time ( ) ; return new self ( $ current ? : $ now , $ startTime ? : $ now , $ value , $ total , $ message ) ; }
Helper function to create a new object
14,213
public function registerClass ( string $ class , string $ name ) { if ( isset ( $ this -> classes [ $ name ] ) ) throw new Exception ( "Cannot register the same name twice" ) ; if ( ! is_a ( $ class , ACLModel :: class , true ) ) throw new TypeError ( "Class must be subclass of ACLModel" ) ; $ this -> classes [ $ name ] = $ class ; $ this -> classes_names [ $ class ] = $ name ; return $ this ; }
Register the name of the object class to be used in ACL entity naming .
14,214
public function loadByACLID ( $ id ) { $ parts = explode ( "#" , $ id ) ; if ( count ( $ parts ) !== 2 ) throw new Exception ( "Invalid DAO ID: {$id}" ) ; if ( ! isset ( $ this -> classes [ $ parts [ 0 ] ] ) ) throw new Exception ( "Invalid DAO type: {$parts[0]}" ) ; $ classname = $ this -> classes [ $ parts [ 0 ] ] ; $ pkey_values = explode ( "-" , $ parts [ 1 ] ) ; $ db = DB :: getInstance ( ) ; $ dao = $ db -> getDAO ( $ classname ) ; return call_user_func ( array ( $ dao , "get" ) , $ pkey_values ) ; }
This method will load a new instance to be used in ACL inheritance
14,215
public function getInstance ( string $ class , $ element_id ) { if ( ! is_a ( $ class , Hierarchy :: class , true ) ) throw new TypeError ( "Not a subclass of Hierarchy: $class" ) ; if ( is_object ( $ element_id ) && get_class ( $ element_id ) === $ class ) return $ element_id ; if ( ! is_scalar ( $ element_id ) ) throw new TypeError ( "Element-ID must be a scalar" ) ; if ( ! $ this -> hasInstance ( $ class , $ element_id ) ) { $ root = $ class :: getRootName ( ) ; if ( $ element_id === $ root ) $ this -> hierarchy [ $ class ] [ $ root ] = new $ class ( $ this , $ root ) ; else throw new Exception ( "Element-ID '{$element_id}' is unknown for {$class}" ) ; } return $ this -> hierarchy [ $ class ] [ $ element_id ] ; }
Get an hierarchy element by specifying its ID
14,216
public function getRoot ( string $ class ) { if ( ! is_a ( $ class , Hierarchy :: class , true ) ) throw new TypeError ( "Not a subclass of Hierarchy: $class" ) ; $ root = $ class :: getRootName ( ) ; return $ this -> getInstance ( $ class , $ root ) ; }
Return the root element for a certain hierarchy
14,217
public function createEntity ( string $ entity_id , array $ parents ) { $ entity = new Entity ( $ this , $ entity_id , $ parents ) ; return $ entity ; }
Create a new entity and store it .
14,218
public function setInstance ( Hierarchy $ element ) { $ class = get_class ( $ element ) ; $ this -> hierarchy [ $ class ] [ $ element -> getID ( ) ] = $ element ; return $ this ; }
Set the instance of a specific ID .
14,219
public function load ( $ file , array $ data = array ( ) ) { $ this -> queries = array ( ) ; $ this -> data = $ data ; include $ file ; return $ this ; }
Load script file
14,220
public function execute ( ) { if ( method_exists ( $ this , 'setUp' ) ) { call_user_func_array ( [ $ this , 'setUp' ] , [ $ this -> request ] ) ; } call_user_func_array ( [ $ this , $ this -> action ] , [ $ this -> request ] ) ; }
Execute la bonne fonction enfante en fonction de l action
14,221
private function getBy ( $ search , $ column ) { $ search = mb_strtolower ( $ search , mb_detect_encoding ( $ search ) ) ; $ this -> procBuilder -> setArguments ( [ '-e' , "\t$search\t" ] ) ; $ process = $ this -> procBuilder -> getProcess ( ) ; $ process -> run ( ) ; $ csv = Csv \ Reader :: createFromString ( $ process -> getOutput ( ) ) ; $ csv -> setDelimiter ( $ this -> delimiter ) ; $ results = [ ] ; foreach ( $ csv -> fetchAssoc ( [ 'id' , 'inflection' , 'lemma' , 'tags' ] ) as $ row ) { if ( $ row [ $ column ] == $ search ) { $ results [ ] = new Inflection ( $ row [ 'id' ] , $ row [ 'inflection' ] , $ row [ 'lemma' ] , explode ( ' ' , $ row [ 'tags' ] ) ) ; } } return $ results ; }
Get inflections by searching in a specific column .
14,222
public function finalize ( ) { $ gen = new UrlGenerator ( ) ; if ( ! empty ( $ this -> redirect ) ) { $ gen -> redirect ( $ this -> redirect ) ; } }
Finalize groups that implement the Groupable trait .
14,223
public static function createSlug ( $ string ) { $ string = self :: remove_accents ( $ string ) ; $ string = strtolower ( $ string ) ; $ slug = preg_replace ( '/[^A-Za-z0-9-]+/' , '-' , $ string ) ; while ( strpos ( '--' , $ slug ) ) { $ slug = str_replace ( '--' , '-' , $ slug ) ; } $ slug = trim ( $ slug , '-' ) ; return $ slug ; }
Creates slug from any string
14,224
public function rules ( ) { $ attributes = [ 'title' => 'required' , 'text' => 'required' , ] ; $ rules = $ this -> buildLocalizedRules ( $ attributes ) ; return array_merge ( $ rules , [ 'id' => 'exists:site_pages,id' , 'slug' => 'required|alpha_dash|unique:site_pages,slug,' . $ this -> route ( 'sites' ) , 'published_at' => 'date' , 'concealed_at' => 'date' , ] ) ; }
validation that has to pass .
14,225
protected function buildLocalizedRules ( $ attributes ) { $ rules = [ ] ; $ locales = config ( 'app.locales' ) ; foreach ( $ locales as $ locale => $ name ) { foreach ( $ attributes as $ attribute => $ rule ) { $ rules [ $ attribute . '_' . $ locale ] = $ rule ; } } return $ rules ; }
builds localized suffixed rules for validation .
14,226
public function getPrimaryKeyValue ( ) { $ primaryKey = $ this -> getPrimaryKey ( ) ; if ( isset ( $ this -> $ primaryKey ) ) { return $ this -> $ primaryKey ; } else { return null ; } }
Returns the value of the primary key
14,227
public function toAssoc ( ) { $ params = [ ] ; foreach ( Extract :: getObjectVars ( $ this ) as $ key => $ value ) { if ( ! $ value instanceof Relation ) { $ params [ $ key ] = $ value ; } } if ( $ this -> getPrimaryKeyValue ( ) === null ) { unset ( $ params [ $ this -> getPrimaryKey ( ) ] ) ; } return $ params ; }
Returns an associative array from this object excluding private variables and Relation objects
14,228
public function hydrate ( $ data , $ removePrimaryKey = false ) { foreach ( $ data as $ key => $ value ) { if ( property_exists ( $ this , $ key ) ) { $ this -> $ key = $ value ; } else { $ this -> extra [ $ key ] = $ value ; } } if ( $ removePrimaryKey ) { $ key = $ this -> getPrimaryKey ( ) ; $ this -> $ key = null ; } return $ this ; }
Sets the properties of this object using an associative array where key is the property name and value is the property value .
14,229
public function limit ( $ limit , $ offset = null ) { $ this -> queryBuilder -> setLimit ( $ limit , $ offset ) ; return $ this ; }
Limit the amount of maximum rows returned
14,230
public function loadRules ( string $ entity_id ) { $ records = ACLRule :: get ( [ "entity_id" => $ entity_id ] ) ; $ rules = array ( ) ; foreach ( $ records as $ record ) { $ rule = new Rule ( $ record -> entity_id , $ record -> role_id , $ record -> action , $ record -> policy ) ; $ rule -> setRecord ( $ record ) ; $ rules [ ] = $ rule ; } return $ rules ; }
Loads the rules for the specified entity from the database .
14,231
public function setTextFont ( $ path ) { if ( ! is_file ( $ path ) || ! is_readable ( $ path ) ) { throw new \ InvalidArgumentException ( 'Unable to load font file at ' . $ path ) ; } $ this -> textFontPath = realpath ( $ path ) ; return $ this ; }
Sets the path to the font file used for rendering text overlays onto the image .
14,232
public function addDictionary ( string $ locale , $ callbackOrArray ) : \ BearFramework \ Localization { if ( ! isset ( $ this -> dictionaries [ $ locale ] ) ) { $ this -> dictionaries [ $ locale ] = [ ] ; } $ this -> dictionaries [ $ locale ] [ ] = $ callbackOrArray ; return $ this ; }
Adds a new dictionary .
14,233
public function getText ( string $ id ) : ? string { $ getText = function ( string $ id , string $ locale ) { if ( isset ( $ this -> defaultLocales [ $ locale ] ) && $ this -> defaultLocales [ $ locale ] === 0 ) { $ app = App :: get ( ) ; $ context = $ app -> contexts -> get ( __FILE__ ) ; $ this -> defaultLocales [ $ locale ] = 1 ; $ filename = $ context -> dir . '/locales/' . $ locale . '.php' ; if ( is_file ( $ filename ) ) { $ data = include $ filename ; if ( is_array ( $ data ) ) { $ this -> addDictionary ( $ locale , $ data ) ; } } } if ( isset ( $ this -> dictionaries [ $ locale ] ) ) { foreach ( $ this -> dictionaries [ $ locale ] as $ i => $ dictionary ) { if ( is_callable ( $ dictionary ) ) { $ dictionary = call_user_func ( $ dictionary ) ; $ this -> dictionaries [ $ locale ] [ $ i ] = $ dictionary ; } if ( is_array ( $ dictionary ) ) { foreach ( $ dictionary as $ _id => $ text ) { if ( $ id === $ _id ) { return ( string ) $ text ; } } } } } return null ; } ; $ text = $ getText ( $ id , $ this -> locale ) ; if ( $ text === null || ! isset ( $ text [ 0 ] ) ) { $ text = $ getText ( $ id , $ this -> backupLocale ) ; } return $ text ; }
Returns a text from the dictionary for the current locale .
14,234
protected function getNewConnection ( $ connections ) { $ connection = $ this -> ApplicationContext -> object ( $ this -> DatabaseServiceName ) ; $ connection -> setConnectionInfo ( $ connections ) ; return $ connection ; }
Gets a new connection using the connection info given
14,235
public function isMatching ( $ url ) { if ( $ this -> getRegex ( ) === null ) { return true ; } if ( preg_match ( $ this -> getRegex ( ) , $ url ) ) { return true ; } return false ; }
Check if route configuration matches url
14,236
public function extractPathInfo ( $ pathInfo ) { if ( $ this -> getRegex ( ) === null ) { return $ pathInfo ; } preg_match ( $ this -> getRegex ( ) , $ pathInfo , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { return $ matches [ 1 ] ; } else { return "/" ; } }
Extract page pathinfo Call isMatching before to be sure regex matches
14,237
public function extractId ( $ routeName ) { if ( ! $ this -> supports ( $ routeName ) ) { return null ; } return ( int ) str_replace ( $ this -> getPrefix ( ) , '' , $ routeName ) ; }
Extract a page id from the route name
14,238
public function buildPath ( $ pathInfo ) { if ( null === $ this -> getPath ( ) ) { return $ pathInfo ; } return sprintf ( $ this -> getPath ( ) , rtrim ( $ pathInfo , '/' ) ) ; }
Build a path
14,239
public function toArray ( ) { $ keys = $ this -> redis -> hKeys ( $ this -> key ) ; $ result = array ( ) ; foreach ( $ keys as $ key ) { $ result [ $ key ] = $ this -> offsetGet ( $ key ) ; } return $ result ; }
Converts the hashset to an php - array
14,240
public function getMaxAge ( ) { if ( $ this -> headers -> hasCacheControlDirective ( 's-maxage' ) ) { return ( int ) $ this -> headers -> getCacheControlDirective ( 's-maxage' ) ; } if ( $ this -> headers -> hasCacheControlDirective ( 'max-age' ) ) { return ( int ) $ this -> headers -> getCacheControlDirective ( 'max-age' ) ; } if ( NULL !== $ this -> getExpires ( ) ) { return $ this -> getExpires ( ) -> format ( 'U' ) - $ this -> getDate ( ) -> format ( 'U' ) ; } return NULL ; }
Returns the number of seconds after the time specified in the response s Date header when the response should no longer be considered fresh . First it checks for a s - maxage directive then a max - age directive and then it falls back on an expires header . It returns null when no maximum age can be established .
14,241
public function setNotModified ( ) { $ this -> setStatusCode ( self :: HTTP_NOT_MODIFIED ) ; $ this -> setContent ( NULL ) ; foreach ( [ 'Allow' , 'Content-Encoding' , 'Content-Language' , 'Content-Length' , 'Content-MD5' , 'Content-Type' , 'Last-Modified' ] as $ header ) { $ this -> headers -> remove ( $ header ) ; } return $ this ; }
Modifies the response so that it conforms to the rules defined for a 304 status code . This sets the status removes the body and discards any headers that MUST NOT be included in 304 responses .
14,242
protected function ensureIEOverSSLCompatibility ( Request $ request ) { if ( FALSE !== stripos ( $ this -> headers -> get ( 'Content-Disposition' ) , 'attachment' ) && preg_match ( '/MSIE (.*?);/i' , $ request -> server -> get ( 'HTTP_USER_AGENT' ) , $ match ) == 1 && TRUE === $ request -> isSecure ( ) ) { if ( intval ( preg_replace ( '/(MSIE )(.*?);/' , '$2' , $ match [ 0 ] ) ) < 9 ) { $ this -> headers -> remove ( 'Cache-Control' ) ; } } }
Check if we need to remove Cache - Control for ssl encrypted downloads when using IE < 9
14,243
public function getValue ( $ field , $ default = null ) { if ( array_key_exists ( $ field , $ this -> defaults ) ) { switch ( $ this -> defaults [ $ field ] [ 'type' ] ) { case self :: TYPE_INT : return ( int ) $ this -> values [ $ field ] ; case self :: TYPE_FLOAT : $ f = sprintf ( '%05.3f' , $ this -> values [ $ field ] ) ; $ f = rtrim ( $ f , '0' ) ; $ f = rtrim ( $ f , '.' ) ; return ( float ) ( empty ( $ f ) ? '0' : $ f ) ; } return $ this -> values [ $ field ] ; } return $ default ; }
Get Label Format field from associative array .
14,244
public function isMetric ( $ field ) { if ( array_key_exists ( $ field , $ this -> defaults ) ) { return ( isset ( $ this -> defaults [ $ field ] [ 'metric' ] ) ) ? $ this -> defaults [ $ field ] [ 'metric' ] : false ; } return false ; }
Check if field is metric
14,245
public function init ( ) { $ host = getenv ( 'PDO_HOST' ) ; if ( $ host ) { $ this -> setHost ( trim ( $ host ) ) ; } $ database = getenv ( 'PDO_DATABASE' ) ; if ( $ database ) { $ this -> setDatabase ( trim ( $ database ) ) ; } $ user = getenv ( 'PDO_USER' ) ; if ( $ user ) { $ this -> setUser ( $ user ) ; } $ password = getenv ( 'PDO_PASSWORD' ) ; if ( $ password ) { $ this -> setPassword ( $ password ) ; } }
Main init method
14,246
public static function getInject ( $ type = null ) { if ( $ type === null ) return static :: $ inject ; elseif ( isset ( static :: $ inject [ $ type ] ) ) return static :: $ inject [ $ type ] ; return array ( ) ; }
Fetches classes to inject from the config
14,247
protected static function initDB ( ) { $ dbConfig = static :: getConfig ( 'db' , static :: getServer ( ) ) ; static :: $ db = new Connection ( $ dbConfig [ 'dsn' ] , $ dbConfig [ 'user' ] , $ dbConfig [ 'password' ] , $ dbConfig [ 'options' ] ) ; static :: $ db -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; if ( ! empty ( $ dbConfig [ 'tablePrefix' ] ) ) static :: $ db -> setTablePrefix ( $ dbConfig [ 'tablePrefix' ] ) ; }
Creates a database connection using \ DBScribe \ Connection
14,248
public static function getUrls ( ) { if ( static :: $ urls !== null ) return static :: $ urls ; $ uri = $ _SERVER [ 'REQUEST_URI' ] ; static :: $ isVirtual = true ; if ( substr ( $ uri , 0 , strlen ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) === $ _SERVER [ 'SCRIPT_NAME' ] ) { $ uri = str_replace ( '/index.php' , '' , $ uri ) ; } else if ( stristr ( $ _SERVER [ 'SCRIPT_NAME' ] , '/index.php' , true ) ) { static :: $ serverPath = stristr ( $ _SERVER [ 'SCRIPT_NAME' ] , '/index.php' , true ) ; $ uri = str_replace ( array ( static :: $ serverPath , '/index.php' ) , '' , $ uri ) ; static :: $ isVirtual = false ; } parse_str ( $ _SERVER [ 'QUERY_STRING' ] , $ _GET ) ; static :: $ urls = static :: updateArrayKeys ( explode ( '/' , str_replace ( '?' . $ _SERVER [ 'QUERY_STRING' ] , '' , $ uri ) ) , true ) ; return static :: $ urls ; }
Fetches the urls from the server request uri
14,249
protected static function checkAlias ( $ module ) { if ( array_key_exists ( $ module , static :: getConfig ( 'modules' ) ) ) return $ module ; foreach ( static :: getConfig ( 'modules' ) as $ cModule => $ moduleOptions ) { if ( ! array_key_exists ( 'alias' , $ moduleOptions ) ) continue ; if ( $ moduleOptions [ 'alias' ] === Util :: camelToHyphen ( $ module ) ) return $ cModule ; } return $ module ; }
Checks if the module is an alias and returns the ModuleName
14,250
public static function getModuleAlias ( $ module ) { if ( NULL !== $ alias = static :: getConfig ( 'modules' , $ module , 'alias' , false ) ) { return $ alias ; } return Util :: camelToHyphen ( $ module ) ; }
Fetches the alias for the given module
14,251
public static function getDefaultModule ( $ getAlias = false ) { if ( ! $ module = static :: getConfig ( 'defaults' , 'module' , false ) ) { $ modules = static :: getConfig ( 'modules' ) ; $ moduleNames = array_keys ( $ modules ) ; $ module = $ moduleNames [ 0 ] ; } return $ getAlias ? static :: getModuleAlias ( $ module ) : $ module ; }
Fetches the default module from the config
14,252
public static function getDefaultController ( $ module = null , $ exception = false ) { $ module = ( $ module === null ) ? static :: getDefaultModule ( ) : $ module ; return static :: getConfig ( 'modules' , $ module , 'defaults' , 'controller' , $ exception ) ; }
Fetches the default controller from the config
14,253
public static function getDefaultAction ( $ module = null , $ exception = false ) { $ module = ( $ module === null ) ? static :: getDefaultModule ( ) : $ module ; return static :: getConfig ( 'modules' , $ module , 'defaults' , 'action' , $ exception ) ; }
Fetches the default action from the config
14,254
protected static function getControllerClass ( $ live = true ) { $ class = static :: getModule ( ) . '\Controllers\\' . static :: getController ( ) . 'Controller' ; if ( ! class_exists ( $ class ) ) ControllerException :: notFound ( $ class ) ; if ( ! in_array ( 'DScribe\Core\AController' , class_parents ( $ class ) ) ) throw new \ Exception ( 'Controller Exception: Controller "' . $ class . '" does not extend "DScribe\Core\AController"' ) ; return ( $ live ) ? new $ class ( ) : $ class ; }
Creates an instance of the current controller class
14,255
protected static function authenticate ( $ controller , $ action , $ params ) { $ auth = new Authenticate ( static :: $ userId , $ controller , $ action ) ; if ( ! $ auth -> execute ( ) ) { $ controller -> accessDenied ( $ action , $ params ) ; exit ; } }
Authenticates the current user against the controller and action
14,256
public static function resetUserIdentity ( AUser $ user = NULL , $ duration = null ) { static :: $ userId = new UserIdentity ( $ user , $ duration ) ; if ( ! $ user ) Session :: reset ( ) ; static :: saveSession ( ) ; }
Resets the user to guest
14,257
protected function createLoginAttempt ( array $ data , array $ headers , array $ query ) { if ( empty ( $ data [ 'grant_type' ] ) ) { throw new \ InvalidArgumentException ( 'Any grant_type given.' ) ; } $ grantType = $ data [ 'grant_type' ] ; if ( ! $ this -> grantExtensions -> containsKey ( $ grantType ) ) { throw new \ InvalidArgumentException ( 'Given grant_type is invalid.' ) ; } $ requestResolver = new OptionsResolver ( ) ; $ requestResolver -> setRequired ( array ( 'client_secret' , 'client_api_key' , 'grant_type' , ) ) ; $ this -> grantExtensions -> get ( $ grantType ) -> configureRequestParameters ( $ requestResolver ) ; return new LoginAttempt ( $ query , $ requestResolver -> resolve ( $ data ) , $ headers ) ; }
Validate given request parameters and build a LoginAttempt object with it .
14,258
protected function loadApplication ( LoginAttempt $ loginAttempt ) { if ( ! $ application = $ this -> applicationLoader -> retrieveByApiKeyAndSecret ( $ loginAttempt -> getData ( 'client_api_key' ) , $ loginAttempt -> getData ( 'client_secret' ) ) ) { throw new InvalidGrantException ( $ loginAttempt , 'Any application found for given api_key / secret.' ) ; } return $ application ; }
Loads application for given login attempt .
14,259
protected function loadAccount ( ApplicationInterface $ application , LoginAttempt $ loginAttempt ) { return $ this -> grantExtensions -> get ( $ loginAttempt -> getData ( 'grant_type' ) ) -> grant ( $ application , $ loginAttempt ) ; }
Runs grant extension to load accounts .
14,260
public function grant ( array $ data , array $ headers = array ( ) , array $ query = array ( ) ) { $ loginAttempt = $ this -> createLoginAttempt ( $ data , $ headers , $ query ) ; $ account = $ this -> loadAccount ( $ application = $ this -> loadApplication ( $ loginAttempt ) , $ loginAttempt ) ; $ this -> eventDispatcher -> dispatch ( AccessTokenEvents :: MAJORA_ACCESS_TOKEN_CREATED , new AccessTokenEvent ( $ accessToken = new $ this -> tokenOptions [ 'access_token_class' ] ( $ application , $ account , $ this -> tokenOptions [ 'access_token_ttl' ] , null , $ this -> randomTokenGenerator -> generate ( 'access_token' ) , in_array ( 'refresh_token' , $ application -> getAllowedGrantTypes ( ) ) && $ this -> grantExtensions -> containsKey ( 'refresh_token' ) ? new $ this -> tokenOptions [ 'refresh_token_class' ] ( $ application , $ account , $ this -> tokenOptions [ 'refresh_token_ttl' ] , null , $ this -> randomTokenGenerator -> generate ( 'refresh_token' ) ) : null ) ) ) ; return $ accessToken ; }
Grant given credentials or throws an exception if invalid credentials for application or account .
14,261
public static function start ( ) { if ( self :: $ _page ) { return null ; } self :: $ _page = new Html \ Document ( ) ; self :: $ _zones [ 'head' ] = self :: $ _page -> head ( ) ; self :: $ _zones [ 'body' ] = self :: $ _page -> body ( ) ; ob_start ( ) ; return self :: $ _page ; }
Initialize page .
14,262
public static function createZone ( $ zoneName , $ tag = 'div' ) { if ( self :: $ _page && ! isset ( self :: $ _zones [ $ zoneName ] ) ) { $ element = new Html \ Element ( $ tag ) ; self :: $ _zones [ $ zoneName ] = $ element ; self :: append ( self :: $ _outputZone , $ element ) ; return $ element ; } return null ; }
Create a new page zone .
14,263
public static function getZone ( $ zoneName = null ) { if ( $ zoneName === null ) { $ zoneName = self :: $ _outputZone ; } return ( isset ( self :: $ _zones [ $ zoneName ] ) ? self :: $ _zones [ $ zoneName ] : null ) ; }
Get zone element .
14,264
public static function append ( $ zoneName , ... $ data ) { if ( isset ( self :: $ _zones [ $ zoneName ] ) ) { self :: flushBuffer ( ) ; call_user_func_array ( array ( self :: $ _zones [ $ zoneName ] , 'append' ) , $ data ) ; return true ; } return false ; }
Append data to to zone .
14,265
public static function flushBuffer ( ) { if ( self :: $ _page && ob_get_length ( ) ) { self :: $ _zones [ self :: $ _outputZone ] -> append ( ob_get_clean ( ) ) ; ob_start ( ) ; return true ; } return false ; }
Flushes the output buffer to the current zone element .
14,266
public static function metaTag ( $ name , $ content ) { if ( self :: $ _page ) { self :: $ _page -> metaTag ( $ name , $ content ) ; } }
Set meta tag .
14,267
public static function end ( ) { if ( ! self :: $ _page || ErrorHandling :: lastError ( ) ) { return ; } self :: $ _zones [ self :: $ _outputZone ] -> append ( ob_get_clean ( ) ) ; self :: $ _page -> output ( ) ; self :: $ _page = null ; self :: $ _zones = array ( ) ; self :: $ _zoneStack = array ( ) ; self :: $ _outputZone = 'body' ; echo '<!-- ' ; echo '~' , Asbestos :: executionTime ( ) ; echo " ; }
Finalize and output page .
14,268
public static function getType ( $ type ) { if ( ! isset ( self :: $ typesMap [ $ type ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid type specified "%s".' , $ type ) ) ; } if ( ! isset ( self :: $ typeObjects [ $ type ] ) ) { $ className = self :: $ typesMap [ $ type ] ; self :: $ typeObjects [ $ type ] = new $ className ; } return self :: $ typeObjects [ $ type ] ; }
Get a Type instance .
14,269
public static function discountIsValid ( $ code ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOrNull ( $ code ) ; if ( $ discount == null ) return false ; $ engine = Discount_Shortcuts_GetEngineOrNull ( $ discount -> get_type ( ) ) ; if ( $ engine == null ) return false ; return $ engine -> isValid ( $ discount ) ; }
Checks if discount with given code is valid .
14,270
public static function getPrice ( $ originPrice , $ discountCode , $ request ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOr404 ( $ discountCode ) ; $ engine = $ discount -> get_engine ( ) ; return $ engine -> getPrice ( $ originPrice , $ discount , $ request ) ; }
Computes and returns new price after using given discount
14,271
public static function consumeDiscount ( $ discountCode ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOr404 ( $ discountCode ) ; $ engine = $ discount -> get_engine ( ) ; $ engine -> consumeDiscount ( $ discount ) ; return $ discount ; }
Decrease one unit of given discount . If discount is one - time - use it will be invalid after this function .
14,272
public function processStack ( $ payload , PipeChainCollectionInterface $ pipeChainCollection ) { foreach ( $ pipeChainCollection as $ stage => $ fallback ) { $ payload = $ this -> process ( $ payload , $ stage , $ fallback ) ; } return $ payload ; }
processes a PipeChainCollection with the provided payload .
14,273
public function fetchJSON ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { $ contents = $ this -> fetchURL ( $ url , $ followRedirects , $ username , $ password , $ headers ) ; return JSONUtils :: decode ( $ contents , true ) ; }
Fetch the contents of a URL as a JSON array
14,274
public function headURL ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { if ( function_exists ( 'curl_init' ) ) { $ contents = $ this -> curlRequest ( $ url , true , $ followRedirects , $ username , $ password , $ headers ) ; return $ contents ; } else { throw new HttpRequestException ( 'headURL not supported without curl' ) ; } }
Fetch the headers of a URL
14,275
public function fetchURL ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { if ( function_exists ( 'curl_init' ) ) { $ contents = $ this -> curlRequest ( $ url , false , $ followRedirects , $ username , $ password , $ headers ) ; return $ contents ; } else { if ( $ this -> userAgent != null ) { $ opts = array ( 'http' => array ( 'user_agent' => $ this -> userAgent , 'max_redirects' => $ this -> redirects , ) ) ; } if ( $ username && $ password ) { $ opts = ( $ opts ) ? $ opts : array ( 'http' => array ( ) ) ; $ opts [ 'http' ] [ 'header' ] = array ( 'Authorization: Basic ' . base64_encode ( "$username:$password" ) ) ; } if ( $ headers ) { $ opts [ 'http' ] [ 'header' ] = $ headers ; } $ context = ( $ opts ) ? stream_context_create ( $ opts ) : null ; unset ( $ opts ) ; $ contents = @ file_get_contents ( $ url , false , $ context ) ; if ( $ contents === false ) throw new HttpRequestException ( "Unknown error fetching URL '" . $ url . "'" ) ; unset ( $ context ) ; unset ( $ url ) ; return $ contents ; } }
Fetch the contents of a URL
14,276
public function setPluginManager ( PluginManager $ plugins ) { $ this -> plugins = $ plugins ; $ this -> plugins -> setController ( $ this -> controller ) ; return $ this ; }
Set plugin manager
14,277
public function getValues ( ) { $ exploded = explode ( "," , $ this -> getValue ( ) ) ; $ values = array ( ) ; foreach ( $ exploded as $ entry ) { $ values [ ] = trim ( $ entry ) ; } return $ values ; }
Return value as an array split by
14,278
public static function fromGlobals ( ) { $ request = new self ( ) ; foreach ( [ 'Accept' , 'Accept-Charset' , 'Accept-Encoding' , 'Accept-Language' , 'Connection' , 'Host' , 'Referer' , 'User-Agent' ] as $ name ) { $ key = 'HTTP_' . str_replace ( '-' , '_' , strtoupper ( $ name ) ) ; if ( isset ( $ _SERVER [ $ key ] ) ) { $ request -> setHeader ( $ name , $ _SERVER [ $ key ] , false ) ; } } $ request -> _isSecure = ( ! empty ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] != 'off' ) ; $ request -> _method = $ _SERVER [ 'REQUEST_METHOD' ] ; $ request -> _uri = $ _SERVER [ 'REQUEST_URI' ] ; $ request -> _path = strstr ( $ _SERVER [ 'REQUEST_URI' ] , '?' , true ) ; if ( $ request -> _path == false ) { $ request -> _path = $ _SERVER [ 'REQUEST_URI' ] ; } $ request -> _query = strstr ( $ _SERVER [ 'REQUEST_URI' ] , '?' ) ; if ( $ request -> _query == false ) { $ request -> _query = '' ; } return $ request ; }
Create request from PHP globals .
14,279
public function executeMigrate ( ) { $ this -> app -> eloquent -> getConnection ( ) -> useDefaultSchemaGrammar ( ) ; $ file = $ this -> app -> path [ 'app' ] -> file ( $ this -> app -> config -> get ( 'db.schema_path' , 'database/schema.php' ) ) ; if ( ! $ file -> isExists ( ) ) throw new \ Exception ( '[' . $ file . '] does not exists.' ) ; $ file -> load ( array ( 'schema' => new \ Laraquent \ Schema ( $ this -> app -> eloquent -> getConnection ( ) ) ) ) ; }
Migrate eloquent schema Use db . schema_path config if configured
14,280
protected function elements ( $ code ) { libxml_use_internal_errors ( true ) ; $ doc = new \ DOMDocument ; $ doc -> loadHTML ( ( string ) $ code ) ; $ tag = ( string ) $ this -> tagname ; $ items = $ doc -> getElementsByTagName ( $ tag ) ; $ items = iterator_to_array ( $ items ) ; return count ( $ items ) > 0 ? $ items : array ( ) ; }
Returns elements by a tag name .
14,281
public function toString ( $ indent = null ) { $ output = parent :: toString ( $ indent ) ; $ output = str_replace ( [ '<title>' , '</title>' ] , [ '<h1>' , '</h1>' ] , $ output ) ; return $ output ; }
Turn helper into string
14,282
private function dumpXmlErrors ( $ xmlFile ) { $ severity = [ LIBXML_ERR_WARNING => 'Warning' , LIBXML_ERR_ERROR => 'Error' , LIBXML_ERR_FATAL => 'Fatal' ] ; $ errors = [ ] ; foreach ( libxml_get_errors ( ) as $ error ) { $ errors [ ] = sprintf ( "Row %d, column %d: %s (%d) %s" , $ error -> line , $ error -> column , $ severity [ $ error -> level ] , $ error -> code , $ error -> message ) ; } throw new ConfigException ( sprintf ( "Could not parse XML configuration in '%s'.\n\n%s" , $ xmlFile , implode ( "\n" , $ errors ) ) ) ; }
Create formatted output of XML errors
14,283
private function parseDbSettings ( \ DOMNode $ db ) { $ context = $ this -> isLocalhost ? 'local' : 'remote' ; $ xpath = new \ DOMXPath ( $ db -> ownerDocument ) ; $ d = $ xpath -> query ( "db_connection[@context='$context']" , $ db ) ; if ( ! $ d -> length ) { $ d = $ db -> getElementsByTagName ( 'db_connection' ) ; } if ( $ d -> length ) { $ this -> db = new \ stdClass ( ) ; foreach ( $ d -> item ( 0 ) -> childNodes as $ node ) { if ( $ node -> nodeType !== XML_ELEMENT_NODE ) { continue ; } $ v = trim ( $ node -> nodeValue ) ; $ k = $ node -> nodeName ; $ this -> db -> $ k = $ v ; } } }
parse db settings
14,284
private function parseVxpdoSettings ( \ DOMNode $ vxpdo ) { if ( is_null ( $ this -> vxpdo ) ) { $ this -> vxpdo = [ ] ; } foreach ( $ vxpdo -> getElementsByTagName ( 'datasource' ) as $ datasource ) { $ name = $ datasource -> getAttribute ( 'name' ) ? : 'default' ; if ( array_key_exists ( $ name , $ this -> vxpdo ) ) { throw new ConfigException ( sprintf ( "Datasource '%s' declared twice." , $ name ) ) ; } $ config = [ 'driver' => null , 'dsn' => null , 'host' => null , 'port' => null , 'user' => null , 'password' => null , 'dbname' => null , ] ; foreach ( $ datasource -> childNodes as $ node ) { if ( $ node -> nodeType !== XML_ELEMENT_NODE ) { continue ; } if ( array_key_exists ( $ node -> nodeName , $ config ) ) { $ config [ $ node -> nodeName ] = trim ( $ node -> nodeValue ) ; } } $ this -> vxpdo [ $ name ] = ( object ) $ config ; } }
parse datasource settings
14,285
private function parseSiteSettings ( \ DOMNode $ site ) { if ( is_null ( $ this -> site ) ) { $ this -> site = new \ stdClass ; $ this -> site -> use_nice_uris = FALSE ; } foreach ( $ site -> childNodes as $ node ) { if ( $ node -> nodeType !== XML_ELEMENT_NODE ) { continue ; } $ v = trim ( $ node -> nodeValue ) ; $ k = $ node -> nodeName ; switch ( $ k ) { case 'locales' : if ( ! isset ( $ this -> site -> locales ) ) { $ this -> site -> locales = [ ] ; } foreach ( $ node -> getElementsByTagName ( 'locale' ) as $ locale ) { $ loc = $ locale -> getAttribute ( 'value' ) ; if ( $ loc && ! in_array ( $ loc , $ this -> site -> locales ) ) { $ this -> site -> locales [ ] = $ loc ; } if ( $ loc && $ locale -> getAttribute ( 'default' ) === '1' ) { $ this -> site -> default_locale = $ loc ; } } break ; case 'site->use_nice_uris' : if ( $ v === '1' ) { $ this -> site -> use_nice_uris = TRUE ; } break ; default : $ this -> site -> $ k = $ v ; } } }
parse general website settings
14,286
private function parseTemplatingSettings ( \ DOMNode $ templating ) { if ( is_null ( $ this -> templating ) ) { $ this -> templating = new \ stdClass ; $ this -> templating -> filters = [ ] ; } $ xpath = new \ DOMXPath ( $ templating -> ownerDocument ) ; foreach ( $ xpath -> query ( "filters/filter" , $ templating ) as $ filter ) { $ id = $ filter -> getAttribute ( 'id' ) ; $ class = $ filter -> getAttribute ( 'class' ) ; if ( ! $ id ) { throw new ConfigException ( 'Templating filter without id found.' ) ; } if ( ! $ class ) { throw new ConfigException ( sprintf ( "No class for templating filter '%s' configured." , $ id ) ) ; } if ( isset ( $ this -> templating -> filters [ $ id ] ) ) { throw new ConfigException ( sprintf ( "Templating filter '%s' has already been defined." , $ id ) ) ; } $ class = '\\' . ltrim ( str_replace ( '/' , '\\' , $ class ) , '/\\' ) ; $ this -> templating -> filters [ $ id ] = [ 'class' => $ class , 'parameters' => $ filter -> getAttribute ( 'parameters' ) ] ; } }
parse templating configuration currently only filters for SimpleTemplate templates and their configuration are parsed
14,287
private function parsePathsSettings ( \ DOMNode $ paths ) { if ( is_null ( $ this -> paths ) ) { $ this -> paths = [ ] ; } foreach ( $ paths -> getElementsByTagName ( 'path' ) as $ path ) { $ id = $ path -> getAttribute ( 'id' ) ; $ subdir = $ path -> getAttribute ( 'subdir' ) ? : '' ; if ( ! $ id || ! $ subdir ) { continue ; } $ subdir = '/' . trim ( $ subdir , '/' ) . '/' ; $ this -> paths [ $ id ] = [ 'subdir' => $ subdir ] ; } }
parse various path setting
14,288
private function parseMenusSettings ( \ DOMNode $ menus ) { foreach ( ( new \ DOMXPath ( $ menus -> ownerDocument ) ) -> query ( 'menu' , $ menus ) as $ menu ) { $ id = $ menu -> getAttribute ( 'id' ) ? : Menu :: DEFAULT_ID ; if ( isset ( $ this -> menus [ $ id ] ) ) { $ this -> appendMenuEntries ( $ menu -> childNodes , $ this -> menus [ $ id ] ) ; } else { $ this -> menus [ $ id ] = $ this -> parseMenu ( $ menu ) ; } } }
parse menu tree if menus share the same id entries of later menus are appended to the first ; other menu attributes are left unchanged
14,289
private function parseServicesSettings ( \ DOMNode $ services ) { if ( is_null ( $ this -> services ) ) { $ this -> services = [ ] ; } foreach ( $ services -> getElementsByTagName ( 'service' ) as $ service ) { if ( ! ( $ id = $ service -> getAttribute ( 'id' ) ) ) { throw new ConfigException ( 'Service without id found.' ) ; } if ( isset ( $ this -> services [ $ id ] ) ) { throw new ConfigException ( sprintf ( "Service '%s' has already been defined." , $ id ) ) ; } if ( ! ( $ class = $ service -> getAttribute ( 'class' ) ) ) { throw new ConfigException ( sprintf ( "No class for service '%s' configured." , $ id ) ) ; } $ class = '\\' . ltrim ( str_replace ( '/' , '\\' , $ class ) , '/\\' ) ; $ this -> services [ $ id ] = [ 'class' => $ class , 'parameters' => [ ] ] ; foreach ( $ service -> getElementsByTagName ( 'parameter' ) as $ parameter ) { $ name = $ parameter -> getAttribute ( 'name' ) ; $ value = $ parameter -> getAttribute ( 'value' ) ; if ( ! $ name ) { throw new ConfigException ( sprintf ( "A parameter for service '%s' has no name." , $ id ) ) ; } $ this -> services [ $ id ] [ 'parameters' ] [ $ name ] = $ value ; } } }
parse settings for services only service id class and parameters are parsed lazy initialization is handled by Application instance
14,290
private function parseMenu ( \ DOMNode $ menu ) { $ root = $ menu -> getAttribute ( 'script' ) ; if ( ! $ root ) { if ( $ this -> site ) { $ root = $ this -> site -> root_document ? : 'index.php' ; } else { $ root = 'index.php' ; } } $ type = $ menu -> getAttribute ( 'type' ) === 'dynamic' ? 'dynamic' : 'static' ; $ service = $ menu -> getAttribute ( 'service' ) ? : NULL ; $ id = $ menu -> getAttribute ( 'id' ) ? : NULL ; if ( $ type === 'dynamic' && ! $ service ) { throw new ConfigException ( "A dynamic menu requires a configured service." ) ; } $ m = new Menu ( $ root , $ id , $ type , $ service ) ; if ( ( $ menuAuth = strtolower ( trim ( $ menu -> getAttribute ( 'auth' ) ) ) ) ) { $ m -> setAuth ( $ menuAuth ) ; if ( ( $ authParameters = $ menu -> getAttribute ( 'auth_parameters' ) ) ) { $ m -> setAuthParameters ( $ authParameters ) ; } } $ this -> appendMenuEntries ( $ menu -> childNodes , $ m ) ; return $ m ; }
Parse XML menu entries and creates menu instance
14,291
public function createConst ( ) { $ properties = get_object_vars ( $ this ) ; if ( isset ( $ properties [ 'db' ] ) ) { foreach ( $ properties [ 'db' ] as $ k => $ v ) { if ( is_scalar ( $ v ) ) { $ k = strtoupper ( $ k ) ; if ( ! defined ( "DB$k" ) ) { define ( "DB$k" , $ v ) ; } } } } if ( isset ( $ properties [ 'site' ] ) ) { foreach ( $ properties [ 'site' ] as $ k => $ v ) { if ( is_scalar ( $ v ) ) { $ k = strtoupper ( $ k ) ; if ( ! defined ( $ k ) ) { define ( $ k , $ v ) ; } } } } if ( isset ( $ properties [ 'paths' ] ) ) { foreach ( $ properties [ 'paths' ] as $ k => $ v ) { $ k = strtoupper ( $ k ) ; if ( ! defined ( $ k ) ) { define ( $ k , $ v [ 'subdir' ] ) ; } } } $ locale = localeconv ( ) ; foreach ( $ locale as $ k => $ v ) { $ k = strtoupper ( $ k ) ; if ( ! defined ( $ k ) && ! is_array ( $ v ) ) { define ( $ k , $ v ) ; } } }
create constants for simple access to certain configuration settings
14,292
public function getPaths ( $ access = 'rw' ) { $ paths = [ ] ; foreach ( $ this -> paths as $ p ) { if ( $ p [ 'access' ] === $ access ) { array_push ( $ paths , $ p ) ; } } return $ paths ; }
returns all paths matching access criteria
14,293
private function getServerConfig ( ) { $ this -> server [ 'apc_on' ] = extension_loaded ( 'apc' ) && function_exists ( 'apc_add' ) && ini_get ( 'apc.enabled' ) && ini_get ( 'apc.rfc1867' ) ; $ fs = ini_get ( 'upload_max_filesize' ) ; $ suffix = strtoupper ( substr ( $ fs , - 1 ) ) ; switch ( $ suffix ) { case 'K' : $ mult = 1024 ; break ; case 'M' : $ mult = 1024 * 1024 ; break ; case 'G' : $ mult = 1024 * 1024 * 1024 ; break ; default : $ mult = 0 ; } $ this -> server [ 'max_upload_filesize' ] = $ mult ? ( float ) ( substr ( $ fs , 0 , - 1 ) ) * $ mult : ( int ) $ fs ; }
add particular information regarding server configuration like PHP extensions
14,294
public function run ( ) { $ request = $ this -> getService ( 'requestStack' ) -> getMasterRequest ( ) ; $ this -> getPreProcesses ( ) -> execute ( $ request ) ; $ response = $ this -> getFrontController ( ) -> call ( $ request ) ; $ this -> getPostProcesses ( ) -> execute ( $ response ) ; $ response -> send ( ) ; }
Sends the http response
14,295
public function initModules ( IModulesLoader $ modulesLoader ) { foreach ( $ modulesLoader -> getModules ( ) as $ module ) { $ this -> addModule ( $ module ) ; } }
Init the modules of the current project .
14,296
public function get ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller , 'get' ) -> getPattern ( ) ) ; }
Adds a controller called by http GET method .
14,297
public function post ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller , 'post' ) -> getPattern ( ) ) ; }
Adds a controller called by http POST method .
14,298
public function json ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller , '' , 'application/json' ) -> getPattern ( ) ) ; }
Adds a controller with a json format .
14,299
public function any ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller ) -> getPattern ( ) ) ; }
Adds a controller called by any http method or format .