idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
13,200
public static function from ( $ file , $ prefix = 'php-tmp-file' ) { $ tmpFile = static :: generate ( $ prefix ) ; copy ( $ file , $ tmpFile ) ; return $ tmpFile ; }
Creates a temp file from an exist file keeping it safe .
13,201
private function init_wordpress ( ) { global $ wp , $ wp_query , $ wp_the_query , $ wp_rewrite , $ wp_did_header ; \ define ( 'DOING_AJAX' , true ) ; \ define ( 'SNAP_DOING_COMMAND' , true ) ; \ define ( 'BASE_PATH' , $ this -> find_wordpress_base_path ( ) ) ; \ define ( 'WP_USE_THEMES' , false ) ; require ( BASE_PATH ...
Include and boot up WordPress .
13,202
private function find_wordpress_base_path ( ) { $ dir = \ dirname ( __FILE__ ) ; do { if ( \ file_exists ( $ dir . "/wp-config.php" ) || \ file_exists ( $ dir . "/wp-config-sample.php" ) ) { return $ dir . '/' ; } } while ( $ dir = \ realpath ( "$dir/.." ) ) ; return null ; }
Traverse up the directory structure looking for the current WP base path .
13,203
protected function generateServerConfig ( ) : void { $ settings = [ ] ; $ settings [ 'ezpublish' ] [ 'siteaccess' ] [ 'match' ] [ 'URIElement' ] = '1' ; $ kernelDir = $ this -> container -> getParameter ( 'kernel.project_dir' ) . '/' . $ this -> container -> getParameter ( 'kernel.name' ) ; $ serverEnv = $ this -> cont...
Generates settings that are specific to server .
13,204
public static function derive ( string $ httpMethod , string $ uri , string $ salt , DateTime $ date , $ payload = '' , int $ version = 2 ) : string { $ httpMethod = \ strtoupper ( $ httpMethod ) ; $ data = self :: serializePayload ( $ payload ) ; $ hash = self :: getSignatureHash ( $ data , $ salt , $ version ) ; $ ti...
Constructs a new signature
13,205
private static function serializePayload ( $ payload = '' ) : string { if ( \ is_string ( $ payload ) ) { return $ payload ; } $ data = '' ; if ( ! empty ( $ payload ) ) { $ data = \ json_encode ( $ payload , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION ) ; } return $ data ; }
Serializes the payload for signing
13,206
private static function getSignatureHash ( string $ data , string $ salt , int $ version = 2 ) : string { if ( $ version === 2 ) { return \ base64_encode ( \ sodium_crypto_generichash ( $ data , $ salt , 64 ) ) ; } return \ hash ( 'sha256' , $ data ) ; }
Returns the signature hash
13,207
public function checkClientCredentials ( $ client_id , $ client_secret = null ) { $ client = $ this -> repo -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } return $ client_secret == $ client -> getSecret ( ) ; }
Checks if client credentials are valid .
13,208
public function getClientDetails ( $ client_id ) { $ client = $ this -> repo -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } $ clientDetails = array ( 'client_id' => $ client -> getId ( ) , 'redirect_uri' => $ client -> getRedirectUri ( ) , ) ; if ( $ client instanceof ScopeInterface ) { if ( is_array ( ...
Returns array containing client_id and redirect_uri . False if missing .
13,209
public function checkRestrictedGrantType ( $ client_id , $ grant_type ) { $ client = $ this -> repo -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } $ restrictedTypes = $ client -> getRestrictedGrantTypes ( ) ; if ( is_null ( $ restrictedTypes ) ) { return true ; } return in_array ( $ grant_type , $ restr...
Checks if grant tpye is restricted .
13,210
public function copyFile ( $ sourcePath , $ targetPath , $ filename ) { if ( $ sourcePath === $ targetPath ) { return ; } $ targetFilepath = $ targetPath . $ filename ; if ( file_exists ( $ targetFilepath ) ) { return ; } $ sourceFilepath = $ sourcePath . $ filename ; $ ctns = '' ; if ( file_exists ( $ sourceFilepath )...
Copy a file contents from this internal assets folder to the public dist Olympus assets folder .
13,211
public static function filePutContents ( $ filepath , $ contents , $ message , $ usedate = true ) { $ suffix = '' ; if ( $ usedate ) { $ suffix = ' on ' . date ( 'l jS \of F Y h:i:s A' ) ; } $ contents = ! empty ( $ contents ) ? $ contents . "\n" : $ contents ; file_put_contents ( $ filepath , "/**\n * " . $ message . ...
Helper function to create a file in a target path with its contents .
13,212
public static function toCamelCaseFormat ( $ text , $ separator = '-' ) { $ slugified = self :: urlize ( $ text , $ separator ) ; $ camel = strtolower ( $ slugified ) ; $ camel = ucwords ( $ camel , $ separator ) ; return str_replace ( $ separator , '' , $ camel ) ; }
Camelize string .
13,213
public static function toFunctionFormat ( $ text , $ separator = '-' ) { $ camelized = self :: toCamelCaseFormat ( $ text , $ separator ) ; return lcfirst ( $ camelized ) ; }
Functionize string .
13,214
public function addCron ( CronInterface $ cron , string $ alias , int $ priority , string $ expression , string $ arguments ) { if ( ! isset ( $ this -> crons [ $ priority ] ) ) { $ this -> crons [ $ priority ] = [ ] ; } $ cron -> setAlias ( $ alias ) ; $ cron -> addArguments ( $ arguments ) ; $ cron -> addPriority ( $...
Add cron to crons list .
13,215
public function getCrons ( ) : array { ksort ( $ this -> crons ) ; $ crons = [ ] ; foreach ( $ this -> crons as $ priority => $ cs ) { foreach ( $ cs as $ cron ) { $ crons [ $ priority . ';' . $ cron -> getAlias ( ) ] = $ cron ; } } return $ crons ; }
Sort and return crons list .
13,216
public function hasAttribute ( $ name ) { if ( $ this -> _attributes === null ) { $ this -> initAttributes ( ) ; } return isset ( $ this -> _attributes [ $ name ] ) ; }
Element has attribute ?
13,217
public function getContent ( ) { if ( $ this -> _content === null ) { $ this -> _content = [ ] ; foreach ( $ this -> _xml -> children ( ) as $ element ) { $ this -> _content [ ] = new static ( $ element ) ; } } return $ this -> _content ; }
Get content of element
13,218
protected function initAttributes ( ) { $ vars = get_object_vars ( $ this -> _xml -> attributes ( ) ) ; $ this -> _attributes = empty ( $ vars ) ? [ ] : $ vars [ '@attributes' ] ; }
Initialize atributes of element
13,219
public function translate ( $ key , $ value ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> test ( 2 , 'string' ) ; $ this -> language [ $ key ] = $ value ; return $ this ; }
Sets the translated value to the specified key
13,220
protected function lookupEntity ( string $ entity_class , int $ entity_id , string $ production_slug ) : array { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'slug' => $ production_slug ] ) ) { throw new NotFoundHttpException...
Helper function that looks up entities for controllers .
13,221
public function getLogger ( ) { $ logger = null ; if ( $ this -> container && $ this -> container -> has ( 'logger' ) ) { $ logger = $ this -> container -> get ( 'logger' ) ; } return ( $ logger ) ; }
getLogger Get the logger from the container if available and provide it to the LogAwareTrait log method .
13,222
public function getRequest ( ) { $ request = null ; if ( $ this -> container ) { $ request = $ this -> container -> get ( 'kernel' ) -> getRequest ( ) ; } return ( $ request ) ; }
getRequest Get the request object from the container
13,223
public function get ( $ name ) { if ( array_key_exists ( $ name , $ this -> services ) ) return $ this -> services [ $ name ] ; return $ this -> services [ $ name ] = $ this -> solve ( 'service' , $ name , array ( $ this ) ) ; }
Get service If has none resolve
13,224
public function dependencyCall ( $ type , $ name , array $ args = array ( ) ) { switch ( $ type ) { case 'service' : return $ this -> get ( $ name ) ; break ; case 'callable' : return $ this -> __call ( $ name , $ args ) ; break ; case 'factory' : return $ this -> create ( $ name , $ args ) ; break ; } }
All - capable dependency call .
13,225
protected function solve ( $ type , $ name , array $ args = array ( ) ) { if ( ! $ this -> services [ $ type ] -> has ( $ name ) ) { if ( $ type == 'callable' && $ this -> services [ 'service' ] -> has ( $ name ) ) { $ service = $ this -> get ( $ name ) ; if ( is_callable ( $ service ) ) { $ this -> invokables [ $ name...
Solve the given type of registry
13,226
public function tokenResolve ( $ name ) { if ( strpos ( $ name , 'self.callable' ) === 0 ) $ name = str_replace ( 'self.callable.' , 'callable.' , $ name ) ; if ( strpos ( $ name , 'self.factory' ) === 0 ) $ name = str_replace ( 'self.factory.' , 'factory.' , $ name ) ; switch ( $ name ) { case 'self' : return $ this ;...
Resolve services factories callables by given token
13,227
protected function resolve ( $ type , $ name , $ registry , array $ args = array ( ) ) { if ( $ registry instanceof \ Closure ) return call_user_func_array ( $ registry -> bindTo ( $ this ) , $ args ) ; if ( is_string ( $ registry ) ) { if ( $ type == 'service' ) return $ this -> instantiate ( $ registry ) ; else retur...
Actual resolve the given type of registry
13,228
public function setDataLinked ( array & $ data ) { $ this -> _data = [ ] ; $ this -> _models = [ ] ; $ modelClass = $ this -> getModel ( ) ; foreach ( $ data as $ key => & $ item ) { if ( is_object ( $ item ) ) { if ( ! $ item instanceof $ modelClass ) { throw new Exception ( 'Model must be an instance of "' . $ modelC...
Set linked collection s data
13,229
public function setPrimary ( $ primaryName ) { if ( is_array ( $ primaryName ) ) { $ idProperty = self :: COMPOSITE_ID_PROPERTY . $ this -> _collectionId ; foreach ( $ this -> _data as & $ dataPart ) { $ dataHashParts = [ ] ; foreach ( $ primaryName as $ keyPart ) { if ( ! isset ( $ dataPart [ $ keyPart ] ) ) { throw n...
Set a property as a primary
13,230
public function getItem ( $ key ) { if ( is_array ( $ key ) ) { $ key = $ this -> arrayHashFunction ( $ key ) ; } if ( isset ( $ this -> _models [ $ key ] ) ) { return $ this -> _models [ $ key ] ; } if ( isset ( $ this -> _data [ $ key ] ) ) { $ modelClass = $ this -> getModel ( ) ; $ item = $ modelClass :: factory ( ...
Get the item
13,231
public function setItem ( $ key , $ item ) { if ( is_array ( $ key ) ) { $ key = $ this -> arrayHashFunction ( $ key ) ; } if ( ! isset ( $ this -> _data [ $ key ] ) ) { $ this -> _map [ ] = $ key ; } if ( is_object ( $ item ) ) { $ modelClass = $ this -> getModel ( ) ; if ( ! $ item instanceof $ modelClass ) { throw n...
Set an item
13,232
public function walk ( Closure $ callback ) { foreach ( $ this -> _data as & $ data ) { $ data = $ callback ( $ data ) ; } unset ( $ data ) ; return $ this ; }
Processing a collection s data
13,233
public function cast ( $ property , $ type , $ useFactory = false ) { foreach ( $ this -> _data as & $ data ) { if ( ! array_key_exists ( $ property , $ data ) ) { continue ; } if ( is_string ( $ type ) ) { if ( $ useFactory ) { $ data [ $ property ] = $ type :: factory ( $ data [ $ property ] ) ; } else { $ data [ $ p...
Cast a property to a type
13,234
protected function buildSortedMap ( array $ definition ) { $ sortArgs = [ ] ; foreach ( $ definition as $ definitionPart ) { list ( $ property , $ direction ) = $ this -> parseSortDefinition ( $ definitionPart ) ; $ sortArgs [ ] = $ this -> getDataColumn ( $ property ) ; $ sortArgs [ ] = $ direction ; } $ this -> _map ...
Build iteration map by data columns
13,235
protected function parseSortDefinition ( $ definition ) { $ definition = trim ( $ definition ) ; $ spacePos = strrpos ( $ definition , ' ' ) ; if ( $ spacePos === false ) { return [ $ definition , SORT_ASC ] ; } $ property = substr ( $ definition , 0 , $ spacePos ) ; $ direction = substr ( $ definition , $ spacePos ) ;...
Parse the sort definition
13,236
protected function getDataColumn ( $ column ) { if ( function_exists ( 'array_column' ) ) { return array_column ( $ this -> _data , $ column ) ; } $ columnData = [ ] ; foreach ( $ this -> _data as $ row ) { $ columnData [ ] = $ row [ $ column ] ; } return $ columnData ; }
Get the data column
13,237
public function setIterationMode ( $ mode ) { switch ( $ mode ) { case self :: ITERATION_STRAIGHT : $ this -> _map = array_keys ( $ this -> _data ) ; break ; case self :: ITERATION_REVERSE : $ this -> _map = array_reverse ( array_keys ( $ this -> _data ) ) ; break ; case self :: ITERATION_EVEN : $ this -> _map = [ ] ; ...
Set mode of a collection s iteration
13,238
public function getCollection ( $ property , $ model = null , $ primary = null ) { $ list = $ this -> getList ( $ property ) ; foreach ( $ list as $ key => $ item ) { if ( $ item === null ) { unset ( $ list [ $ key ] ) ; continue ; } if ( ! is_object ( $ item ) ) { throw new Exception ( 'Unable to create a collection o...
Get a collection of properties - models
13,239
public function getList ( $ propertyValues , $ propertyKeys = null , $ uniqueValues = false ) { $ this -> initialize ( $ propertyValues ) ; $ list = [ ] ; if ( $ propertyKeys === true ) { $ propertyKeys = $ this -> getPrimary ( ) ; } if ( $ propertyKeys === null ) { foreach ( $ this -> _map as $ key ) { if ( isset ( $ ...
Get list of values by a single property considering an order
13,240
public function setList ( $ property , $ data , $ primary = null , $ overwrite = true ) { if ( $ primary !== true && ( is_array ( $ data ) || $ data instanceof Collection ) ) { if ( $ primary === null ) { $ primary = $ this -> getPrimary ( ) ; if ( $ primary === null ) { throw new Exception ( 'Unable to determine a pri...
Set the list of a values to the data
13,241
public function chunk ( $ size , $ offset = 0 ) { $ data = $ this -> createClone ( ) ; $ availSize = count ( $ this -> _map ) - $ offset ; if ( $ size > $ availSize ) { $ size = $ availSize ; } $ last = $ size + $ offset ; for ( $ i = $ offset ; $ i < $ last ; ++ $ i ) { $ key = $ this -> _map [ $ i ] ; if ( isset ( $ ...
Get chunk of the collection
13,242
public function fetch ( array $ propertiesList ) { $ data = $ this -> createClone ( ) ; foreach ( $ this -> _map as $ key ) { $ item = $ this -> _data [ $ key ] ; $ itemFetched = [ ] ; foreach ( $ propertiesList as $ property ) { if ( isset ( $ item [ $ property ] ) ) { $ itemFetched [ $ property ] = $ item [ $ propert...
Fetch data partly as a collection
13,243
public function sum ( $ property ) { $ sum = 0 ; foreach ( $ this -> _map as $ key ) { $ item = $ this -> _data [ $ key ] ; if ( isset ( $ item [ $ property ] ) ) { $ sum += $ item [ $ property ] ; } } return $ sum ; }
Get amount of the properties
13,244
public function getPropertiesNames ( ) { $ propertiesList = [ ] ; foreach ( $ this -> _data as $ item ) { $ propertiesList += array_keys ( $ item ) ; } return $ propertiesList ; }
Get a list of objects properties
13,245
public function join ( Collection $ collection , $ onProperty = null , $ sourceProperty = null ) { if ( $ collection -> isEmpty ( ) ) { return $ this ; } $ sourcePrimary = $ collection -> getPrimary ( ) ; if ( $ onProperty === null ) { if ( $ sourcePrimary === null ) { throw new Exception ( 'Unable to determine a prope...
Merge items of source collection into items of this collection
13,246
public function merge ( Collection $ collection ) { if ( $ collection -> isEmpty ( ) ) { return $ this ; } $ primary = $ this -> getPrimary ( ) ; if ( $ primary !== null ) { $ sourcePrimary = $ collection -> getPrimary ( ) ; if ( $ primary !== $ sourcePrimary ) { $ collection = clone $ collection ; $ collection -> setP...
Merge a collection into this collection
13,247
public function truncate ( ) { $ this -> _map = [ ] ; $ this -> _data = [ ] ; $ this -> _models = [ ] ; $ this -> _pointer = 0 ; return $ this ; }
Truncate a collection s data
13,248
public function toArray ( $ recursively = false ) { $ array = [ ] ; if ( $ recursively === true ) { foreach ( $ this -> _map as $ key ) { $ array [ $ key ] = $ this -> getItem ( $ key ) -> toArray ( ) ; } } else { foreach ( $ this -> _map as $ key ) { $ array [ $ key ] = $ this -> getItem ( $ key ) ; } } return $ array...
Get collection as an array considering an order
13,249
public function issetItem ( $ key ) { if ( is_array ( $ key ) ) { $ key = $ this -> arrayHashFunction ( $ key ) ; } return isset ( $ this -> _data [ $ key ] ) ; }
Item exists check
13,250
public function unsetProperty ( $ property ) { foreach ( $ this -> _data as & $ item ) { unset ( $ item [ $ property ] ) ; } unset ( $ item ) ; return $ this ; }
Unset a property in each item
13,251
public function createClone ( $ data = [ ] ) { $ collection = static :: factory ( $ data , $ this -> getModel ( ) , $ this -> getPrimary ( ) ) ; if ( $ this -> hasDatagate ( ) ) { $ collection -> setDatagate ( $ this -> getDatagate ( ) ) ; } if ( $ this -> hasLocator ( ) ) { $ collection -> setLocator ( $ this -> getLo...
Create the same empty collection
13,252
public function count ( $ property = null ) { if ( $ property === null ) { return count ( $ this -> _map ) ; } if ( is_array ( $ property ) ) { $ reduceFunction = function ( & $ result , & $ item ) use ( $ property ) { foreach ( $ property as $ part ) { if ( ! isset ( $ item [ $ part ] ) ) { return ; } } return $ resul...
Count number of items
13,253
function showView ( $ template = null ) { return '<div id="' . $ this -> ObjectId ( ) . '"></div><script type="text/javascript">timeToTimer("' . $ this -> viewVal . '", "' . $ this -> orderFormatFlags ( $ this -> timerFormat ) . '", "' . $ this -> ObjectId ( ) . '")</script>' ; }
function showView - This function shows the date selected in the input to be displayed in the view .
13,254
static public function create ( $ params , LocatorInterface $ locator = null ) { if ( ! is_array ( $ params ) && ! $ params instanceof Traversable ) { throw new InvalidOptions ( 'Options must be an array or a Traversable implementation' ) ; } if ( $ params instanceof Traversable ) { $ params = Std :: iteratorToArray ( ...
Crteate the translator by the params
13,255
static protected function createResources ( $ definitions ) { $ resources = [ ] ; foreach ( $ definitions as $ name => $ options ) { if ( ! isset ( $ options [ 'type' ] ) ) { throw new InvalidOptions ( 'Type of resource must be specified' ) ; } $ class = self :: NAMESPACE_RESOURCE . '\\' . ucfirst ( $ options [ 'type' ...
Create the resources by the definitions
13,256
public function getBaseDir ( ) : string { $ ds = DIRECTORY_SEPARATOR ; $ dir = __DIR__ . "$ds..$ds..$ds..$ds..$ds" ; $ base_dir = realpath ( $ dir ) ; if ( ! $ base_dir ) { $ message = 'Cannot resolve project base directory.' ; throw new Exception \ RuntimeException ( $ message ) ; } return $ base_dir ; }
Return pjbserver - tools installation base directory .
13,257
public static function printResult ( $ title , $ objectName , $ objectId = null , $ request = null , $ response = null ) { self :: printOutput ( $ title , $ objectName , $ objectId , $ request , $ response , false ) ; }
Prints success response HTML Output to web page .
13,258
public static function printOutput ( $ title , $ objectName , $ objectId = null , $ request = null , $ response = null , $ errorMessage = null ) { if ( PHP_SAPI == 'cli' ) { self :: $ printResultCounter ++ ; printf ( "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" ) ; printf ( "(%d) %s" , self :: $ ...
Prints HTML Output to web page .
13,259
public function digipolisDeployDrupal8 ( array $ arguments , $ opts = [ 'app' => 'default' , 'site-name' => 'Drupal' , 'profile' => 'standard' , 'force-install' => false , 'config-import' => false , 'existing-config' => false , 'worker' => null , 'ssh-verbose' => false , ] ) { return $ this -> deployTask ( $ arguments ...
Build a Drupal 8 site and push it to the servers .
13,260
public function digipolisInitDrupal8Remote ( $ server , $ user , $ privateKeyFile , $ opts = [ 'app' => 'default' , 'site-name' => 'Drupal' , 'profile' => 'standard' , 'force-install' => false , 'config-import' => false , 'existing-config' => false , ] ) { $ remote = $ this -> getRemoteSettings ( $ server , $ user , $ ...
Install or update a drupal 8 remote site .
13,261
public function digipolisUpdateDrupal8 ( $ opts = [ 'config-import' => false ] ) { $ this -> readProperties ( ) ; $ collection = $ this -> collectionBuilder ( ) ; $ collection -> taskExecStack ( ) -> exec ( 'cd -P $(ls -vdr ' . $ this -> getConfig ( ) -> get ( 'digipolis.root.project' ) . '/../* | head -n2 | tail -n1) ...
Executes D8 database updates of the D8 site in the current folder .
13,262
protected function varnishCheckCommand ( ) { $ this -> readProperties ( ) ; $ drushVersion = $ this -> taskDrushStack ( ) -> drupalRootDirectory ( $ this -> getConfig ( ) -> get ( 'digipolis.root.web' ) ) -> getVersion ( ) ; if ( version_compare ( $ drushVersion , '9.0' , '<' ) ) { return 'bash -c "[[ ' . '\'$ENABLED_M...
Get the command to check if the page_cache module and varnish are not enabled simultaneously . Command differs for Drush 9 vs Drush 8 .
13,263
protected function checkModuleCommand ( $ module , $ remote = null ) { $ this -> readProperties ( ) ; $ drushVersion = $ this -> taskDrushStack ( ) -> drupalRootDirectory ( $ this -> getConfig ( ) -> get ( 'digipolis.root.web' ) ) -> getVersion ( ) ; $ webroot = $ remote ? $ remote [ 'currentdir' ] : $ this -> getConfi...
Get the command to check if the locale module is enabled . Command differs for Drush 9 vs Drush 8 .
13,264
public function digipolisSyncDrupal8 ( $ sourceUser , $ sourceHost , $ sourceKeyFile , $ destinationUser , $ destinationHost , $ destinationKeyFile , $ sourceApp = 'default' , $ destinationApp = 'default' , $ opts = [ 'files' => false , 'data' => false ] ) { if ( ! $ opts [ 'files' ] && ! $ opts [ 'data' ] ) { $ opts [...
Sync the database and files between two Drupal 8 sites .
13,265
public function normalizePrefix ( $ qname ) { $ prefix = strstr ( $ qname , ":" , true ) ; if ( isset ( $ this -> namespacePrefixMap [ $ prefix ] ) ) { $ qname = str_replace ( "$prefix:" , "{$this->namespacePrefixMap[ $prefix ]}:" , $ qname ) ; } return $ qname ; }
The prefix is replaced with its namespace
13,266
public function AddAttribute ( $ prefix , $ name , $ parentType = "xs:anySimpleType" ) { $ attribute = array ( ) ; $ parts = explode ( ":" , $ parentType ) ; $ parentLocalName = count ( $ parts ) == 1 ? $ parts [ 0 ] : $ parts [ 1 ] ; $ parentPrefix = count ( $ parts ) == 1 ? SCHEMA_PREFIX : $ parts [ 0 ] ; $ type = $ ...
Add an entry to the global attributes list
13,267
public function gatherElementsFromType ( $ type ) { if ( is_string ( $ type ) ) { $ type = $ this -> getType ( $ type ) ; } if ( ! is_array ( $ type ) ) return false ; $ elements = array ( ) ; foreach ( array ( 'elements' , 'sequence' , 'choice' , 'group' ) as $ typeComponent ) { if ( ! isset ( $ type [ $ typeComponent...
Complex types and groups may contain nested elements The purpose of this function is to retrieve such nested elements
13,268
public function hasElement ( $ name , $ prefix = null ) { return isset ( $ this -> elements [ is_null ( $ prefix ) ? $ name : "$prefix:$name" ] ) ; }
Return true if a named element exists
13,269
public function getElement ( $ name , $ prefix = null ) { return $ this -> hasElement ( $ name , $ prefix ) ? $ this -> elements [ is_null ( $ prefix ) ? $ name : "$prefix:$name" ] : false ; }
Return a named element
13,270
public function hasType ( $ name , $ prefix = null ) { return isset ( $ this -> types [ is_null ( $ prefix ) ? $ name : "$prefix:$name" ] ) ; }
Return true if a named type exists
13,271
public function getType ( $ name , $ prefix = null ) { if ( is_array ( $ name ) && isset ( $ name [ 'class' ] ) && isset ( $ name [ 'parent' ] ) ) { $ name = $ name [ 'parent' ] ; } if ( strpos ( $ name , ":" ) === false && is_null ( $ prefix ) ) { $ prefix = "xs" ; } return $ this -> hasType ( $ name , $ prefix ) ? $ ...
Return a named type
13,272
public function getSimpleTypesFromUnion ( $ qname ) { $ name = $ qname instanceof QName ? "{$qname->prefix}:{$qname->localName}" : $ qname ; while ( true ) { if ( ! $ this -> hasType ( $ name ) ) return array ( ) ; $ type = $ this -> getType ( $ name ) ; if ( isset ( $ type [ 'restrictionType' ] ) && $ type [ 'restrict...
Get all the types associated with a union type
13,273
public function isUnionType ( $ qname ) { $ name = $ qname instanceof QName ? "{$qname->prefix}:{$qname->localName}" : $ qname ; $ type = $ this -> getType ( $ name ) ; if ( ! $ type ) return false ; if ( isset ( $ type [ 'restrictionType' ] ) && $ type [ 'restrictionType' ] == 'union' ) { return true ; } if ( ! isset ...
Returns true if the type is union
13,274
public function getTypeById ( $ id , $ prefix = null ) { if ( ! isset ( $ this -> typeIds [ $ id ] ) ) return false ; return isset ( $ this -> typeIds [ $ id ] [ 'istype' ] ) && $ this -> typeIds [ $ id ] [ 'istype' ] ? $ this -> getType ( $ this -> typeIds [ $ id ] [ 'name' ] , $ prefix ) : $ this -> getElement ( $ th...
Try to access a type by an id
13,275
public function getAttribute ( $ name , $ prefix ) { return $ this -> hasAttribute ( $ name , $ prefix ) ? $ this -> attributes [ "$prefix:$name" ] : ( $ this -> hasAttributeGroup ( $ name , $ prefix ) ? $ this -> attributeGroups [ "$prefix:$name" ] : false ) ; }
Return a named attribute
13,276
public function processSchema ( $ xsd , $ includeElements = false ) { libxml_use_internal_errors ( ) ; $ xml = @ simplexml_load_file ( $ xsd ) ; if ( ! $ xml ) { return false ; } $ activeSchemaPrefix = null ; $ prefix = null ; $ targetNamespace = ( string ) $ xml -> attributes ( ) -> targetNamespace ; foreach ( $ xml -...
Load types from a schema file
13,277
private function getNodeContent ( $ contentNode , $ prefix ) { $ contentType = "" ; if ( property_exists ( $ contentNode , 'restriction' ) ) { $ parent = ( string ) $ contentNode -> restriction -> attributes ( ) -> base ; $ contentType = "restriction" ; } else if ( property_exists ( $ contentNode , 'extension' ) ) { $ ...
Returns an array representing a complex content of a complex type
13,278
public function isNumeric ( $ type ) { if ( $ type instanceof QName ) { $ type = "{$type->prefix}:{$type->localName}" ; } else if ( is_string ( $ type ) && isset ( $ this -> types [ $ type ] ) ) { $ type = $ this -> types [ $ type ] ; } $ result = $ this -> resolvesToBaseType ( $ type , array ( 'xs:decimal' , 'xs:doubl...
Returns true if the array passed reprsents a numeric type
13,279
function processGroup ( $ node , $ prefix ) { $ ref = ( string ) $ node -> attributes ( ) -> ref ; if ( empty ( $ ref ) ) { $ content = array ( ) ; foreach ( $ node -> children ( SCHEMA_NAMESPACE ) as $ key => $ groupChild ) { $ x = $ this -> getContent ( $ key , $ groupChild , $ prefix ) ; $ content = array_merge_recu...
Returns an array representing a group type
13,280
function getEnumeration ( $ node ) { if ( ! count ( $ node -> children ( SCHEMA_NAMESPACE ) -> enumeration ) ) return false ; $ result = array ( ) ; foreach ( $ node -> children ( SCHEMA_NAMESPACE ) -> enumeration as $ enumeration ) { if ( empty ( $ enumeration -> attributes ( ) -> value ) ) continue ; $ result [ ] = (...
Return the enumeration values associated with the node or false
13,281
function createBaseTypes ( ) { if ( $ this -> baseTypesLoaded ) return ; $ types = SchemaTypes :: $ xsTypes ; $ this -> types = array_reduce ( array_keys ( SchemaTypes :: $ xsTypes ) , function ( $ carry , $ type ) use ( $ types ) { $ qn = \ lyquidity \ xml \ qname ( $ type , array ( SCHEMA_PREFIX => SCHEMA_NAMESPACE )...
Create the default types provided by the schema spec .
13,282
public function fromArray ( $ types ) { $ this -> types = & $ types [ 'types' ] ; $ this -> attributes = & $ types [ 'attributes' ] ; $ this -> attributeGroups = & $ types [ 'attributeGroups' ] ; $ this -> elements = & $ types [ 'elements' ] ; $ this -> processedSchemas = & $ types [ 'processedSchemas' ] ; if ( isset (...
Create an types instance from an array
13,283
public function mergeTypes ( $ types ) { $ this -> types = array_merge ( $ this -> types , $ types [ 'types' ] ) ; $ this -> attributes = array_merge ( $ this -> attributes , $ types [ 'attributes' ] ) ; $ this -> attributeGroups = array_merge ( $ this -> attributeGroups , $ types [ 'attributeGroups' ] ) ; $ this -> el...
Merge types from an array
13,284
public function set ( $ path , $ value ) { $ this -> callAtPath ( $ path , function ( & $ offset ) use ( $ value ) { $ offset = $ value ; } , true ) ; return $ this ; }
Insert a value to the array at the specified path .
13,285
public function run ( $ input = null ) { $ callback = $ this -> getCallback ( ) ; ob_start ( ) ; $ exitCode = $ callback ( $ input ) ; $ output = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( $ this -> hasPipedCommand ( ) ) { $ pipedCommand = $ this -> getPipedCommand ( ) ; $ pipedCommand -> run ( $ output ) ; $ output...
Run this command and get the exit code for it .
13,286
public function getCallbackCode ( ) { $ reflection = new \ ReflectionFunction ( $ this -> _callback ) ; $ file = new \ SplFileObject ( $ reflection -> getFileName ( ) ) ; $ file -> seek ( $ reflection -> getStartLine ( ) - 1 ) ; $ code = '' ; while ( $ file -> key ( ) < $ reflection -> getEndLine ( ) ) { $ code .= $ fi...
Get the code of the inner callback as string .
13,287
public function addSidebars ( $ configs ) { $ default = [ 'name' => Translate :: t ( 'configuration.sidebar.name' ) , 'id' => '' , 'description' => '' , 'class' => '' , 'before_widget' => '' , 'after_widget' => '' , 'before_title' => '' , 'after_title' => '' , ] ; if ( empty ( $ configs ) ) { return ; } foreach ( $ con...
Register sidebars to WP .
13,288
protected function compile ( ) { if ( $ this -> objWrapper -> getType ( ) == ContentWrapper \ Model :: TYPE_START ) { $ this -> Template -> count = ContentWrapper \ Repository :: countRelatedElements ( $ this -> objWrapper ) ; $ cssID = $ this -> cssID ; if ( $ cssID [ 0 ] == '' ) { $ cssID [ 0 ] = sprintf ( $ this -> ...
compile wrapper element
13,289
public function headerDeferJavascripts ( ) { add_filter ( 'script_loader_tag' , function ( $ tag , $ handle ) { if ( strpos ( $ tag , '/wp-includes/js/jquery/jquery' ) ) { return $ tag ; } if ( isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) && false !== strpos ( $ _SERVER [ 'HTTP_USER_AGENT' ] , 'MSIE 9.' ) ) { return $ tag...
Defer Javascripts calls
13,290
public function headerWpHead ( $ key ) { if ( in_array ( $ key , [ 'parent_post_rel_link' , 'start_post_rel_link' ] ) ) { remove_action ( 'wp_head' , $ key , 10 , 0 ) ; } else if ( 'wp_resource_hints' === $ key ) { remove_action ( 'wp_head' , $ key , 2 ) ; } else { remove_action ( 'wp_head' , $ key ) ; } }
Remove the next and previous post links from the header
13,291
protected function trait_get_child_details ( ) { $ table = self :: trait_get_child_database_table ( ) ; if ( $ table === null ) { return ; } if ( ! isset ( $ this -> id ) OR $ this -> id === null ) { throw new \ Exception ( 'Could not fetch ' . $ table . ' data: id not set' ) ; } $ db = self :: trait_get_database ( ) ;...
Get the child details of this object
13,292
public static function strictCheck ( string $ firstValue , string $ secondValue ) : bool { return $ firstValue === $ secondValue ? TRUE : FALSE ; }
Performs strick check on values parsed in .
13,293
protected function setExternals ( ) { if ( empty ( $ this -> externals ) ) { return ; } $ externals = [ ] ; $ internals = $ this -> internals ; foreach ( $ this -> externals as $ alias => $ component ) { $ class = new \ ReflectionClass ( $ component ) ; $ path = dirname ( dirname ( $ class -> getFileName ( ) ) ) . S . ...
Prepare externals .
13,294
public function getImageSize ( $ file , $ force = false ) { $ cache = false ; if ( $ this -> container -> has ( 'nyrodev_image_cache' ) ) { $ cache = $ this -> get ( 'nyrodev_image_cache' ) ; } $ cacheKey = 'imageSize_' . sha1 ( $ file ) ; $ imageSize = [ ] ; if ( $ force || ! $ cache || ! $ cache -> contains ( $ cache...
Get image size array possibily using a cache if configured .
13,295
public function hexa2dec ( $ col ) { if ( '#' === substr ( $ col , 0 , 1 ) ) { $ col = substr ( $ col , 1 ) ; } return array ( base_convert ( substr ( $ col , 0 , 2 ) , 16 , 10 ) , base_convert ( substr ( $ col , 2 , 2 ) , 16 , 10 ) , base_convert ( substr ( $ col , 4 , 2 ) , 16 , 10 ) , ) ; }
Convert an hexadecimal color to an rgb .
13,296
public function handleGetReferer ( GetReferrerEvent $ event ) { $ systemAdapter = $ this -> framework -> getAdapter ( System :: class ) ; $ event -> setReferrerUrl ( $ systemAdapter -> getReferer ( $ event -> isEncodeAmpersands ( ) , $ event -> getTableName ( ) ) ) ; }
Retrieve the current referrer url .
13,297
public function handleLog ( LogEvent $ event ) { $ level = TL_ERROR === $ event -> getCategory ( ) ? LogLevel :: ERROR : LogLevel :: INFO ; $ this -> logger -> log ( $ level , $ event -> getText ( ) , [ 'contao' => new ContaoContext ( $ event -> getFunction ( ) , $ event -> getCategory ( ) ) ] ) ; }
Handle a log event .
13,298
public function handleLoadLanguageFile ( LoadLanguageFileEvent $ event ) { $ systemAdapter = $ this -> framework -> getAdapter ( System :: class ) ; $ systemAdapter -> loadLanguageFile ( $ event -> getFileName ( ) , $ event -> getLanguage ( ) , $ event -> isCacheIgnored ( ) ) ; }
Handle a load language file event .
13,299
public function prePersist ( LifecycleEventArgs $ args ) : void { $ object = $ args -> getObject ( ) ; if ( ! $ object instanceof PublishableInterface ) { return ; } if ( $ object -> isActive ( ) ) { $ object -> setPublished ( true ) ; } else { $ object -> setPublished ( false ) ; } }
If an object is active set published value .