idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
7,400
public static function build ( array $ values ) { $ result = new static ; foreach ( $ values as $ field => $ value ) { $ result -> $ field = $ value ; } return $ result ; }
Builds object from array of field values indexed by field name .
7,401
protected function getOnInitScriptText ( ) { $ scriptText = "" ; if ( $ this -> minimumCoordinates ) { $ minimumCoordinatesValue = Builder :: getVec2 ( $ this -> minimumCoordinates ) ; $ scriptText .= "Graph.CoordsMin = {$minimumCoordinatesValue};" ; } if ( $ this -> maximumCoordinates ) { $ maximumCoordinatesValue = Builder :: getVec2 ( $ this -> maximumCoordinates ) ; $ scriptText .= "Graph.CoordsMax = {$maximumCoordinatesValue};" ; } return $ scriptText ; }
Get the on init event script text
7,402
public function addChild ( ManiaLink $ child ) { if ( ! in_array ( $ child , $ this -> children , true ) ) { array_push ( $ this -> children , $ child ) ; } return $ this ; }
Add a child ManiaLink
7,403
public function getCustomUI ( $ createIfEmpty = true ) { if ( ! $ this -> customUI && $ createIfEmpty ) { $ this -> setCustomUI ( new CustomUI ( ) ) ; } return $ this -> customUI ; }
Get the CustomUI
7,404
public function render ( $ echo = false ) { $ domDocument = new \ DOMDocument ( "1.0" , "utf-8" ) ; $ domDocument -> xmlStandalone = true ; $ maniaLinks = $ domDocument -> createElement ( "manialinks" ) ; $ domDocument -> appendChild ( $ maniaLinks ) ; foreach ( $ this -> children as $ child ) { $ childXml = $ child -> render ( false , $ domDocument ) ; $ maniaLinks -> appendChild ( $ childXml ) ; } if ( $ this -> customUI ) { $ customUIElement = $ this -> customUI -> render ( $ domDocument ) ; $ maniaLinks -> appendChild ( $ customUIElement ) ; } if ( $ echo ) { header ( "Content-Type: application/xml; charset=utf-8;" ) ; echo $ domDocument -> saveXML ( ) ; } return $ domDocument ; }
Render the ManiaLinks object
7,405
protected function decoded ( ) { if ( $ this -> json === null ) { $ contentType = ( string ) $ this -> response -> getHeader ( 'content-type' ) ; if ( $ contentType === 'application/json' ) $ this -> json = json_decode ( $ this -> response -> getBody ( true ) ) ; } return $ this -> json ; }
returns decoded object
7,406
public function errorMessage ( ) { if ( $ this -> decoded ( ) === null ) { throw new \ RuntimeException ( 'No result from server.' ) ; } $ decoded = $ this -> decoded ( ) ; if ( isset ( $ decoded -> error ) ) return sprintf ( '%s (%s)' , $ decoded -> error -> message , $ decoded -> error -> code ) ; $ message = sprintf ( '%s (%s)' , $ decoded -> message , $ this -> statusCode ( ) ) ; if ( isset ( $ this -> decoded ( ) -> errors ) ) { $ errors = $ this -> decoded ( ) -> errors ; $ message .= $ this -> resolveAttributes ( $ errors ) ; } return $ message ; }
returns the error message
7,407
private function resolveAttributes ( stdClass $ stdClass ) { $ attributes = array ( 'action' , 'hash' , 'scope' , 'data' ) ; $ message = '' ; foreach ( $ attributes as $ attribute ) { $ message .= $ this -> resolveAttribute ( $ stdClass , $ attribute ) ; } return $ message ; }
resolves all known attributes
7,408
private function resolveAttribute ( stdClass $ stdClass , $ attribute ) { if ( isset ( $ stdClass -> $ attribute ) ) return PHP_EOL . sprintf ( ' %s: %s' , $ attribute , implode ( ', ' , $ stdClass -> $ attribute ) ) ; return '' ; }
resolves an attribute
7,409
public function setChannels ( $ channels ) { foreach ( $ channels as $ id => $ channel ) { $ this -> set ( $ id , $ channel ) ; } }
Registers a set of channel definitions in this locator .
7,410
public function parse ( $ pattern ) { $ this -> mustBeExtracted = array ( ) ; $ filteredPattern = mb_strtolower ( $ this -> remove_accents ( $ pattern ) ) ; $ terms = $ this -> extractTerms ( $ filteredPattern ) ; $ terms [ '_domain' ] = $ this -> extractDomain ( $ filteredPattern ) ; $ terms [ '_default' ] = $ this -> extractDefault ( $ filteredPattern ) ; return $ terms ; }
parse the search string to extract domain and terms
7,411
public function getSearchResults ( $ pattern , $ start = 0 , $ limit = 50 ) { $ terms = $ this -> parse ( $ pattern ) ; $ results = array ( ) ; $ sortedSearchServices = array ( ) ; foreach ( $ this -> searchServices as $ service ) { $ sortedSearchServices [ $ service -> getOrder ( ) ] = $ service ; } if ( $ terms [ '_domain' ] !== NULL ) { foreach ( $ sortedSearchServices as $ service ) { if ( $ service -> supports ( $ terms [ '_domain' ] ) ) { $ results [ ] = $ service -> renderResult ( $ terms , $ start , $ limit ) ; } } if ( count ( $ results ) === 0 ) { throw new UnknowSearchDomainException ( $ terms [ '_domain' ] ) ; } } else { foreach ( $ sortedSearchServices as $ service ) { if ( $ service -> isActiveByDefault ( ) ) { $ results [ ] = $ service -> renderResult ( $ terms , $ start , $ limit ) ; } } } ksort ( $ results ) ; return $ results ; }
search through services which supports domain and give results as html string
7,412
public function getByName ( $ name ) { if ( isset ( $ this -> searchServices [ $ name ] ) ) { return $ this -> searchServices [ $ name ] ; } else { throw new UnknowSearchNameException ( $ name ) ; } }
return search services with a specific name defined in service definition .
7,413
public function addClass ( $ classname ) { $ classArr = $ this -> getClassArray ( ) ; $ classArr [ ] = $ classname ; return $ this -> setClassArray ( $ classArr ) ; }
Add a class
7,414
public function removeClass ( $ classname ) { $ classArr = array_diff ( $ this -> getClassArray ( ) , [ $ classname ] ) ; return $ this -> setClassArray ( $ classArr ) ; }
Remove a class
7,415
public static function keep ( $ type = null ) { $ type = self :: check_type ( $ type ) ; if ( self :: cookie_exists ( $ type ) ) { self :: start ( $ type ) ; } }
keep a current session active use this when you want to start using a session in the current request
7,416
private static function validate ( ) { if ( self :: is_active ( ) == false ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'inactive session' ) ; } if ( empty ( $ _SESSION [ '_session_type' ] ) || empty ( $ _SESSION [ '_session_last_active' ] ) ) { return false ; } if ( ! empty ( $ _SESSION [ '_session_expire_at' ] ) && $ _SESSION [ '_session_expire_at' ] < time ( ) ) { return false ; } $ type_duration = self :: $ type_durations [ $ _SESSION [ '_session_type' ] ] ; $ active_enough = ( $ _SESSION [ '_session_last_active' ] > ( time ( ) - $ type_duration ) ) ; if ( $ active_enough == false ) { return false ; } return true ; }
checks whether the session is still valid to continue on this mainly checks the duration and delayed deletions
7,417
private static function get_cookie_name ( $ type = null ) { if ( is_null ( $ type ) ) { $ type = $ _SESSION [ '_session_type' ] ; } return self :: COOKIE_NAME_PREFIX . '-' . $ type ; }
generates a key for the session cookie
7,418
private static function get_cookie_settings ( $ type ) { $ name = self :: get_cookie_name ( $ type ) ; $ duration = self :: $ type_durations [ $ type ] ; $ domain = $ _SERVER [ 'SERVER_NAME' ] ; $ path = '/' ; $ secure = ! empty ( $ _SERVER [ 'HTTPS' ] ) ? true : false ; $ http_only = true ; return [ 'name' => $ name , 'duration' => $ duration , 'domain' => $ domain , 'path' => $ path , 'secure' => $ secure , 'http_only' => $ http_only , ] ; }
returns all keys needed for session cookie management
7,419
private static function destroy_cookie ( $ type = null ) { if ( is_null ( $ type ) ) { foreach ( self :: $ type_durations as $ type => $ null ) { self :: destroy_cookie ( $ type ) ; } return ; } if ( self :: cookie_exists ( $ type ) == false ) { return ; } self :: update_cookie_expiration ( $ type , $ expire_now = true ) ; $ cookie_name = self :: get_cookie_name ( $ type ) ; unset ( $ _COOKIE [ $ cookie_name ] ) ; }
throws away the session cookie
7,420
private static function update_cookie_expiration ( $ type , $ expire_now = false ) { $ params = self :: get_cookie_settings ( $ type ) ; $ value = session_id ( ) ; $ expire = ( time ( ) + $ params [ 'duration' ] ) ; if ( $ expire_now ) { $ value = null ; $ expire = ( time ( ) - 604800 ) ; } setcookie ( $ params [ 'name' ] , $ value , $ expire , $ params [ 'path' ] , $ params [ 'domain' ] , $ params [ 'secure' ] , $ params [ 'http_only' ] ) ; }
updates the cookies expiration with the type s duration useful to keep the cookie active after each user activity
7,421
protected function connect ( ) : void { if ( ! $ this -> isLaravel ( ) ) { throw new Exception ( 'This migrator must be ran from inside a Laravel application.' ) ; } $ this -> manager = app ( 'db' ) ; $ this -> database = $ this -> manager -> connection ( ) ; $ this -> schema = $ this -> database -> getSchemaBuilder ( ) ; }
Check the database connection and use of the Laravel framework .
7,422
protected function dropColumn ( string $ tableName , string $ column ) : void { if ( ! $ this -> schema -> hasColumn ( $ tableName , $ column ) ) { return ; } $ this -> schema -> table ( $ tableName , function ( Blueprint $ table ) use ( $ column ) { $ table -> dropColumn ( $ column ) ; } ) ; }
Safely drop a column from a table .
7,423
protected function drop ( $ tables , bool $ ignoreKeyConstraints = false ) : void { if ( $ ignoreKeyConstraints ) { $ this -> database -> statement ( 'SET FOREIGN_KEY_CHECKS=0;' ) ; } if ( ! is_array ( $ tables ) ) { $ tables = [ $ tables ] ; } foreach ( $ tables as $ table ) { if ( $ this -> tableExists ( $ table ) ) { $ this -> schema -> drop ( $ table ) ; } } if ( $ ignoreKeyConstraints ) { $ this -> database -> statement ( 'SET FOREIGN_KEY_CHECKS=1;' ) ; } }
Safely drop a table .
7,424
protected function dropAllTables ( bool $ ignoreKeyConstraints = false ) : void { $ this -> drop ( $ this -> tables , $ ignoreKeyConstraints ) ; }
Safely drop all tables .
7,425
public static function _init ( ) { CCServer :: $ _instance = CCIn :: create ( $ _GET , $ _POST , $ _COOKIE , $ _FILES , $ _SERVER ) ; }
The initial call of the CCServer get all Superglobals and assigns them to itself as an holder .
7,426
protected function _installAutoloader ( PackageInterface $ package ) { $ path = $ this -> _getAutoloaderPath ( $ package ) ; $ manifest = $ this -> _getKoowaManifest ( $ package ) ; if ( ! file_exists ( $ path ) ) { $ platform = $ this -> _isPlatform ( ) ; $ classname = $ platform ? 'Nooku\Library\ObjectManager' : 'KObjectManager' ; $ bootstrap = $ platform ? '' : 'KoowaAutoloader::bootstrap();' ; list ( $ vendor , ) = explode ( '/' , $ package -> getPrettyName ( ) ) ; $ component = ( string ) $ manifest -> name ; $ contents = <<<EOL<?php/** * This file has been generated automatically by Composer. Any changes to this file will not persist. * You can override this autoloader by supplying an autoload.php file in the root of the relevant component. **/$bootstrap$classname::getInstance() ->getObject('lib:object.bootstrapper') ->registerComponent( '$component', __DIR__, '$vendor' );EOL ; file_put_contents ( $ path , $ contents ) ; } }
Installs the default autoloader if no autoloader is supplied .
7,427
protected function _removeAutoloader ( PackageInterface $ package ) { $ path = $ this -> _getAutoloaderPath ( $ package ) ; if ( file_exists ( $ path ) ) { $ contents = file_get_contents ( $ path ) ; if ( strpos ( $ contents , 'This file has been generated automatically by Composer.' ) !== false ) { unlink ( $ path ) ; } } }
Removes the autoloader for the given package if it was generated automatically .
7,428
protected function _getKoowaManifest ( PackageInterface $ package ) { $ path = $ this -> getInstallPath ( $ package ) ; $ directory = new \ RecursiveDirectoryIterator ( $ path , \ RecursiveDirectoryIterator :: KEY_AS_PATHNAME ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directory ) ; $ regex = new \ RegexIterator ( $ iterator , '/koowa-component\.xml/' , \ RegexIterator :: GET_MATCH ) ; $ files = iterator_to_array ( $ regex ) ; if ( empty ( $ files ) ) { return false ; } $ manifests = array_keys ( $ files ) ; $ manifest = simplexml_load_file ( $ manifests [ 0 ] ) ; if ( ! ( $ manifest instanceof \ SimpleXMLElement ) ) { throw new \ InvalidArgumentException ( 'Failed to load `koowa-component.xml` manifest for package `' . $ package -> getPrettyName ( ) . '`.' ) ; } return $ manifest ; }
Attempts to locate and initialize the koowa - component . xml manifest
7,429
protected function _copyAssets ( PackageInterface $ package ) { $ path = rtrim ( $ this -> getInstallPath ( $ package ) , '/' ) ; $ asset_path = $ path . '/resources/assets' ; $ vendor_dir = dirname ( dirname ( $ path ) ) ; $ is_joomla = is_dir ( dirname ( $ vendor_dir ) . '/joomla' ) || is_dir ( dirname ( $ vendor_dir ) . '/libraries/joomla' ) ; if ( $ is_joomla && is_dir ( $ asset_path ) ) { $ manifest = $ this -> _getKoowaManifest ( $ package ) ; $ root = is_dir ( dirname ( $ vendor_dir ) . '/joomla' ) ? dirname ( dirname ( $ vendor_dir ) ) : dirname ( $ vendor_dir ) ; $ destination = $ root . '/media/koowa/com_' . $ manifest -> name ; $ this -> _copyDirectory ( $ asset_path , $ destination ) ; } }
Copy assets into the media folder if the installation is running in a Joomla context
7,430
protected function _copyDirectory ( $ source , $ target ) { $ result = false ; if ( ! is_dir ( $ target ) ) { $ result = mkdir ( $ target , 0755 , true ) ; } else { $ iter = new \ RecursiveDirectoryIterator ( $ target ) ; foreach ( new \ RecursiveIteratorIterator ( $ iter , \ RecursiveIteratorIterator :: CHILD_FIRST ) as $ f ) { if ( $ f -> isDir ( ) ) { if ( ! in_array ( $ f -> getFilename ( ) , array ( '.' , '..' ) ) ) { rmdir ( $ f -> getPathname ( ) ) ; } } else { unlink ( $ f -> getPathname ( ) ) ; } } } if ( is_dir ( $ target ) ) { $ result = true ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ source ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iterator as $ f ) { if ( $ f -> isDir ( ) ) { $ path = $ target . '/' . $ iterator -> getSubPathName ( ) ; if ( ! is_dir ( $ path ) ) { $ result = mkdir ( $ path ) ; } } else { $ result = copy ( $ f , $ target . '/' . $ iterator -> getSubPathName ( ) ) ; } if ( $ result === false ) { break ; } } } return $ result ; }
Copy source folder into target . Clears the target folder first .
7,431
public function setMin ( $ min ) { if ( is_array ( $ min ) and isset ( $ min [ 'min' ] ) ) { $ min = $ min [ 'min' ] ; } if ( ! is_string ( $ min ) and ! is_numeric ( $ min ) ) { require_once 'Zend/Validate/Exception.php' ; throw new Zend_Validate_Exception ( 'Invalid options to validator provided' ) ; } $ min = ( integer ) $ min ; if ( ( $ this -> _max !== null ) && ( $ min > $ this -> _max ) ) { require_once 'Zend/Validate/Exception.php' ; throw new Zend_Validate_Exception ( "The minimum must be less than or equal to the maximum file count, but $min >" . " {$this->_max}" ) ; } $ this -> _min = $ min ; return $ this ; }
Sets the minimum file count
7,432
public function addCell ( $ width , $ style = null ) { $ cell = new PHPWord_Section_Table_Cell ( $ this -> _insideOf , $ this -> _pCount , $ width , $ style ) ; $ i = count ( $ this -> _rows ) - 1 ; $ this -> _rows [ $ i ] [ ] = $ cell ; return $ cell ; }
Add a cell
7,433
public function safe_email ( $ name = NULL ) { $ tlds = array ( 'org' , 'com' , 'net' ) ; return implode ( '@' , array ( $ this -> user_name ( $ name ) , 'example.' . $ tlds [ array_rand ( $ tlds ) ] ) ) ; }
Generate a safe email address ending with example . tld with a TLD of org com or net only .
7,434
public function user_name ( $ name = NULL ) { $ delim = array ( '.' , '_' ) ; if ( $ name ) { $ names = preg_split ( '/[^\w]+/' , $ name , NULL , PREG_SPLIT_NO_EMPTY ) ; shuffle ( $ names ) ; return implode ( $ delim [ array_rand ( $ delim ) ] , $ names ) ; } if ( mt_rand ( 0 , 1 ) ) { $ name = preg_replace ( '/\W/' , '' , \ Phaker :: name ( ) -> first_name ) ; } else { $ names = preg_replace ( '/\W/' , '' , array ( \ Phaker :: name ( ) -> first_name , \ Phaker :: name ( ) -> last_name ) ) ; $ name = implode ( $ delim [ array_rand ( $ delim ) ] , $ names ) ; } return static :: fix_umlauts ( strtolower ( $ name ) ) ; }
Generate a lowercase user name from a full or partial name .
7,435
public static function write ( ) { if ( empty ( static :: $ _data ) ) { return ; } $ buffer = date ( "H:i:s" ) . " - " . CCServer :: method ( ) . ' ' . CCServer :: server ( 'REQUEST_URI' ) . "\n" ; $ buffer .= implode ( "\n" , static :: $ _data ) ; CCFile :: append ( CCStorage :: path ( 'logs/' . date ( 'Y-m' ) . '/' . date ( 'd' ) . '.log' ) , $ buffer . "\n" ) ; static :: clear ( ) ; }
write the log down to disk
7,436
public function row ( $ data = array ( ) , $ attr = array ( ) ) { $ this -> data [ ] = $ this -> _repair_row ( $ data , $ attr ) ; return $ this ; }
add a new row
7,437
public function header ( $ data = array ( ) , $ attr = array ( ) ) { $ this -> header = $ this -> _repair_row ( $ data , $ attr ) ; return $ this ; }
set the header
7,438
private function _repair_row ( $ data = array ( ) , $ attr = array ( ) ) { $ row = array ( ) ; foreach ( $ data as $ key => $ value ) { if ( ! $ value instanceof HTML || ( $ value -> name != 'td' && $ value -> name != 'th' ) ) { $ value = static :: cell ( ( string ) $ value ) ; } if ( is_string ( $ key ) ) { $ row [ $ key ] = $ value ; } else { $ row [ ] = $ value ; } } return array ( $ row , $ attr ) ; }
repair a row for rendering
7,439
public function setOwner ( $ name = '' , $ email = '' ) { if ( ! empty ( $ email ) ) { require_once 'Zend/Validate/EmailAddress.php' ; $ validate = new Zend_Validate_EmailAddress ( ) ; if ( ! $ validate -> isValid ( $ email ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to set a valid email address into the itunes owner's email property" ) ; } } $ this -> offsetSet ( 'owner' , array ( 'name' => $ name , 'email' => $ email ) ) ; return $ this ; }
Sets the owner of the postcast
7,440
public function setBlock ( $ block ) { $ block = strtolower ( $ block ) ; if ( ! in_array ( $ block , array ( 'yes' , 'no' ) ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to set yes or no to the itunes block property" ) ; } $ this -> offsetSet ( 'block' , $ block ) ; return $ this ; }
Prevent a feed from appearing
7,441
public function setExplicit ( $ explicit ) { $ explicit = strtolower ( $ explicit ) ; if ( ! in_array ( $ explicit , array ( 'yes' , 'no' , 'clean' ) ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to set yes, no or clean to the itunes explicit property" ) ; } $ this -> offsetSet ( 'explicit' , $ explicit ) ; return $ this ; }
Configuration of the parental advisory graphic
7,442
public function addConfig ( array $ conf = array ( ) ) { $ appConfig = & $ this -> config ; foreach ( $ conf as $ key => $ value ) { if ( ! isset ( $ appConfig [ $ key ] ) ) { $ appConfig [ $ key ] = $ value ; continue ; } if ( is_array ( $ appConfig [ $ key ] ) ) { $ mergedArray = array_merge_recursive ( $ appConfig [ $ key ] , $ value ) ; $ appConfig [ $ key ] = $ mergedArray ; continue ; } $ appConfig [ $ key ] = $ value ; } }
Recursively merge array of settings into app config . This is needed because \ Slim \ ConfigurationHander doesn t seem to like recursing ...
7,443
protected function setupAutoloaders ( $ modulePath , array $ mConf ) { if ( isset ( $ mConf [ 'autoload' ] [ 'psr-4' ] ) ) { foreach ( $ mConf [ 'autoload' ] [ 'psr-4' ] as $ ns => $ path ) { $ path = $ modulePath . DIRECTORY_SEPARATOR . preg_replace ( "/^\\.\\//" , "" , $ path ) ; $ this -> classLoader -> registerNamespace ( $ ns , $ path , 'psr-4' ) ; } } }
Copy autoloader settings to global collection ready for registering
7,444
static function CleanUp ( ) { $ limit = new \ DateTime ( '-30 minutes' ) ; foreach ( self :: $ instances as $ login => $ player ) if ( $ player -> awaySince && $ player -> awaySince < $ limit ) unset ( self :: $ instances [ $ login ] ) ; }
Destroy players disconnected for more than 1 hour
7,445
protected function failed ( ) { $ retryCount = $ this -> model -> getTriedCount ( ) + 1 ; if ( $ retryCount >= $ this -> getMaxRetryCount ( ) ) { $ this -> model -> setStatus ( JobsConst :: JOB_STATUS_FAILED ) ; } else { $ this -> model -> setStatus ( JobsConst :: JOB_STATUS_WAITING_RETRY ) ; $ this -> model -> setTryAt ( $ this -> getNextTryTime ( ) ) ; } $ this -> model -> setTriedCount ( $ retryCount ) ; return $ this -> model -> persist ( ) ; }
After failed we need to update tried count and check whether the tried count have reached to max retry count
7,446
public static function mergeConfig ( $ key , $ config ) { $ values = Hash :: merge ( ( array ) Configure :: read ( $ key ) , $ config ) ; Configure :: write ( $ key , $ values ) ; return $ values ; }
Merge configure values by key .
7,447
protected function _initPaths ( ) { $ path = Path :: getInstance ( ) ; $ path -> setRoot ( ROOT ) ; $ path -> set ( 'webroot' , Configure :: read ( 'App.wwwRoot' ) ) ; foreach ( ( array ) Plugin :: loaded ( ) as $ name ) { $ plgPath = Plugin :: path ( $ name ) . '/' . Configure :: read ( 'App.webroot' ) . '/' ; $ path -> set ( 'webroot' , FS :: clean ( $ plgPath ) , Path :: MOD_APPEND ) ; } $ paths = Configure :: read ( 'App.paths' ) ; foreach ( $ paths as $ alias => $ _paths ) { $ path -> set ( $ alias , $ _paths ) ; } return $ path ; }
Init base paths .
7,448
public function executed ( ) { $ this -> setLastRun ( new \ DateTime ( ) ) ; if ( ! $ this -> getModify ( ) ) { $ this -> setStatus ( self :: STATUS_DISABLED ) ; } if ( $ this -> getStatus ( ) == self :: STATUS_ENABLED ) { $ next_run = $ this -> getNextRun ( ) ; do { if ( $ next_run -> modify ( $ this -> getModify ( ) ) === false ) { $ this -> setModify ( '' ) ; $ this -> setStatus ( self :: STATUS_DISABLED ) ; break ; } } while ( $ next_run -> getTimestamp ( ) <= time ( ) ) ; $ this -> setNextRun ( $ next_run ) ; } }
Update task after execution .
7,449
public function getUserCustomerRelations ( $ criteria = null , PropelPDO $ con = null ) { $ partial = $ this -> collUserCustomerRelationsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collUserCustomerRelations || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collUserCustomerRelations ) { $ this -> initUserCustomerRelations ( ) ; } else { $ collUserCustomerRelations = UserCustomerRelationQuery :: create ( null , $ criteria ) -> filterByUser ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collUserCustomerRelationsPartial && count ( $ collUserCustomerRelations ) ) { $ this -> initUserCustomerRelations ( false ) ; foreach ( $ collUserCustomerRelations as $ obj ) { if ( false == $ this -> collUserCustomerRelations -> contains ( $ obj ) ) { $ this -> collUserCustomerRelations -> append ( $ obj ) ; } } $ this -> collUserCustomerRelationsPartial = true ; } $ collUserCustomerRelations -> getInternalIterator ( ) -> rewind ( ) ; return $ collUserCustomerRelations ; } if ( $ partial && $ this -> collUserCustomerRelations ) { foreach ( $ this -> collUserCustomerRelations as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collUserCustomerRelations [ ] = $ obj ; } } } $ this -> collUserCustomerRelations = $ collUserCustomerRelations ; $ this -> collUserCustomerRelationsPartial = false ; } } return $ this -> collUserCustomerRelations ; }
Gets an array of UserCustomerRelation objects which contain a foreign key that references this object .
7,450
public function countUserCustomerRelations ( Criteria $ criteria = null , $ distinct = false , PropelPDO $ con = null ) { $ partial = $ this -> collUserCustomerRelationsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collUserCustomerRelations || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collUserCustomerRelations ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getUserCustomerRelations ( ) ) ; } $ query = UserCustomerRelationQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByUser ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collUserCustomerRelations ) ; }
Returns the number of related UserCustomerRelation objects .
7,451
public function getUserCustomerRelationsJoinCustomer ( $ criteria = null , $ con = null , $ join_behavior = Criteria :: LEFT_JOIN ) { $ query = UserCustomerRelationQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Customer' , $ join_behavior ) ; return $ this -> getUserCustomerRelations ( $ query , $ con ) ; }
If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this User is new it will return an empty collection ; or if this User has previously been saved it will retrieve related UserCustomerRelations from storage .
7,452
public function getUserRoles ( $ criteria = null , PropelPDO $ con = null ) { $ partial = $ this -> collUserRolesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collUserRoles || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collUserRoles ) { $ this -> initUserRoles ( ) ; } else { $ collUserRoles = UserRoleQuery :: create ( null , $ criteria ) -> filterByUser ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collUserRolesPartial && count ( $ collUserRoles ) ) { $ this -> initUserRoles ( false ) ; foreach ( $ collUserRoles as $ obj ) { if ( false == $ this -> collUserRoles -> contains ( $ obj ) ) { $ this -> collUserRoles -> append ( $ obj ) ; } } $ this -> collUserRolesPartial = true ; } $ collUserRoles -> getInternalIterator ( ) -> rewind ( ) ; return $ collUserRoles ; } if ( $ partial && $ this -> collUserRoles ) { foreach ( $ this -> collUserRoles as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collUserRoles [ ] = $ obj ; } } } $ this -> collUserRoles = $ collUserRoles ; $ this -> collUserRolesPartial = false ; } } return $ this -> collUserRoles ; }
Gets an array of UserRole objects which contain a foreign key that references this object .
7,453
public static function _init ( ) { if ( ! static :: $ _enabled = ClanCats :: $ config -> get ( 'profiler.enabled' ) ) { return ; } if ( ClanCats :: in_development ( ) ) { CCEvent :: mind ( 'response.output' , function ( $ output ) { if ( strpos ( $ output , '</body>' ) === false ) { return $ output ; } $ table = \ UI \ Table :: create ( array ( 'style' => array ( 'width' => '100%' , ) , 'cellpadding' => '5' , 'class' => 'table debug-table debug-table-profiler' , ) ) ; $ table -> header ( array ( '#' , 'message' , 'memory' , 'time' ) ) ; foreach ( \ CCProfiler :: data ( ) as $ key => $ item ) { $ table -> row ( array ( $ key + 1 , $ item [ 0 ] , $ item [ 1 ] , $ item [ 2 ] ) ) ; } return str_replace ( '</body>' , $ table . "\n</body>" , $ output ) ; } ) ; CCError_Inspector :: info_callback ( 'Profiler' , function ( ) { $ table = array ( ) ; foreach ( \ CCProfiler :: data ( ) as $ key => $ check ) { $ table [ ( '#' . ( $ key + 1 ) . ': ' . $ check [ 2 ] ) ] = $ check [ 0 ] ; } return $ table ; } ) ; } }
The Autoloader initialisation
7,454
public static function memory ( $ format = false ) { $ memory = memory_get_usage ( ) - CCF_PROFILER_MEM ; if ( $ format ) { return CCStr :: bytes ( $ memory ) ; } return $ memory ; }
returns current memory usage
7,455
public static function time ( $ format = false ) { $ time = microtime ( true ) - CCF_PROFILER_TME ; if ( $ format ) { return CCStr :: microtime ( $ time ) ; } return $ time ; }
returns current execution time
7,456
public function process ( $ data , $ file ) { if ( empty ( $ data ) ) { return array ( ) ; } if ( isset ( $ data [ 'imports' ] ) ) { if ( false === is_array ( $ data [ 'imports' ] ) ) { throw ImportException :: format ( 'The "imports" value is not valid in "%s".' , $ file ) ; } $ dir = dirname ( $ file ) ; foreach ( $ data [ 'imports' ] as $ i => $ import ) { if ( false === is_array ( $ import ) ) { throw ImportException :: format ( 'One of the "imports" values (#%d) is not valid in "%s".' , $ i , $ file ) ; } if ( false === isset ( $ import [ 'resource' ] ) ) { throw ImportException :: format ( 'A resource was not defined for an import in "%s".' , $ file ) ; } $ this -> setCurrentDir ( $ dir ) ; $ data = array_replace_recursive ( $ this -> import ( $ import [ 'resource' ] , null , isset ( $ import [ 'ignore_errors' ] ) ? ( bool ) $ import [ 'ignore_errors' ] : false ) , $ data ) ; } } $ global = $ this -> wise ? $ this -> wise -> getGlobalParameters ( ) : array ( ) ; $ _this = $ this ; ArrayUtil :: walkRecursive ( $ data , function ( & $ value , $ key , & $ array ) use ( & $ data , $ global , $ _this ) { $ value = $ _this -> doReplace ( $ value , $ data , $ global ) ; if ( false !== strpos ( $ key , '%' ) ) { unset ( $ array [ $ key ] ) ; $ key = $ _this -> doReplace ( $ key , $ data , $ global ) ; $ array [ $ key ] = $ value ; } } ) ; return $ data ; }
Imports other configuration files and resolves references .
7,457
public function resolveReference ( $ reference , $ values ) { foreach ( explode ( '.' , $ reference ) as $ leaf ) { if ( ( ! is_array ( $ values ) && ! ( $ values instanceof ArrayAccess ) ) || ( is_array ( $ values ) && ! array_key_exists ( $ leaf , $ values ) ) || ( ( $ values instanceof ArrayAccess ) && ! $ values -> offsetExists ( $ leaf ) ) ) { throw InvalidReferenceException :: format ( 'The reference "%s" could not be resolved (failed at "%s").' , "%$reference%" , $ leaf ) ; } $ values = $ values [ $ leaf ] ; } return $ values ; }
Resolves the reference and returns its value .
7,458
public static function getDataObjectFor ( $ id ) { if ( $ id == 'root' ) { return null ; } $ obj = null ; if ( preg_match ( self :: ID_FORMAT , $ id , $ matches ) ) { $ id = $ matches [ 1 ] ; $ composed = isset ( $ matches [ 2 ] ) ? trim ( $ matches [ 2 ] , self :: ID_SEPARATOR ) : null ; $ obj = DataObject :: get_by_id ( self :: DEFAULT_CLASS , $ id ) ; if ( $ composed && $ obj ) { $ obj = $ obj -> getObject ( $ composed ) ; } } else { } return $ obj ; }
Get the actual object based on a composite ID
7,459
protected function loadClasses ( ) { if ( ! is_dir ( $ this -> srcDirectory ) ) { throw new \ Exception ( 'Source directory not found : ' . $ this -> srcDirectory ) ; } $ objects = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> srcDirectory ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; $ Regex = new \ RegexIterator ( $ objects , '/^.+\.php$/i' , \ RecursiveRegexIterator :: GET_MATCH ) ; foreach ( $ Regex as $ name => $ object ) { if ( ! empty ( $ name ) ) { require_once $ name ; } } $ classes = get_declared_classes ( ) ; $ traits = get_declared_traits ( ) ; $ interfaces = get_declared_interfaces ( ) ; $ this -> loadedClasses = array_merge ( $ classes , $ traits , $ interfaces ) ; }
Load class in the source directory
7,460
public function filterNamespace ( $ namespaceName ) { $ FilteredClasses = [ ] ; foreach ( $ this -> loadedClasses as $ loadedClass ) { if ( 0 == substr_compare ( $ loadedClass , $ namespaceName , 0 , strlen ( $ namespaceName ) ) ) { $ FilteredClasses [ ] = $ loadedClass ; } } $ this -> loadedClasses = $ FilteredClasses ; }
Filter class who are in a specific namespace
7,461
public function filterSubClasses ( $ className ) { $ FilteredClasses = [ ] ; foreach ( $ this -> loadedClasses as $ loadedClass ) { if ( is_subclass_of ( $ loadedClass , $ className ) ) { $ FilteredClasses [ ] = $ loadedClass ; } } $ this -> loadedClasses = $ FilteredClasses ; }
Filter class who are sub - classes of a specific class
7,462
public function generate ( $ directory = '.' ) { $ chapters = $ this -> generateClassMdFromLoadedClasses ( ) ; $ this -> rootPage = new models \ NamespaceMd ( $ this -> rootNamespace , $ chapters ) ; $ this -> rootPage -> setDirectory ( $ directory ) ; $ this -> rootPage -> write ( ) ; }
Generate markdown files
7,463
private function createCreateForm ( Center $ center ) { $ form = $ this -> createForm ( new CenterType ( ) , $ center , array ( 'action' => $ this -> generateUrl ( 'admin_center_create' ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Create' ) ) ; return $ form ; }
Creates a form to create a Center entity .
7,464
public function newAction ( ) { $ center = new Center ( ) ; $ form = $ this -> createCreateForm ( $ center ) ; return $ this -> render ( 'ChillMainBundle:Center:new.html.twig' , array ( 'entity' => $ center , 'form' => $ form -> createView ( ) , ) ) ; }
Displays a form to create a new Center entity .
7,465
private function createEditForm ( Center $ center ) { $ form = $ this -> createForm ( new CenterType ( ) , $ center , array ( 'action' => $ this -> generateUrl ( 'admin_center_update' , array ( 'id' => $ center -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Update' ) ) ; return $ form ; }
Creates a form to edit a Center entity .
7,466
public function updateAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ center = $ em -> getRepository ( 'ChillMainBundle:Center' ) -> find ( $ id ) ; if ( ! $ center ) { throw $ this -> createNotFoundException ( 'Unable to find Center entity.' ) ; } $ editForm = $ this -> createEditForm ( $ center ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_center_edit' , array ( 'id' => $ id ) ) ) ; } return $ this -> render ( 'ChillMainBundle:Center:edit.html.twig' , array ( 'entity' => $ center , 'edit_form' => $ editForm -> createView ( ) ) ) ; }
Edits an existing Center entity .
7,467
public function generateHash ( $ object ) { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 1 , 'object' ) ; } $ properties = call_user_func ( $ this -> propertyReader , $ object ) ; ksort ( $ properties ) ; if ( isset ( $ properties [ '__freezer' ] ) ) { unset ( $ properties [ '__freezer' ] ) ; } foreach ( $ properties as $ name => $ value ) { if ( is_array ( $ value ) ) { $ properties [ $ name ] = '<array>' ; } elseif ( is_object ( $ value ) ) { if ( ! isset ( $ value -> { $ this -> idProperty } ) ) { $ value -> { $ this -> idProperty } = $ this -> generateId ( ) ; } $ properties [ $ name ] = ( string ) $ value -> { $ this -> idProperty } ; } elseif ( is_resource ( $ value ) ) { $ properties [ $ name ] = null ; } } return sha1 ( get_class ( $ object ) . join ( ':' , $ properties ) ) ; }
Hashes an object using the SHA1 hashing function on the property values of an object without recursing into aggregated arrays or objects .
7,468
public function generateId ( ) { $ data = openssl_random_pseudo_bytes ( 16 ) ; $ data [ 6 ] = chr ( ord ( $ data [ 6 ] ) & 0x0f | 0x40 ) ; $ data [ 8 ] = chr ( ord ( $ data [ 8 ] ) & 0x3f | 0x80 ) ; return vsprintf ( '%s%s-%s-%s-%s-%s%s%s' , str_split ( bin2hex ( $ data ) , 4 ) ) ; }
This implementation of UUID generation is based on code from an answer on stackoverflow .
7,469
public function readProperties ( $ object ) { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 1 , 'object' ) ; } $ reflector = new \ ReflectionObject ( $ object ) ; $ result = array ( ) ; foreach ( $ reflector -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ result [ $ property -> getName ( ) ] = $ property -> getValue ( $ object ) ; } return $ result ; }
Returns an associative array of all properties of an object including those declared as protected or private .
7,470
private function getChainedMockCounter ( $ methods ) { $ mockReturnValues = ShortifyPunit :: getReturnValues ( ) ; $ mockResponse = $ mockReturnValues [ $ this -> mockedClass ] [ $ this -> instanceId ] ; foreach ( $ methods as $ method ) { $ methodName = key ( $ method ) ; $ args = $ method [ $ methodName ] ; $ serializedArgs = serialize ( $ args ) ; if ( ! isset ( $ mockResponse [ $ methodName ] [ $ serializedArgs ] ) ) { if ( ! isset ( $ mockResponse [ $ methodName ] ) ) { break ; } $ serializedArgs = static :: checkMatchingArguments ( $ mockResponse [ $ methodName ] , $ args ) ; if ( is_null ( $ serializedArgs ) ) { break ; } } $ mockResponse = $ mockResponse [ $ methodName ] [ $ serializedArgs ] ; } return isset ( $ mockResponse [ 'response' ] [ 'counter' ] ) ? $ mockResponse [ 'response' ] [ 'counter' ] : 0 ; }
Getting the call counter for the specific chained stubbing methods
7,471
public function setLayout ( $ template ) { $ layout = $ this -> getTemplatePathname ( $ template ) ; if ( ! is_file ( $ layout ) ) { throw new \ RuntimeException ( "Layout file `$template` does not exist." ) ; } else { $ this -> layout = $ template ; } }
Layout Configuration Getters and Setters
7,472
public function renderJson ( $ data , $ status = 200 ) { $ app = \ Slim \ Slim :: getInstance ( ) ; $ app -> response ( ) -> status ( $ status ) ; $ app -> response ( ) -> header ( 'Content-Type' , 'application/json' ) ; $ body = json_encode ( $ data ) ; $ app -> response ( ) -> body ( $ body ) ; $ app -> stop ( ) ; }
New function for pre - rendering JSON without having to call disableLayout AND other rendering code .
7,473
public function partial ( $ template , $ data = array ( ) ) { return parent :: render ( $ template , array_merge ( $ this -> layoutData , ( array ) $ data ) ) ; }
Function for rendering partial content . This WILL inject the layout parameters .
7,474
public static function factory ( $ callback , $ params = array ( ) ) { $ route = new static ( ) ; $ route -> callback = $ callback ; $ route -> params = $ params ; return $ route ; }
static route factory
7,475
public static function make ( $ uri , $ params = [ ] , $ queryDelimeter = '?' ) { $ uri .= ( strstr ( $ uri , $ queryDelimeter ) === false ) ? $ queryDelimeter : '&' ; return $ uri . http_build_query ( $ params ) ; }
Generate a new redirect uri
7,476
public function getDetectionRulesExtended ( ) { static $ rules ; if ( ! $ rules ) { $ rules = $ this -> mergeRules ( static :: $ additionalDevices , static :: getPhoneDevices ( ) , static :: getTabletDevices ( ) , static :: getOperatingSystems ( ) , static :: $ additionalOperatingSystems , static :: getBrowsers ( ) , static :: $ additionalBrowsers , static :: getUtilities ( ) ) ; } return $ rules ; }
Get all detection rules . These rules include the additional platforms and browsers .
7,477
public function browser ( $ userAgent = null ) { $ rules = $ this -> mergeRules ( static :: $ additionalBrowsers , static :: $ browsers ) ; return $ this -> findDetectionRulesAgainstUA ( $ rules , $ userAgent ) ; }
Get the browser name .
7,478
public function platform ( $ userAgent = null ) { $ rules = $ this -> mergeRules ( static :: $ operatingSystems , static :: $ additionalOperatingSystems ) ; return $ this -> findDetectionRulesAgainstUA ( $ rules , $ userAgent ) ; }
Get the platform name .
7,479
protected function mergeRules ( ... $ rulesGroups ) { $ merged = [ ] ; foreach ( $ rulesGroups as $ rules ) { foreach ( $ rules as $ key => $ value ) { if ( empty ( $ merged [ $ key ] ) ) $ merged [ $ key ] = $ value ; elseif ( is_array ( $ merged [ $ key ] ) ) $ merged [ $ key ] [ ] = $ value ; else $ merged [ $ key ] .= '|' . $ value ; } } return $ merged ; }
Merge multiple rules into one array .
7,480
function postPublicEvent ( $ message , $ eventDate , $ link = null , $ titleIdString = null , $ mediaURL = null ) { $ e = new Event ( ) ; $ e -> senderName = $ this -> manialink ; $ e -> message = $ message ; $ e -> link = $ link ; $ e -> eventDate = $ eventDate ; $ e -> titleId = $ titleIdString ; $ e -> mediaURL = $ mediaURL ; return $ this -> execute ( 'POST' , '/maniahome/event/public/' , array ( $ e ) ) ; }
Create an event visible by all players who bookmarked your Manialink
7,481
public function response ( array $ errors ) : JsonResponse { return $ this -> respondValidationError ( ApiResponse :: CODE_VALIDATION_ERROR , $ this -> transformErrors ( $ errors ) ) ; }
Method throws validation error response .
7,482
public static function make ( $ cmd , $ params ) { if ( ! is_array ( $ params ) ) { $ params = array ( $ params ) ; } $ forge = new static ; if ( ! method_exists ( $ forge , $ cmd ) ) { throw new CCException ( "CCForge_Php - Command could not be found." ) ; } return call_user_func_array ( array ( $ forge , $ cmd ) , $ params ) ; }
runs a forge command on a dummy forge
7,483
public function comment ( $ str , $ wordwrap = 80 ) { $ str = trim ( wordwrap ( $ str , $ wordwrap ) ) ; $ str = str_replace ( "\n" , "\n" . ' * ' , $ str ) ; $ str = str_replace ( "\n" . ' * *' , "\n" . ' **' , $ str ) ; return $ this -> add ( "/**\n * " . $ str . "\n */" ) ; }
generates an PHP comment
7,484
public function closure ( $ name , $ content = null , $ comment ) { return $ this -> add ( ( $ comment ? static :: make ( 'comment' , array ( $ comment ) ) . "\n" : '' ) . $ name . "\n{\n" . str_replace ( "\n" , "\n\t" , "\t" . CCStr :: capture ( $ content ) ) . "\n}" ) ; }
generates an closure
7,485
public function a_class ( $ name , $ content , $ extends = null , $ implements = null ) { return $ this -> add ( $ this -> closure ( "class " . $ name . ( $ extends ? ' extends ' . $ extends : '' ) . ( $ implements ? ' implements ' . $ implements : '' ) , $ content ) ) ; }
generates an PHP class
7,486
public function property ( $ name , $ default = null , $ comment = null , $ export = true ) { if ( $ default !== null ) { if ( $ export ) { $ default = var_export ( $ default , true ) ; } } return $ this -> add ( ( $ comment ? static :: make ( 'comment' , array ( $ comment ) ) . "\n" : '' ) . $ name . ( $ default !== null ? ' = ' . $ default : '' ) . ';' ) ; }
generates a class property
7,487
public function enableAutoRecharges ( $ whenCredit , $ total ) { $ this -> setArgument ( "autorecharge_enabled" , true ) ; $ this -> setArgument ( "autorecharge_total" , $ total ) ; return $ this -> setArgument ( "autorecharge_when_credit" , $ whenCredit ) ; }
Enables auto recharges .
7,488
public function publishEventsToSns ( $ key , $ secret , $ topicArn ) { $ this -> setArgument ( "sns_publish_enabled" , true ) ; $ this -> setArgument ( "sns_access_key" , $ key ) ; $ this -> setArgument ( "sns_access_secret" , $ secret ) ; return $ this -> setArgument ( "sns_topic" , $ topicArn ) ; }
Enables publishing of events to an SNS topic .
7,489
protected function apply ( $ function , $ args = array ( ) ) { foreach ( $ this -> data as $ key => & $ value ) { if ( ! is_array ( $ value ) ) { $ value = $ this -> applyToValue ( $ function , $ args , $ value ) ; } else { $ value = array_map ( function ( $ v ) use ( $ function , $ args ) { return $ this -> applyToValue ( $ function , $ args , $ v ) ; } , $ value ) ; } } }
Apply a function to each value
7,490
public function beforeRedirect ( Event $ event , $ url , Response $ response ) { $ pluginEvent = Plugin :: getData ( 'Core' , 'Controller.beforeRedirect' ) ; if ( is_callable ( $ pluginEvent -> find ( 0 ) ) && Plugin :: hasManifestEvent ( 'Controller.beforeRedirect' ) ) { call_user_func_array ( $ pluginEvent -> find ( 0 ) , [ $ this , $ event , $ url , $ response ] ) ; } }
The beforeRedirect method is invoked when the controller s redirect method is called but before any further action .
7,491
public function afterFilter ( Event $ event ) { $ pluginEvent = Plugin :: getData ( 'Core' , 'Controller.afterFilter' ) ; if ( is_callable ( $ pluginEvent -> find ( 0 ) ) && Plugin :: hasManifestEvent ( 'Controller.afterFilter' ) ) { call_user_func_array ( $ pluginEvent -> find ( 0 ) , [ $ this , $ event ] ) ; } }
Called after the controller action is run and rendered .
7,492
protected function _setTheme ( ) { $ theme = $ this -> request -> getParam ( 'theme' ) ; if ( $ theme ) { $ this -> viewBuilder ( ) -> setTheme ( $ theme ) ; } }
Setup application theme .
7,493
private function appendAggregatorForm ( FormBuilderInterface $ builder , $ nbAggregators ) { $ builder -> add ( 'order' , 'choice' , array ( 'choices' => array_combine ( range ( 1 , $ nbAggregators ) , range ( 1 , $ nbAggregators ) ) , 'multiple' => false , 'expanded' => false ) ) ; $ builder -> add ( 'position' , 'choice' , array ( 'choices' => array ( 'row' => 'r' , 'column' => 'c' ) , 'choices_as_values' => true , 'multiple' => false , 'expanded' => false ) ) ; }
append a form line by aggregator on the formatter form .
7,494
protected function orderingHeaders ( $ formatterData ) { $ this -> formatterData = $ formatterData ; uasort ( $ this -> formatterData , function ( $ a , $ b ) { return ( $ a [ 'order' ] <= $ b [ 'order' ] ? - 1 : 1 ) ; } ) ; }
ordering aggregators preserving key association .
7,495
public function shown ( ) { if ( is_null ( $ this -> date_closed ) ) { $ this -> date_closed = new \ DateTime ( ) ; $ this -> date_closed -> modify ( sprintf ( '+%s seconds' , $ this -> lifetime ) ) ; } $ this -> status = self :: STATUS_SHOWN ; }
Notice shown .
7,496
public function getNotificationFactory ( ) : ? Factory { if ( ! $ this -> hasNotificationFactory ( ) ) { $ this -> setNotificationFactory ( $ this -> getDefaultNotificationFactory ( ) ) ; } return $ this -> notificationFactory ; }
Get notification factory
7,497
public function objectConfigGet ( $ key , $ default = null ) { if ( array_key_exists ( $ key , $ this -> objectConfig ) ) { return $ this -> objectConfig [ $ key ] ; } return $ default ; }
Get a value from the config .
7,498
static function notify ( $ message , $ type ) { $ nots = State :: get ( 'notifications' ) ; array_push ( $ nots , array ( 'message' => $ message , 'type' => $ type ) ) ; State :: set ( 'notifications' , $ nots ) ; }
Register a notification .
7,499
private function register_hooks ( ) { register_activation_hook ( $ this -> plugin_file , get_called_class ( ) . '::activate' ) ; register_deactivation_hook ( $ this -> plugin_file , get_called_class ( ) . '::deactivate' ) ; register_uninstall_hook ( $ this -> plugin_file , get_called_class ( ) . '::uninstall' ) ; }
Register hooks that are fired when the plugin is activated deactivated and uninstalled respectively . The array s first argument is the name of the plugin defined in class - plugin - name . php