idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
22,800
public function renderAction ( Request $ request ) { $ blockType = $ request -> get ( 'blockType' , null ) ; $ action = $ request -> get ( 'action' , null ) ; $ params = array_merge ( $ request -> request -> all ( ) , $ request -> query -> all ( ) ) ; $ block = $ this -> getBlockServiceManager ( ) -> getService ( $ blockType ) ; if ( ! $ block ) { throw $ this -> createNotFoundException ( sprintf ( 'Cannot find block service "%s"' , $ blockType ) ) ; } if ( ! $ block instanceof AbstractAdminBlockService ) { throw new \ Exception ( 'Block should be an instance of AbstractAdminBlockService' ) ; } $ params [ 'block' ] = $ block ; $ methodName = sprintf ( "%sAction" , $ action ) ; if ( ! is_callable ( array ( $ block , $ methodName ) , false ) ) { throw $ this -> createNotFoundException ( sprintf ( 'Cannot find method "%s" in block service "%s"' , $ methodName , $ blockType ) ) ; } return call_user_func_array ( array ( $ block , $ methodName ) , array ( $ request , $ params ) ) ; }
Default render action
22,801
public function decode ( \ FreeFW \ JsonApi \ V1 \ Model \ Document $ p_document ) : \ FreeFW \ Core \ Model { if ( $ p_document -> isSimpleResource ( ) ) { $ resource = $ p_document -> getData ( ) ; $ cls = $ resource -> getType ( ) ; $ class = str_replace ( '_' , '::Model::' , $ cls ) ; $ obj = \ FreeFW \ DI \ DI :: get ( $ class ) ; $ attr = $ resource -> getAttributes ( ) ; $ obj -> initWithJson ( $ attr -> __toArray ( ) ) ; return $ obj ; } die ( 'decoder' ) ; return null ; }
Decode a ApiResponseInterface
22,802
public function getFields ( ) { $ fields = array ( ) ; foreach ( $ this -> columns as $ column ) { $ fields = array_merge ( $ fields , $ column -> getFields ( ) ) ; } return $ fields ; }
Returns the fields used in the different cells of the list
22,803
public function getSubView ( $ name ) { if ( isset ( $ this -> subViews [ $ name ] ) ) return $ this -> subViews [ $ name ] ; else return $ this -> getNewSubView ( $ name ) ; }
Will return an instance of the Controller required as a subview .
22,804
public function getNewSubView ( $ name ) { try { $ controller = new $ name ( ) ; if ( ! ( $ controller instanceof \ OWeb \ types \ Controller ) ) throw new \ OWeb \ manage \ exceptions \ Controller ( "The class \"" . $ name . "\" isn't an instance of \OWeb\Types\Controller" ) ; if ( ! isset ( $ this -> subViews [ $ name ] ) ) $ this -> subViews [ $ name ] = $ controller ; \ OWeb \ manage \ Events :: getInstance ( ) -> sendEvent ( 'loaded@OWeb\manage\SubViews' , $ controller ) ; $ controller -> init ( ) ; return $ controller ; } catch ( \ Exception $ ex ) { throw new \ OWeb \ manage \ exceptions \ Controller ( "The SubView : \"" . $ name . "\"couldn't be loaded due to Errors" , 0 , $ ex ) ; } }
Will return a new instance of the Controller required as a subview . After having initialized it .
22,805
private function detectHomeDirectory ( ) { if ( false !== ( $ home = getenv ( 'COMPOSER' ) ) ) { return dirname ( $ home ) ; } if ( '' !== \ Phar :: running ( ) ) { $ home = dirname ( substr ( \ Phar :: running ( ) , 7 ) ) ; } else { $ home = getcwd ( ) ; } if ( ( PHP_SAPI !== 'cli' ) && ( substr ( $ home , - 4 ) !== DIRECTORY_SEPARATOR . 'web' ) ) { throw new \ RuntimeException ( 'Tenside is intended to be run from within the web directory but it appears you are running it from ' . basename ( $ home ) ) ; } return dirname ( $ home ) ; }
Determine the correct working directory .
22,806
public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillDependencyTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } $ query = SkillDependencyQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; }
Performs an INSERT on the database given a SkillDependency or Criteria object .
22,807
public function spell ( $ item ) { $ formatter = new NumberFormatter ( $ this -> config [ 'locale' ] , NumberFormatter :: SPELLOUT ) ; if ( is_int ( $ item ) ) { return $ formatter -> format ( $ item ) ; } return preg_replace_callback ( '/([0-9]+)/' , function ( $ matches ) use ( $ formatter ) { return $ formatter -> format ( $ matches [ 0 ] ) ; } , $ item ) ; }
Convert a number into a word
22,808
public function ordinal ( $ item ) { $ formatter = new NumberFormatter ( $ this -> config [ 'locale' ] , NumberFormatter :: ORDINAL ) ; if ( is_int ( $ item ) ) { return $ formatter -> format ( $ item ) ; } return preg_replace_callback ( '/([0-9]+)/' , function ( $ matches ) use ( $ formatter ) { return $ formatter -> format ( $ matches [ 0 ] ) ; } , $ item ) ; }
Convert a number into it s ordinal type eg 1 - > 1st 2 - > 2nd
22,809
public function ConditionExpr ( $ Field , $ Value , $ EscapeFieldSql = TRUE , $ EscapeValueSql = TRUE ) { if ( $ EscapeFieldSql === FALSE ) { $ Field = '@' . $ Field ; } if ( is_array ( $ Value ) ) { $ ValueStr = 'ARRAY' ; Deprecated ( "Gdn_SQL->ConditionExpr(VALUE, {$ValueStr})" , 'Gdn_SQL->ConditionExpr(VALUE, VALUE)' ) ; if ( $ EscapeValueSql ) throw new Gdn_UserException ( 'Invalid function call.' ) ; $ FunctionCall = array_keys ( $ Value ) ; $ FunctionCall = $ FunctionCall [ 0 ] ; $ FunctionArg = $ Value [ $ FunctionCall ] ; if ( $ EscapeValueSql ) $ FunctionArg = '[' . $ FunctionArg . ']' ; if ( stripos ( $ FunctionCall , '%s' ) === FALSE ) $ Value = '=' . $ FunctionCall . '(' . $ FunctionArg . ')' ; else $ Value = '=' . sprintf ( $ FunctionCall , $ FunctionArg ) ; $ EscapeValueSql = FALSE ; } else if ( ! $ EscapeValueSql && ! is_null ( $ Value ) ) { $ Value = '@' . $ Value ; } if ( ! $ EscapeFieldSql && ! $ EscapeValueSql && is_null ( $ Value ) ) return substr ( $ Field , 1 ) ; $ Expr = '' ; $ Op = '' ; $ FieldOpRegex = "/(?:\s*(=|<>|>|<|>=|<=)\s*$)|\s+(like|not\s+like)\s*$|\s+(?:(is)\s+(null)|(is\s+not)\s+(null))\s*$/i" ; $ Split = preg_split ( $ FieldOpRegex , $ Field , - 1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; if ( count ( $ Split ) > 1 ) { $ Field = $ Split [ 0 ] ; $ Op = $ Split [ 1 ] ; if ( count ( $ Split ) > 2 ) { $ Value = null ; } } else { $ Op = '=' ; } if ( $ Op == '=' && is_null ( $ Value ) ) { $ Op = 'is' ; $ Value = '@null' ; $ EscapeValueSql = FALSE ; } $ Expr .= $ this -> _ParseExpr ( $ Field , NULL , $ EscapeFieldSql ) ; $ Expr .= ' ' . $ Op . ' ' ; if ( $ Op == 'is' || $ Op == 'is not' && is_null ( $ Value ) ) { $ Expr .= 'null' ; } else { $ Expr .= $ this -> _ParseExpr ( $ Value , $ Field , $ EscapeValueSql ) ; } return $ Expr ; }
Returns a single Condition Expression for use in a where or an on clause .
22,810
public function Cache ( $ Key , $ Operation = NULL , $ Options = NULL ) { if ( ! $ Key ) { $ this -> _CacheKey = NULL ; $ this -> _CacheOperation = NULL ; $ this -> _CacheOptions = NULL ; return $ this ; } $ this -> _CacheKey = $ Key ; if ( ! is_null ( $ Operation ) ) $ this -> _CacheOperation = $ Operation ; if ( ! is_null ( $ Options ) ) $ this -> _CacheOptions = $ Options ; return $ this ; }
Set the cache key for this transaction
22,811
public function Delete ( $ Table = '' , $ Where = '' , $ Limit = FALSE ) { if ( $ Table == '' ) { if ( ! isset ( $ this -> _Froms [ 0 ] ) ) return FALSE ; $ Table = $ this -> _Froms [ 0 ] ; } elseif ( is_array ( $ Table ) ) { foreach ( $ Table as $ t ) { $ this -> Delete ( $ t , $ Where , $ Limit , FALSE ) ; } return ; } else { $ Table = $ this -> EscapeIdentifier ( $ this -> Database -> DatabasePrefix . $ Table ) ; } if ( $ Where != '' ) $ this -> Where ( $ Where ) ; if ( $ Limit !== FALSE ) $ this -> Limit ( $ Limit ) ; if ( count ( $ this -> _Wheres ) == 0 ) return FALSE ; $ Sql = $ this -> GetDelete ( $ Table , $ this -> _Wheres , $ this -> _Limit ) ; return $ this -> Query ( $ Sql , 'delete' ) ; }
Builds and executes a delete from query .
22,812
public function Distinct ( $ Bool = TRUE ) { $ this -> _Distinct = ( is_bool ( $ Bool ) ) ? $ Bool : TRUE ; return $ this ; }
Specifies that the query should be run as a distinct so that duplicate columns are grouped together . Returns this object for chaining purposes .
22,813
public function EmptyTable ( $ Table = '' ) { if ( $ Table == '' ) { if ( ! isset ( $ this -> _Froms [ 0 ] ) ) return FALSE ; $ Table = $ this -> _Froms [ 0 ] ; } else { $ Table = $ this -> EscapeIdentifier ( $ this -> Database -> DatabasePrefix . $ Table ) ; } $ Sql = $ this -> GetDelete ( $ Table ) ; return $ this -> Query ( $ Sql , 'delete' ) ; }
Removes all data from a table .
22,814
public function FetchTables ( $ LimitToPrefix = FALSE ) { $ Sql = $ this -> FetchTableSql ( $ LimitToPrefix ) ; $ Data = $ this -> Query ( $ Sql ) ; $ Return = array ( ) ; foreach ( $ Data -> ResultArray ( ) as $ Row ) { if ( isset ( $ Row [ 'TABLE_NAME' ] ) ) $ Return [ ] = $ Row [ 'TABLE_NAME' ] ; else $ Return [ ] = array_shift ( $ Row ) ; } return $ Return ; }
Returns an array containing table names in the database .
22,815
public function Get ( $ Table = '' , $ OrderFields = '' , $ OrderDirection = 'asc' , $ Limit = FALSE , $ PageNumber = FALSE ) { if ( $ Table != '' ) { $ this -> From ( $ Table ) ; } if ( $ OrderFields != '' ) $ this -> OrderBy ( $ OrderFields , $ OrderDirection ) ; if ( $ Limit !== FALSE ) { if ( $ PageNumber == FALSE || $ PageNumber < 1 ) $ PageNumber = 1 ; $ Offset = ( $ PageNumber - 1 ) * $ Limit ; $ this -> Limit ( $ Limit , $ Offset ) ; } $ Result = $ this -> Query ( $ this -> GetSelect ( ) ) ; return $ Result ; }
Builds the select statement and runs the query returning a result object .
22,816
protected function _GetIdentifierTokens ( $ Sql ) { $ Tokens = preg_split ( '/`/' , $ Sql , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ Result = array ( ) ; $ InIdent = FALSE ; $ CurrentToken = '' ; for ( $ i = 0 ; $ i < count ( $ Tokens ) ; $ i ++ ) { $ Token = $ Tokens [ i ] ; $ Result .= $ Token ; if ( $ Token == '`' ) { if ( $ InIdent && $ i < count ( $ Tokens ) - 1 && $ Tokens [ $ i + 1 ] == '`' ) { $ i ++ ; } else if ( $ InIdent ) { $ Result [ ] = $ CurrentToken ; $ CurrentToken = $ CurrentToken ; $ InIdent = false ; } else { $ InIdent = true ; } } else if ( ! $ InIdent ) { $ Result [ ] = $ CurrentToken ; $ CurrentToken = '' ; } } return $ Result ; }
A helper function for escaping sql identifiers .
22,817
public function GetWhere ( $ Table = '' , $ Where = FALSE , $ OrderFields = '' , $ OrderDirection = 'asc' , $ Limit = FALSE , $ Offset = 0 ) { if ( $ Table != '' ) { $ this -> From ( $ Table ) ; } if ( $ Where !== FALSE ) $ this -> Where ( $ Where ) ; if ( $ OrderFields != '' ) $ this -> OrderBy ( $ OrderFields , $ OrderDirection ) ; if ( $ Limit !== FALSE ) $ this -> Limit ( $ Limit , $ Offset ) ; $ Result = $ this -> Query ( $ this -> GetSelect ( ) ) ; return $ Result ; }
Builds the select statement and runs the query returning a result object . Allows a where clause limit and offset to be added directly .
22,818
public function GetWhereLike ( $ Table = '' , $ Like = FALSE , $ OrderFields = '' , $ OrderDirection = 'asc' , $ Limit = FALSE , $ PageNumber = FALSE ) { if ( $ Table != '' ) { $ this -> MapAliases ( $ Table ) ; $ this -> From ( $ Table ) ; } if ( $ Like !== FALSE ) $ this -> Like ( $ Like ) ; if ( $ OrderFields != '' ) $ this -> OrderBy ( $ OrderFields , $ OrderDirection ) ; if ( $ Limit !== FALSE ) { if ( $ PageNumber == FALSE || $ PageNumber < 1 ) $ PageNumber = 1 ; $ Offset = ( $ PageNumber - 1 ) * $ Limit ; $ this -> Limit ( $ Limit , $ Offset ) ; } $ Result = $ this -> Query ( $ this -> GetSelect ( ) ) ; return $ Result ; }
Builds the select statement and runs the query returning a result object . Allows a like clause limit and offset to be added directly .
22,819
public function Insert ( $ Table = '' , $ Set = NULL , $ Select = '' ) { if ( count ( $ Set ) == 0 && count ( $ this -> _Sets ) == 0 ) { return FALSE ; } if ( ! is_null ( $ Set ) && $ Select == '' && ! array_key_exists ( 0 , $ Set ) ) { $ this -> Set ( $ Set ) ; $ Set = $ this -> _Sets ; } if ( $ Table == '' ) { if ( ! isset ( $ this -> _Froms [ 0 ] ) ) return FALSE ; $ Table = $ this -> _Froms [ 0 ] ; } $ Sql = $ this -> GetInsert ( $ this -> EscapeIdentifier ( $ this -> Database -> DatabasePrefix . $ Table ) , $ Set , $ Select ) ; $ Result = $ this -> Query ( $ Sql , 'insert' ) ; return $ Result ; }
Builds the insert statement and runs the query returning a result object .
22,820
public function Replace ( $ Table = '' , $ Set = NULL , $ Where , $ CheckExisting = FALSE ) { if ( count ( $ this -> _Sets ) > 0 ) { foreach ( $ this -> _Sets as $ Key => $ Value ) { if ( array_key_exists ( $ Value , $ this -> _NamedParameters ) ) { $ Set [ $ Key ] = $ this -> _NamedParameters [ $ Value ] ; unset ( $ this -> _NamedParameters [ $ Value ] ) ; } else { $ Set [ $ Key ] = $ Value ; } } $ this -> _Sets = array ( ) ; } if ( $ CheckExisting ) { $ Row = $ this -> GetWhere ( $ Table , $ Where ) -> FirstRow ( DATASET_TYPE_ARRAY ) ; $ Update = FALSE ; if ( $ Row ) { $ Update = TRUE ; foreach ( $ Set as $ Key => $ Value ) { unset ( $ Set [ $ Key ] ) ; $ Key = trim ( $ Key , '`' ) ; if ( ! $ this -> CaptureModifications && ! array_key_exists ( $ Key , $ Row ) ) continue ; if ( in_array ( $ Key , array ( 'DateInserted' , 'InsertUserID' , 'DateUpdated' , 'UpdateUserID' ) ) ) continue ; if ( preg_match ( '/^`(.+)`$/' , $ Value , $ Matches ) ) { if ( ! array_key_exists ( $ Key , $ Row ) || $ Row [ $ Key ] != $ Row [ $ Matches [ 1 ] ] ) $ this -> Set ( '`' . $ Key . '`' , $ Value , FALSE ) ; } elseif ( ! array_key_exists ( $ Key , $ Row ) || $ Row [ $ Key ] != $ Value ) { $ this -> Set ( '`' . $ Key . '`' , $ Value ) ; } } if ( count ( $ this -> _Sets ) == 0 ) { $ this -> Reset ( ) ; return ; } } } else { $ Count = $ this -> GetCount ( $ Table , $ Where ) ; $ Update = $ Count > 0 ; } if ( $ Update ) { $ this -> Put ( $ Table , $ Set , $ Where ) ; } else { $ Set = array_merge ( $ Set , $ Where ) ; $ this -> Insert ( $ Table , $ Set ) ; } }
Inserts or updates values in the table depending on whether they are already there .
22,821
public function MapAliases ( $ TableString ) { if ( strpos ( $ TableString , ' ' ) === FALSE ) { $ TableString .= " `$TableString`" ; } $ TableString = trim ( preg_replace ( '/\s+as\s+/i' , ' ' , $ TableString ) ) ; $ Alias = strrchr ( $ TableString , " " ) ; $ TableName = substr ( $ TableString , 0 , strlen ( $ TableString ) - strlen ( $ Alias ) ) ; $ Alias = trim ( $ Alias ) ; if ( strlen ( $ Alias ) == 0 ) { $ Alias = $ TableName ; $ TableString .= " `$Alias`" ; } return $ this -> Database -> DatabasePrefix . $ TableString ; }
Takes a provided table specification and parses out any table aliases provided placing them in an alias mapping array . Returns the table specification with any table prefix prepended .
22,822
public function NamedParameter ( $ Name , $ CreateNew = FALSE , $ Value = NULL ) { $ NiceName = ':' . preg_replace ( '/([^\w\d_-])/' , '' , $ Name ) ; if ( $ CreateNew ) { $ NumberedName = $ NiceName ; $ i = 0 ; while ( array_key_exists ( $ NumberedName , $ this -> _NamedParameters ) ) { $ NumberedName = $ NiceName . $ i ; ++ $ i ; } $ NiceName = $ NumberedName ; } if ( ! is_null ( $ Value ) ) { $ this -> _NamedParameters [ $ NiceName ] = $ Value ; } return $ NiceName ; }
Takes a parameter name and makes sure it is cleaned up to be used as a named parameter in a pdo prepared statement .
22,823
protected function _ParseExpr ( $ Expr , $ Name = NULL , $ EscapeExpr = FALSE ) { $ Result = '' ; $ C = substr ( $ Expr , 0 , 1 ) ; if ( $ C === '=' && $ EscapeExpr === FALSE ) { $ FunctionArray = preg_split ( '/(\[[^\]]+\])/' , substr ( $ Expr , 1 ) , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 0 ; $ i < count ( $ FunctionArray ) ; $ i ++ ) { $ Part = $ FunctionArray [ $ i ] ; if ( substr ( $ Part , 1 ) == '[' ) { $ Part = $ this -> _FieldExpr ( substr ( $ Part , 1 , strlen ( $ Part ) - 2 ) , $ Name ) ; $ FunctionArray [ $ i ] = $ Part ; } } $ Result = join ( $ FunctionArray ) ; } elseif ( $ C === '@' && $ EscapeExpr === FALSE ) { $ Result = substr ( $ Expr , 1 ) ; } else { if ( is_null ( $ Name ) ) { $ Result = $ this -> EscapeIdentifier ( $ Expr ) ; } else { if ( in_array ( substr ( $ Expr , 0 , 1 ) , array ( '=' , '@' ) ) ) { $ Result = $ this -> NamedParameter ( 'Param' , TRUE ) ; } else { $ Result = $ this -> NamedParameter ( $ Name , TRUE ) ; } $ this -> _NamedParameters [ $ Result ] = $ Expr ; } } return $ Result ; }
Parses an expression for use in where clauses .
22,824
public function PrefixTable ( $ Table ) { $ Prefix = $ this -> Database -> DatabasePrefix ; if ( $ Prefix != '' && substr ( $ Table , 0 , strlen ( $ Prefix ) ) != $ Prefix ) $ Table = $ Prefix . $ Table ; return $ Table ; }
Prefixes a table with the database prefix if it is not already there .
22,825
public function Put ( $ Table = '' , $ Set = NULL , $ Where = FALSE , $ Limit = FALSE ) { $ this -> Update ( $ Table , $ Set , $ Where , $ Limit ) ; if ( count ( $ this -> _Sets ) == 0 || ! isset ( $ this -> _Froms [ 0 ] ) ) { $ this -> Reset ( ) ; return FALSE ; } $ Sql = $ this -> GetUpdate ( $ this -> _Froms , $ this -> _Sets , $ this -> _Wheres , $ this -> _OrderBys , $ this -> _Limit ) ; $ Result = $ this -> Query ( $ Sql , 'update' ) ; return $ Result ; }
Builds the update statement and runs the query returning a result object .
22,826
public function SelectCase ( $ Field , $ Options , $ Alias ) { $ CaseOptions = '' ; foreach ( $ Options as $ Key => $ Val ) { if ( $ Key == '' ) $ CaseOptions .= ' else ' . $ Val ; else $ CaseOptions .= ' when ' . $ Key . ' then ' . $ Val ; } $ Expr = array ( 'Field' => $ Field , 'Function' => '' , 'Alias' => $ Alias , 'CaseOptions' => $ CaseOptions ) ; if ( $ Alias == '' ) $ this -> _Selects [ ] = $ Expr ; else $ this -> _Selects [ $ Alias ] = $ Expr ; return $ this ; }
Allows the specification of a case statement in the select list .
22,827
public function register ( Application $ app ) { $ app [ 'resolver' ] = $ app -> share ( $ app -> extend ( 'resolver' , function ( $ resolver , $ app ) { return new Resolver ( $ resolver , $ app ) ; } ) ) ; $ app -> initializer ( 'Synapse\\Application\\UrlGeneratorAwareInterface' , function ( $ object , $ app ) { $ object -> setUrlGenerator ( $ app [ 'url_generator' ] ) ; return $ object ; } ) ; $ app -> initializer ( 'Synapse\\Debug\\DebugModeAwareInterface' , function ( $ object , $ app ) { $ object -> setDebug ( $ app [ 'debug' ] ) ; return $ object ; } ) ; }
Register the controller resolver and initializers
22,828
public function make ( $ host ) { $ host = $ this -> resolver -> resolve ( $ host , '/' ) ; $ hash = md5 ( $ host ) ; if ( isset ( $ this -> instances [ $ hash ] ) ) { return $ this -> instances [ $ hash ] ; } $ validator = new Validator ( $ this -> validator , new ResourceNormalizer ) ; $ instance = new Server ( $ this -> capabilities -> make ( $ host ) , new Client ( $ this -> loader -> make ( $ host ) , $ this -> serializer , $ this -> resolver , $ validator , $ this -> dispatcher , $ this -> http ) ) ; $ this -> instances [ $ hash ] = $ instance ; return $ instance ; }
Make a server object for the given host
22,829
public function setNotFoundHandler ( $ handler ) : ClosureAutoBind { if ( ! $ this -> isClosure ( $ handler ) ) { throw new InvalidArgumentException ( 'Handler must be closure' ) ; } $ this -> notFoundHandler = $ handler ; return $ this ; }
Sets not found handler
22,830
private function getFunctionArguments ( array $ paramMap , array $ matches , array $ parameters ) : array { $ output = [ ] ; $ matches = array_values ( $ matches ) ; foreach ( $ parameters as $ valueName ) { foreach ( $ paramMap as $ possition => $ value ) { if ( $ value == $ valueName [ 1 ] [ 0 ] ) { $ output [ ] = $ matches [ $ possition ] ; } } } return $ output ; }
Get arguments for closure function in proper order from provided parameters
22,831
private function getFunctionArgumentsNames ( $ closure ) : array { $ result = [ ] ; $ closureReflection = new ReflectionFunction ( $ closure ) ; foreach ( $ closureReflection -> getParameters ( ) as $ param ) { $ result [ ] = $ param -> name ; } return $ result ; }
Get name of parameters for provided closure
22,832
public function renderWithLayout ( $ template , array $ localVariables = array ( ) ) { $ this -> addData ( array ( 'localVariables' => $ localVariables , 'view' => $ template , ) ) ; return $ this -> render ( $ this -> getLayout ( ) , $ localVariables ) ; }
Renders with layout
22,833
public function parse ( $ file ) { if ( ! is_file ( $ file ) || ! is_readable ( $ file ) ) { return null ; } $ sheet = new Sheet \ Structure ( ) ; $ this -> buffer = @ file_get_contents ( $ file ) ; $ this -> acceptBom ( ) ; while ( ! empty ( $ this -> buffer ) ) { $ this -> acceptEntry ( $ sheet ) ; } return $ sheet ; }
Parse a css file
22,834
public function acceptWhiteSpace ( $ additional = '' ) { $ this -> buffer = ltrim ( $ this -> buffer , self :: WHITE_SPACE . $ additional ) ; while ( substr ( $ this -> buffer , 0 , 2 ) == '/*' ) { $ this -> buffer = ltrim ( preg_replace ( '#/\*.*?\*/s#' , '' , $ this -> buffer ) , self :: WHITE_SPACE . $ additional ) ; } }
Accept white - space & comments
22,835
public static function get ( $ name , $ options = [ ] ) { $ default = isset ( $ options [ "default" ] ) ? $ options [ "default" ] : null ; return isset ( $ _COOKIE [ $ name ] ) ? $ _COOKIE [ $ name ] : $ default ; }
Gets a cookie .
22,836
public function setBoard ( array $ board ) { if ( empty ( $ board ) ) { return false ; } if ( ( $ boardSize = count ( $ board , COUNT_RECURSIVE ) ) == count ( $ board ) && $ boardSize != pow ( $ this -> size , 2 ) ) { return false ; } if ( count ( $ board , COUNT_RECURSIVE ) == count ( $ board ) ) { $ this -> board = array_chunk ( $ board , $ this -> size ) ; } else { $ this -> board = $ board ; } $ boardDistinctValues = array_unique ( array_filter ( array_reduce ( $ this -> board , 'array_merge' , [ ] ) ) ) ; if ( count ( $ boardDistinctValues ) > 2 ) { return false ; } return $ this -> board ; }
Set Board Values
22,837
public function setValue ( array $ position , $ value ) { if ( ! $ this -> validatePosition ( $ position ) ) { return false ; } list ( $ xPos , $ yPos ) = $ position ; if ( ! empty ( $ this -> board [ $ xPos ] [ $ yPos ] ) ) { return false ; } $ this -> board [ $ xPos ] [ $ yPos ] = $ value ; }
Set value to a particular position on board
22,838
public function isFull ( ) { return ( bool ) ( pow ( $ this -> size , 2 ) == count ( array_filter ( array_reduce ( $ this -> getBoard ( ) , 'array_merge' , [ ] ) ) ) ) ; }
Check if board is full
22,839
public function setEnableFileDispersion ( $ enableFileDispersion ) { $ this -> enableFileDispersion = ( bool ) $ enableFileDispersion ; if ( $ enableFileDispersion ) { $ this -> setAllowCreateFolders ( true ) ; $ this -> setTransliterateFilename ( true ) ; } return $ this ; }
Set enable files dispersion .
22,840
protected function createFolders ( ) { $ dir = null ; $ target = $ this -> getTargetDirectory ( ) ; if ( ! empty ( $ target ) ) { $ dir = rtrim ( $ target , '/' ) . DIRECTORY_SEPARATOR ; $ this -> setTarget ( $ dir ) ; } if ( $ dir !== null && ! is_dir ( $ dir ) && $ this -> isAllowCreateFolders ( ) ) { if ( ! @ mkdir ( $ dir , 0777 , true ) && ! is_dir ( $ dir ) ) { throw new Exception \ NoSuchDirectoryException ( sprintf ( 'Directory %s does not exists.' , $ dir ) ) ; } } }
Create destination folder on the fly .
22,841
protected function fixCaseInsensitiveFilename ( $ finalTarget ) { $ targetFile = basename ( $ finalTarget ) ; if ( $ this -> isCaseInsensitiveFilename ( ) ) { $ finalTarget = str_replace ( $ targetFile , StringUtils :: lower ( $ targetFile ) , $ finalTarget ) ; } return $ finalTarget ; }
Fix case - insensitive filename .
22,842
protected function transliterateFilename ( $ finalTarget ) { $ targetFile = basename ( $ finalTarget ) ; if ( $ this -> isTransliterateFilename ( ) ) { $ filename = pathinfo ( $ targetFile ) [ 'filename' ] ; $ finalTarget = str_replace ( $ filename , StringUtils :: slug ( $ filename ) , $ finalTarget ) ; } return $ finalTarget ; }
Transliterate filename .
22,843
protected function fileDispersion ( $ finalTarget ) { if ( strpos ( $ finalTarget , DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR ) !== false ) { return $ finalTarget ; } if ( $ this -> isFileDispersionEnabled ( ) ) { $ file = pathinfo ( $ finalTarget , PATHINFO_BASENAME ) ; $ dispersionPath = $ this -> getDispersionPath ( $ file ) ; $ directory = pathinfo ( $ finalTarget , PATHINFO_DIRNAME ) . $ dispersionPath ; $ finalTarget = $ directory . $ file ; $ this -> setTargetDirectory ( $ directory ) ; $ this -> createFolders ( ) ; } return $ finalTarget ; }
Process file dispersion .
22,844
private function getDispersionPath ( $ fileName ) { $ char = 0 ; $ dispersionPath = DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR ; while ( $ char < 2 && $ char < strlen ( $ fileName ) ) { if ( empty ( $ dispersionPath ) ) { $ dispersionPath = DIRECTORY_SEPARATOR . ( '.' === $ fileName [ $ char ] ? '_' : $ fileName [ $ char ] ) ; } else { $ dispersionPath = $ this -> addDirectorySeparator ( $ dispersionPath ) . ( '.' === $ fileName [ $ char ] ? '_' : $ fileName [ $ char ] ) ; } $ char ++ ; } return $ dispersionPath . DIRECTORY_SEPARATOR ; }
Get dispersion path .
22,845
public static function createSuccess ( string $ routeName , array $ routeParams = [ ] , array $ routeAllowedMethods = [ ] , array $ routeMiddlewares = [ ] , array $ routeHandler = [ ] ) : self { $ result = new self ( ) ; $ result -> routeName = $ routeName ; $ result -> routeParams = $ routeParams ; $ result -> routeAllowedMethods = $ routeAllowedMethods ; $ result -> routeMiddlewares = $ routeMiddlewares ; $ result -> routeHandler = $ routeHandler ; $ result -> status = $ result :: ROUTE_FOUND ; return $ result ; }
Create an instance if matching was success
22,846
public static function createMethodNotAllowed ( array $ routeAllowedMethods ) : self { $ result = new self ( ) ; $ result -> routeAllowedMethods = $ routeAllowedMethods ; $ result -> status = $ result :: ROUTE_METHOD_NOT_ALLOWED ; return $ result ; }
Create an instance if method not allowed
22,847
public function getPreviewHtml ( BBcodeElementNodeInterface $ el ) { if ( ! $ this -> hasValidInputs ( $ el ) ) { return $ el -> getAsBBCode ( ) ; } $ html = $ this -> getReplacementText ( ) ; if ( $ this -> usesOption ( ) ) { $ options = $ el -> getAttribute ( ) ; if ( count ( $ options ) == 1 ) { $ vals = array_values ( $ options ) ; $ html = str_ireplace ( '{option}' , reset ( $ vals ) , $ html ) ; } else { foreach ( $ options as $ key => $ val ) { $ html = str_ireplace ( '{' . $ key . '}' , $ val , $ html ) ; } } } $ content = $ this -> getPreviewContent ( $ el ) ; $ html = str_ireplace ( '{param}' , $ content , $ html ) ; return $ html ; }
Get the html representation of the node in a preview context
22,848
public function query ( $ query , $ data = array ( ) , $ entity = null ) { if ( $ this -> cache -> isCached ( $ query ) ) { return $ this -> cache -> getCachedResult ( $ query ) ; } else { try { $ statement = $ this -> database -> prepare ( ( string ) $ query , array ( PDO :: ATTR_CURSOR => PDO :: CURSOR_SCROLL ) ) ; $ result = $ statement -> execute ( $ data ) ; $ this -> lastQuery = $ statement -> queryString ; $ this -> lastStatement = $ statement ; if ( ! $ result ) { throw new DatabaseException ( implode ( ': ' , $ statement -> errorInfo ( ) ) . PHP_EOL . PHP_EOL . $ query ) ; } } catch ( PDOException $ e ) { throw new DatabaseException ( $ e -> getMessage ( ) . PHP_EOL . PHP_EOL . $ query ) ; } $ databaseResult = $ this -> createResult ( $ statement , $ entity ) ; if ( $ query instanceof DatabaseQuery && $ databaseResult instanceof DatabaseResult ) { $ this -> cache -> cacheQuery ( $ query , $ databaseResult ) ; } if ( $ query instanceof DatabaseQuery ) { $ this -> cache -> refreshCache ( $ query ) ; } if ( $ databaseResult instanceof DatabaseResult ) { return $ databaseResult ; } else if ( $ query instanceof DatabaseQuery && $ query -> getType ( ) == DatabaseQuery :: QUERY_TYPE_INSERT ) { return $ this -> insertId ( $ query -> getTable ( ) ) ; } else { return $ databaseResult ; } } }
query function .
22,849
public function quote ( $ string ) { if ( is_null ( $ string ) ) { return 'NULL' ; } else if ( is_int ( $ string ) || is_float ( $ string ) ) { return $ string ; } else if ( $ string instanceof Raw || $ string instanceof DatabaseQuery ) { return ( string ) $ string ; } else { return $ this -> database -> quote ( $ string ) ; } }
quote function .
22,850
public function insertId ( $ name = null ) { if ( $ name === null ) { return $ this -> database -> lastInsertId ( ) ; } else { return $ this -> database -> lastInsertId ( $ name ) ; } }
lastId function .
22,851
public function saveState ( ) { $ this -> stateService -> setByKey ( self :: IDENTIFIER , [ $ this -> total , $ this -> status , $ this -> updateRequested ] ) ; }
Saves the state of the Transaction object
22,852
public function restoreState ( ) { if ( $ data = $ this -> stateService -> getByKey ( self :: IDENTIFIER ) ) { list ( $ this -> total , $ this -> status , $ this -> updateRequested ) = $ data ; } }
Restores the state of the Transaction object
22,853
public function addModifier ( TransactionModifierInterface $ modifier ) { $ this -> modifiers [ $ modifier -> getIdentifier ( ) -> getFull ( ) ] = $ modifier ; if ( $ modifier instanceof HasTransactionInterface ) { $ modifier -> setTransaction ( $ this ) ; } }
Add a TransactionModifier to the Transaction
22,854
public function getModifier ( $ identifier ) { $ modifiers = $ this -> getModifiers ( ) ; return isset ( $ modifiers [ $ identifier ] ) ? $ modifiers [ $ identifier ] : null ; }
Returns a TransactionModifier based on the identifier
22,855
public function getModifiersByType ( $ type ) { $ modifiers = [ ] ; foreach ( $ this -> modifiers as $ modifier ) { if ( $ modifier -> getType ( ) === $ type ) { $ modifiers [ $ modifier -> getIdentifier ( ) -> getFull ( ) ] = $ modifier ; } } return $ modifiers ; }
Returns modifiers on the transaction by TranactionModifierType
22,856
public function getTotal ( ) { if ( $ this -> updateRequested ) { $ this -> total = $ this -> getTotalWithExclusions ( [ ] ) ; $ this -> updateRequested = false ; $ this -> saveState ( ) ; } return $ this -> total ; }
Returns the aggregate total of the TransactionModifers held by the Transaction object
22,857
public function getStorableData ( ) { return [ 'id' => 'Transaction' , 'flat' => [ 'Total' => \ Heystack \ Ecommerce \ convertMoneyToString ( $ this -> total ) , 'Status' => $ this -> status , 'Currency' => $ this -> currencyService -> getActiveCurrencyCode ( ) ] , 'related' => [ ] ] ; }
Get the data to store
22,858
public function setStatus ( $ status ) { if ( $ this -> isValidStatus ( $ status ) ) { $ this -> status = $ status ; $ this -> saveState ( ) ; } else { throw new \ InvalidArgumentException ( sprintf ( "Status '%s' is not a valid status" , $ status ) ) ; } }
Sets the status of the transaction
22,859
public function actionUpdate ( ) { $ collection = \ App :: $ domain -> tool -> openServer -> update ( ) ; $ hosts = ArrayHelper :: getColumn ( $ collection , 'host' ) ; Output :: items ( $ hosts , count ( $ collection ) . ' hosts' ) ; Output :: line ( ) ; }
Update domains config
22,860
public function setBlocksize ( $ blocksize ) { if ( ( $ blocksize < 0 ) || ( $ blocksize > 9 ) ) { throw new Exception \ InvalidArgumentException ( 'Blocksize must be between 0 and 9' ) ; } $ this -> options [ 'blocksize' ] = ( int ) $ blocksize ; return $ this ; }
Sets a new blocksize
22,861
public static function createFromFileGroup ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new \ InvalidArgumentException ( 'Invalid file name provided.' ) ; } if ( ! function_exists ( 'posix_getgrgid' ) ) { throw new PosixNotAvailableException ( 'Could not retrieve information about the operating system group because POSIX functions ' . 'are not available to your PHP executable.' ) ; } if ( false === $ gid = \ filegroup ( $ filename ) ) { throw new \ Exception ( 'Could not get the group of the file "' . $ filename . '".' ) ; } return new Group ( $ gid ) ; }
Factory method to get the group of a file .
22,862
private function set ( $ name , $ value ) { if ( property_exists ( $ this , $ name ) ) { $ this -> $ name = $ value ; $ this -> attributes [ $ name ] = $ value ; return true ; } return false ; }
Generic setter Since
22,863
public function populate ( $ data = array ( ) , $ direct = false ) { if ( ! $ direct ) $ data = Cii :: get ( $ data , get_class ( $ this ) ) ; foreach ( $ data as $ attribute => $ value ) $ this -> set ( $ attribute , $ value ) ; return true ; }
Provides a generic method for populating data
22,864
public function password ( $ attribute , $ params ) { $ this -> attributes [ $ attribute ] = $ this -> $ attribute = Cii :: encrypt ( $ this -> $ attribute ) ; return true ; }
Validates passwords by encrypting them for storage
22,865
protected function afterSave ( ) { if ( $ this -> hasEventHandler ( 'onAfterSave' ) ) $ this -> onAfterSave ( new CEvent ( $ this ) ) ; foreach ( $ this -> attributes as $ key => $ value ) Yii :: app ( ) -> cache -> set ( 'settings_' . $ key , $ value ) ; return true ; }
Allow for afterSave events
22,866
public function getStringValidator ( $ attribute = NULL , $ validators = NULL ) { if ( $ attribute == NULL && $ validators == NULL ) return array ( ) ; $ v = array ( ) ; if ( $ validators == NULL && $ attribute !== NULL ) $ validators = $ this -> getValidators ( $ attribute ) ; $ validators = array_values ( $ validators ) ; foreach ( $ validators as $ validator ) { $ ve = strtolower ( str_replace ( 'Validator' , '' , substr ( get_class ( $ validator ) , 1 , strlen ( get_class ( $ validator ) ) ) ) ) ; if ( $ ve == 'inline' ) $ v [ ] = $ validator -> method ; else $ v [ ] = $ ve ; } return $ v ; }
Gets the validator types as strings to be used for the form parser
22,867
public function save ( $ runValidation = true ) { if ( $ this -> beforeSave ( ) ) { if ( $ this -> beforeValidate ( ) ) { if ( $ runValidation && ! $ this -> validate ( ) ) return false ; } else return false ; $ this -> afterValidate ( ) ; $ connection = Yii :: app ( ) -> db ; $ transaction = $ connection -> beginTransaction ( ) ; try { foreach ( $ this -> attributes as $ key => $ value ) { $ command = $ connection -> createCommand ( 'INSERT INTO `configuration` VALUES (:key, :value, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE value = :value2, updated = UTC_TIMESTAMP()' ) ; $ command -> bindParam ( ':key' , $ key ) ; $ command -> bindParam ( ':value' , $ value ) ; $ command -> bindParam ( ':value2' , $ value ) ; $ command -> execute ( ) ; Yii :: app ( ) -> cache -> delete ( 'settings_' . $ key ) ; } } catch ( Exception $ e ) { $ transaciton -> rollBack ( ) ; return false ; } $ transaction -> commit ( ) ; $ this -> afterSave ( ) ; return true ; } }
Save function for Configuration Everything should be wrapped inside of a transaction - if there is an error saving any of the items then there was an error saving all of them and we should abort
22,868
public function & addButtongroup ( ButtonGroup $ buttongroup ) { $ uniqeid = uniqid ( 'btntoolbar_btngrp_' ) ; $ this -> groups [ $ uniqeid ] = $ buttongroup ; return $ this -> groups [ $ uniqeid ] ; }
Adds a ButtonGroup object to the groups list and returns reference to it .
22,869
public function getName ( ) : string { if ( ! $ this -> name ) { $ name = $ this -> getModule ( ) -> getKey ( ) ; if ( preg_match ( '/Controllers\\\\(.*?)$/' , static :: class , $ e ) ) { $ name .= '::' . preg_replace_callback ( '/[A-Z]/' , static function ( $ m ) { return '_' . lcfirst ( $ m [ 0 ] ) ; } , lcfirst ( $ e [ 1 ] ) ) ; $ name = str_replace ( '\\' , ':' , $ name ) ; } $ this -> name = strtolower ( $ name ) ; } return $ this -> name ; }
Get controller name
22,870
public function supportPortalMethod ( $ name , $ method ) { if ( $ name instanceof Module ) { $ name = $ name -> getKey ( ) ; } return $ this -> module -> support ( $ name ) && method_exists ( $ this , $ method ) ; }
Check support method for other module
22,871
public function sendResponse ( ) { if ( $ this -> response instanceof SymfonyResponse ) { $ this -> response -> sendContent ( ) ; } if ( $ this -> templatefile !== false ) { echo $ this -> template -> render ( $ this -> templatefile , $ this -> templatefileParameters ) ; } }
Send content back .
22,872
public static function isRegex ( $ pValue , $ pExpr ) { if ( is_array ( $ pValue ) ) { foreach ( $ pValue as $ value ) { if ( ! preg_match ( $ pExpr , $ value ) ) { return false ; } } } else { if ( ! preg_match ( $ pExpr , $ pValue ) ) { return false ; } } return true ; }
Regex validation .
22,873
public function numberindication ( $ zipcode , $ number ) { $ url = self :: API_URL . '/nummeraanduidingen' ; $ request = new \ LibX \ Net \ Rest \ Request ( $ url , \ LibX \ Net \ Rest \ Request :: REQUEST_METHOD_GET ) ; $ parameters = [ ] ; $ parameters [ 'postcode' ] = $ zipcode ; $ parameters [ 'huisnummer' ] = $ number ; $ request -> setParameters ( $ parameters ) ; $ response = new \ LibX \ Net \ Rest \ Response ( ) ; $ data = $ this -> call ( $ request , $ response ) ; $ indications = $ data -> _embedded -> nummeraanduidingen ; foreach ( $ indications as $ indication ) { } }
Retrieve number indications
22,874
public function search ( $ type , Polygon $ polygon ) { $ url = self :: API_URL . '/' . $ type ; $ data = new \ StdClass ( ) ; $ data -> geometrie = new \ StdClass ( ) ; $ data -> geometrie -> contains = new \ StdClass ( ) ; $ data -> geometrie -> contains -> type = 'Point' ; $ data -> geometrie -> contains -> coordinates = [ ] ; $ points = $ polygon -> getPoints ( ) ; foreach ( $ points as $ point ) $ data -> geometrie -> contains -> coordinates [ ] = [ $ point -> getX ( ) , $ point -> getY ( ) ] ; $ request = new \ LibX \ Net \ Rest \ Request ( $ url , \ LibX \ Net \ Rest \ Request :: REQUEST_METHOD_POST ) ; $ request -> setData ( json_encode ( $ data ) ) ; $ response = new \ LibX \ Net \ Rest \ Response ( ) ; return ; $ data = $ this -> call ( $ request , $ response ) ; }
Search BAG data
22,875
public function details ( $ type , $ id ) { $ url = self :: API_URL . '/' . $ type . '/' . $ id ; $ request = new \ LibX \ Net \ Rest \ Request ( $ url , \ LibX \ Net \ Rest \ Request :: REQUEST_METHOD_GET ) ; $ response = new \ LibX \ Net \ Rest \ Response ( ) ; $ data = $ this -> call ( $ request , $ response ) ; return $ data ; }
Retrieve BAG details
22,876
public function geo ( $ type , $ id ) { $ url = self :: API_URL . '/' . $ type . '/' . $ id ; $ request = new \ LibX \ Net \ Rest \ Request ( $ url , \ LibX \ Net \ Rest \ Request :: REQUEST_METHOD_GET ) ; $ response = new \ LibX \ Net \ Rest \ Response ( ) ; $ data = $ this -> call ( $ request , $ response ) ; $ coordinates = null ; if ( isset ( $ data -> _embedded -> geometrie ) ) { $ geo = $ data -> _embedded -> geometrie ; if ( $ geo -> type === 'Point' ) { $ longitude = $ geo -> coordinates [ 0 ] ; $ latitude = $ geo -> coordinates [ 1 ] ; $ coordinates = new Coordinates ( $ latitude , $ longitude ) ; } elseif ( $ geo -> type === 'Polygon' ) { $ points = new PointStack ( ) ; foreach ( $ geo -> coordinates [ 0 ] as $ coordinates ) { $ longitude = $ coordinates [ 0 ] ; $ latitude = $ coordinates [ 1 ] ; $ points -> push ( new Coordinates ( $ latitude , $ longitude ) ) ; } $ coordinates = new Polygon ( $ points ) ; } } return $ coordinates ; }
Retrieve BAG geo data
22,877
protected function processRequest ( Builder $ query , $ results ) { if ( array_keys ( $ results ) !== range ( 0 , count ( $ results ) - 1 ) ) { return [ $ results ] ; } return $ results ; }
Process the results of an API request .
22,878
protected function doClassify ( $ string ) { $ partsNamespace = explode ( '\\' , $ string ) ; $ return = [ ] ; foreach ( $ partsNamespace as $ partNamespace ) { $ parts = explode ( "-" , $ partNamespace ) ; $ parts = array_map ( [ $ this , "camelize" ] , $ parts ) ; $ return [ ] = implode ( "_" , $ parts ) ; } return implode ( '\\' , $ return ) ; }
Converts lowercase string to underscored camelize class format
22,879
public function addChild ( TreeNodeInterface $ node ) : void { $ this -> children [ ] = $ node ; $ this -> isLeaf = false ; }
Adds the given tree node to this nodes child list .
22,880
public function getSumChildCount ( ) : int { $ count = count ( $ this -> children ) ; foreach ( $ this -> children as $ node ) { $ count += $ node -> getChildCount ( ) ; } return $ count ; }
Returns the total sum of all children and their children .
22,881
public function addResult ( $ child , $ result ) { if ( ! $ result instanceof Result \ ResultInterface ) { throw new RuntimeException ( 'Result type must be implements ResultInterface' ) ; } $ this -> results [ $ child - 1 ] = $ result ; }
add a result object
22,882
public static function initiate ( array $ params ) { try { if ( ! is_array ( $ params ) ) { throw new \ Exception ( 'Parameters need to be as an associative array' ) ; } if ( isset ( $ params [ 'db_hostname' ] ) ) { self :: $ db_params [ 'db_hostname' ] = $ params [ 'db_hostname' ] ; } else { throw new \ Exception ( 'Database host need to be set!' ) ; } if ( isset ( $ params [ 'db_driver' ] ) ) { self :: $ db_params [ 'db_driver' ] = $ params [ 'db_driver' ] ; } else { throw new \ Exception ( 'Database driver need to be set!' ) ; } if ( isset ( $ params [ 'db_port' ] ) ) { self :: $ db_params [ 'db_port' ] = ":" . $ params [ 'db_port' ] ; } else { self :: $ db_params [ 'db_port' ] = "" ; } if ( isset ( $ params [ 'db_schema' ] ) ) { self :: $ db_params [ 'db_schema' ] = $ params [ 'db_schema' ] ; } else { throw new \ Exception ( 'Database name need to be set!' ) ; } if ( isset ( $ params [ 'db_username' ] ) ) { self :: $ db_params [ 'db_username' ] = $ params [ 'db_username' ] ; } else { self :: $ db_params [ 'db_username' ] = "" ; } if ( isset ( $ params [ 'db_password' ] ) ) { self :: $ db_params [ 'db_password' ] = $ params [ 'db_password' ] ; } else { self :: $ db_params [ 'db_password' ] = "" ; } } catch ( \ Exception $ e ) { die ( $ e -> getMessage ( ) ) ; } }
Initiates database configuration parameters
22,883
public static function get ( $ param ) { if ( isset ( self :: $ db_params [ $ param ] ) ) { return self :: $ db_params [ $ param ] ; } return false ; }
Returns parameter s value if exists otherwise returns null
22,884
public function exists ( $ path ) { $ keys = $ this -> explode ( $ path ) ; $ parameters = $ this -> parameters ; foreach ( $ keys as $ key ) { if ( ! is_array ( $ parameters ) ) { return false ; } if ( array_key_exists ( $ key , $ parameters ) ) { $ parameters = $ parameters [ $ key ] ; } else { return false ; } } return true ; }
Determines if a parameter exists regardless of null value .
22,885
public function getAsInstance ( $ path ) { if ( empty ( $ path ) ) { return static :: create ( [ ] , $ this -> separator ) ; } $ value = $ this -> getAsArray ( $ path ) ; if ( ! is_array ( $ value ) ) { throw new \ InvalidArgumentException ( 'You cannot return a Parameter instance on a non-array value.' ) ; } return static :: create ( $ this -> getAsArray ( $ path ) , $ this -> separator ) ; }
Gets a value based on a path and returns it as a Parameters instance .
22,886
public function set ( $ path , $ value ) { $ keys = $ this -> explode ( $ path ) ; $ parameters = & $ this -> parameters ; while ( count ( $ keys ) > 0 ) { if ( count ( $ keys ) === 1 ) { if ( ! is_array ( $ parameters ) ) { $ parameters = [ ] ; } $ parameters [ array_shift ( $ keys ) ] = $ value ; } else { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ parameters [ $ key ] ) ) { $ parameters [ $ key ] = [ ] ; } $ parameters = & $ parameters [ $ key ] ; } } return $ this ; }
Sets a value to a key path .
22,887
private function castObjectsAsArrays ( array $ parameters ) { foreach ( $ parameters as $ key => $ value ) { if ( is_object ( $ value ) ) { $ value = ( array ) $ value ; $ parameters [ $ key ] = $ value ; } if ( is_array ( $ value ) ) { $ parameters [ $ key ] = $ this -> castObjectsAsArrays ( $ value ) ; } } return $ parameters ; }
Ensures any object values are cast as arrays . Is recursive .
22,888
public function deleteDoctrineCache ( SiteEvent $ event ) { if ( $ cacheImpl = $ this -> em -> getConfiguration ( ) -> getResultCacheImpl ( ) ) { $ cacheImpl -> delete ( SiteInterface :: SITE ) ; } }
Delete doctrine cache .
22,889
public function log ( $ level , $ message , array $ context = array ( ) ) { $ group = '' ; if ( isset ( $ context [ 'group' ] ) ) { $ group = $ context [ 'group' ] ; } if ( $ this -> groupfilter == '' || $ group == '' && $ this -> groupfilter != 'all' ) { return false ; } $ logallowed = false ; if ( $ this -> groupfilter == 'all' ) { $ logallowed = true ; } else { foreach ( explode ( '|' , $ group ) as $ f ) { if ( preg_match ( '!\\|' . preg_quote ( $ f ) . '\\|!' , '|' . $ this -> groupfilter . '|' ) ) { $ logallowed = true ; break ; } } } if ( ! $ logallowed ) { return false ; } if ( ! $ this -> extraFilter ( $ level , $ context ) ) { return false ; } if ( is_array ( $ message ) || is_object ( $ message ) ) { $ message = print_r ( $ message , true ) ; } $ logfilehandle = @ fopen ( $ this -> logfile , 'a' ) ; if ( ! $ logfilehandle ) { return false ; } fwrite ( $ logfilehandle , $ this -> formatLogLine ( $ message ) . "\n" ) ; if ( isset ( $ context [ 'extrainfo' ] ) ) { fwrite ( $ logfilehandle , "\t" . $ context [ 'extrainfo' ] . "\n" ) ; } if ( $ level == LogLevel :: ERROR || $ level == LogLevel :: CRITICAL || $ level == LogLevel :: EMERGENCY ) { if ( isset ( $ context [ 'exception' ] ) && $ context [ 'exception' ] instanceof \ Exception ) { if ( $ this -> forcelogtrace || $ context [ 'forcelogtrace' ] === true ) { fwrite ( $ logfilehandle , $ context [ 'exception' ] -> getTraceAsString ( ) . "\n" ) ; } } } fclose ( $ logfilehandle ) ; return true ; }
The log function . It is not usually called directly . Usually it is better to call other functions from Psr \ Log like debug error alert etc
22,890
public static function run ( ) { self :: init ( ) ; call_user_func ( function ( ) { require self :: $ basePath . '/boot/routes.php' ; if ( file_exists ( self :: $ basePath . '/.manifest/plugins/routes.php' ) ) { include self :: $ basePath . '/.manifest/plugins/routes.php' ; } } ) ; $ router = DI :: getInstance ( ) -> get ( 'router' ) ; $ request = DI :: getInstance ( ) -> get ( 'request' ) ; $ response = $ router -> dispatch ( $ request ) ; $ response -> send ( ) ; }
Start the application .
22,891
public static function console ( ) { self :: init ( ) ; $ argv = $ _SERVER [ 'argv' ] ; array_shift ( $ argv ) ; $ command = DI :: getInstance ( ) -> get ( 'command-factory' ) -> command ( $ argv ) ; $ status = $ command -> run ( ) ; return $ status ; }
Start a console .
22,892
public function registerPackages ( $ package , $ path ) { $ this -> updateLog ( "info" , "Preparing package {$package} for registration with path {$path}." ) ; $ package = trim ( $ package , "\\" ) ; $ package = $ package . "\\" ; $ path = rtrim ( $ path , DIRECTORY_SEPARATOR ) ; $ path = $ path . "/" ; $ path_registered = $ this -> registrationExists ( $ package , $ path ) ; if ( ! $ path_registered ) { $ this -> packages [ $ package ] [ ] = $ path ; $ this -> updateLog ( "info" , "Registered index {$package} as {$path}" ) ; } }
Registers a given package with an associated path .
22,893
protected function includeClass ( $ class ) { $ this -> updateLog ( "info" , "Setting up {$class} class for inclusion." ) ; $ class_bits = explode ( "\\" , $ class ) ; $ package = "" ; $ package_stack = array ( ) ; foreach ( $ class_bits as $ bit ) { $ package = $ package . $ bit . "\\" ; $ package_registered = $ this -> packageRegistered ( $ package ) ; if ( $ package_registered ) { $ package_stack [ ] = $ package ; } } $ this -> loadPackageStack ( $ class , $ package_stack ) ; }
Includes the file corresponding with the class name to be autoloaded
22,894
protected function loadPackageStack ( $ class , array $ package_stack ) { foreach ( $ package_stack as $ package ) { $ package_length = strlen ( $ package ) ; $ class_path = substr ( $ class , $ package_length ) ; $ this -> updateLog ( "debug" , "Found class path {$class_path} in {$class} given {$package}" ) ; $ package_loaded = $ this -> loadPackage ( $ package , $ class_path ) ; if ( $ package_loaded ) { $ this -> updateLog ( "info" , "Loaded {$class_path} using package {$package}" ) ; return true ; } } $ this -> updateLog ( "alert" , "No files found for {$class} in registered packages!" ) ; return false ; }
Attempts to load a class from a stack of packages
22,895
protected function loadPackage ( $ package_name , $ class_name ) { $ this -> updateLog ( "info" , "Working on loading {$class_name} from {$package_name}" ) ; $ file_required = false ; foreach ( $ this -> packages [ $ package_name ] as $ path ) { $ converted_class = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ class_name ) ; $ class_path = $ path . $ converted_class . ".php" ; $ this -> updateLog ( "debug" , "Class file path is {$class_path}" ) ; $ file_required = $ this -> requireFile ( $ class_path ) ; } return $ file_required ; }
Loads a package based on registered paths associated with the package .
22,896
private function packageRegistered ( $ package ) { $ package_registered = array_key_exists ( $ package , $ this -> packages ) ; if ( $ package_registered ) { $ this -> updateLog ( "info" , "Package {$package} is registered" ) ; } else { $ this -> updateLog ( "info" , "Package {$package} is not registered" ) ; } return $ package_registered ; }
Determines whether a given package is registered with the Autoloader
22,897
private function requireFile ( $ path ) { if ( file_exists ( $ path ) ) { $ this -> updateLog ( "debug" , "File {$path} exists; requiring file" ) ; require $ path ; $ this -> updateLog ( "info" , "Completed loading {$path}" ) ; return true ; } else { $ this -> updateLog ( "debug" , "File {$path} does not exist" ) ; return false ; } }
Requires a file only if it existss
22,898
public function all ( $ app = NULL ) : Bool { if ( ! is_string ( $ app ) ) { if ( $ app === NULL ) { $ MLFiles = Filesystem :: getFiles ( $ this -> appdir , 'ml' ) ; } elseif ( is_array ( $ app ) ) { $ MLFiles = $ app ; } else { return false ; } $ allMLFiles = [ ] ; if ( ! empty ( $ MLFiles ) ) foreach ( $ MLFiles as $ file ) { $ removeExtension = str_replace ( $ this -> extension , '' , $ file ) ; $ this -> all ( $ removeExtension ) ; } return true ; } else { $ createFile = $ this -> _langFile ( $ app ) ; if ( is_file ( $ createFile ) ) { return unlink ( $ createFile ) ; } return false ; } }
Delete all langauges keys
22,899
protected function getMicrotime ( ) : float { list ( $ uSec , $ sec ) = \ explode ( ' ' , \ microtime ( ) ) ; return ( ( float ) $ uSec + ( float ) $ sec ) ; }
Returns current server time in milliseconds .