idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
55,400
public static function getPath ( $ className , $ ext = "php" ) { if ( substr ( $ className , 0 , 1 ) == "\\" ) { $ className = substr ( $ className , 1 ) ; } $ delimiters = array ( "_" , "\\" ) ; foreach ( $ delimiters as $ symbol ) { $ className = str_replace ( $ symbol , "/" , $ className ) ; } return $ className . "...
Returns class path .
55,401
public static function getClassName ( $ prefix , $ name , $ ucfirst = false ) { if ( substr ( $ prefix , - 1 , 1 ) == "\\" ) { $ className = $ prefix ; } else { $ className = $ prefix . "_" ; } $ className .= $ name ; if ( $ ucfirst ) { $ result = "" ; $ nsPath = explode ( "\\" , $ className ) ; $ name = array_pop ( $ ...
Returns className .
55,402
public static function timeFunction ( $ function , $ description = null ) { $ duration = self :: time ( $ function ) ; Logger :: log ( "Code Block " . ( $ description ? '"' . $ description . '"' : "" ) . " Executed in " . $ duration . " Seconds" ) ; return $ duration ; }
Time the passed function
55,403
public static function recordFunctionTimingForGroup ( $ function , $ group ) { $ functionTiming = CodeTimer :: time ( $ function ) ; if ( isset ( CodeTimer :: $ groupTimings [ $ group ] ) ) { CodeTimer :: $ groupTimings [ $ group ] += $ functionTiming ; } else { CodeTimer :: $ groupTimings [ $ group ] = $ functionTimin...
Record the timing of a passed function against a group . All Timings for a group are added up .
55,404
public static function reportTimingsForGroup ( $ group ) { if ( isset ( CodeTimer :: $ groupTimings [ $ group ] ) ) { Logger :: log ( 'Group "' . $ group . '" Executed in ' . CodeTimer :: $ groupTimings [ $ group ] . " Seconds" ) ; return CodeTimer :: $ groupTimings [ $ group ] ; } else { Logger :: log ( 'No group timi...
Report timings for a group
55,405
protected function makeRepository ( ) { $ full_path = $ this -> getFullRepositoryPath ( ) ; if ( file_exists ( $ full_path ) ) { throw new RepositoryExistsException ( sprintf ( '%s file already exists' , $ full_path ) ) ; } $ contract_contents = str_replace ( [ '%%MODEL_BASENAME%%' , '%%MODEL_NAME%%' , '%%CLASS_NAME%%'...
Make repository file
55,406
protected function makeContract ( ) { $ full_path = $ this -> getFullContractPath ( ) ; if ( file_exists ( $ full_path ) ) { return true ; } $ contract_contents = str_replace ( [ '%%MODEL_BASENAME%%' , '%%MODEL_NAME%%' , '%%CLASS_NAME%%' , '%%NAMESPACE%%' , ] , [ $ this -> getModelBasename ( ) , $ this -> getModelName ...
Make contract file
55,407
public static function assetsSettings ( ) { if ( isset ( self :: $ _assetsSettings ) ) { return self :: $ _assetsSettings ; } return self :: getSettingsBlock ( self :: BLOCK_NAME ) ; }
Get assets settings
55,408
public static function assetsUseStatic ( ) { if ( isset ( self :: $ _useStatic ) ) { return self :: $ _useStatic ; } return self :: getSettingsItem ( self :: $ _useStatic , self :: assetsSettings ( ) , self :: USE_STATIC , self :: DEFAULT_USE_STATIC ) ; }
Get assetsUseStatic setting - use static resources
55,409
public static function assetsStaticEnd ( ) { if ( isset ( self :: $ _staticEnd ) ) { return self :: $ _staticEnd ; } return self :: getSettingsItem ( self :: $ _staticEnd , self :: assetsSettings ( ) , self :: STATIC_END , self :: DEFAULT_STATIC_END ) ; }
Get assetsStaticEnd setting - static application end
55,410
public function setCategory ( \ Innova \ LexiconBundle \ Entity \ Category $ category = null ) { $ this -> category = $ category ; return $ this ; }
Set category .
55,411
public function setSubcategory ( \ Innova \ LexiconBundle \ Entity \ Subcategory $ subcategory = null ) { $ this -> subcategory = $ subcategory ; return $ this ; }
Set subcategory .
55,412
public static function transform_sub_post_fields ( & $ field ) { if ( is_array ( $ field [ 'value' ] ) ) { $ data = [ ] ; foreach ( $ field [ 'value' ] as $ post_id ) { $ data [ ] = Acf :: get_post_field ( $ post_id ) ; } $ field [ 'value' ] = $ data ; } else { $ field [ 'value' ] = Acf :: get_post_field ( $ field [ 'v...
Transform to get the WP and ACF fields of the sub post .
55,413
protected function createContainer ( ContainerModuleLoader $ loader , ScopeLoader $ scopes ) { $ contextCachePath = $ this -> cacheDirectory . DIRECTORY_SEPARATOR . $ this -> contextName ; $ cacheFile = $ contextCachePath . DIRECTORY_SEPARATOR . 'container.php' ; $ containerTypeName = __NAMESPACE__ . '\\CompiledContain...
Create the DI container instance .
55,414
protected function createContainerBuilder ( ) { $ builder = new ContainerBuilder ( ) ; foreach ( $ this -> getContainerParams ( ) as $ k => $ v ) { $ builder -> setParameter ( $ k , $ v ) ; } return $ builder ; }
Create the DI container builder instance .
55,415
protected function setupInstrumentationProcessor ( ) { $ file = $ this -> cacheDirectory . '/' . $ this -> contextName . '/instrument.php' ; if ( is_file ( $ file ) ) { $ this -> instrumentationProcessor = new InstrumentationProcessor ( $ this , require $ file ) ; $ this -> instrumentationProcessor -> registertAutoload...
Setup an instrumentation processor that hooks into the autoloader .
55,416
protected function bindInitialInstances ( ContainerInterface $ container ) { foreach ( $ this -> komponents as $ komponent ) { $ container -> bindInstance ( get_class ( $ komponent ) , $ komponent ) ; } }
Bind initial object instances to the DI container .
55,417
public static function runBackups ( $ disk = null ) { try { $ backupJob = BackupJobFactory :: createFromArray ( config ( 'laravel-backup' ) ) ; if ( ! is_null ( $ disk ) ) { $ backupJob -> onlyBackupTo ( $ disk ) ; } $ backupJob -> run ( ) ; } catch ( \ Exception $ ex ) { return false ; } return true ; }
Run the backups .
55,418
public static function clearBackups ( ) { try { $ config = config ( 'laravel-backup' ) ; $ backupDestinations = BackupDestinationFactory :: createFromArray ( $ config [ 'backup' ] ) ; $ strategy = app ( $ config [ 'cleanup' ] [ 'strategy' ] ) ; $ disableNotification = false ; ( new CleanupJob ( $ backupDestinations , $...
Clean the backups .
55,419
public function get ( array $ adapters , CacheableInterface $ item ) { foreach ( $ adapters as $ adapter ) { if ( false !== $ value = $ adapter -> get ( $ item ) ) { return $ value ; } } return false ; }
Get cache from any adapter if contains
55,420
public function set ( array $ adapters , CacheableInterface $ item ) { foreach ( $ adapters as $ adapter ) { $ adapter -> set ( $ item ) ; } }
Set cache to all adapters
55,421
private function autoAssign ( $ attributes = null ) { if ( ! is_array ( $ attributes ) ) return false ; $ this -> max = isset ( $ attributes [ 0 ] ) ? $ attributes [ 0 ] : $ this -> max ; $ this -> minutes = isset ( $ attributes [ 1 ] ) ? $ attributes [ 1 ] : 1 ; $ this -> decay = isset ( $ attributes [ 1 ] ) ? strtoti...
Set request attributes
55,422
private function canProceed ( $ request ) : bool { $ time = $ this -> decay - date ( 's' ) ; if ( $ request -> cookies -> has ( 'clusters' ) ) { $ value = $ request -> cookie ( 'clusters' ) ; $ value = $ this -> hashids -> decode ( $ value ) [ 0 ] - 1 ; if ( $ value == 0 ) { $ this -> withHeaders ( $ request , $ value ...
Check if request can proceed
55,423
public function inArray ( $ values , $ args , $ do , $ strict = false ) { if ( ! is_callable ( $ do ) ) { throw new \ InvalidArgumentException ( 'Third argument must be a callable' ) ; } foreach ( $ values as $ single ) { $ result = $ do ( $ single , $ args ) ; if ( $ strict && ! $ result ) { break ; } } return $ resul...
Performs an operation in a given array . It stops if strict is set to true and the result of the operation is false .
55,424
public function registerLoader ( $ alias , $ loader ) { if ( $ this -> hasLoader ( $ alias ) ) { throw new \ RuntimeException ( sprintf ( 'Alias "%s" already used by another form loader' , $ alias ) ) ; } $ this -> loaders [ $ alias ] = $ loader ; }
Register a loader .
55,425
private function getLoader ( $ alias ) { if ( ! $ this -> hasLoader ( $ alias ) ) { throw new \ RuntimeException ( sprintf ( 'Form loader with alias "%s" not found.' , $ alias ) ) ; } return $ this -> loaders [ $ alias ] ; }
Get a loader by his alias .
55,426
public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( C2MTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> bui...
Performs an INSERT on the database given a C2M or Criteria object .
55,427
protected function loadQuery ( ) { if ( ! isset ( $ this -> session [ $ this -> saveID ] ) ) { return ; } $ saved = $ this -> session [ $ this -> saveID ] ; $ this -> inputs = array_merge ( $ saved [ 'inputs' ] , $ this -> inputs ) ; $ this -> perPage = $ saved [ 'perPage' ] ; if ( $ currPage = $ this -> getKey ( $ thi...
loads query information from saved session .
55,428
protected function saveQuery ( ) { $ this -> session [ $ this -> saveID ] = [ 'perPage' => $ this -> perPage , 'currPage' => $ this -> currPage , 'inputs' => $ this -> inputs , ] ; }
saves query information into session .
55,429
public function setDefaultValue ( $ defaultValue ) : FieldInterface { if ( ! is_scalar ( $ defaultValue ) && ! is_null ( $ defaultValue ) ) { throw new \ InvalidArgumentException ( "invalid value provided for 'defaultValue'; " . "expecting either a scalar or null value" ) ; } $ this -> defaultValue = $ defaultValue ; r...
Set the default value for the field
55,430
public function actionProfile ( ) { $ user = Yii :: $ app -> getUser ( ) -> getIdentity ( ) ; $ model = new MultiModel ( [ 'models' => [ 'user' => $ user , 'profile' => $ user -> profile , ] , ] ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { Yii :: $ app -> session -> addFla...
Updates own profile . If update is successful the browser will be redirected to the view page .
55,431
public function cmdGetProductClass ( ) { $ result = $ this -> getListProductClass ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableProductClass ( $ result ) ; $ this -> output ( ) ; }
Callback for product - class - get command
55,432
public function cmdDeleteProductClass ( ) { $ id = $ this -> getParam ( 0 ) ; $ result = null ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ result = $ this -> product_class -> delete ( $ id ) ; } else if ( $ this -> getP...
Callback for product - class - delete command
55,433
public function cmdUpdateProductClass ( ) { $ 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' ) ) ; } $ ...
Callback for product - class - update command
55,434
protected function addProductClass ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> product_class -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new product class
55,435
protected function submitAddProductClass ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'product_class' ) ; $ this -> addProductClass ( ) ; }
Add a new product class at once
55,436
protected function wizardAddProductClass ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'product_class' ) ; $ this -> validatePrompt ( 'status' , $ this -> text ( 'Status' ) , 'product_class' , 0 ) ; $ this -> validateComponent ( 'product_class' ) ; $ this -> addProductClass ( ) ; }
Add a new product class step by step
55,437
final public static function getAlignedPos ( Base $ object , $ newHalign , $ newValign ) { $ newPosX = self :: getAlignedPosX ( $ object -> getPosnX ( ) , $ object -> getRealSizeX ( ) , $ object -> getHalign ( ) , $ newHalign ) ; $ newPosY = self :: getAlignedPosY ( $ object -> getPosnY ( ) , $ object -> getRealSizeY (...
Returns the position of an element in relation to another element and according to their respective alignments
55,438
protected function createMatchQuery ( $ expression , array $ fields = [ ] ) { if ( 0 == strlen ( $ expression ) ) { return new Query \ MatchAll ( ) ; } if ( empty ( $ fields ) ) { $ fields = $ this -> getDefaultMatchFields ( ) ; } $ query = new Query \ MultiMatch ( ) ; $ query -> setQuery ( $ expression ) -> setFields ...
Creates the match query .
55,439
public function writeXML ( \ XMLWriter $ w , string $ elementName = 'ImageSizeReducer' ) { $ w -> startElement ( $ elementName ) ; $ this -> writeXMLAttributes ( $ w ) ; $ w -> endElement ( ) ; }
Writes all instance options to an XML element .
55,440
public function writeXMLAttributes ( \ XMLWriter $ w ) { switch ( $ this -> data [ 'type' ] ) { case ImageSizeReducerType :: CROP : $ w -> writeAttribute ( 'type' , 'crop' ) ; $ w -> writeAttribute ( 'width' , $ this -> data [ 'width' ] ) ; $ w -> writeAttribute ( 'height' , $ this -> data [ 'height' ] ) ; break ; case...
Writes all instance options to XML attributes inside the opened XML element .
55,441
protected static function Create ( int $ type , int $ width , int $ height , int $ gravity = Gravity :: MIDDLE_CENTER , int $ portraitLength = 0 , int $ landscapeLength = 0 ) : ImageSizeReducer { switch ( $ type ) { case ImageSizeReducerType :: CROP : if ( $ width < 1 ) { throw new ArgumentError ( 'width' , $ width , '...
Init an Image size reducer .
55,442
public static function TryParse ( $ value , & $ refReducer = null ) : bool { if ( \ is_null ( $ value ) ) { return false ; } if ( $ value instanceof \ SimpleXMLElement ) { return static :: TryParseXmlElement ( $ value , $ refReducer ) ; } if ( \ is_string ( $ value ) && ! empty ( $ value ) && $ value [ 0 ] == '{' ) { t...
Tries to parse the defined value to an ImageSizeReducer instance
55,443
public function resolve ( $ databaseResult ) { $ className = $ this -> className ; try { $ object = new $ className ( ) ; $ this -> loader -> mapObjectWithOptions ( $ object , $ databaseResult ) ; $ databaseResult -> { $ this -> fieldName } = $ object ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) ; } }
Resolve data by splicing in the completed object
55,444
public function joinOn ( $ foreignKeyColumn ) { return 'join ' . $ this -> getTable ( ) . ' on ' . $ this -> loader -> getPrimaryKey ( $ this -> alias ) . ' = ' . $ foreignKeyColumn . ' ' ; }
Print out Join SQL
55,445
protected function prefixedResource ( $ name , $ controller , array $ options ) { list ( $ name , $ prefix ) = $ this -> getResourcePrefix ( $ name ) ; $ callback = function ( $ me ) use ( $ name , $ controller , $ options ) { $ me -> resource ( $ name , $ controller , $ options ) ; } ; $ this -> router -> group ( comp...
Build a set of prefixed resource routes .
55,446
protected function addResourceShow ( $ name , $ base , $ controller , $ options ) { $ uri = $ this -> getResourceUri ( $ name ) . '/{' . $ base . '' ; $ action = $ this -> getResourceAction ( $ name , $ controller , 'show' , $ options ) ; return $ this -> router -> get ( $ uri , $ action ) ; }
Add the show method for a resourceful route .
55,447
public static function generateRandomAlphaNumericString ( $ length ) { $ chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ; $ size = strlen ( $ chars ) ; $ randomChars = array ( ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ randomChars [ ] = $ chars [ mt_rand ( 0 , $ size - 1 ) ] ; } return ...
Generate a random string with repeatable letters .
55,448
public function verifyPassword ( $ name , $ pass ) { $ this -> find ( "name" , $ name ) ; return password_verify ( $ pass , $ this -> pass ) ; }
Verify the name and the pass if successful the object contains all details from the database row .
55,449
public function controlAuthority ( $ loggedUser , $ name ) { $ this -> find ( "name" , $ loggedUser ) ; if ( $ this -> authority != "admin" ) { return ( $ this -> name == $ name ) ; } return true ; }
Check if a post belongs to user
55,450
public function get ( ) { return new JSendResponse ( $ this -> status , $ this -> data , $ this -> errors , $ this -> code , $ this -> message ) ; }
Returns the built object
55,451
function getStatement ( $ cKey , $ sqlCallback , $ types , $ params ) { if ( ! $ this -> stmtCache [ $ cKey ] ) { if ( ! ( $ stmt = $ this -> mysqli -> prepare ( $ sqlCallback instanceof \ Closure ? $ sqlCallback ( ) : $ sqlCallback ) ) ) { throw new \ Exception ( "Statement Error: {$this->mysqli->error}" , $ this -> m...
array and returns the statement ready to execute .
55,452
public static function check ( $ path , $ fd , $ rw ) { if ( $ fd == 'f' ) { if ( is_file ( $ path ) != true ) { return false ; } } elseif ( $ fd == 'd' ) { if ( is_dir ( $ path ) != true ) { return false ; } } else { return false ; } if ( $ rw == 'r' ) { if ( ! is_readable ( $ path ) ) { return false ; } } elseif ( $ ...
Checks a file or directory existence and readability
55,453
public function loadConfig ( $ configFiles ) { if ( ! is_array ( $ configFiles ) ) { $ configFiles = array ( $ configFiles ) ; } $ this -> configFiles = $ configFiles ; foreach ( $ configFiles as $ configFile ) { $ this -> config = array_merge ( $ this -> config , $ this -> loadConfigFile ( $ configFile ) ) ; } }
Sets to the config property the merged content from all the config files .
55,454
public function fetch ( ) { $ keys = func_get_args ( ) ; $ config = $ this -> config ; foreach ( $ keys as $ key ) { if ( isset ( $ config [ $ key ] ) ) { $ config = $ config [ $ key ] ; } else { throw new KeyNotFoundException ( "Key $key not found." ) ; } } return $ config ; }
Fetches a single value from a key chain of N depth
55,455
public function flush ( ) { if ( $ this -> useCache ) { foreach ( $ this -> configFiles as $ configFile ) { if ( function_exists ( 'apc_delete' ) ) { \ apc_delete ( $ configFile ) ; } } } $ this -> config = array ( ) ; }
If cache is used flushes it . Otherwise it just empties config property .
55,456
private function loadConfigFile ( $ configFile ) { if ( $ this -> useCache ) { if ( function_exists ( 'apc_fetch' ) ) { $ config = apc_fetch ( $ configFile ) ; } elseif ( function_exists ( 'apcu_fetch' ) ) { $ config = apcu_fetch ( $ configFile ) ; } if ( ! empty ( $ config ) ) { return $ config ; } } if ( ! is_readabl...
Loads a config file into config property . If cache is used first check if the config file was previously loaded .
55,457
public function initializeRequest ( $ request = null ) { if ( empty ( $ request ) ) { $ this -> request = Request :: createFromGlobals ( ) ; } else { $ this -> request = $ request ; } $ this -> input = new Input ( $ this -> request ) ; }
Get info about the HTTP Request
55,458
public function jsonp ( $ content = [ ] , $ jsonCallback = 'callback' ) { $ response = new JsonResponse ( ) ; $ response -> setData ( $ content ) ; $ response -> setCallback ( $ jsonCallback ) ; $ response -> send ( ) ; }
Send a jsonp response with given content .
55,459
public function getRequestedController ( $ default = null ) { if ( property_exists ( $ this , 'app' ) && is_object ( $ this -> app ) && property_exists ( $ this -> app , 'controller' ) ) { return $ this -> app -> controller ; } elseif ( ! empty ( $ default ) ) { return $ default ; } else { $ reflect = new \ ReflectionC...
Which controller was requested?
55,460
public function getRequestedAction ( $ default = 'index' ) { if ( property_exists ( $ this , 'app' ) && is_object ( $ this -> app ) && property_exists ( $ this -> app , 'action' ) ) { return $ this -> app -> action ; } else { return $ default ; } }
Which action was requested?
55,461
public static function initialize ( Connection $ connection , string $ baseNamespace = "\\" ) { self :: $ _connection = $ connection ; self :: $ _baseNamespace = Str :: trailing ( $ baseNamespace , "\\" ) ; }
Initializes the class .
55,462
public static function find ( $ id , $ limit = - 1 , string $ table = "" , bool $ setRelations = true ) { $ query = new QueryBuilder ( self :: $ _connection ) ; $ model = new static ( ) ; $ query -> select ( "*" ) ; if ( $ table === "" ) { $ query -> from ( $ model -> getTable ( ) ) ; } else { $ query -> from ( $ table...
Finds and returns one or more record from the database .
55,463
public static function all ( array $ where = [ ] , string $ table = "" , bool $ setRelations = true ) : array { $ query = new QueryBuilder ( self :: $ _connection ) ; $ model = new static ( ) ; $ query -> select ( "*" ) ; if ( $ table === "" ) { $ query -> from ( $ model -> getTable ( ) ) ; } else { $ query -> from ( $...
Returns all records from database .
55,464
private static function _setWhere ( $ where , QueryBuilder $ query , string $ primaryKey = "id" ) : QueryBuilder { if ( ! is_array ( $ where ) ) { return $ query -> where ( [ $ primaryKey => $ where ] ) ; } $ columns = $ where ; unset ( $ columns [ "ORDER BY" ] ) ; unset ( $ columns [ "LIMIT" ] ) ; unset ( $ columns [ ...
Sets the WHERE param to the query .
55,465
public function set ( string $ name , $ value ) { $ this -> _data [ $ name ] = $ value ; if ( ! is_object ( $ value ) ) { $ this -> _changed [ $ name ] = $ value ; } }
Sets a column .
55,466
public function save ( ) { $ query = new QueryBuilder ( self :: $ _connection ) ; if ( $ this -> _isInsert ) { $ query -> insert ( $ this -> getTable ( ) ) -> values ( $ this -> _changed ) ; $ id = self :: $ _connection -> insert ( $ query -> getQuery ( ) ) ; $ this -> _data [ $ this -> _primaryKey ] = $ id ; $ this ->...
Saves the changes to the database .
55,467
public function getTable ( ) : string { if ( ! empty ( $ this -> _table ) ) { return $ this -> _table ; } $ class = explode ( "\\" , str_replace ( self :: $ _baseNamespace , "" , "\\" . get_called_class ( ) ) ) ; $ table = Str :: snake ( Str :: plural ( $ class ) ) ; $ this -> _table = $ table ; return $ this -> _table...
Builds and returns table name .
55,468
public function asArray ( bool $ decodeJSON = true ) : array { if ( ! $ decodeJSON ) { return $ this -> _data ; } $ return = [ ] ; foreach ( $ this -> _data as $ key => $ value ) { $ decoded = json_decode ( $ value ) ; $ return [ $ key ] = $ decoded ; if ( ! is_array ( $ decoded ) && ! is_object ( $ decoded ) ) { $ ret...
Returns table values .
55,469
public function asJSON ( ) : string { $ fields = [ ] ; foreach ( $ this -> _data as $ key => $ value ) { if ( ! is_object ( $ value ) ) { $ fields [ $ key ] = $ value ; } } return json_encode ( $ fields ) ; }
Returns values as a JSON .
55,470
public static function findRoute ( $ route , $ properties = [ ] ) { if ( ! empty ( $ properties ) ) { foreach ( self :: $ routes as $ r ) { if ( $ r [ 'props' ] [ 'as' ] == $ route ) { $ parts = explode ( '/' , $ r [ 'url' ] ) ; $ url = "" ; $ count = 1 ; foreach ( $ parts as $ part ) { if ( substr ( $ part , 0 , 1 ) =...
Finds a route by the given route name . Also takes properties to put into the route url .
55,471
private static function callController ( $ route , $ properties = [ ] ) { $ props = $ route [ 'props' ] ; $ uses = $ props [ 'uses' ] ; if ( ! empty ( $ props [ 'middleware' ] ) ) { if ( ! ctype_upper ( substr ( $ props [ 'middleware' ] , 0 , 1 ) ) ) { $ middleware = substr_replace ( $ props [ 'middleware' ] , strtoupp...
Call controller by route .
55,472
public static function execute ( $ currentRoute ) { $ currentRouteParts = explode ( '/' , $ currentRoute ) ; foreach ( self :: $ routes as $ route ) { if ( $ route [ 'url' ] == $ currentRoute ) { return self :: callController ( $ route ) ; } $ routeParts = explode ( '/' , $ route [ 'url' ] ) ; if ( count ( $ currentRou...
Execute routing .
55,473
protected function transformDataProvider ( DataProviderInterface $ dataProvider ) { if ( Craft :: $ app -> getRequest ( ) -> getIsHead ( ) ) { return null ; } else { if ( ! $ transformer = $ this -> dataTransformer ( ) ) { return $ dataProvider ; } $ models = Factory :: collection ( $ this -> resolveTransformer ( $ tra...
Serializes a data provider .
55,474
public function sortCategories ( array $ items ) { $ repository = $ this -> getRepository ( ) ; $ em = $ this -> getDoctrineHelper ( ) -> getEntityManager ( ) ; foreach ( $ items as $ item ) { $ parent = $ repository -> find ( $ item [ 'parent' ] ) ; $ child = $ repository -> find ( $ item [ 'id' ] ) ; if ( null !== $ ...
Sorts categories passed in request
55,475
protected function translateCategory ( Locale $ locale , CategoryInterface $ category , $ name ) { $ translation = $ category -> translate ( $ locale -> getCode ( ) ) ; $ slug = $ this -> getLocaleSlug ( $ locale , $ name ) ; $ translation -> setName ( $ name ) ; $ translation -> setSlug ( $ slug ) ; $ category -> merg...
Translates the category
55,476
protected function getLocaleSlug ( Locale $ locale , $ categoryName ) { $ slug = Sluggable :: makeSlug ( $ categoryName ) ; $ currentLocale = $ this -> getRequestHelper ( ) -> getCurrentLocale ( ) ; if ( $ locale -> getCode ( ) != $ currentLocale ) { $ slug = Sluggable :: makeSlug ( sprintf ( '%s-%s' , $ categoryName ,...
Returns category slug
55,477
public function data ( $ key = null ) { $ data = $ this -> body [ 'data' ] ; if ( $ key !== null ) { foreach ( explode ( '.' , $ key ) as $ part ) { if ( isset ( $ data [ $ part ] ) ) { $ data = $ data [ $ part ] ; } else { $ data = null ; break ; } } } return $ data ; }
Return the response s data a key from the data or null if the data or key does not exist .
55,478
public function rateLimit ( $ key = null ) { return $ key ? ( isset ( $ this -> rate_limit [ $ key ] ) ? $ this -> rate_limit [ $ key ] : null ) : $ this -> rate_limit ; }
Return the response s rate limit info array a key from the array or null if the info or key does not exist .
55,479
public function getHeader ( string $ headerName ) { return $ this -> hasHeader ( $ headerName ) ? $ this -> headers [ $ headerName ] : null ; }
Get header from request
55,480
public function setHeader ( string $ headerName , $ headerValue ) : HttpRequestContract { $ this -> headers [ $ headerName ] = $ headerValue ; return $ this ; }
Set header in request
55,481
protected function loadSkinAssets ( $ aAssets , $ aCssInline , $ aJsInline , $ sUrl ) { $ oAsset = Factory :: service ( 'Asset' ) ; if ( ! empty ( $ aAssets ) && is_array ( $ aAssets ) ) { foreach ( $ aAssets as $ asset ) { if ( is_string ( $ asset ) ) { $ oAsset -> load ( $ asset ) ; } else { $ oAsset -> load ( $ asse...
Loads any assets required by the skin
55,482
public static function tick ( float $ ms , callable $ callback , $ params = null ) { $ tid = Timer :: tick ( $ ms , $ callback , $ params ) ; self :: $ timers [ $ tid ] = [ 'type' => 'tick' , 'ctime' => \ time ( ) , 'interval' => $ ms , ] ; return $ tid ; }
add a interval timer
55,483
public static function getType ( $ type ) { if ( ! isset ( static :: $ mappedTypeInstances [ $ type ] ) ) { if ( ! static :: hasType ( $ type ) ) { throw TypeException :: typeDoesNotExist ( $ type ) ; } static :: $ mappedTypeInstances [ $ type ] = new static :: $ mappedTypeClasses [ $ type ] ( ) ; } return static :: $ ...
Gets a type .
55,484
public static function overrideType ( $ type , $ class ) { if ( ! static :: hasType ( $ type ) ) { throw TypeException :: typeDoesNotExist ( $ type ) ; } if ( ! class_exists ( $ class ) ) { throw TypeException :: classNotFound ( $ class ) ; } if ( ! in_array ( 'Fridge\DBAL\Type\TypeInterface' , class_implements ( $ cla...
Overrides an existing type .
55,485
protected function getFieldOutputEnumSetReadOnly ( $ val , $ adnlThings ) { $ inputFeatures = [ 'name' => $ val [ 'COLUMN_NAME' ] . $ adnlThings [ 'suffix' ] , 'id' => $ val [ 'COLUMN_NAME' ] , 'readonly' => 'readonly' , 'class' => 'input_readonly' , 'size' => 50 , 'value' => $ this -> getFieldValue ( $ val ) , ] ; ret...
Creates an input for ENUM or SET if marked Read - Only
55,486
protected function getFieldOutputTT ( $ value , $ szN , $ iar = [ ] ) { $ inAdtnl = [ 'id' => $ value [ 'COLUMN_NAME' ] , 'maxlength' => $ szN , 'name' => $ value [ 'COLUMN_NAME' ] , 'size' => $ szN , 'type' => 'text' , 'value' => $ this -> getFieldValue ( $ value ) , ] ; if ( $ iar !== [ ] ) { $ inAdtnl = array_merge ...
Builds output as text input type
55,487
protected function getFieldValue ( $ details ) { $ this -> initializeSprGlbAndSession ( ) ; $ rqCN = $ this -> tCmnRequest -> request -> get ( $ details [ 'COLUMN_NAME' ] ) ; if ( ! is_null ( $ rqCN ) ) { if ( ( $ details [ 'IS_NULLABLE' ] == 'YES' ) && ( $ rqCN == '' ) ) { return 'NULL' ; } return $ rqCN ; } return $ ...
Returns given value for a field from REQUEST global variable
55,488
protected function setFieldLabel ( $ details , $ features , $ fieldLabel ) { $ aLabel = [ 'for' => $ details [ 'COLUMN_NAME' ] , 'id' => $ details [ 'COLUMN_NAME' ] . '_label' ] ; if ( isset ( $ features [ 'disabled' ] ) ) { if ( in_array ( $ details [ 'COLUMN_NAME' ] , $ features [ 'disabled' ] ) ) { $ aLabel = array_...
Prepares the label for inputs
55,489
protected function setFieldNumbers ( $ fieldDetails , $ outputFormated = false ) { $ sRtrn = $ this -> setFieldSpecific ( $ fieldDetails ) ; if ( $ outputFormated ) { foreach ( $ sRtrn as $ key => $ value ) { $ sRtrn [ $ key ] = $ this -> setNumberFormat ( $ value ) ; } } return $ sRtrn ; }
Returns maximum length for a given MySQL field
55,490
private function setFieldSpecific ( $ fieldDetails ) { if ( in_array ( $ fieldDetails [ 'DATA_TYPE' ] , [ 'char' , 'varchar' , 'tinytext' , 'text' , 'mediumtext' , 'longtext' ] ) ) { return [ 'M' => $ fieldDetails [ 'CHARACTER_MAXIMUM_LENGTH' ] ] ; } elseif ( in_array ( $ fieldDetails [ 'DATA_TYPE' ] , [ 'decimal' , 'n...
Establishes numbers of fields
55,491
protected function setFormButtons ( $ feat , $ hiddenInfo = [ ] ) { $ btn = [ ] ; $ btn [ ] = '<input type="submit" id="submit" style="margin-left:220px;" value="' . $ this -> lclMsgCmn ( 'i18n_Form_ButtonSave' ) . '" />' ; if ( isset ( $ feat [ 'insertAndUpdate' ] ) ) { $ btn [ ] = '<input type="hidden" id="insertAndU...
Form default buttons
55,492
public function init ( $ config = NULL ) { $ this -> mailer = new PHPMailer ( ) ; foreach ( $ config as $ key => $ value ) { switch ( $ key ) { case 'from_email' : $ this -> mailer -> From = $ value ; break ; case 'from_name' : $ this -> mailer -> FromName = $ value ; break ; case 'is_html' : $ this -> mailer -> isHTML...
Initialises the mailer .
55,493
public function addCC ( $ email ) { if ( is_array ( $ email ) ) { $ this -> mailer -> addCC ( $ email [ 'email' ] , $ email [ 'name' ] ) ; } else { $ this -> mailer -> addCC ( $ email ) ; } }
Adds a CC address to the email .
55,494
public function addBCC ( $ email ) { if ( is_array ( $ email ) ) { $ this -> mailer -> addBCC ( $ email [ 'email' ] , $ email [ 'name' ] ) ; } else { $ this -> mailer -> addBCC ( $ email ) ; } }
Adds a BCC address to the email .
55,495
public function getReferenceName ( ) { $ options = $ this -> getOptions ( ) ; if ( ! empty ( $ options [ 'tag' ] ) ) { return 'Tag: ' . $ options [ 'tag' ] ; } elseif ( ! empty ( $ options [ 'branch' ] ) ) { return 'Branch: ' . $ options [ 'branch' ] ; } elseif ( ! empty ( $ options [ 'sha1' ] ) ) { return 'Sha1: ' . $...
Since sha1 is always shipped with branch and tag configuration we consider it for referenceName only if neither tag nor branch was set .
55,496
public static function singleton ( $ class = null ) { if ( ! $ class ) { $ class = get_called_class ( ) ; } if ( ! isset ( self :: $ singletons [ $ class ] ) ) { self :: $ singletons [ $ class ] = self :: create ( $ class ) ; } return self :: $ singletons [ $ class ] ; }
Creates a class instance by the singleton design pattern . It will always return the same instance for this class .
55,497
protected function handleException ( Exception $ e ) { $ handler = 'errorHandler' ; $ params = [ $ e ] ; if ( $ this -> getContainer ( ) -> has ( $ handler ) ) { $ callable = $ this -> getContainer ( ) -> get ( $ handler ) ; return call_user_func_array ( $ callable , $ params ) ; } $ this -> displayError ( $ e -> getMe...
Call relevant handler from the Container if needed . If it doesn t exist then just print error
55,498
private function apiCall ( $ method , array $ query = array ( ) , callable $ onSuccess , $ emptyValue = null ) { try { return $ onSuccess ( $ this -> restApiClient -> $ method ( $ query ) ) ; } catch ( BadResponseException $ e ) { if ( ( $ response = $ e -> getResponse ( ) ) && $ response -> getStatusCode ( ) == 404 ) ...
Performs an Api call on given method .
55,499
public function hasKey ( string $ needle , array $ haystack ) : bool { foreach ( $ haystack as $ key => $ value ) { if ( $ key === $ needle ) { return true ; } if ( is_array ( $ value ) ) { if ( $ x = $ this -> hasKey ( $ needle , $ value ) ) { return $ x ; } } } return false ; }
Check if array has key recursivly