idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
12,100
public function getBalance ( $ email , $ appUid = null ) { if ( null === $ appUid ) $ appUid = $ this -> defaultAppUid ; if ( ! $ appUid ) throw new \ InvalidArgumentException ( 'No appUid specified' ) ; $ response = $ this -> apiClient -> get ( 'app_store/balance' , [ 'app_uid' => $ appUid , 'email' => $ email , ] ) ;...
Returns the user s balance
12,101
private function buildColorTags ( ) { $ this -> aColorTags = array ( ) ; foreach ( $ this -> aConfig [ 'colors' ] as $ sRawName => $ sSequence ) { $ sName = '{' . $ this -> aConfig [ 'color_tag_prefix' ] . $ sRawName . '}' ; $ this -> aColorTags [ $ sName ] = $ sSequence ; } }
Build full length color tags by adding prefix to user define colors .
12,102
private function processLeadingIndentationTags ( $ sMessage ) { $ bTagFound = true ; while ( $ bTagFound && strlen ( $ sMessage ) > 0 ) { if ( substr ( $ sMessage , 0 , $ this -> iIndentTagLength ) == $ this -> aConfig [ 'indent_tag' ] ) { $ this -> iIndentationLevel ++ ; $ sMessage = substr ( $ sMessage , $ this -> iI...
Update indentation level according to leading indentation tags and remove them from the returned string .
12,103
public function actionUpdate ( ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( ! is_dir ( Yii :: getAlias ( $ module -> pages_directory ) ) ) { $ this -> stderr ( "Execution terminated: the repository to update does not exist - please run init first.\n" , Console :: FG_RED ) ; return self :: EXIT_C...
Updates the database if there are remote changes
12,104
public function actionInit ( ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( is_dir ( Yii :: getAlias ( $ module -> pages_directory ) ) ) { $ this -> stdout ( "Content directory already cloned - terminating.\n" , Console :: FG_GREEN ) ; return self :: EXIT_CODE_ERROR ; } if ( ! $ this -> acquireMut...
Initializes the content directory and Flywheel database from scratch
12,105
public function actionRebuild ( ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( ! is_dir ( Yii :: getAlias ( $ module -> pages_directory ) ) ) { $ this -> stderr ( "Execution terminated: the repository to update does not exist - please run init first.\n" , Console :: FG_RED ) ; return self :: EXIT_...
Rebuilds the Flywheel database
12,106
protected function createImageSymlink ( ) { $ image_dir = Yii :: getAlias ( '@pages' ) . '/images' ; if ( is_dir ( $ image_dir ) ) { if ( ! is_link ( Yii :: getAlias ( '@app/web' ) . '/images' ) ) { $ this -> stdout ( "Creating images symlink\n\n" , Console :: FG_GREEN ) ; symlink ( $ image_dir , Yii :: getAlias ( '@ap...
Creates a symlink from the images directory in content to the public web directory
12,107
protected function acquireMutex ( ) { $ this -> mutex = Instance :: ensure ( $ this -> mutex , Mutex :: className ( ) ) ; return $ this -> mutex -> acquire ( $ this -> composeMutexName ( ) ) ; }
Acquires current action lock .
12,108
protected function getFlywheelRepo ( ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( ! isset ( $ this -> flywheel_config ) ) { $ config_dir = Yii :: getAlias ( $ module -> flywheel_config ) ; if ( ! file_exists ( $ config_dir ) ) { FileHelper :: createDirectory ( $ config_dir ) ; } $ this -> flywhe...
Gets the Flywheel Repository instance . Creates it if it doesn t exist .
12,109
private function runCurl ( $ curl_url , $ module ) { $ curl_token_auth = 'Authorization: token ' . $ module -> github_token ; $ ch = curl_init ( $ curl_url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'User-Agent: Awesome-Octocat-App' , $ curl_token_auth ) ) ...
Calls the Github API using Curl and a secret Github token .
12,110
private function committersFromFile ( $ file , $ module ) { $ curl_url = "https://api.github.com/repos/$module->github_owner/$module->github_repo/commits?path=$file" ; $ output = $ this -> runCurl ( $ curl_url , $ module ) ; $ commits = json_decode ( $ output ) ; $ contributors = array ( ) ; $ dates = array ( ) ; forea...
Asks Github for the list of contributors to a file
12,111
private function unique_multidim_array ( $ array , $ key ) { $ temp_array = array ( ) ; $ i = 0 ; $ key_array = array ( ) ; foreach ( $ array as $ val ) { if ( ! in_array ( $ val [ $ key ] , $ key_array ) ) { $ key_array [ $ i ] = $ val [ $ key ] ; $ temp_array [ $ i ] = $ val ; } $ i ++ ; } return $ temp_array ; }
Produces an array with unique entries from an array with possible duplicate entries
12,112
public function actionClearAll ( ) { $ module = \ jacmoe \ mdpages \ Module :: getInstance ( ) ; if ( $ this -> confirm ( 'Delete content and data directories ?' ) ) { FileHelper :: removeDirectory ( Yii :: getAlias ( $ module -> pages_directory ) ) ; FileHelper :: removeDirectory ( Yii :: getAlias ( $ module -> flywhe...
Removes content and data directories
12,113
public function create ( ServerRequestInterface $ request , Route $ route ) { $ this -> uriGenerator -> setRequest ( $ request ) ; return new Context ( $ request , $ route , $ this -> uriGenerator ) ; }
Creates a container context for provided request and route
12,114
public static function on ( $ class , $ name , $ handler , $ data = null , $ append = true ) { $ class = ltrim ( $ class , '\\' ) ; if ( $ append || empty ( self :: $ _events [ $ name ] [ $ class ] ) ) { self :: $ _events [ $ name ] [ $ class ] [ ] = [ $ handler , $ data ] ; } else { array_unshift ( self :: $ _events [...
Attaches an event handler to a class - level event .
12,115
public static function off ( $ class , $ name , $ handler = null ) { $ class = ltrim ( $ class , '\\' ) ; if ( empty ( self :: $ _events [ $ name ] [ $ class ] ) ) { return false ; } if ( $ handler === null ) { unset ( self :: $ _events [ $ name ] [ $ class ] ) ; return true ; } else { $ removed = false ; foreach ( sel...
Detaches an event handler from a class - level event .
12,116
public static function hasHandlers ( $ class , $ name ) { if ( empty ( self :: $ _events [ $ name ] ) ) { return false ; } if ( is_object ( $ class ) ) { $ class = get_class ( $ class ) ; } else { $ class = ltrim ( $ class , '\\' ) ; } $ classes = array_merge ( [ $ class ] , class_parents ( $ class , true ) , class_imp...
Returns a value indicating whether there is any handler attached to the specified class - level event . Note that this method will also check all parent classes to see if there is any handler attached to the named event .
12,117
public function toString ( ) { $ constraints = [ ] ; foreach ( $ this -> constraints as $ name => $ constraint ) { $ constraints [ ] = "$constraint" ; } return implode ( $ this -> toStringSeparator , $ constraints ) ; }
Returns a rendered version of the constraints .
12,118
protected function checkType ( ExpressionContract $ expression ) { if ( ! $ expression instanceof ConstraintContract ) { throw new InvalidArgumentException ( "ConstraintGroup works only with Constraint not " . Type :: of ( $ expression ) ) ; } return $ expression ; }
Throws an error if the expression is not a constraint .
12,119
protected function generateNodeMarkup ( Node $ node ) : string { if ( $ node instanceof TagNode ) { $ tag = $ node -> getTag ( ) ; $ tagName = $ tag -> getTagName ( ) ; $ tagDef = $ this -> tagDefs -> get ( $ tagName ) ; $ children = $ node -> getChildren ( ) ; $ content = $ this -> generateMarkup ( $ children ) ; $ at...
Generates markup string for a node .
12,120
private function addRepository ( RepositoryManager $ repoManager , array & $ repositories , $ repoJson ) { if ( isset ( $ repoJson [ 'type' ] ) ) { $ this -> getLogger ( ) -> info ( "Prepending {$repoJson['type']} repository" ) ; $ repository = $ repoManager -> createRepository ( $ repoJson [ 'type' ] , $ repoJson ) ; ...
Add a repository to collection of repositories .
12,121
private function prepareRequest ( ServerRequestInterface $ request ) { $ serverData = [ 'SCRIPT_NAME' => '/base/test.php' , 'HTTPS' => 'not-empty' , 'SERVER_PORT' => '12541' , 'SERVER_NAME' => 'localhost' , ] ; $ request -> getServerParams ( ) -> shouldBeCalled ( ) -> willReturn ( $ serverData ) ; $ request -> getQuery...
Prepares the request collaborator
12,122
private function findRoute ( string $ path , array $ listFolder ) { foreach ( $ listFolder as $ lib ) { foreach ( $ lib as $ this -> lib => $ item ) { if ( file_exists ( PATH_HOME . "{$item}/{$path}.php" ) ) { $ url = explode ( '/' , $ path ) ; $ this -> file = array_pop ( $ url ) ; return "{$item}/{$path}.php" ; } } }...
Busca por rota
12,123
protected function getDataTable ( ) { if ( ! $ this -> _datatable ) { if ( in_array ( $ this -> params ( 'table' ) , $ this -> getNameManager ( ) -> getTableNames ( ) ) ) { $ DataTable = "\\{$this->getNameManager()->namespace_model}\\{$this->getNameManager()->modelName}" ; $ this -> _datatable = new $ DataTable ( ) ; }...
Creates and returns a DataTable or null if invalid
12,124
protected function getEntity ( ) { if ( ! $ this -> _entity ) { if ( $ this -> getDataTable ( ) ) { $ this -> _entity = $ this -> getDataTable ( ) -> getEntity ( ) ; } } return $ this -> _entity ; }
Creates and returns an Entity or null if invalid
12,125
public function get ( $ id ) { $ e = $ this -> getEntity ( ) ; if ( ! $ e ) return $ this -> createResponse ( $ this -> getNameManager ( ) -> getTableNames ( ) , 401 , "Tables" ) ; if ( ! $ e -> get ( $ id ) ) return $ this -> createResponse ( $ id , 401 , "{$this->getNameManager()->entityName} not found" ) ; return $ ...
Return single resource
12,126
public function delete ( $ id ) { $ dt = $ this -> getDataTable ( ) ; if ( ! $ dt ) return $ this -> createResponse ( $ this -> getNameManager ( ) -> getTableNames ( ) , 401 , "Tabels" ) ; return $ this -> createResponse ( [ ] , 200 , "{$this->getNameManager()->entityName}: No Delete" ) ; }
Delete an existing resource
12,127
public function parse ( ) { $ args = $ this -> formatInputArguments ( ) ; foreach ( $ args as $ key => $ value ) { if ( '--' === substr ( $ value , 0 , 2 ) ) { $ this -> parseOption ( substr ( $ value , 2 ) ) ; } else if ( '-' === substr ( $ value , 0 , 1 ) ) { $ this -> parseOption ( substr ( $ value , 1 ) ) ; } else ...
Parse CLI input arguments .
12,128
public function getFirstArgument ( ) { foreach ( $ this -> argv as $ value ) { if ( $ value && '-' === $ value [ 0 ] ) { continue ; } return $ value ; } return isset ( $ this -> definition -> getDefaultInputArguments ( ) [ 0 ] ) ? $ this -> definition -> getDefaultInputArguments ( ) [ 0 ] -> getDefault ( ) : false ; }
get first argument
12,129
protected function initializeBundleOption ( array $ attr ) { $ parentId = $ attr [ MemberNames :: PARENT_ID ] ; $ name = $ this -> getValue ( ColumnKeys :: BUNDLE_VALUE_NAME ) ; $ storeId = $ this -> getRowStoreId ( StoreViewCodes :: ADMIN ) ; if ( $ entity = $ this -> loadBundleOption ( $ name , $ storeId , $ parentId...
Initialize the bundle option with the passed attributes and returns an instance .
12,130
public function setParserOption ( $ parserName , $ key , $ value = null ) { if ( ! isset ( $ this -> parserOptions [ $ parserName ] ) ) { $ this -> parserOptions [ $ parserName ] = [ ] ; } if ( ! is_array ( $ key ) ) { $ this -> parserOptions [ $ parserName ] [ $ key ] = $ value ; return $ this ; } foreach ( $ key as $...
Set a parser option .
12,131
public function lazyLoadBy ( Repository $ repository , array $ attributes ) { $ this -> repository = $ repository ; $ this -> lazyLoadAttributes = $ attributes ; $ this -> lazyLoad = true ; return $ this ; }
Lazyload the attributes of this BuildConfig by passing some attributes and let it later be filled by the passed repository This is typehinted against the core repository because it only needs the fill method .
12,132
protected function fillIfNotFilled ( ) { if ( ! $ this -> lazyLoad || $ this -> lazyLoaded || ! $ this -> repository ) { return ; } $ this -> repository -> fill ( $ this , $ this -> lazyLoadAttributes ) ; $ this -> lazyLoaded = true ; }
Fills the config by the repository once .
12,133
public static function writePbjSchemaStoresFile ( PackageEvent $ event ) { if ( ! $ event -> isDevMode ( ) ) { return ; } $ dirs = [ ] ; foreach ( $ event -> getInstalledRepo ( ) -> getPackages ( ) as $ package ) { if ( ! $ package instanceof PackageInterface ) { continue ; } if ( 'pbj-schema-store' !== $ package -> ge...
Auto registers the pbj - schema - store repos with the SchemaStore .
12,134
public function deregisterEntity ( $ entity ) { $ entityState = $ this -> getEntityState ( $ entity ) ; unset ( $ this -> aggregateRootChildren [ $ this -> getObjectHashId ( $ entity ) ] ) ; if ( $ entityState == EntityStates :: QUEUED || $ entityState == EntityStates :: REGISTERED ) { $ className = $ this -> getClassN...
Deregisters an entity This should only be called through a unit of work
12,135
public function getEntity ( $ className , $ id ) { if ( isset ( $ this -> entities [ $ className ] ) && isset ( $ this -> entities [ $ className ] [ $ id ] ) ) { return $ this -> entities [ $ className ] [ $ id ] ; } if ( isset ( $ this -> stashedEntities [ $ className ] ) && isset ( $ this -> stashedEntities [ $ class...
Attempts to get a registered entity
12,136
public function isRegistered ( $ entity ) { try { $ entityId = $ this -> getEntityId ( $ entity ) ; return ( $ this -> getEntityState ( $ entity ) == EntityStates :: REGISTERED ) || isset ( $ this -> entities [ $ this -> getClassName ( $ entity ) ] [ $ entityId ] ) ; } catch ( OrmException $ e ) { return false ; } }
Gets whether or not an entity is registered
12,137
public function registerAggregateRootCallback ( $ aggregateRoot , $ child , callable $ function ) { $ childObjectHashId = $ this -> getObjectHashId ( $ child ) ; if ( ! isset ( $ this -> aggregateRootChildren [ $ childObjectHashId ] ) ) { $ this -> aggregateRootChildren [ $ childObjectHashId ] = [ ] ; } $ this -> aggre...
Registers a function to set the aggregate root Id in a child entity after the aggregate root has been inserted Since the child depends on the aggregate root s Id being set make sure the root is inserted before the child
12,138
public function registerEntity ( & $ entity ) { $ this -> unstashEntity ( $ entity ) ; $ className = $ this -> getClassName ( $ entity ) ; $ objectHashId = $ this -> getObjectHashId ( $ entity ) ; $ entityId = $ this -> getEntityId ( $ entity ) ; if ( ! isset ( $ this -> entities [ $ className ] ) ) { $ this -> entitie...
Registers an entity
12,139
public function runAggregateRootCallbacks ( $ child ) { $ objectHashId = $ this -> getObjectHashId ( $ child ) ; if ( ! isset ( $ this -> aggregateRootChildren [ $ objectHashId ] ) ) { return ; } foreach ( $ this -> aggregateRootChildren [ $ objectHashId ] as $ aggregateRootData ) { $ aggregateRoot = $ aggregateRootDat...
Runs any aggregate root child functions registered for the entity
12,140
public function compileFunction ( ) { $ params = func_get_args ( ) ; $ name = array_shift ( $ params ) ; array_pop ( $ params ) ; if ( function_exists ( $ name ) ) { return $ name . '(' . join ( ', ' , $ params ) . ')' ; } }
This method is called on any attempt to compile a function call
12,141
public function get ( $ key ) { if ( isset ( $ this -> config [ $ key ] ) ) { return $ this -> config [ $ key ] [ 'config' ] ; } $ conf = null ; $ file = $ this -> getFileNameForKey ( $ key ) ; if ( null !== $ this -> cache ) { $ cacheKey = $ this -> getCacheKeyForFile ( $ file ) ; $ conf = $ this -> app [ $ this -> ca...
Get configuration by the given key .
12,142
public function setDir ( $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new FileNotFoundException ( sprintf ( 'Config "%s" is not a directory.' , is_string ( $ dir ) ? $ dir : ( is_object ( $ dir ) ? get_class ( $ dir ) : gettype ( $ dir ) ) ) ) ; } $ newDir = realpath ( $ dir ) . '/' ; if ( null === $ this -> configDirec...
Set the directory location for the config files .
12,143
public function setEnvironment ( $ environment ) { $ this -> environment = null === $ environment ? '' : $ environment ; $ this -> flushAll ( ) ; return $ this ; }
Set the version of the configuration files used in the file name format .
12,144
public function setFormat ( $ format ) { if ( $ this -> app [ 'debug' ] ) { if ( false === is_string ( $ format ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Format must be a string, got "%s".' , is_object ( $ format ) ? get_class ( $ format ) : gettype ( $ format ) ) ) ; } if ( false === strpos ( $ format , ...
Set the file format to search for in the configuration directory .
12,145
public function flushAll ( ) { if ( null !== $ this -> cache ) { foreach ( $ this -> config as $ config ) { if ( array_key_exists ( 'cacheKey' , $ config ) ) { $ this -> app [ $ this -> cache ] -> delete ( $ config [ 'cacheKey' ] ) ; } } } $ this -> config = [ ] ; }
Flush all config loaded by this loader .
12,146
public function flushConfig ( $ key ) { if ( null !== $ this -> cache ) { if ( isset ( $ this -> config [ $ key ] ) && array_key_exists ( 'cacheKey' , $ this -> config [ $ key ] ) ) { $ cacheKey = $ this -> config [ $ key ] [ 'cacheKey' ] ; } else { $ cacheKey = $ this -> getCacheKeyForFile ( $ this -> getFileNameForKe...
Flush config from the loader .
12,147
public function evaluate ( $ value ) { switch ( $ this -> comparison ) { case '' : case '=' : foreach ( $ this -> value as $ value_item ) { if ( $ value_item == $ value ) { return true ; } } return false ; case '!=' : case '<>' : foreach ( $ this -> value as $ value_item ) { if ( $ value_item != $ value ) { return true...
evaluate the condition against the given value
12,148
final protected function checkBooleanResponse ( string $ res ) : int { if ( trim ( $ res ) == "yes" || trim ( $ res ) == "no" || trim ( $ res ) == "" ) { return ( 1 ) ; } return ( - 1 ) ; }
Check boolean response
12,149
final protected function checkAppExist ( string $ appname ) : bool { if ( file_exists ( FEnvFcm :: get ( "framework.apps" ) . $ appname ) ) { return ( true ) ; } return ( false ) ; }
Check if app name exist
12,150
final protected function stepDisabledProject ( ) { Output :: clear ( ) ; Output :: displayAsGreen ( "Welcome on App Manager.\n" . "I'm assist you to disabled your app. Many question will ask you.\n" . $ this -> stage [ 7 ] , "none" ) ; if ( $ this -> showEnabledAppsRegister ( ) == false ) { return ; } Output :: outputA...
Disable an app
12,151
final protected function checkAppRegister ( string $ appname ) : bool { $ file = json_decode ( file_get_contents ( FEnvFcm :: get ( "framework.config.core.apps.file" ) ) ) ; if ( empty ( $ file ) ) { return ( false ) ; } foreach ( $ file as $ val ) { if ( $ val -> name == $ appname ) { return ( true ) ; } } return ( fa...
Check if app is registered to apps . json
12,152
final protected function showAppsRegister ( ) { $ file = json_decode ( file_get_contents ( FEnvFcm :: get ( "framework.config.core.apps.file" ) ) ) ; $ i = 1 ; if ( count ( $ file ) == 0 ) { Output :: outputAsError ( "Ops! You have no app registered. Please create an app with app" ) ; } $ str = "" ; foreach ( $ file as...
Show all app in apps . json
12,153
final protected function showEnabledAppsRegister ( ) : int { $ this -> params [ 'applist' ] = array ( ) ; $ file = json_decode ( file_get_contents ( FEnvFcm :: get ( "framework.config.core.apps.file" ) ) ) ; $ i = 1 ; if ( ( is_string ( $ file ) && strlen ( $ file ) < 3 ) || ( count ( ( array ) $ file ) == 0 ) ) { Outp...
Show enabled app in apps . json
12,154
final protected function enabledAppProcess ( ) { $ appname = $ this -> params [ 'capp' ] ; Output :: displayAsGreen ( "Processing to enabled app : $appname will be enabled \n" , "none" , false ) ; sleep ( 1 ) ; $ file = json_decode ( file_get_contents ( FEnvFcm :: get ( "framework.config.core.apps.file" ) ) ) ; foreac...
Processing to enabled an app
12,155
final protected function removeAppProcess ( ) { $ appname = $ this -> params [ 'appname' ] ; Output :: displayAsGreen ( "Processing to delete app : $appname \n" , "none" , false ) ; sleep ( 1 ) ; $ file = json_decode ( file_get_contents ( FEnvFcm :: get ( "framework.config.core.apps.file" ) ) ) ; if ( ! empty ( $ file ...
Processing to remove app
12,156
public function nextTable ( ) { $ this -> dataTable = null ; $ this -> entityAbstract = null ; $ this -> entity = null ; return $ this -> getNames ( ) -> nextTable ( ) ; }
Load next table
12,157
protected function verifyPath ( $ path ) { if ( file_exists ( $ path ) ) return true ; if ( mkdir ( $ path , 0777 , true ) ) return true ; return false ; }
Check & Create Path
12,158
public function verifyModuleStructure ( ) { $ isValid = $ this -> verifyPath ( dirname ( $ this -> getNames ( ) -> modelPath ) ) ; $ isValid = $ isValid && $ this -> verifyPath ( dirname ( $ this -> getNames ( ) -> entityPath ) ) ; return $ isValid ; }
Verify module and try create any missing items
12,159
protected function getPath ( ) { switch ( $ this -> type ) { case self :: TYPE_MODEL : $ path = $ this -> getNames ( ) -> modelPath ; break ; case self :: TYPE_ENTITYABSTRACT : $ path = $ this -> getNames ( ) -> entityAbstractPath ; break ; case self :: TYPE_ENTITY : $ path = $ this -> getNames ( ) -> entityPath ; brea...
Path for file
12,160
protected function init ( ) { $ this -> _file = new FileGenerator ( ) ; $ this -> _class = new ClassGenerator ( ) ; $ this -> setupFile ( ) ; $ this -> setupFileDocBlock ( ) ; $ this -> setupClass ( ) ; $ this -> setupMethods ( ) ; }
Kick off generation proccess
12,161
protected function setupFileDocBlock ( ) { $ warn = PHP_EOL . "SAFE TO EDIT, BUILDER WILL NEVER OVERWRITE" ; if ( in_array ( $ this -> type , [ 'DataTable' , 'EntityAbstract' ] ) ) { $ warn = PHP_EOL . "DO NOT MAKE CHANGES TO THIS FILE" ; } $ docBlock = DocBlockGenerator :: fromArray ( array ( 'shortDescription' => $ t...
Create file Comments
12,162
public function editProfilAction ( ) { $ app = $ this -> get ( 'canal_tp_sam.application.finder' ) -> getCurrentApp ( ) ; $ id = $ this -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) -> getId ( ) ; $ userManager = $ this -> container -> get ( 'fos_user.user_manager' ) ; $ user = $ userManager -> findUserB...
Displays a form to edit profil of current user .
12,163
protected function getIdentifier ( $ entity ) { $ entityId = json_decode ( $ this -> entityRegistry -> getEntityId ( $ entity ) , true ) ; if ( is_array ( $ entityId ) ) { $ identifier = [ ] ; foreach ( $ entityId as $ key => $ value ) { $ key = strtolower ( Normalise :: toUnderscoreSeparated ( Normalise :: fromCamelCa...
Gets the identifier for an entity
12,164
public function onWpLoaded ( ) { if ( $ this -> c :: isCli ( ) ) { return ; } elseif ( empty ( $ _REQUEST [ $ this -> var ] ) ) { return ; } $ this -> action = ( string ) $ _REQUEST [ $ this -> var ] ; $ this -> action = $ this -> c :: unslash ( $ this -> action ) ; $ this -> action = $ this -> c :: mbTrim ( $ this -> ...
On wp_loaded hook .
12,165
public function data ( string $ action = '' , bool $ allow_dimensions = false ) { $ action = $ action ? : $ this -> action ; if ( ! $ this -> action ) { return ; } elseif ( $ action !== $ this -> action ) { return ; } elseif ( ! isset ( $ _REQUEST [ $ this -> data_var ] ) ) { return ; } $ data = $ _REQUEST [ $ this -> ...
Action data .
12,166
public function urlAdd ( string $ action , $ data = null , string $ url = null ) : string { if ( $ this -> viaApi ( $ action ) ) { $ action = $ this -> addApiVersion ( $ action ) ; } $ url = $ this -> urlRemove ( $ url ? : $ this -> bestUrl ( $ action ) ) ; $ url = $ this -> c :: addUrlQueryArgs ( [ $ this -> var => $ ...
Add action to a URL .
12,167
public function formElementId ( string $ action , string $ var_name = '' ) : string { return $ this -> data_slug . '-' . $ this -> c :: nameToSlug ( $ action ) . ( $ var_name ? '-' . $ this -> c :: nameToSlug ( $ var_name ) : '' ) ; }
Data form element ID .
12,168
public function formElementClass ( string $ var_name = '' ) : string { return $ this -> data_slug . ( $ var_name ? '-' . $ this -> c :: nameToSlug ( $ var_name ) : '' ) ; }
Data form element class .
12,169
public function formElementName ( string $ var_name = '' ) : string { $ parts = $ var_name ? preg_split ( '/(\[[^[\]]*\])/u' , $ var_name , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) : [ ] ; if ( ! $ parts ) { return $ this -> data_var ; } elseif ( mb_strpos ( $ parts [ 0 ] , '[' ) === 0 ) { return $ this -...
Data form element name .
12,170
public function register ( string $ action , string $ class , string $ method , array $ args = [ ] ) { if ( ! $ action || ! $ class || ! $ method ) { throw $ this -> c :: issue ( 'Action args empty.' ) ; } if ( ( $ via_api = $ this -> viaApi ( $ action ) ) ) { $ action = $ this -> stripApiVersion ( $ action ) ; } $ def...
Registers an action .
12,171
protected function viaApi ( string $ action ) : bool { if ( mb_strpos ( $ action , 'api.' ) === 0 ) { return true ; } return mb_strpos ( $ action , 'api-v' ) === 0 && preg_match ( '/^api\-v[0-9]+[0-9.]*\./u' , $ action ) ; }
An action via API?
12,172
protected function parseApiVersion ( string $ action ) : string { if ( mb_strpos ( $ action , 'api-v' ) === 0 ) { $ version = preg_replace ( '/^api\-v([0-9]+[0-9.]*)\..+$/u' , '${1}' , $ action ) ; } return $ version ?? '' ; }
Parse API version .
12,173
protected function addApiVersion ( string $ action ) : string { if ( mb_strpos ( $ action , 'api.' ) === 0 ) { $ action = preg_replace ( '/^api\./u' , 'api-v' . $ this -> App :: REST_ACTION_API_VERSION . '.' , $ action ) ; } return $ action ; }
Add API version .
12,174
protected function stripApiVersion ( string $ action ) : string { if ( mb_strpos ( $ action , 'api-v' ) === 0 ) { $ action = preg_replace ( '/^api\-v[0-9]+[0-9.]*\./u' , 'api.' , $ action ) ; } return $ action ; }
Strip API version .
12,175
private function getReplacementCommand ( $ fromText , $ toText ) { $ characters = [ "'" , ";" , "\\" , "/" ] ; $ escaped = [ "\\'" , "\\;" , "\\\\" , "\\/" ] ; return sprintf ( 's/%s/%s/g' , str_replace ( $ characters , $ escaped , $ fromText ) , str_replace ( $ characters , $ escaped , $ toText ) ) ; }
Get the string replacement command for a single item
12,176
public function setType ( $ type ) { if ( ! self :: isValidType ( $ type ) ) { throw new \ InvalidArgumentException ( "$type is not a valid event type" ) ; } $ this -> type = $ type ; return $ this ; }
Sets the event type
12,177
protected function performConfig ( array & $ array , $ option ) { foreach ( explode ( '|' , $ option ) as $ action ) { $ action = explode ( ':' , $ action ) ; switch ( current ( $ action ) ) { case 'randomize' : shuffle ( $ array ) ; break ; case 'limit' : if ( isset ( $ action [ 1 ] ) ) { $ array = $ this -> arrayLimi...
Take a promotion group and perform an action on it
12,178
public function set ( string $ name , string $ config ) : self { try { $ this -> sections [ $ name ] = new SectionConfiguration ( $ config ) ; } catch ( \ Throwable $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'AppSection "%s" configuration is invalid: %s' , $ name , $ e -> getMessage ( ) ) , 0 , $ e ) ; } ...
Set the configuration for a section .
12,179
public static function changeKeyCase ( $ data , int $ case = null ) { $ properties = get_object_vars ( $ data ) ; foreach ( $ properties as & $ key ) { $ value = & $ data -> $ key ; unset ( $ data -> $ key ) ; $ changeCaseKey = ( $ case == CASE_UPPER ) ? strtoupper ( $ key ) : strtolower ( $ key ) ; $ data -> $ changeC...
Changes the case of all properties in an object
12,180
public static function getPropertyForKeyOrDefault ( & $ data , string $ property , $ default , bool $ ignoreCase = false , bool $ deepSearchDotNotation = false ) { $ keyToCheck = $ property ; $ objectToCheck = & $ data ; if ( $ ignoreCase ) { $ keyToCheck = strtolower ( $ keyToCheck ) ; $ objectToCheck = ObjectUtils ::...
Get the value from an object of the given property . Return a default value if the property could not be found .
12,181
public static function addError ( $ messageOrException = 'UNKNOWN' , $ key = null ) { $ formId = Actions :: DEFAULT_ERRORS_ID ; $ actionQueryString = Request :: getInputValue ( "do" , false , true ) ; if ( ! empty ( $ actionQueryString ) ) { $ actionQuery = self :: parseActionQueryString ( $ actionQueryString ) ; $ for...
Add error to the reponse which will be retrievable once after doing a redirect . Retrievable in templates via the errors variable inside a form - tag or _ . errors when the action was called from another scope .
12,182
public static function getErrorsOccurred ( string $ formId = Actions :: DEFAULT_ERRORS_ID ) : array { $ errors = Cache :: getInstance ( FlashCache :: CACHE_INSTANCE_NAME ) -> getCached ( $ formId ) ; $ errorList = json_decode ( $ errors , true ) ; return ! is_array ( $ errorList ) ? array ( ) : $ errorList ; }
Get all errors added to the response in the previous request .
12,183
public static function createActionQueryString ( $ actionId , string $ addon , string $ function , array $ arguments = array ( ) ) : string { if ( empty ( $ addon ) && empty ( $ function ) ) { TemplateRenderException :: throw ( 'Unknown addon and function while trying to create actionable query.' ) ; } $ origin = Reque...
Generate sealed hash for an actionable function .
12,184
public static function parseActionQueryString ( string $ actionQueryString ) { if ( empty ( $ actionQueryString ) ) { return null ; } $ action = Security :: open ( $ actionQueryString ) ; if ( $ action === false ) { throw new SecurityException ( 'Action has expired, please try again' ) ; } $ actionObj = json_decode ( $...
Open previously generated string for actionable function .
12,185
public function performInclusions ( & $ attr ) { if ( ! isset ( $ attr [ 0 ] ) ) { return ; } $ merge = $ attr [ 0 ] ; $ seen = array ( ) ; for ( $ i = 0 ; isset ( $ merge [ $ i ] ) ; $ i ++ ) { if ( isset ( $ seen [ $ merge [ $ i ] ] ) ) { continue ; } $ seen [ $ merge [ $ i ] ] = true ; if ( ! isset ( $ this -> info ...
Takes a reference to an attribute associative array and performs all inclusions specified by the zero index .
12,186
public function expandIdentifiers ( & $ attr , $ attr_types ) { $ processed = array ( ) ; foreach ( $ attr as $ def_i => $ def ) { if ( $ def_i === 0 ) { continue ; } if ( isset ( $ processed [ $ def_i ] ) ) { continue ; } if ( $ required = ( strpos ( $ def_i , '*' ) !== false ) ) { unset ( $ attr [ $ def_i ] ) ; $ def...
Expands all string identifiers in an attribute array by replacing them with the appropriate values inside HTMLPurifier_AttrTypes
12,187
public function prependCSS ( & $ attr , $ css ) { $ attr [ 'style' ] = isset ( $ attr [ 'style' ] ) ? $ attr [ 'style' ] : '' ; $ attr [ 'style' ] = $ css . $ attr [ 'style' ] ; }
Prepends CSS properties to the style attribute creating the attribute if it doesn t exist .
12,188
public function confiscateAttr ( & $ attr , $ key ) { if ( ! isset ( $ attr [ $ key ] ) ) { return null ; } $ value = $ attr [ $ key ] ; unset ( $ attr [ $ key ] ) ; return $ value ; }
Retrieves and removes an attribute
12,189
public static function registerAutoload ( ) { $ autoload = array ( 'HTMLPurifier_Bootstrap' , 'autoload' ) ; if ( ( $ funcs = spl_autoload_functions ( ) ) === false ) { spl_autoload_register ( $ autoload ) ; } elseif ( function_exists ( 'spl_autoload_unregister' ) ) { if ( version_compare ( PHP_VERSION , '5.3.0' , '>='...
Pre - registers our autoloader on the SPL stack .
12,190
public function setup ( $ config ) { if ( $ this -> setup ) { return ; } $ this -> setup = true ; $ this -> doSetup ( $ config ) ; }
Setup function that aborts if already setup
12,191
protected function triggerError ( $ msg , $ no ) { $ extra = '' ; if ( $ this -> chatty ) { $ trace = debug_backtrace ( ) ; for ( $ i = 0 , $ c = count ( $ trace ) ; $ i < $ c - 1 ; $ i ++ ) { if ( $ trace [ $ i + 1 ] [ 'class' ] === 'HTMLPurifier_Config' ) { continue ; } $ frame = $ trace [ $ i ] ; $ extra = " invoked...
Produces a nicely formatted error message by supplying the stack frame information OUTSIDE of HTMLPurifier_Config .
12,192
public function getChildDef ( $ def , $ module ) { $ value = $ def -> content_model ; if ( is_object ( $ value ) ) { trigger_error ( 'Literal object child definitions should be stored in ' . 'ElementDef->child not ElementDef->content_model' , E_USER_NOTICE ) ; return $ value ; } switch ( $ def -> content_model_type ) {...
Instantiates a ChildDef based on content_model and content_model_type member variables in HTMLPurifier_ElementDef
12,193
public function & get ( $ name , $ ignore_error = false ) { if ( ! array_key_exists ( $ name , $ this -> _storage ) ) { if ( ! $ ignore_error ) { trigger_error ( "Attempted to retrieve non-existent variable $name" , E_USER_ERROR ) ; } $ var = null ; return $ var ; } return $ this -> _storage [ $ name ] ; }
Retrieves a variable reference from the context .
12,194
public function generateKey ( $ config ) { return $ config -> version . ',' . $ config -> getBatchSerial ( $ this -> type ) . ',' . $ config -> get ( $ this -> type . '.DefinitionRev' ) ; }
Generates a unique identifier for a particular configuration
12,195
public function isOld ( $ key , $ config ) { if ( substr_count ( $ key , ',' ) < 2 ) { return true ; } list ( $ version , $ hash , $ revision ) = explode ( ',' , $ key , 3 ) ; $ compare = version_compare ( $ version , $ config -> version ) ; if ( $ compare != 0 ) { return true ; } if ( $ hash == $ config -> getBatchSer...
Tests whether or not a key is old with respect to the configuration s version and revision number .
12,196
public static function iconv ( $ in , $ out , $ text , $ max_chunk_size = 8000 ) { $ code = self :: testIconvTruncateBug ( ) ; if ( $ code == self :: ICONV_OK ) { return self :: unsafeIconv ( $ in , $ out , $ text ) ; } elseif ( $ code == self :: ICONV_TRUNCATES ) { if ( $ in == 'utf-8' ) { if ( $ max_chunk_size < 4 ) ...
iconv wrapper which mutes errors and works around bugs .
12,197
public static function convertToUTF8 ( $ str , $ config , $ context ) { $ encoding = $ config -> get ( 'Core.Encoding' ) ; if ( $ encoding === 'utf-8' ) { return $ str ; } static $ iconv = null ; if ( $ iconv === null ) { $ iconv = self :: iconvAvailable ( ) ; } if ( $ iconv && ! $ config -> get ( 'Test.ForceNoIconv' )...
Convert a string to UTF - 8 based on configuration .
12,198
public static function instance ( $ prototype = false ) { static $ instance = null ; if ( $ prototype ) { $ instance = $ prototype ; } elseif ( ! $ instance ) { $ instance = new HTMLPurifier_EntityLookup ( ) ; $ instance -> setup ( ) ; } return $ instance ; }
Retrieves sole instance of the object .
12,199
public function generateFromTokens ( $ tokens ) { if ( ! $ tokens ) { return '' ; } $ html = '' ; for ( $ i = 0 , $ size = count ( $ tokens ) ; $ i < $ size ; $ i ++ ) { if ( $ this -> _scriptFix && $ tokens [ $ i ] -> name === 'script' && $ i + 2 < $ size && $ tokens [ $ i + 2 ] instanceof HTMLPurifier_Token_End ) { $...
Generates HTML from an array of tokens .