idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
5,400
public function register ( ) { wp_register_style ( $ this -> handle , $ this -> url , $ this -> dependencies , $ this -> version , $ this -> media ) ; $ this -> is_registered = true ; }
Register the stylesheet .
5,401
public function autoload_init ( ) { $ this -> init ( ) ; for ( $ i = count ( $ this -> addons ) - 1 ; $ i >= 0 ; -- $ i ) { $ this -> addons [ $ i ] -> init ( ) ; } }
Called by autoload to init class .
5,402
public function autoload_on_admin ( ) { $ this -> on_admin ( ) ; for ( $ i = count ( $ this -> addons ) - 1 ; $ i >= 0 ; -- $ i ) { $ this -> addons [ $ i ] -> on_admin ( ) ; } }
Called by autoload to init on admin .
5,403
public function add_hooks ( ) { if ( function_exists ( 'add_action' ) && function_exists ( 'add_filter' ) && function_exists ( 'add_shortcode' ) ) { foreach ( $ this -> actions as $ action ) { add_action ( $ action [ 'hook' ] , [ & $ this , $ this -> get_mapped_mvc_call ( $ action [ 'mvc' ] ) ] , $ action [ 'priority' ...
Adds hooks and filters into Wordpress core .
5,404
public function addClockFeature ( $ showSeconds = true , $ showFullDate = false ) { $ clock = new Clock ( $ this , $ showSeconds , $ showFullDate ) ; $ this -> addScriptFeature ( $ clock ) ; return $ this ; }
Add a dynamic Feature showing the current time
5,405
protected function handlePATCH ( ) { $ content = $ this -> getPayloadData ( ) ; if ( empty ( $ this -> folderPath ) ) { $ this -> driver -> updateContainerProperties ( $ this -> container , $ content ) ; } else { if ( empty ( $ this -> filePath ) ) { $ this -> driver -> updateFolderProperties ( $ this -> container , $ ...
Handles PATCH actions .
5,406
protected function handleDELETE ( ) { $ force = $ this -> request -> getParameterAsBool ( 'force' , false ) ; $ noCheck = $ this -> request -> getParameterAsBool ( 'no_check' , false ) ; $ contentOnly = $ this -> request -> getParameterAsBool ( 'content_only' , false ) ; if ( empty ( $ this -> folderPath ) ) { if ( ! e...
Handles DELETE actions .
5,407
private static function resetAsseticConfig ( ) { return ; $ aYaml = Yaml :: parse ( file_get_contents ( self :: $ _container -> get ( 'kernel' ) -> getRootDir ( ) . '/config/config_dev.yml' ) ) ; $ aYaml [ 'assetic' ] [ 'use_controller' ] = false ; $ sNewYaml = Yaml :: dump ( $ aYaml , 5 ) ; file_put_contents ( self ::...
reset assitx - config not to use controller
5,408
private static function _saveControlUrl ( ) { $ oStatement = self :: $ _connection -> prepare ( 'INSERT INTO `system_settings` (`key` ,`value`)VALUES (:key, :value);' ) ; $ oResult = $ oStatement -> execute ( array ( ":key" => "control_url" , ":value" => self :: $ _data [ 'controlUrl' ] , ) ) ; if ( $ oResult !== tru...
save control - url to database
5,409
private static function _saveSystemConfig ( ) { $ sYmlDump = array ( 'parameters' => array ( 'database_driver' => self :: checkEmpty ( self :: $ _data [ 'dbDriver' ] ) , 'database_host' => self :: checkEmpty ( self :: $ _data [ 'dbHost' ] ) , 'database_port' => self :: checkEmpty ( self :: $ _data [ 'dbPort' ] ) , 'dat...
save systemconfig to parameters . yml
5,410
private static function _createAdminUser ( ) { $ oUser = new User ( ) ; $ factory = self :: $ _container -> get ( 'security.encoder_factory' ) ; $ encoder = $ factory -> getEncoder ( $ oUser ) ; $ sSalt = $ oUser -> getSalt ( ) ; $ sPassword = $ encoder -> encodePassword ( self :: $ _data [ 'adminPassword' ] , $ sSalt ...
create the admin user
5,411
protected static function __getType ( $ param ) { $ type = is_object ( $ param ) ? get_class ( $ param ) : gettype ( $ param ) ; return $ type === 'integer' ? 'int' : $ type ; }
Get type OR class for params as well as re - mapping inconsistencies
5,412
protected static function __match ( array $ patterns ) { return function ( ... $ args ) use ( $ patterns ) { $ parameterTypes = array_map ( self :: getType ( ) , $ args ) ; try { $ keysToValues = Arrays :: zip ( array_keys ( $ patterns ) , array_values ( $ patterns ) ) ; list ( $ key , $ matchingPattern ) = Arrays :: f...
Pattern Matching . Use switch - case for explicit values this for everything else .
5,413
private static function unwrapArgs ( array $ args ) : array { $ hasExtractable = false ; $ unwrappedArgs = self :: flatten ( array_map ( function ( $ arg ) use ( & $ hasExtractable ) { if ( method_exists ( $ arg , 'extract' ) ) { $ hasExtractable = true ; return $ arg -> extract ( ) ; } return $ arg ; } , $ args ) ) ; ...
Extracts args from Extractable values
5,414
function getMultiplayerPlayer ( $ titleId , $ login ) { if ( ! $ login ) { throw new Exception ( 'Invalid login' ) ; } return $ this -> execute ( 'GET' , $ this -> getPrefixEndpoint ( $ titleId ) . '/rankings/multiplayer/player/%s/?title=%s' , array ( $ login , $ titleId ) ) ; }
Get player ranking for the give title
5,415
public function withNumber ( $ number , $ variables = null ) { if ( ! is_null ( $ variables ) ) { $ vars = array ( ) ; foreach ( $ variables as $ k => $ v ) { $ vars [ ] = array ( 'key' => $ k , 'value' => $ v ) ; } $ this -> setArgument ( "variables" , $ vars ) ; } return $ this -> setArgument ( "number" , $ number ) ...
Add or remove this number to the contact list .
5,416
private function detectManyToOne ( $ tables , $ modelTable ) { $ manyToOneRelations = [ ] ; $ foreignKeys = $ modelTable -> foreignKeys ; foreach ( $ foreignKeys as $ foreignKey ) { $ foreignTable = $ foreignKey -> foreignTable ; $ foreignField = $ foreignKey -> foreignField ; if ( ! isset ( $ tables [ $ foreignTable ]...
Detect many to one relationship on model table If foreign key of model table is primary key of foreign table .
5,417
public function __ ( $ key , $ params = array ( ) ) { $ namespace = explode ( "\\" , get_called_class ( ) ) ; $ class = strtolower ( 'model/' . str_replace ( '_' , '/' , array_pop ( $ namespace ) ) ) ; $ namespace = implode ( "\\" , $ namespace ) ; if ( $ namespace ) { $ class = $ namespace . '::' . $ class ; } return ...
Label translation helper
5,418
public function strict_assign ( array $ fields , array $ data ) { foreach ( $ fields as $ field ) { if ( isset ( $ data [ $ field ] ) ) { $ this -> __set ( $ field , $ data [ $ field ] ) ; } } }
Strict assign only sets some values out of an array . This can be useful to easly set some values from post .
5,419
protected function _type_assignment_set ( $ type , $ value ) { switch ( $ type ) { case 'int' : case 'timestamp' : return ( int ) $ value ; break ; case 'string' : return ( string ) $ value ; break ; case 'bool' : return ( bool ) $ value ; break ; case 'json' : return json_encode ( $ value ) ; break ; } return $ value ...
Assign the data type in a set operation
5,420
protected function _type_assignment_get ( $ type , $ value ) { switch ( $ type ) { case 'int' : case 'timestamp' : return ( int ) $ value ; break ; case 'string' : return ( string ) $ value ; break ; case 'bool' : return ( bool ) $ value ; break ; case 'json' : if ( is_array ( $ value ) ) { return $ value ; } if ( is_a...
Assign the data type in a get operation
5,421
public function & __get ( $ key ) { $ value = null ; $ has_modifier = method_exists ( $ this , '_get_modifier_' . $ key ) ; if ( array_key_exists ( $ key , $ this -> _data_store ) ) { $ value = & $ this -> _data_store [ $ key ] ; if ( $ has_modifier ) { $ tmpvalue = $ this -> { '_get_modifier_' . $ key } ( $ value ) ; ...
Get a value by key from the model data
5,422
public function __isset ( $ key ) { return ( array_key_exists ( $ key , $ this -> _data_store ) || method_exists ( $ this , '_get_modifier_' . $ key ) ) ? true : false ; }
Check if model data isset This also checks if a get modifier function exists which will also count as ture .
5,423
public function raw ( $ key = null ) { if ( ! is_null ( $ key ) ) { if ( isset ( $ this -> _data_store [ $ key ] ) ) { return $ this -> _data_store [ $ key ] ; } throw new \ InvalidArgumentException ( "CCModel - Invalid or undefined model property '" . $ key . "'." ) ; } return $ this -> _data_store ; }
Returns all raw data of the object or a single property
5,424
private function parseField ( string $ field ) : array { $ source = static :: DEFAULT_SOURCE ; $ type = static :: DEFAULT_TYPE ; $ origin = null ; if ( strpos ( $ field , '(' ) !== false ) { $ source = substr ( $ field , strpos ( $ field , '(' ) + 1 , - 1 ) ; $ field = substr ( $ field , 0 , strpos ( $ field , '(' ) ) ...
Parse field to fetch source origin and type .
5,425
protected function initialRedirectUrl ( ) { $ defaultUrl = '/' . $ this -> controller -> id . '/' . $ this -> controller -> defaultAction ; if ( isset ( $ this -> controller -> module -> id ) && ! $ this -> controller -> module instanceof Application ) { $ defaultUrl = '/' . $ this -> controller -> module -> id . $ def...
Set default redirect url
5,426
private function validate_config ( $ config ) { $ this -> section_names = array ( ) ; foreach ( $ config [ 'sections' ] as $ section ) { if ( in_array ( $ section -> title , $ this -> section_names ) ) { throw new DuplicateSectionException ( $ section -> title ) ; } foreach ( $ section -> get_fields ( ) as $ field ) { ...
Validate the integrity of the provided configuration array
5,427
private function set_section_slugs ( ) { if ( count ( $ this -> sections ) > 1 ) { foreach ( $ this -> sections as $ section ) { $ section -> set_slug ( \ Amarkal \ Common \ Tools :: strtoslug ( $ section -> title ) ) ; } } else { $ this -> sections [ 0 ] -> set_slug ( \ Amarkal \ Common \ Tools :: strtoslug ( $ this -...
Set slugs to each section according the number of sections .
5,428
public function toArray ( ) { return array ( 'site' => $ this -> site , 'type' => $ this -> type , 'storage_time' => $ this -> storage_time , 'credits' => $ this -> credits , 'soft_quota' => $ this -> soft_quota , 'hard_quota' => $ this -> hard_quota , 'daily_credits_usage' => $ this -> daily_credits_usage , 'unique_ha...
returns status as array
5,429
public function add ( string $ type , string $ value ) : void { if ( $ this -> entry [ $ type ] === null ) { $ this -> entry [ $ type ] = array ( ) ; } $ this -> entry [ $ type ] = ( array ) $ this -> entry [ $ type ] ; $ this -> entry [ $ type ] [ ] = $ value ; }
add a value to an array type in the entry
5,430
public function addQuoted ( string $ type , string $ value ) : void { if ( $ value [ 0 ] == '"' ) { $ value = substr ( $ value , 1 , - 1 ) ; } $ value = stripcslashes ( $ value ) ; if ( $ this -> entry [ $ type ] === null ) { $ this -> entry [ $ type ] = array ( ) ; } $ this -> entry [ $ type ] = ( array ) $ this -> en...
add a quoted value to the array type in the entry
5,431
public function addQuotedAtPosition ( string $ type , int $ position , string $ value ) : void { if ( $ value [ 0 ] == '"' ) { $ value = substr ( $ value , 1 , - 1 ) ; } $ value = stripcslashes ( $ value ) ; if ( $ this -> entry [ $ type ] === null ) { $ this -> entry [ $ type ] = array ( ) ; } if ( isset ( $ this -> e...
add a quoted value to the nested array type in the entry
5,432
public function getAsString ( string $ type ) : ? string { $ ret = $ this -> entry [ $ type ] ; if ( is_array ( $ ret ) ) { $ ret = implode ( '' , $ ret ) ; } return $ ret ; }
get the value of a specified type as a string
5,433
public function getAsStringArray ( string $ type ) : ? array { $ plurals = $ this -> entry [ $ type ] ; $ plurals = is_array ( $ plurals ) ? $ plurals : array ( '' , '' ) ; $ ret = array ( ) ; foreach ( $ plurals as $ i => $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( '' , $ value ) ; } $ ret [ $ i ] = ...
Get the value of a specified type as an array of strings . This is mainly for plural TRANSLATED messages .
5,434
protected function formatQuotedString ( $ value , bool $ bare = false ) : string { if ( is_array ( $ value ) ) { $ string = '' ; foreach ( $ value as $ partial ) { $ string .= $ this -> formatQuotedString ( $ partial , true ) . "\n" ; } return $ bare ? $ string : ' ' . $ string ; } else { $ string = ( $ value === null ...
format a string for output by escaping control and double quote characters then surrounding with double quotes
5,435
public function hasFlag ( string $ name ) : bool { $ flags = array ( ) ; $ flagEntry = $ this -> entry [ PoTokens :: FLAG ] ; if ( ! empty ( $ flagEntry ) ) { foreach ( ( array ) $ flagEntry as $ csv ) { $ temp = str_getcsv ( $ csv , ',' ) ; foreach ( $ temp as $ flag ) { $ flag = strtolower ( trim ( $ flag ) ) ; $ fla...
check for presence of a flag
5,436
public function addFlag ( string $ name ) : void { if ( ! $ this -> hasFlag ( $ name ) ) { $ flagEntry = $ this -> entry [ PoTokens :: FLAG ] ; if ( $ flagEntry === null ) { $ this -> set ( PoTokens :: FLAG , $ name ) ; } elseif ( is_array ( $ flagEntry ) ) { $ flagEntry [ ] = $ name ; $ this -> set ( PoTokens :: FLAG ...
add a flag to the entry
5,437
public function getProvider ( $ key ) { if ( ! $ this -> hasProvider ( $ key ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Location Provider with key "%s" does not exist' , $ key ) ) ; } return $ this -> providers [ $ key ] ; }
Get specified provider
5,438
public function setOption ( $ option , $ value ) { $ this -> options [ $ option ] = $ value ; $ this -> resolve ( $ this -> options ) ; }
Set or modify an option after the object has been initialized
5,439
private function createEditForm ( License $ oLicense ) { $ oForm = $ this -> createForm ( new LicenseType ( ) , $ oLicense , array ( 'action' => $ this -> generateUrl ( 'license_update' , array ( 'id' => $ oLicense -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ oForm -> add ( 'submit' , 'submit' , array ( 'label' => 'U...
Create edit form for lucense
5,440
private function publishContentObjects ( TreeObject $ object ) { $ last = $ this -> objectService -> createOrUpdate ( $ object -> data ) ; foreach ( $ object -> getNodes ( ) as $ subObject ) { if ( $ subObject instanceof TreeObject ) { $ this -> publishContentObjects ( $ subObject ) ; } else { $ subObject -> addParentL...
Publishes content objects .
5,441
public function remove ( $ object ) { if ( $ this -> logger ) { $ this -> logger -> warning ( sprintf ( 'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.' , __CLASS__ , EzPlatformObject :: class ) ) ; } return ; }
Bulk - deletions is not supported .
5,442
public function attach ( Threaded $ object , $ data = null ) { $ this -> data [ ] = $ object ; $ this -> info [ ] = $ data ; }
Adds an object in the storage
5,443
public function addAll ( self $ storage ) { foreach ( $ storage -> data as $ object ) { $ this -> attach ( $ object ) ; } }
Adds all objects from another storage
5,444
public function removeAll ( self $ storage ) { foreach ( $ this -> data as $ key => $ value ) { foreach ( $ storage -> data as $ object ) { if ( $ object === $ value ) { unset ( $ this -> data [ $ key ] ) ; unset ( $ this -> info [ $ key ] ) ; } } } }
Removes objects contained in another storage from the current storage
5,445
public function getInfo ( Threaded $ object ) { foreach ( $ this -> data as $ key => $ value ) { if ( $ object === $ value ) { return $ this -> info [ $ key ] ; } } }
Returns the data associated with the current iterator entry
5,446
public function setInfo ( Threaded $ object , $ data ) { foreach ( $ this -> data as $ key => $ value ) { if ( $ object -> equals ( $ value ) ) { $ this -> info [ $ key ] = $ data ; break ; } } }
Sets the data associated with the current iterator entry
5,447
public function toXLIFF ( $ pretty_print = FALSE ) { $ this -> doc -> formatOutput = $ pretty_print ; $ xpath = new \ DOMXPath ( $ this -> doc ) ; $ wrapper_div = $ xpath -> query ( "//*[@id='eggs-n-cereal-dont-ever-use-this-id']" ) -> item ( 0 ) ; $ out = $ this -> doc -> createDocumentFragment ( ) ; $ domNodeList = a...
Converts HTML to the corresponding XLIFF representation .
5,448
protected function sanitize ( ) { $ sanitized = sanitizer ( ) -> make ( $ this -> all ( ) , $ this -> sanitizerRules ( ) ) ; $ this -> replace ( $ sanitized ) ; }
Sanitize this request s input .
5,449
private function parseNameFromKeyDefinition ( $ strKeyDefinition ) { $ strKeyDefinition = trim ( $ strKeyDefinition ) ; $ intPosition = strpos ( $ strKeyDefinition , '(' ) ; if ( $ intPosition === false ) { throw new \ Exception ( "Invalid Key Definition: $strKeyDefinition" ) ; } else { if ( $ intPosition == 0 ) { retu...
If the key name exists this will parse it out and return it
5,450
public function getFiles ( Array $ criteria = array ( ) , Array $ orderBy = NULL ) { $ files = new \ Psc \ Data \ ArrayCollection ( $ this -> manager -> getRepository ( ) -> findBy ( $ criteria , $ orderBy ) ) ; foreach ( $ files as $ file ) { $ this -> manager -> attach ( $ file ) ; } return $ files ; }
Returns a list of all uploaded files
5,451
public function getViewFile ( $ name ) { list ( $ plugin , $ name ) = $ this -> pluginSplit ( $ name ) ; $ return = null ; foreach ( $ this -> _paths ( $ plugin ) as $ path ) { $ viewFile = FS :: clean ( $ path . $ name . $ this -> _ext ) ; if ( FS :: isFile ( $ viewFile ) ) { $ return = $ this -> _checkFilePath ( $ vi...
Get view file path .
5,452
public function partial ( $ name , array $ data = [ ] ) { $ file = $ this -> _getLayoutPartialPath ( $ name ) ; if ( FS :: isFile ( $ file ) ) { return $ this -> _render ( $ file , $ data ) ; } return null ; }
Render layout partial .
5,453
protected function _findViewByRequest ( ) { $ paths = App :: path ( 'Template' , $ this -> plugin ) ; $ action = ( string ) $ this -> request -> getParam ( 'action' ) ; $ controller = $ this -> request -> getParam ( 'controller' ) ; $ viewFile = $ action . $ this -> _ext ; $ viewSubPath = $ this -> _getSubPaths ( $ con...
Find form view by request .
5,454
protected function _getFormView ( $ view = null ) { if ( empty ( $ view ) && Arr :: in ( $ this -> request -> getParam ( 'action' ) , $ this -> _formActions ) ) { $ view = $ this -> _findViewByRequest ( ) ; } return $ view ; }
Get current form view .
5,455
protected function _getLayoutPartialPath ( $ name ) { list ( $ plugin , $ name ) = $ this -> pluginSplit ( $ name ) ; $ paths = $ this -> _paths ( $ plugin ) ; $ layoutPaths = $ this -> _getSubPaths ( 'Layout' . DS . 'Partial' ) ; foreach ( $ paths as $ path ) { foreach ( $ layoutPaths as $ layoutPath ) { $ partial = $...
Finds an partial filename returns false on failure .
5,456
public static function deleteDirectoryContents ( string $ directoryPath ) { $ paths = scandir ( $ directoryPath ) ; if ( $ paths === false ) { throw new \ Exception ( "cannot list directory '{$directoryPath}'" ) ; } foreach ( $ paths as $ path ) { if ( $ path === '.' || $ path === '..' ) { continue ; } $ fullPath = "{$...
Recursively deletes directory contents
5,457
public function getCsvfile ( $ key ) { if ( array_key_exists ( $ key , $ this -> csv ) ) { return $ this -> csv [ $ key ] ; } return false ; }
Get the CSV file details for data source or false on failure
5,458
public function setCsvOptions ( $ charSet = 'utf-8' , $ delimField = "," , $ delimNewLine = "\n" , array $ columnHeaderNames = [ ] ) { $ this -> csv [ 'charSet' ] = $ charSet ; $ this -> csv [ 'delimField' ] = $ delimField ; $ this -> csv [ 'delimNewLine' ] = $ delimNewLine ; $ this -> csv [ 'columnHeaderNames' ] = $ c...
Set the CSV file details for data source
5,459
public function offsetSet ( $ id , $ value ) { if ( $ this -> locked ) { throw new BadMethodCallException ( 'Setting values into a locked container is not allowed' ) ; } if ( $ value instanceof JuiceParam ) { $ this -> values [ $ id ] = $ value -> value ; return ; } if ( is_callable ( $ value ) || $ value instanceof Ju...
Sets a parameter or a definition
5,460
private function getServiceOrParameter ( $ id ) { if ( array_key_exists ( $ id , $ this -> aliases ) ) { return $ this -> offsetGet ( $ this -> aliases [ $ id ] ) ; } if ( array_key_exists ( $ id , $ this -> values ) ) { return $ this -> values [ $ id ] ; } if ( array_key_exists ( $ id , $ this -> definitions ) ) { ret...
Return the service associated with this unique identifier
5,461
public function build ( $ definition ) { if ( is_callable ( $ definition ) ) { return call_user_func ( $ definition , $ this ) ; } return $ this -> buildFromDefinition ( $ definition ) ; }
Build a definition and return the instantiated object
5,462
protected function resolveValue ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ index => $ val ) { $ value [ $ index ] = $ this -> resolveValue ( $ val ) ; } return $ value ; } if ( is_string ( $ value ) && '@' == $ value [ 0 ] ) { return $ this -> offsetGet ( substr ( $ value , 1 ) ) ; } return $ va...
Finds and marks references ( strings beginning with an
5,463
private function getAssociatedLogLevel ( $ errno ) { $ associations = [ E_WARNING => LogLevel :: WARNING , E_NOTICE => LogLevel :: NOTICE , E_USER_ERROR => LogLevel :: ERROR , E_USER_WARNING => LogLevel :: WARNING , E_USER_NOTICE => LogLevel :: NOTICE , E_STRICT => LogLevel :: NOTICE , E_RECOVERABLE_ERROR => LogLevel :...
Getting the log level constant associated with error code .
5,464
public function isCanSearch ( Item $ item , $ field ) { if ( ! in_array ( $ field , $ this -> supported_fields ) ) { return false ; } if ( $ this -> isCanRefill ( $ item , $ field ) || $ item -> getName ( ) ) { return true ; } foreach ( $ item -> getNames ( ) as $ name ) { if ( $ name -> getName ( ) ) { return true ; }...
Is can search .
5,465
public function search ( Item $ item , $ field ) { if ( $ url = $ this -> getSourceForFill ( $ item ) ) { return [ new ItemRefiller ( $ item -> getName ( ) , [ 'url' => $ url ] , $ url , $ item -> getCover ( ) , $ item -> getSummary ( ) ) , ] ; } if ( ! ( $ name = $ item -> getName ( ) ) ) { foreach ( $ item -> getName...
Search items for refill .
5,466
protected function fillItem ( Item $ item , Item $ new_item , $ field ) { switch ( $ field ) { case self :: FIELD_COUNTRY : $ item -> setCountry ( $ new_item -> getCountry ( ) ) ; break ; case self :: FIELD_DATE_END : $ item -> setDateEnd ( $ new_item -> getDateEnd ( ) ) ; break ; case self :: FIELD_DATE_PREMIERE : $ i...
Fill item .
5,467
protected function setDefaultRule ( ) { if ( RBACHelper :: getAuthManager ( ) -> getRule ( RouteRule :: RULE_NAME ) === null ) { RBACHelper :: getAuthManager ( ) -> add ( new RouteRule ( ) ) ; } }
Set default rule of parametrize route .
5,468
public function getJobType ( ) { $ sourceObject = ExternalContent :: getDataObjectFor ( $ this -> sourceObjectID ) ; if ( ! $ sourceObject ) { $ this -> addMessage ( "ERROR: Source object $this->sourceObjectID cannot be found" ) ; return QueuedJob :: QUEUED ; } if ( ! $ this -> includeChildren ) { return QueuedJob :: Q...
By default jobs should just go into the default processing queue
5,469
public function process ( ) { $ remainingChildren = $ this -> remainingChildren ; if ( ! count ( $ remainingChildren ) ) { $ this -> isComplete = true ; return ; } $ this -> currentStep ++ ; $ pair = array_shift ( $ remainingChildren ) ; $ sourceObject = ExternalContent :: getDataObjectFor ( $ pair -> sourceID ) ; if (...
Lets process a single node and collect its children
5,470
protected function _migrateFile ( $ version , $ filePath , $ direction = 'up' ) { $ classVersion = preg_replace ( '/[^0-9A-Za-z]/' , '' , $ version ) ; $ className = 'Migration_' . $ classVersion ; if ( file_exists ( $ filePath ) ) { require_once $ filePath ; if ( class_exists ( $ className ) ) { $ migration = new $ cl...
Migrate Single File Up or Down
5,471
public function generate ( ) { $ version = date ( 'YmdHis' ) ; $ this -> _generateMigrationFile ( $ version ) ; print PHP_EOL . Color :: success ( 'Version ' . $ version . ' was successfully generated' ) . PHP_EOL ; }
Generate Empty Migration file
5,472
protected function _generateMigrationFile ( $ version , $ contentUp = "" , $ contentDown = "" ) { $ classVersion = preg_replace ( '/[^0-9A-Za-z]/' , '' , $ version ) ; $ className = 'Migration_' . $ classVersion ; $ classData = "<?phpuse Phalcon\Migrations\MigrationScript as Migration;class " . $ className . " extends ...
Generate Migration file
5,473
protected function getVerifyCredentialsCallback ( ) { if ( is_null ( $ this -> callback ) || ! is_callable ( $ this -> callback ) ) { throw new Exception \ ServerErrorException ( 'Null or non-callable callback set on Password grant' ) ; } return $ this -> callback ; }
Return the callback function
5,474
public function getAccessToken ( ) { if ( ! $ this -> accessTokenEntity instanceof AccessTokenEntity ) { $ this -> accessTokenEntity = $ this -> server -> getAccessTokenStorage ( ) -> get ( $ this -> accessTokenId ) ; } return $ this -> accessTokenEntity ; }
Return access token
5,475
public static function setDefaultTranslator ( $ translator = null ) { if ( ( null === $ translator ) || ( $ translator instanceof Zend_Translate_Adapter ) ) { self :: $ _defaultTranslator = $ translator ; } elseif ( $ translator instanceof Zend_Translate ) { self :: $ _defaultTranslator = $ translator -> getAdapter ( )...
Set default translation object for all validate objects
5,476
public static function getDefaultTranslator ( ) { if ( null === self :: $ _defaultTranslator ) { require_once 'Zend/Registry.php' ; if ( Zend_Registry :: isRegistered ( 'Zend_Translate' ) ) { $ translator = Zend_Registry :: get ( 'Zend_Translate' ) ; if ( $ translator instanceof Zend_Translate_Adapter ) { return $ tran...
Get default translation object for all validate objects
5,477
public function build_alert ( $ alerts ) { return HTML :: tag ( 'div' , function ( ) use ( $ alerts ) { foreach ( $ alerts as $ type => $ items ) { foreach ( $ items as $ alert ) { $ alert = implode ( "<br>\n" , $ alert ) ; $ close = HTML :: tag ( 'button' , '&times;' ) -> add_class ( 'close' ) -> type ( 'button' ) -> ...
Build the UI alerts
5,478
public function setCurrentDriver ( string $ name ) : ITaxFacade { $ this -> currentDriverName = $ name ; $ this -> makeCurrentDriver ( $ name ) ; return $ this ; }
Set current driver
5,479
public function driverInstance ( string $ driver ) : ? ITaxFacade { if ( ( $ driverClass = $ this -> getDriver ( $ driver ) ) !== null ) { return app ( $ driverClass , [ 'config' => config ( 'taxes.' . $ driverClass ) , ] ) ; } return null ; }
Build driver by name
5,480
public function setMagicFile ( $ file ) { if ( empty ( $ file ) ) { $ this -> _magicfile = null ; } else if ( ! is_readable ( $ file ) ) { require_once 'Zend/Validate/Exception.php' ; throw new Zend_Validate_Exception ( 'The given magicfile can not be read' ) ; } else { $ this -> _magicfile = ( string ) $ file ; } retu...
Sets the magicfile to use if null the MAGIC constant from php is used
5,481
public function getScriptText ( $ parameters = null ) { if ( ! $ parameters ) { $ parameters = $ this -> parameters ; } ob_start ( ) ; include $ this -> filePath ; $ scriptText = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ scriptText ; }
Get the compiled script text
5,482
protected function decorateResults ( Coordinates $ searchCenter , array $ results ) { $ search = new Search ( ) ; $ search -> setCenter ( $ searchCenter ) ; foreach ( $ results as $ result ) { $ distanceInMiles = UnitConverter :: kmToMiles ( $ result [ 'distance' ] ) ; $ search -> addResult ( new Result ( $ result [ 0 ...
Helper method to decorate search results
5,483
protected static function _clear ( $ menu ) { if ( array_key_exists ( $ menu , self :: $ _items ) ) { self :: $ _items [ $ menu ] = [ ] ; } else { throw new \ UnexpectedValueException ( 'Invalid menu: ' . $ menu ) ; } }
Clear menu items .
5,484
protected static function _replace ( & $ target , $ path , $ options ) { $ pathE = explode ( '.' , $ path ) ; $ path = array_shift ( $ pathE ) ; $ fragment = join ( '.' , $ pathE ) ; if ( ! empty ( $ pathE ) ) { self :: _replace ( $ target [ $ path ] , $ fragment , $ options ) ; } else { $ target [ $ path ] = self :: _...
Replace a menu element .
5,485
protected static function _setupOptions ( & $ options ) { $ options = self :: _merge ( self :: $ _defaults , $ options ) ; foreach ( $ options [ 'children' ] as & $ child ) { self :: _setupOptions ( $ child ) ; } }
Setup options .
5,486
public static function write ( $ str , $ color = null , $ background = null ) { if ( ! is_null ( $ color ) ) { $ str = static :: color ( $ str , $ color , $ background ) ; } fwrite ( STDOUT , $ str ) ; }
Write to the standard output device
5,487
public static function line ( $ str , $ color = null , $ background = null ) { if ( is_array ( $ str ) ) { $ str = implode ( PHP_EOL , $ str ) ; } static :: write ( $ str . PHP_EOL , $ color , $ background ) ; }
Write to the standard output device with an end of line .
5,488
public static function confirm ( $ question , $ strict = false ) { $ question .= ' [yes/no]: ' ; if ( $ strict ) { do { $ res = strtolower ( static :: read ( $ question ) ) ; } while ( $ res !== 'yes' && $ res !== 'no' ) ; return ( $ res == 'yes' ) ? true : false ; } do { $ res = strtolower ( static :: read ( $ questio...
Get a bool value from the user This will write the question down and waiting for a yes or no .
5,489
public static function read ( $ prefix = '' ) { if ( ! static :: is_windows ( ) ) { $ line = readline ( $ prefix ) ; readline_add_history ( $ line ) ; } else { static :: write ( $ prefix ) ; $ line = trim ( fgets ( STDIN ) ) ; } return $ line ; }
Read from comman line Because windows does not support readline we use normal fgets in that case .
5,490
protected function manageEdit ( $ entity , Request $ request , $ formTypeFQCN ) { $ form = $ this -> createForm ( $ formTypeFQCN , $ entity , array ( 'action' => $ this -> getEditUrl ( $ entity ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'save' , SubmitType :: class , array ( 'attr' => array ( 'class' => 'btn btn-pr...
Generic edit controller helper .
5,491
protected function manageNew ( $ entity , Request $ request , $ formTypeFQCN ) { $ form = $ this -> createForm ( $ formTypeFQCN , $ entity , array ( 'action' => $ this -> getNewUrl ( $ entity ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'create' , submitType :: class , array ( 'attr' => array ( 'class' => 'btn btn-pr...
Generic new controller helper .
5,492
protected function dispatchCrudEvent ( $ entity , $ action , $ eventName ) { $ event = new AdminCrudEvent ( $ entity , $ action , $ this -> getUser ( ) ) ; $ this -> get ( 'event_dispatcher' ) -> dispatch ( $ eventName , $ event ) ; return $ event ; }
Generic Event dispatcher .
5,493
protected function dispatchAssociationActionEvent ( $ entity , $ action , $ target , $ eventName ) { $ event = new AdminAssociationActionEvent ( $ entity , $ action , $ target , $ this -> getUser ( ) ) ; $ this -> get ( 'event_dispatcher' ) -> dispatch ( $ eventName , $ event ) ; return $ event ; }
Generic Association Action dispatcher .
5,494
public static function charAt ( string $ str , int $ i ) : string { return ( string ) BaseStringy :: create ( $ str ) -> at ( $ i ) ; }
Returns the character at a specific point in a potentially multibyte string .
5,495
public static function lines ( string $ str ) : array { $ lines = BaseStringy :: create ( $ str ) -> lines ( ) ; foreach ( $ lines as $ i => $ line ) { $ lines [ $ i ] = $ line ; } return $ lines ; }
Splits on newlines and carriage returns returning an array of strings corresponding to the lines in the string .
5,496
public static function toKebabCase ( string $ string , string $ glue = '-' , bool $ lower = true , bool $ removePunctuation = true ) : string { $ words = self :: _prepStringForCasing ( $ string , $ lower , $ removePunctuation ) ; return implode ( $ glue , $ words ) ; }
kebab - cases a string .
5,497
public static function toCamelCase ( string $ string ) : string { $ words = self :: _prepStringForCasing ( $ string ) ; if ( empty ( $ words ) ) { return '' ; } $ string = array_shift ( $ words ) . implode ( '' , array_map ( [ static :: class , 'upperCaseFirst' ] , $ words ) ) ; return $ string ; }
camelCases a string .
5,498
public static function toPascalCase ( string $ string ) : string { $ words = self :: _prepStringForCasing ( $ string ) ; $ string = implode ( '' , array_map ( [ static :: class , 'upperCaseFirst' ] , $ words ) ) ; return $ string ; }
PascalCases a string .
5,499
public static function toSnakeCase ( string $ string ) : string { $ words = self :: _prepStringForCasing ( $ string ) ; return implode ( '_' , $ words ) ; }
snake_cases a string .