idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
11,300
public static function call ( callable $ callable , $ args = null ) { if ( ! is_array ( $ args ) ) { $ args = $ args === null ? [ ] : [ $ args ] ; } return static :: callFast ( $ callable , static :: evaluateArgs ( $ args ) ) ; }
Call a callable and parse its lambdas
11,301
public static function evaluateArgs ( array $ args ) { $ parsedArgs = [ ] ; foreach ( $ args as $ key => $ value ) { if ( $ value instanceof self ) { $ parsedArgs [ $ key ] = static :: callFast ( $ value ) ; continue ; } $ parsedArgs [ $ key ] = $ args [ $ key ] ; } return $ parsedArgs ; }
Run all Lambdas in arguments anf return the parsed
11,302
public static function currify ( array $ args ) { $ curried = [ ] ; foreach ( $ args as $ key => $ value ) { if ( is_callable ( $ value ) ) { $ curried [ $ key ] = new static ( $ value ) ; continue ; } $ curried [ $ key ] = $ value ; } return $ curried ; }
Replace all callables in an array with lambdas
11,303
protected function parseCall ( ) { if ( $ this -> call instanceof Closure ) { $ this -> callClass = Closure :: class ; $ this -> callMethod = '' ; $ this -> isStaticMethod = false ; $ this -> isFunction = false ; $ this -> isClosure = true ; return ; } list ( $ class , $ method ) = $ this -> toClassAndMethod ( $ this -...
Parse the call to make it callable and know a few things about it .
11,304
protected static function cacheId ( $ callable ) { if ( is_array ( $ callable ) ) { $ class = is_string ( $ callable [ 0 ] ) ? $ callable [ 0 ] : get_class ( $ callable [ 0 ] ) ; return "$class::" . $ callable [ 1 ] ; } if ( is_string ( $ callable ) ) { return $ callable ; } if ( ! $ callable instanceof \ Closure ) { r...
Return a cache id for the passed callable
11,305
protected static function getReflection ( $ callable ) { if ( is_array ( $ callable ) ) { return new ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; } if ( $ callable instanceof \ Closure ) { return new ReflectionFunction ( $ callable ) ; } if ( is_object ( $ callable ) ) { return new ReflectionMethod ( $ ca...
Get a reflection object for the passed callable . The callable typehint is removed to support protected methods .
11,306
public function renderContent ( $ content ) { $ layoutFile = $ this -> findLayoutFile ( $ this -> getView ( ) ) ; if ( $ layoutFile !== false ) { return $ this -> getView ( ) -> renderFile ( $ layoutFile , [ 'content' => $ content ] , $ this ) ; } else { return $ content ; } }
Renders a static string by applying a layout .
11,307
protected function getTargetFile ( LocalFileNodeInterface $ file , $ postfix ) { if ( strlen ( $ postfix ) > 0 ) { $ postfix = '-' . $ postfix ; } $ pathInfo = pathinfo ( $ file -> getPath ( ) ) ; $ extension = isset ( $ pathInfo [ 'extension' ] ) ? '.' . $ pathInfo [ 'extension' ] : '' ; $ path = sprintf ( '%s/%s%s%s'...
Create a target file from a source file and postfix
11,308
public function add ( TextParser $ parser ) { $ objectHash = $ this -> objectHash ( $ parser ) ; if ( isset ( $ this -> parserIds [ $ objectHash ] ) ) { return $ this ; } $ this -> parsers [ ] = $ parser ; $ this -> parserIds [ $ objectHash ] = true ; return $ this ; }
Add a new parser to the render queue .
11,309
public function remove ( TextParser $ parser ) { $ parserHash = $ this -> objectHash ( $ parser ) ; $ this -> parsers = array_filter ( $ this -> parsers , function ( $ known ) use ( $ parserHash ) { return $ this -> objectHash ( $ known ) != $ parserHash ; } ) ; if ( isset ( $ this -> parserIds [ $ parserHash ] ) ) { u...
Remove a parser from the render queue .
11,310
public function getChildSkuSelectionMapping ( $ childSku ) { if ( isset ( $ this -> childSkuSelectionIdMapping [ $ childSku ] ) ) { return $ this -> childSkuSelectionIdMapping [ $ childSku ] ; } throw new \ Exception ( $ this -> appendExceptionSuffix ( sprintf ( 'Found not mapped selection ID mapping for SKU %s' , $ ch...
Return s the selection ID for the passed child SKU .
11,311
public function mapPriceType ( $ priceType ) { if ( isset ( $ this -> priceTypeMapping [ $ priceType ] ) ) { return $ this -> priceTypeMapping [ $ priceType ] ; } throw new \ Exception ( $ this -> appendExceptionSuffix ( sprintf ( 'Can\'t find mapping for price type %s' , $ priceType ) ) ) ; }
Return s the mapping for the passed price type .
11,312
public function getStoreByStoreCode ( $ storeCode ) { if ( isset ( $ this -> stores [ $ storeCode ] ) ) { return $ this -> stores [ $ storeCode ] ; } throw new \ Exception ( $ this -> appendExceptionSuffix ( sprintf ( 'Found invalid store code %s' , $ storeCode ) ) ) ; }
Return s the store for the passed store code .
11,313
public function getOptionIdForName ( $ name ) { if ( isset ( $ this -> nameOptionIdMapping [ $ name ] ) ) { return $ this -> nameOptionIdMapping [ $ name ] ; } throw new \ Exception ( $ this -> appendExceptionSuffix ( sprintf ( 'Can\'t find option ID for name %s' , $ name ) ) ) ; }
Return s the option ID for the passed name .
11,314
protected function mergeSuggests ( RootPackageInterface $ root ) { if ( ! empty ( $ suggests = $ this -> getPackage ( ) -> getSuggests ( ) ) ) { static :: unwrapIfNeeded ( $ root , 'setSuggests' ) -> setSuggests ( array_merge ( $ root -> getSuggests ( ) , $ suggests ) ) ; } }
Merge suggested packages into a RootPackage .
11,315
public function hasAllowedType ( $ value ) { if ( ! $ this -> forceType ) { return true ; } return Type :: is ( $ value , $ this -> forceType ) ; }
Does the actual type checks .
11,316
public function getStatisticsDatabases ( ) : array { $ file = ( array ) JL :: open ( FEnv :: get ( "framework.config.db.file" ) ) ; JL :: close ( FEnv :: get ( "framework.config.db.file" ) ) ; return ( array ( "number" => count ( $ file ) ) ) ; }
Get databases statistics
11,317
public function getAllDatabasesActivity ( ) : Renderer { $ file = ( array ) JL :: open ( FEnv :: get ( "framework.config.db.file" ) ) ; foreach ( $ file as $ one => $ val ) { $ val -> remove = $ this -> generateRoute ( "iumio_manager_databases_manager_remove" , array ( "dbconfiguration" => $ one ) , null , true ) ; $ v...
Get Databases list
11,318
public function removeActivity ( string $ dbconfiguration ) : Renderer { $ remove = false ; $ file = JL :: open ( FEnv :: get ( "framework.config.db.file" ) ) ; foreach ( $ file as $ one => $ value ) { if ( $ one == $ dbconfiguration ) { unset ( $ file -> $ one ) ; $ remove = true ; break ; } } if ( $ remove == false )...
remove one database
11,319
public function getonedbActivity ( string $ dbconfiguration ) : Renderer { $ file = ( array ) JL :: open ( FEnv :: get ( "framework.config.db.file" ) ) ; foreach ( $ file as $ one => $ val ) { if ( $ one == $ dbconfiguration ) { return ( ( new Renderer ( ) ) -> jsonRenderer ( array ( "code" => 200 , "results" => $ val ...
Get one Database
11,320
public function total ( array $ args = [ ] ) : int { $ default_args = [ 'filters' => [ ] , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'filters' ] = ( array ) $ args [ 'filters' ] ; $ args [ 'no_cache' ] = ( bool ) $ ar...
Total users .
11,321
public function all ( array $ args = [ ] ) : array { $ default_args = [ 'max' => PHP_INT_MAX , 'fail_on_max' => false , 'filters' => [ 'orderby' => 'display_name' , ] , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'max' ...
All users .
11,322
protected function defineErrorHandler ( ) { $ errorRender = $ this -> obtainErrorRender ( ) ; if ( $ errorRender === false ) { return ; } set_error_handler ( [ $ this , 'errorHandler' ] ) ; \ BFW \ Application :: getInstance ( ) -> getMonolog ( ) -> getLogger ( ) -> debug ( 'New error handler defined.' ) ; }
Find and create the handler for errors
11,323
protected function defineExceptionHandler ( ) { $ exceptionRender = $ this -> obtainExceptionRender ( ) ; if ( $ exceptionRender === false ) { return ; } set_exception_handler ( [ $ this , 'exceptionHandler' ] ) ; \ BFW \ Application :: getInstance ( ) -> getMonolog ( ) -> getLogger ( ) -> debug ( 'New exception handle...
Find and create the handler for exceptions
11,324
protected function obtainErrorRender ( ) { $ app = \ BFW \ Application :: getInstance ( ) ; $ renderFcts = $ app -> getConfig ( ) -> getValue ( 'errorRenderFct' , 'errors.php' ) ; return $ this -> defineRenderToUse ( $ renderFcts ) ; }
Get the error render from config for cli or default
11,325
protected function defineRenderToUse ( array $ renderConfig ) { if ( $ renderConfig [ 'enabled' ] === false ) { return false ; } if ( PHP_SAPI === 'cli' && isset ( $ renderConfig [ 'cli' ] ) ) { return $ renderConfig [ 'cli' ] ; } if ( isset ( $ renderConfig [ 'default' ] ) ) { return $ renderConfig [ 'default' ] ; } r...
Find the render to use with the config If cli render is not define it s use the default render .
11,326
public function exceptionHandler ( \ Throwable $ exception ) { \ BFW \ Application :: getInstance ( ) -> getMonolog ( ) -> getLogger ( ) -> debug ( 'New exception catched.' , [ 'msg' => $ exception -> getMessage ( ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) ] ) ; $ errorRender = $ th...
The default exception handler included in BFW
11,327
public function errorHandler ( int $ errSeverity , string $ errMsg , string $ errFile , int $ errLine ) { $ errType = $ this -> obtainErrorType ( $ errSeverity ) ; $ errorRender = $ this -> obtainErrorRender ( ) ; \ BFW \ Application :: getInstance ( ) -> getMonolog ( ) -> getLogger ( ) -> debug ( 'New error catched.' ...
The default error handler included in BFW
11,328
protected function callRender ( array $ renderInfos , string $ errType , string $ errMsg , string $ errFile , int $ errLine , array $ backtrace , $ exceptionCode = null ) { $ this -> saveIntoPhpLog ( $ errType , $ errMsg , $ errFile , $ errLine ) ; $ class = $ renderInfos [ 'class' ] ; $ method = $ renderInfos [ 'metho...
Call the personnal class - method or function declared on config when an exception or an error is triggered .
11,329
protected function saveIntoPhpLog ( string $ errType , string $ errMsg , string $ errFile , int $ errLine ) { error_log ( 'Error detected : ' . $ errType . ' ' . $ errMsg . ' at ' . $ errFile . ':' . $ errLine ) ; }
Save the error into the PHP log
11,330
protected function obtainErrorType ( int $ errSeverity ) : string { $ errorMap = [ E_ERROR => 'Fatal' , E_CORE_ERROR => 'Fatal' , E_USER_ERROR => 'Fatal' , E_COMPILE_ERROR => 'Fatal' , E_RECOVERABLE_ERROR => 'Fatal' , E_WARNING => 'Warning' , E_CORE_WARNING => 'Warning' , E_USER_WARNING => 'Warning' , E_COMPILE_WARNING...
Map array to have a human readable severity .
11,331
public static function register ( Users $ user , string $ name ) : Companies { $ company = new self ( ) ; $ company -> name = $ name ; $ company -> users_id = $ user -> getId ( ) ; if ( ! $ company -> save ( ) ) { throw new Exception ( current ( $ company -> getMessages ( ) ) ) ; } return $ company ; }
Register a company given a user and name
11,332
public function afterCreate ( ) { $ companySettings = new CompanySettings ( ) ; $ companySettings -> company_id = $ this -> getId ( ) ; $ companySettings -> name = 'notifications' ; $ companySettings -> value = $ this -> user -> email ; if ( ! $ companySettings -> save ( ) ) { throw new Exception ( current ( $ companyS...
After creating the company
11,333
public static function getDefaultByUser ( Users $ user ) : Companies { $ defaultCompany = UserConfig :: findFirst ( [ 'conditions' => 'users_id = ?0 and name = ?1' , 'bind' => [ $ user -> getId ( ) , self :: DEFAULT_COMPANY ] , ] ) ; if ( $ defaultCompany ) { return self :: findFirst ( $ defaultCompany -> value ) ; } $...
Get the default company the users has selected
11,334
public function checkImageFixedSize ( $ fixedSize ) { if ( ! $ this -> isImage ( ) ) { return true ; } $ originalImageMeta = $ this -> getImageMeta ( FileModule :: PROCESSOR_NAME_ORIGINAL ) ; $ originalImageMeta -> checkFixedSize ( ( int ) $ fixedSize [ 0 ] , ( int ) $ fixedSize [ 1 ] ) ; if ( $ originalImageMeta -> ha...
Checks if the file s image is of the given size or ratio
11,335
public function tryLoad ( $ path ) { $ result = false ; foreach ( $ this -> directories as $ directory ) { $ fullPath = $ this -> createPath ( $ directory , $ path ) ; $ fileResult = $ this -> tryLoadSingleFile ( $ fullPath ) ; $ result = $ result || $ fileResult ; } return $ result ; }
This function will try to include files in all directories passed to the constructor and return false if at least one directory had a config file .
11,336
private function getRequestOptions ( Request $ request ) { $ options = [ 'http_errors' => false , 'synchronous' => true ] ; if ( $ request -> getQuery ( ) ) { $ options [ 'query' ] = array_merge ( $ this -> getDefaultQuery ( ) , $ request -> getQuery ( ) ) ; } else { $ options [ 'query' ] = $ this -> getDefaultQuery ( ...
Returns request options
11,337
public function read ( $ bytes = 0 ) { if ( $ this -> didWrite ) { $ this -> stream = null ; } if ( ! $ bytes ) { return $ this -> stream ( ) -> toString ( ) ; } $ stream = $ this -> stream ( ) ; $ stream -> setChunkSize ( $ bytes ) ; if ( ! $ stream -> isOpen ( ) ) { $ stream -> rewind ( ) ; } else { $ stream -> next ...
Read some bytes from the connection . This is handled by read
11,338
public function write ( $ content ) { $ bytes = $ this -> stream ( ) -> write ( $ content ) ; $ this -> didWrite = true ; return $ bytes ; }
Write some bytes into the connection .
11,339
private function assertValidTransaction ( array $ transaction ) { if ( ! isset ( $ transaction [ 'transaction_type' ] ) ) { throw new InvalidArgumentException ( "Transaction type is empty" ) ; } $ this -> assertValidContent ( $ transaction [ 'content' ] ) ; $ this -> assertValidSender ( $ transaction [ 'from' ] ) ; $ t...
Check if transaction data is valid
11,340
public function findFile ( $ filename ) { $ filename = basename ( str_replace ( '\\' , '/' , $ filename ) ) ; foreach ( $ this -> strategies as $ strategy ) { $ path = $ strategy -> locate ( $ filename ) ; if ( ! is_null ( $ path ) ) { return $ path ; } } return null ; }
Find the description file for an entity
11,341
public function prepend ( $ segment ) { $ segments = is_array ( $ segment ) ? $ segment : func_get_args ( ) ; $ newPath = $ this -> path -> copy ( ) ; foreach ( array_reverse ( $ segments ) as $ segment ) { $ newPath -> prepend ( $ segment ) ; } return $ this -> replicate ( [ 'path' => $ newPath ] ) ; }
Prepend a segment to the path .
11,342
protected function setPath ( $ path ) { if ( $ path instanceof StringList ) { $ this -> path = $ path ; return $ this ; } if ( $ path === '' ) { $ this -> path -> setPrefix ( '' ) -> setSource ( [ ] ) ; return $ this ; } $ hasLeadingSlash = ( $ path [ 0 ] == '/' ) ; $ hasTrailingSlash = ( substr ( $ path , - 1 ) == '/'...
Set the path inline .
11,343
protected function mergeOrReplaceQuery ( $ query ) { if ( is_array ( $ query ) ) { return array_merge ( $ this -> query , $ query ) ; } if ( ! is_string ( $ query ) ) { throw new InvalidArgumentException ( 'Query has to be array or string not ' . gettype ( $ query ) ) ; } if ( $ query === '' ) { return [ ] ; } $ normal...
Merges a new query or replace the current one if the query is a string and starts with ?
11,344
protected function parseUrl ( $ url ) { if ( $ parsed = parse_url ( $ url ) ) { return $ this -> addPassword ( $ parsed ) ; } $ parts = explode ( ':' , $ url , 2 ) ; if ( count ( $ parts ) != 2 || strlen ( $ parts [ 0 ] ) > 24 ) { throw new InvalidArgumentException ( "Unparseable url $url" ) ; } if ( ! $ parsed = parse...
Parses the url .
11,345
public function path ( $ name = null ) { if ( ! $ name || in_array ( $ name , [ '/' , '.' , 'root' , 'app' ] ) ) { return $ this -> path ; } list ( $ scope , $ path ) = $ this -> splitNameAndPath ( $ name ) ; if ( ! $ scope ) { return $ this -> path -> append ( $ path ) ; } if ( ! isset ( $ this -> paths [ $ scope ] ) ...
This is a method to retrieve paths of the application . Without any parameter it returns the root path . This is typically a directory root with a public folder .
11,346
public function setConfig ( $ config ) { if ( $ this -> wasBooted ( ) ) { throw new UnsupportedUsageException ( 'You can only set configuration before boot.' ) ; } $ this -> config = Type :: forceAndReturn ( $ config , ArrayAccess :: class ) ; return $ this ; }
Set the application configuration .
11,347
public function configure ( $ key , $ value = null ) { if ( $ this -> wasBooted ( ) ) { throw new UnsupportedUsageException ( 'You can only set configuration before boot.' ) ; } if ( ! is_array ( $ key ) ) { $ this -> config [ $ key ] = $ value ; return $ this ; } foreach ( $ key as $ configKey => $ value ) { $ this ->...
Set a configuration value . To prevent misuse the configuration values can not be changed after booting . Otherwise somebody will use it as a global variable storage .
11,348
public function environment ( ) { if ( $ this -> environment ) { return $ this -> environment ; } if ( ! $ this -> environmentProvider ) { $ this -> environment = static :: PRODUCTION ; return $ this -> environment ; } $ this -> setEnvironment ( call_user_func ( $ this -> environmentProvider , $ this ) ) ; return $ thi...
Return the application environment .
11,349
protected function splitNameAndPath ( $ name ) { list ( $ start , $ end ) = strpos ( $ name , '::' ) ? explode ( '::' , $ name ) : [ '' , $ name ] ; if ( $ start ) { return [ $ start , $ end ] ; } $ paths = $ this -> getPaths ( ) ; if ( ! isset ( $ paths [ $ end ] ) ) { return [ '' , $ end ] ; } return [ $ end , '' ] ;...
Splits the name and path of a path query .
11,350
public function assertEqualsSQLQueries ( $ expected , $ actual , string $ message = '' , float $ delta = 0.0 , int $ maxDepth = 10 , bool $ canonicalize = FALSE , bool $ ignoreCase = FALSE ) : void { $ flatten = function ( array $ value ) { $ flattened = [ ] ; array_walk_recursive ( $ value , function ( $ a ) use ( & $...
Assert two SQL queries or two series of SQL queries are equal .
11,351
public function assertExecutedSQLQueries ( $ expected , string $ message = '' , float $ delta = 0.0 , int $ maxDepth = 10 , bool $ canonicalize = FALSE , bool $ ignoreCase = FALSE ) : void { $ actual = $ this -> getDatabaseDriver ( ) -> getExecutedQueries ( ) ; $ this -> assertEqualsSQLQueries ( $ expected , $ actual ,...
Asserts the executed SQL equal the expected values . Works only if getDatabaseDriver method is implemented .
11,352
public function keys ( Model $ model ) { $ pk = $ model -> getKeyName ( ) ; $ pool = [ [ $ pk ] , $ model -> getVisible ( ) , $ model -> getHidden ( ) , $ model -> getFillable ( ) , $ model -> getGuarded ( ) , $ model -> getDates ( ) , array_keys ( $ this -> getCasts ( $ model ) ) ] ; if ( method_exists ( $ model , 'ge...
Guess the available keys by standard eloquent mechanisms like casts timestamps fillable ...
11,353
protected function getFromCasts ( Model $ model , $ key ) { $ casts = $ this -> getCasts ( $ model ) ; if ( ! isset ( $ casts [ $ key ] ) ) { return '' ; } $ cast = $ casts [ $ key ] ; foreach ( $ this -> xTypeToCasts as $ xType => $ casts ) { if ( in_array ( $ cast , $ casts ) ) { return $ xType ; } } return 'string' ...
Get the typename from the casts array
11,354
private function initialiseForWriting ( ) { fseek ( $ this -> stream , 0 , SEEK_END ) ; if ( ftell ( $ this -> stream ) === 0 ) { fwrite ( $ this -> stream , $ this -> formatter -> getInitialBlock ( ) ) ; } elseif ( strlen ( $ this -> formatter -> getClosingBlock ( ) ) > 0 ) { $ endBlock = $ this -> formatter -> getClo...
Initialise the resource for writing .
11,355
public function submitButton ( string $ label = '' ) { $ markup = '<p class="-submit submit">' ; $ markup .= '<button class="button button-primary" type="submit">' ; $ markup .= $ label ? : __ ( 'Save Changes' , 'wp-sharks-core' ) ; $ markup .= '</button>' ; $ markup .= '</p>' ; return $ markup ; }
Create submit button .
11,356
protected function elementId ( string $ var_name = '' ) : string { if ( $ this -> action ) { return $ this -> s :: restActionFormElementId ( $ this -> action , $ var_name ) ; } elseif ( $ this -> cfg -> Widget ) { return $ this -> cfg -> Widget -> get_field_id ( $ var_name ) ; } return $ this -> cfg -> slug . ( $ var_n...
Form element ID .
11,357
protected function elementClass ( string $ var_name = '' ) : string { if ( $ this -> action ) { return $ this -> s :: restActionFormElementClass ( $ var_name ) ; } elseif ( $ this -> cfg -> Widget ) { return $ this -> cfg -> Widget -> get_field_id ( $ var_name ) ; } return $ this -> cfg -> slug . ( $ var_name ? '-' . $...
Form element class .
11,358
protected function elementName ( string $ var_name = '' ) : string { if ( $ this -> action ) { return $ this -> s :: restActionFormElementName ( $ var_name ) ; } elseif ( $ this -> cfg -> Widget ) { return $ this -> cfg -> Widget -> get_field_name ( $ var_name ) ; } $ parts = $ var_name ? preg_split ( '/(\[[^[\]]*\])/u...
Form element name .
11,359
public function toString ( ) { $ url = $ this -> scheme . ':' ; if ( trim ( $ this -> host ) != '' ) { $ url .= '//' ; if ( trim ( $ this -> user ) != '' ) { $ url .= $ this -> user . ( ( trim ( $ this -> pass ) != '' ) ? ':' . $ this -> pass : '' ) . '@' ; } $ url .= $ this -> host ; if ( trim ( $ this -> port ) != ''...
Rebuilt the URL with all known parts
11,360
protected function populate ( $ name , $ value ) { switch ( $ name ) { case 'port' : if ( ! is_int ( $ value ) ) { throw new InvalidArgumentException ( 'Value given to set "' . $ name . '" must be a valid int!!' ) ; } if ( isset ( self :: $ defaultPorts [ $ this -> scheme ] ) && $ value == self :: $ defaultPorts [ $ th...
Fill a property with the given value
11,361
protected function retrieve ( $ name ) { switch ( $ name ) { case 'port' : if ( is_null ( $ this -> $ name ) && isset ( self :: $ defaultPorts [ $ this -> scheme ] ) ) { return self :: $ defaultPorts [ $ this -> scheme ] ; } default : return $ this -> $ name ; } }
Property name to retrieve from the current object This function is defined only for the special port case
11,362
protected function loadParameters ( ContainerBuilder $ container , array $ config ) : void { $ container -> setParameter ( 'fxp_require_asset.config.default_locale' , $ config [ 'default_locale' ] ) ; $ container -> setParameter ( 'fxp_require_asset.config.fallback_locale' , $ config [ 'fallback_locale' ] ) ; $ contain...
Load the parameters in container .
11,363
protected function configureWebpack ( LoaderInterface $ loader , ContainerBuilder $ container , array $ config , $ withTwig ) : void { if ( $ config [ 'enabled' ] ) { $ loader -> load ( 'webpack.xml' ) ; $ container -> setParameter ( 'fxp_require_asset.webpack.adapter' , $ config [ 'adapter' ] ) ; $ this -> configureWe...
Configure the webpack section .
11,364
private function configureWebpackAssets ( ContainerBuilder $ container , array $ config ) : void { $ assetsFile = $ config [ 'file' ] ; $ cacheId = $ config [ 'cache' ] [ 'service_id' ] ; $ cacheKey = $ config [ 'cache' ] [ 'key' ] ; $ cacheEnabled = $ config [ 'cache' ] [ 'enabled' ] ; $ cacheEnabled = null !== $ cach...
Configure the webpack assets adapter .
11,365
public function addDynamicPlaceholder ( $ placeholder , $ statements ) { foreach ( $ this -> cacheStack as $ cache ) { $ cache -> dynamicPlaceholders [ $ placeholder ] = $ statements ; } $ this -> dynamicPlaceholders [ $ placeholder ] = $ statements ; }
Adds a placeholder for dynamic content . This method is internally used .
11,366
public function pagination ( $ total , $ current , $ perPage = null , $ neighbours = null ) { return $ this [ 'pagination' ] ( $ total , $ current , $ perPage , $ neighbours ) ; }
Returns pagination service instance .
11,367
public function mergeDevInto ( RootPackageInterface $ root , PluginState $ state ) { $ this -> mergeDevRequires ( $ root , $ state ) ; $ this -> mergeDevAutoload ( $ root ) ; $ this -> mergeReferences ( $ root ) ; }
Merge just the dev portion into a RootPackageInterface .
11,368
private function mergeDevAutoload ( RootPackageInterface $ root ) { if ( ! empty ( $ autoload = $ this -> getPackage ( ) -> getDevAutoload ( ) ) ) { static :: unwrapIfNeeded ( $ root , 'setDevAutoload' ) -> setDevAutoload ( array_merge_recursive ( $ root -> getDevAutoload ( ) , Util :: fixRelativePaths ( $ this -> getP...
Merge autoload - dev into a RootPackage .
11,369
public function get ( Asset $ asset ) : Asset { $ cache = $ this -> locator -> get ( AssetsCache :: class ) ; $ cachedAsset = $ cache -> get ( $ asset ) ; if ( null !== $ cachedAsset ) { return $ cachedAsset ; } return $ this -> addAsset ( $ asset ) ; }
Gets the asset from the cache and adds it if it is missing
11,370
public function add ( array $ assets , ? callable $ progress ) : void { $ fileTypeRegistry = $ this -> locator -> get ( FileTypeRegistry :: class ) ; $ deferred = [ ] ; foreach ( $ assets as $ asset ) { if ( $ fileTypeRegistry -> importDeferred ( $ asset ) ) { $ deferred [ ] = $ asset ; continue ; } $ this -> addAsset ...
Adds a list of asset paths
11,371
private function addAsset ( Asset $ asset ) : Asset { $ storage = $ this -> locator -> get ( AssetStorage :: class ) ; $ cache = $ this -> locator -> get ( AssetsCache :: class ) ; $ asset = $ storage -> import ( $ asset ) ; $ cache -> add ( $ asset ) ; return $ asset ; }
Adds an asset to the registry
11,372
public function clear ( ) : void { $ storage = $ this -> locator -> get ( AssetStorage :: class ) ; $ cache = $ this -> locator -> get ( AssetsCache :: class ) ; $ storage -> removeAllStoredFiles ( ) ; $ cache -> clear ( ) ; }
Clears the assets registry
11,373
protected function initialize ( ) : void { unset ( $ this -> functions , $ this -> humanReadableName , $ this -> rewindable , $ this -> memoryUsageReport ) ; $ this -> rewindable = new Rewindable ( $ this -> iterationNumberGenerator , $ this -> iterations ) ; $ this -> humanReadableName = null ; $ this -> functions = [...
Resets Benchmark object clear
11,374
public function reset ( ? string $ char = null ) : string { $ this -> initialize ( ) ; return $ this -> sectionSeparator ( $ char ) ; }
Resets Benchmark object clear . Returns divider string .
11,375
public function findLastIndex ( string $ tagName ) : int { $ tags = $ this -> asArray ( ) ; return ArrayUtils :: lastIndexOf ( $ tags , function ( Tag $ tag ) use ( $ tagName ) { return $ tag -> getTagName ( ) === $ tagName ; } ) ; }
Finds index of a tag in the stack by tag name .
11,376
public function removeLast ( string $ tagName ) : bool { $ index = $ this -> findLastIndex ( $ tagName ) ; if ( $ index === - 1 ) { return false ; } $ this -> removeAt ( $ index ) ; return true ; }
Finds and removes last tag by tag name .
11,377
private function getContxtualModule ( AbstractAppMeta $ appMeta , $ contexts ) { $ contextsArray = array_reverse ( explode ( '-' , $ contexts ) ) ; $ module = null ; foreach ( $ contextsArray as $ context ) { $ class = $ appMeta -> name . '\Module\\' . ucwords ( $ context ) . 'Module' ; if ( ! class_exists ( $ class ) ...
Return configured module
11,378
public static function connectWithUser ( BaseClientInterface $ client ) { if ( Yii :: $ app -> user -> isGuest ) { Yii :: $ app -> session -> setFlash ( 'danger' , Yii :: t ( 'user' , 'Something went wrong' ) ) ; return ; } $ account = static :: fetchAccount ( $ client ) ; if ( $ account -> user === null ) { $ account ...
Tries to find an account and then connect that account with current user .
11,379
public static function createFromString ( string $ uri ) : self { if ( ! \ is_string ( $ uri ) && ! \ method_exists ( $ uri , '__toString' ) ) { throw new \ InvalidArgumentException ( 'Uri must be a string' ) ; } $ parts = \ parse_url ( $ uri ) ; $ scheme = $ parts [ 'scheme' ] ?? '' ; $ user = $ parts [ 'user' ] ?? ''...
Create new Uri from string .
11,380
public function withScheme ( $ scheme ) : self { $ scheme = $ this -> filterScheme ( $ scheme ) ; $ clone = clone $ this ; $ clone -> scheme = $ scheme ; return $ clone ; }
Return an instance with the specified scheme . This method MUST retain the state of the current instance and return an instance that contains the specified scheme . Implementations MUST support the schemes http and https case insensitively and MAY accommodate other schemes if required . An empty scheme is equivalent to...
11,381
protected function filterScheme ( $ scheme ) : string { if ( ! \ is_string ( $ scheme ) && ! \ method_exists ( $ scheme , '__toString' ) ) { throw new \ InvalidArgumentException ( 'Uri scheme must be a string' ) ; } $ scheme = \ str_replace ( '://' , '' , \ strtolower ( ( string ) $ scheme ) ) ; if ( ! isset ( static :...
Filter Uri scheme .
11,382
public function withQuery ( $ query ) : self { if ( ! \ is_string ( $ query ) && ! method_exists ( $ query , '__toString' ) ) { throw new \ InvalidArgumentException ( 'Uri query must be a string' ) ; } $ query = ltrim ( ( string ) $ query , '?' ) ; $ clone = clone $ this ; $ clone -> query = $ this -> filterQuery ( $ q...
Return an instance with the specified query string . An empty query string value is equivalent to removing the query string .
11,383
public function enable ( $ start_time = null , $ memory_usage = null ) { $ this -> enabled = true ; $ this -> start_time = $ start_time ? : ( $ _SERVER [ "REQUEST_TIME_FLOAT" ] * 1000 ) ; $ this -> start_memory_usage = $ memory_usage ? : memory_get_usage ( ) ; $ this -> log ( "Profiling enabled" ) ; }
Enables the logger and sets the start time and memory usage
11,384
public function log ( $ string , $ context = [ ] ) { if ( ! $ this -> enabled ) { return ; } $ this -> logger -> info ( $ string , [ 'time' => static :: formatTime ( static :: getTime ( ) - $ this -> start_time ) , 'memory' => static :: formatSize ( memory_get_usage ( ) ) , 'memory_bytes' => memory_get_usage ( ) , 'tim...
Logs time and memory usage
11,385
public function logStart ( $ string , $ context = [ ] ) { if ( ! $ this -> enabled ) { return ; } $ this -> timer = static :: getTime ( ) ; $ this -> log ( "Start: " . $ string , [ 'elapsed' => 'start' ] + $ context ) ; }
Starts a timer . Ideal for logging elapsed time for database queries
11,386
public function logStop ( $ string , $ context = [ ] ) { if ( ! $ this -> enabled ) { return ; } $ this -> log ( "Stop: " . $ string , [ 'elapsed' => static :: formatTime ( static :: getTime ( ) - $ this -> timer ) , 'elapsed_microtime' => static :: getTime ( ) - $ this -> timer ] + $ context ) ; }
Stops the timer
11,387
protected static function formatTime ( $ time ) { if ( $ time > 1000 && $ time < 60000 ) { return sprintf ( '%02.2f' , $ time / 1000 ) . 's' ; } if ( $ time > 60000 ) { return sprintf ( '%02.2f' , $ time / 60000 ) . 'm' ; } return sprintf ( '%02.2f' , $ time ) . 'ms' ; }
Pretty - prints the current time
11,388
private function resolveErrorHandlerFromAcceptHeader ( Request $ request ) : callable { $ accepts = $ request -> hasHeader ( 'Accept' ) ? $ request -> getHeaderLine ( 'Accept' ) : $ this -> defaultContentType ; $ accepts = explode ( ',' , $ accepts ) ; foreach ( $ accepts as $ accept ) { if ( ! $ this -> errorHandlerMa...
Tries to resolve an error response generator based on request s accept header
11,389
public function total ( array $ args = [ ] ) : int { $ default_args = [ 'include' => [ ] , 'exclude' => [ ] , 'no_cache' => false , ] ; $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; $ args [ 'include' ] = ( array ) $ args [ 'include' ] ; $ args [ 'exclude'...
Total roles .
11,390
public function initialize ( ) { $ this -> hasOne ( 'id' , 'Baka\Auth\Models\Sessions' , 'users_id' , [ 'alias' => 'session' ] ) ; $ this -> hasMany ( 'id' , 'Baka\Auth\Models\Sessions' , 'users_id' , [ 'alias' => 'sessions' ] ) ; $ this -> hasMany ( 'id' , 'Baka\Auth\Models\SessionKeys' , 'users_id' , [ 'alias' => 'se...
initialize the model
11,391
public function validation ( ) { $ validator = new Validation ( ) ; $ validator -> add ( 'email' , new Email ( [ 'field' => 'email' , 'required' => true , ] ) ) ; $ validator -> add ( 'displayname' , new PresenceOf ( [ 'field' => 'displayname' , 'required' => true , ] ) ) ; $ validator -> add ( 'displayname' , new Rege...
Validations and business logic
11,392
public static function getById ( $ userId , $ cache = false ) : Users { $ options = null ; $ key = 'userInfo_' . $ userId ; if ( $ cache ) { $ options = [ 'cache' => [ 'lifetime' => 3600 , 'key' => $ key ] ] ; } if ( $ userData = Users :: findFirstById ( $ userId , $ options ) ) { return $ userData ; } else { throw new...
get the user by its Id we can specify the cache if we want to we only get result if the user is active
11,393
public function signUp ( ) : Users { $ this -> sex = 'U' ; if ( empty ( $ this -> firstname ) ) { $ this -> firstname = ' ' ; } if ( empty ( $ this -> lastname ) ) { $ this -> lastname = ' ' ; } $ this -> displayname = empty ( $ this -> displayname ) && ! empty ( $ this -> firstname ) ? $ this -> generateDisplayName ( ...
user signup to the service
11,394
public static function getSocialProfile ( $ site = 'facebook' ) { $ config = \ Phalcon \ DI :: getDefault ( ) -> getConfig ( ) -> social_config -> toArray ( ) ; $ hybridauth = new \ Hybridauth \ Hybridauth ( $ config ) ; $ adapter = $ hybridauth -> authenticate ( $ site ) ; return $ adapter -> getUserProfile ( ) ; }
cget the social profile of a users passing its socialnetwork
11,395
public static function disconnectSocialProfile ( $ site = 'facebook' ) { $ config = \ Phalcon \ DI :: getDefault ( ) -> getConfig ( ) -> social_config -> toArray ( ) ; $ hybridauth = new \ Hybridauth \ Hybridauth ( $ config ) ; return $ hybridauth -> logoutAllProviders ( ) ; $ adapter = $ hybridauth -> authenticate ( $...
logout the user from its social network
11,396
public static function passwordHash ( string $ password ) : string { $ options = [ 'cost' => 12 , ] ; $ hash = password_hash ( $ password , PASSWORD_DEFAULT , $ options ) ; return $ hash ; }
Has for the user password
11,397
public static function getByEmail ( string $ email ) : Users { $ user = self :: findFirst ( [ 'conditions' => 'email = ?0' , 'bind' => [ $ email ] ] ) ; if ( ! $ user ) { throw new Exception ( 'No User Found' ) ; } return $ user ; }
get user by there email address
11,398
public function getProfileHeader ( bool $ mobile = false ) : ? string { $ cdn = \ Phalcon \ DI :: getDefault ( ) -> getCdn ( ) . '/profile_headers/' ; $ header = null ; $ image = ! $ mobile ? $ this -> profile_header : $ this -> profile_header_mobile ; if ( ! empty ( $ this -> profile_header ) ) { $ header = $ cdn . $ ...
get the user profileHeader
11,399
public function getAvatar ( ) : ? string { $ cdn = \ Phalcon \ DI :: getDefault ( ) -> getCdn ( ) . '/avatars/' ; $ avatar = $ cdn . 'nopicture.png' ; if ( ! empty ( $ this -> profile_image ) ) { $ avatar = $ cdn . $ this -> profile_image ; } elseif ( ! empty ( $ this -> profile_remote_image ) ) { $ avatar = $ this -> ...
get the user avatar