idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
13,000
|
private function analyzeModel ( $ model , $ textOnly ) { $ featureNum = count ( $ model -> getFeatures ( ) ) ; $ rootFeatureName = $ model -> getRootFeature ( ) -> getName ( ) ; $ constraintNum = count ( $ model -> getConstraintSolver ( ) -> getConstraints ( ) ) ; $ ruleNum = count ( $ model -> getXmlModel ( ) -> getRules ( ) ) ; $ str = "" ; $ maxLen = fphp \ Helper \ _String :: getMaxLength ( $ model -> getFeatures ( ) , "getName" ) ; if ( $ textOnly ) $ str .= "The given feature model with the root feature " . "$this->accentColor$rootFeatureName$this->defaultColor has the following $featureNum features:\n\n" ; else { $ str .= "<div>" ; $ str .= "<p>The given feature model with the root feature <span class='feature'>$rootFeatureName</span> " . "has the following $featureNum features:</p>" ; $ str .= "<ul>" ; } foreach ( $ model -> getFeatures ( ) as $ feature ) { $ description = $ feature -> getDescription ( ) ; if ( $ this -> productLine ) $ class = $ this -> productLine -> getArtifact ( $ feature ) -> isGenerated ( ) ? "" : "unimplemented" ; else $ class = "" ; if ( $ textOnly ) { $ color = $ class === "unimplemented" ? "" : $ this -> accentColor ; $ str .= sprintf ( "%s%-{$maxLen}s$this->defaultColor %s\n" , $ color , $ feature -> getName ( ) , fphp \ Helper \ _String :: truncate ( $ description ) ) ; } else $ str .= "<li><span class='feature $class'>" . $ feature -> getName ( ) . ( $ description ? "</span><br /><span style='font-size: 0.8em'>" . str_replace ( "\n" , "<br />" , $ description ) . "</span>" : "" ) . "</li>" ; } if ( $ textOnly ) $ str .= "\nThere are $constraintNum feature constraints ($ruleNum of them cross-tree constraints).\n" ; else { $ str .= "</ul>" ; $ str .= "<p>There are $constraintNum feature constraints ($ruleNum of them cross-tree constraints).</p>" ; $ str .= "</div>" ; } return $ str ; }
|
Returns a model analysis .
|
13,001
|
private function analyzeConfiguration ( $ configuration , $ textOnly ) { $ validity = $ configuration -> isValid ( ) ? "valid" : "invalid" ; $ str = "" ; $ selectedColor = "\033[1;32m" ; $ deselectedColor = "\033[1;31m" ; if ( $ textOnly ) $ str .= "The given configuration has the following feature selection:\n\n" ; else { $ str .= "<div style='font-family: monospace'>" ; $ str .= "<p>The given configuration has the following feature selection:</p>" ; $ str .= "<ul>" ; } foreach ( $ configuration -> getModel ( ) -> getFeatures ( ) as $ feature ) { $ isSelected = Feature :: has ( $ configuration -> getSelectedFeatures ( ) , $ feature ) ; $ mark = $ isSelected ? "x" : " " ; $ class = $ isSelected ? "selected" : "deselected" ; if ( $ textOnly ) $ str .= "[" . ( $ isSelected ? "x" : " " ) . "] " . ( $ isSelected ? $ selectedColor : $ deselectedColor ) . $ feature -> getName ( ) . "$this->defaultColor\n" ; else $ str .= "<li>[$mark] <span class='feature $class'>" . $ feature -> getName ( ) . "</span></li>" ; } if ( $ textOnly ) $ str .= "\nThis configuration is $validity.\n" ; else { $ str .= "</ul>" ; $ str .= "<p>This configuration is $validity.</p>" ; $ str .= "</div>" ; } return $ str ; }
|
Returns a configuration analysis .
|
13,002
|
public function getConfigTreeBuilder ( ) { $ treeBuilder = new TreeBuilder ( ) ; $ rootNode = $ treeBuilder -> root ( 'gauges' ) ; $ rootNode -> useAttributeAsKey ( 'path' ) -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'class' ) -> isRequired ( ) -> cannotBeEmpty ( ) -> end ( ) -> variableNode ( 'arguments' ) -> end ( ) -> end ( ) ; return $ treeBuilder ; }
|
Provides configuration mapping
|
13,003
|
public function execute ( ProjectDescriptor $ project ) { $ this -> setObjectAliasesList ( $ project -> getIndexes ( ) -> elements -> getAll ( ) ) ; $ this -> substitute ( $ project ) ; }
|
Executes the linker .
|
13,004
|
public function substitute ( $ item , $ container = null ) { $ result = null ; if ( is_string ( $ item ) ) { $ result = $ this -> findAlias ( $ item , $ container ) ; } elseif ( is_array ( $ item ) || ( $ item instanceof \ Traversable && ! $ item instanceof ProjectInterface ) ) { $ isModified = false ; foreach ( $ item as $ key => $ element ) { $ isModified = true ; $ element = $ this -> substitute ( $ element , $ container ) ; if ( $ element !== null ) { $ item [ $ key ] = $ element ; } } if ( $ isModified ) { $ result = $ item ; } } elseif ( is_object ( $ item ) && $ item instanceof UnknownTypeDescriptor ) { $ alias = $ this -> findAlias ( $ item -> getName ( ) ) ; $ result = $ alias ? : $ item ; } elseif ( is_object ( $ item ) ) { $ hash = spl_object_hash ( $ item ) ; if ( isset ( $ this -> processedObjects [ $ hash ] ) ) { return null ; } $ newContainer = ( $ this -> isDescriptorContainer ( $ item ) ) ? $ item : $ container ; $ this -> processedObjects [ $ hash ] = true ; $ objectClassName = get_class ( $ item ) ; $ fieldNames = isset ( $ this -> substitutions [ $ objectClassName ] ) ? $ this -> substitutions [ $ objectClassName ] : array ( ) ; foreach ( $ fieldNames as $ fieldName ) { $ fieldValue = $ this -> findFieldValue ( $ item , $ fieldName ) ; $ response = $ this -> substitute ( $ fieldValue , $ newContainer ) ; if ( $ response !== null ) { $ setter = 'set' . ucfirst ( $ fieldName ) ; $ item -> $ setter ( $ response ) ; } } } return $ result ; }
|
Substitutes the given item or its children s FQCN with an object alias .
|
13,005
|
protected function isDescriptorContainer ( $ item ) { return $ item instanceof FileDescriptor || $ item instanceof NamespaceDescriptor || $ item instanceof ClassDescriptor || $ item instanceof TraitDescriptor || $ item instanceof InterfaceDescriptor ; }
|
Returns true if the given Descriptor is a container type .
|
13,006
|
protected function replacePseudoTypes ( $ fqsen , $ container ) { $ pseudoTypes = array ( 'self' , '$this' ) ; foreach ( $ pseudoTypes as $ pseudoType ) { if ( ( strpos ( $ fqsen , $ pseudoType . '::' ) === 0 || $ fqsen === $ pseudoType ) && $ container ) { $ fqsen = $ container -> getFullyQualifiedStructuralElementName ( ) . substr ( $ fqsen , strlen ( $ pseudoType ) ) ; } } return $ fqsen ; }
|
Replaces pseudo - types such as self into a normalized version based on the last container that was encountered .
|
13,007
|
protected function fetchElementByFqsen ( $ fqsen ) { return isset ( $ this -> elementList [ $ fqsen ] ) ? $ this -> elementList [ $ fqsen ] : null ; }
|
Attempts to find an element with the given Fqsen in the list of elements for this project and returns null if it cannot find it .
|
13,008
|
public function widget ( $ args , $ instance ) { $ content = $ this -> widget_content ( $ instance ) ; if ( $ content ) { echo $ args [ 'before_widget' ] ; if ( isset ( $ instance [ 'title' ] ) && ! empty ( $ instance [ 'title' ] ) ) { echo $ args [ 'before_title' ] ; echo $ instance [ 'title' ] ; echo $ args [ 'after_title' ] ; } echo $ content ; echo $ args [ 'after_widget' ] ; } }
|
Show widget content
|
13,009
|
protected function fill ( $ placeholder , $ instance ) { switch ( $ placeholder ) { case 'title' : return get_the_title ( ) ; break ; case 'url' : return get_permalink ( ) ; break ; case 'excerpt' : return get_the_excerpt ( ) ; break ; case 'date' : return get_the_date ( ) ; break ; case 'modified' : return get_the_modified_date ( ) ; break ; case 'author' : return get_the_author ( ) ; break ; default : return false ; break ; } }
|
Get placeholder s content
|
13,010
|
public function take ( ) { $ params = array_merge ( array ( 'author' => null , 'categories' => null ) , $ this -> input -> getOptions ( ) ) ; $ params = $ this -> fixAuthorSetupParameters ( $ params ) ; $ params = $ this -> fixCategoriesSetupParameters ( $ params ) ; $ this -> writeOutputLine ( "writing site configuration..." , 2 ) ; $ this -> store -> write ( $ params ) ; $ this -> writeOutputLine ( "done" , 2 ) ; }
|
Creates the site structure .
|
13,011
|
protected function fixAuthorSetupParameters ( array $ params ) { if ( ! isset ( $ params [ 'author' ] ) ) { $ params [ 'author' ] = null ; } if ( preg_match ( '/(.*) <(.+)>/' , $ params [ 'author' ] , $ m ) ) { $ params [ 'author' ] = $ m [ 1 ] ; $ params [ 'author-email' ] = $ m [ 2 ] ; } else { $ params [ 'author-email' ] = null ; } return $ params ; }
|
Fixes the author setup parameter .
|
13,012
|
public function field ( string $ field , ... $ rules ) : self { $ this -> validators [ $ field ] = $ this -> parser -> parse ( $ rules ) ; return $ this ; }
|
Adds one or more rules to this builder .
|
13,013
|
public function build ( $ ruleset = null ) : Validator { $ validators = array_merge ( [ ] , $ this -> validators ) ; if ( is_object ( $ ruleset ) || ( is_array ( $ ruleset ) && Parser :: isAssociative ( $ ruleset ) ) ) { foreach ( $ ruleset as $ field => $ rules ) { $ validators [ $ field ] = $ this -> parser -> parse ( $ rules ) ; } } return new Validator ( $ validators ) ; }
|
Builds a validator for the provided ruleset .
|
13,014
|
public function cmdGetShipping ( ) { $ result = $ this -> getListShipping ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableShipping ( $ result ) ; $ this -> output ( ) ; }
|
Callback for shipping - get command
|
13,015
|
protected function getListShipping ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { $ list = $ this -> shipping -> getList ( ) ; $ this -> limitArray ( $ list ) ; return $ list ; } $ method = $ this -> shipping -> get ( $ id ) ; if ( empty ( $ method ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } return array ( $ method ) ; }
|
Returns an array of shipping methods
|
13,016
|
public function setArraySource ( array $ data = null ) { if ( $ data === null ) { $ this -> iterator = null ; } else { $ this -> iterator = new \ ArrayIterator ( $ data ) ; } }
|
Array as import source
|
13,017
|
public function setIteratorSource ( \ Iterator $ iterator = null , $ start = 0 , $ end = - 1 ) { $ this -> iteratorstartindex = ( int ) $ start ; $ this -> iteratorendindex = ( int ) $ end ; $ this -> iterator = $ iterator ; }
|
Iterator as import source
|
13,018
|
public function importInto ( ArrayBase $ collection ) { if ( $ this -> iterator instanceof \ Iterator ) { $ i = 0 ; foreach ( $ this -> iterator as $ key => $ row ) { if ( $ this -> iteratorendindex >= 0 && $ i > $ this -> iteratorendindex ) { break ; } elseif ( $ i >= $ this -> iteratorstartindex ) { $ tempkey = $ key ; $ tempvalue = $ row ; if ( $ tempvalue !== null && $ tempkey !== null ) { $ collection -> set ( $ tempkey , $ tempvalue ) ; } } $ i ++ ; } } }
|
Import into ArrayBase
|
13,019
|
public function newInstance ( ) { $ class = get_called_class ( ) ; $ instance = new $ class ( ) ; $ instance -> setSerializer ( $ this -> getSerializer ( ) ) ; $ instance -> setItemConverter ( $ this -> getItemConverter ( ) -> newInstance ( ) ) ; return $ instance ; }
|
Creates a new instance of this class
|
13,020
|
public function setUp ( $ entityClass , array $ entityProperties , $ collectionClass , RepositoryInterface $ entityRepository = null ) { @ trigger_error ( __METHOD__ . '() is deprecated and will be removed in 2.0. Please use configureMetadata() instead.' , E_USER_DEPRECATED ) ; if ( $ entityRepository ) { @ trigger_error ( 'Repository injection throught ' . __METHOD__ . '() is deprecated and will be removed in 2.0. Please inject it by constructor.' , E_USER_DEPRECATED ) ; $ this -> entityRepository = $ entityRepository ; } return $ this -> configureMetadata ( $ entityClass , $ entityProperties , $ collectionClass ) ; }
|
setUp method .
|
13,021
|
public function create ( $ fileName , $ data ) { $ path = $ this -> getPathBase ( $ fileName ) ; if ( file_exists ( $ path ) ) { return ; } $ data = serialize ( $ data ) ; return file_put_contents ( $ path , $ data ) ; }
|
serialises and creates cache file if required if the file already exists skip this
|
13,022
|
public function read ( $ fileName ) { $ path = $ this -> getPathBase ( $ fileName ) ; if ( ! file_exists ( $ path ) ) { return ; } $ data = file_get_contents ( $ path ) ; return $ this -> data = unserialize ( $ data ) ; }
|
reads in the cached file if it exists unserialises and stores in data property
|
13,023
|
public function delete ( $ fileName ) { $ path = $ this -> getPathBase ( $ fileName ) ; if ( ! file_exists ( $ path ) ) { return ; } return unlink ( $ path ) ; }
|
removes the file from the cache
|
13,024
|
public function checkOptions ( MvcEvent $ e ) { $ matches = $ e -> getRouteMatch ( ) ; $ response = $ e -> getResponse ( ) ; $ request = $ e -> getRequest ( ) ; $ method = $ request -> getMethod ( ) ; if ( $ matches -> getParam ( 'id' , false ) ) { if ( ! in_array ( $ method , $ this -> allowedResourceMethods ) ) { $ response -> setStatusCode ( 405 ) ; return $ response ; } return ; } if ( ! in_array ( $ method , $ this -> allowedCollectionMethods ) ) { $ response -> setStatusCode ( 405 ) ; return $ response ; } }
|
Checks that is an allowed method
|
13,025
|
public function injectLinkHeader ( MvcEvent $ e ) { $ response = $ e -> getResponse ( ) ; $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeaderLine ( 'Access-Control-Allow-Origin' , '*' ) ; $ headers -> addHeaderLine ( 'Access-Control-Allow-Methods' , 'POST PUT DELETE GET' ) ; }
|
Inject documentation link header to the response
|
13,026
|
private function buildQuery ( $ pattern , $ args ) { if ( count ( $ args [ 'parameters' ] ) > 0 ) { $ string = $ pattern [ 0 ] ; } else { $ string = $ pattern [ 1 ] ; } if ( preg_match_all ( "/:(\w+)/" , $ string , $ match ) ) { $ match = $ match [ 0 ] ; $ values = array_values ( $ args ) ; return str_replace ( $ match , $ values , $ string ) ; } }
|
create the a sql query
|
13,027
|
public function endpoint ( ) { $ endpoint = $ this -> getset ( 'endpoint' , func_get_args ( ) ) ; return $ this -> validateEndpoint ( $ endpoint ? : self :: URI_API ) ; }
|
Get and optionally set the endpoint .
|
13,028
|
public function authorizationEndpoint ( ) { $ endpoint = $ this -> getset ( 'authorization_endpoint' , func_get_args ( ) ) ; return $ this -> validateEndpoint ( $ endpoint ? : self :: URI_AUTHORIZE ) ; }
|
Get and optionally set the authorization endpoint .
|
13,029
|
protected function run ( $ method , $ args ) { $ request = $ this -> request ( ) ; $ request -> method ( $ method ) ; $ request -> resource ( array_shift ( $ args ) ) ; if ( count ( $ args ) ) { $ request -> params ( array_shift ( $ args ) ) ; } if ( count ( $ args ) ) { $ request -> files ( array_shift ( $ args ) ) ; } return $ request -> send ( ) ; }
|
Convenience method for sending a request and returning a response .
|
13,030
|
public function isAbstract ( $ status = null ) { $ this -> is_abstract = $ status !== null ? $ status : $ this -> is_abstract ; return $ this -> is_abstract ; }
|
Is an abstract class
|
13,031
|
public function addParam ( \ Deflection \ Element \ Param $ param ) { $ element = $ param -> getElement ( ) ; $ this -> params = array_merge ( $ this -> params , array ( '' ) , $ element ) ; return $ this ; }
|
Add function to structure
|
13,032
|
public function addFunction ( \ Deflection \ Element \ Functions $ function ) { $ element = $ function -> getElement ( ) ; $ this -> functions = array_merge ( $ this -> functions , array ( '' ) , $ element ) ; return $ this ; }
|
Add param to structure
|
13,033
|
public function isAllowed ( $ role , $ resource ) { if ( false === is_string ( $ role ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ role ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ resource ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ resource ) ) , E_USER_ERROR ) ; } if ( true === isset ( $ this -> permissions [ $ role ] [ $ resource ] ) ) { return $ this -> permissions [ $ role ] [ $ resource ] ; } return false ; }
|
Returns if a role is allowed access to the resource
|
13,034
|
public function inherit ( $ roles , $ inherits ) { if ( true === is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } if ( true === is_string ( $ inherits ) ) { $ inherits = [ $ inherits ] ; } if ( false === is_array ( $ roles ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ roles ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ inherits ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ inherits ) ) , E_USER_ERROR ) ; } foreach ( $ inherits as $ inherit ) { if ( true === isset ( $ this -> permissions [ $ inherit ] ) ) { foreach ( $ this -> permissions [ $ inherit ] as $ resource => $ allowed ) { foreach ( $ roles as $ role ) { $ this -> fill ( $ role , $ resource , $ allowed ) ; } } } } return $ this ; }
|
Let a single or multiple roles inherit the resources of other single or multiple roles
|
13,035
|
public function getRoles ( ) { $ roles = [ ] ; foreach ( $ this -> permissions as $ role => $ permissions ) { $ roles [ $ role ] = $ this -> getRole ( $ role ) ; } return $ roles ; }
|
Returns all the roles as an array
|
13,036
|
public function getRole ( $ role ) { if ( false === is_string ( $ role ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ role ) ) , E_USER_ERROR ) ; } foreach ( $ this -> permissions as $ type => $ resources ) { if ( $ role === $ type ) { $ p = new Resources ( ) ; $ p -> setResources ( $ resources ) ; return $ p ; } } return null ; }
|
Returns the roles in array
|
13,037
|
public function getResources ( $ match = null ) { if ( null !== $ match && false === is_string ( $ match ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ match ) ) , E_USER_ERROR ) ; } $ permissions = [ ] ; $ match = null === $ match ? '.*?' : $ match ; foreach ( $ this -> permissions as $ permission ) { foreach ( $ permission as $ type => $ value ) { if ( preg_match ( sprintf ( '#%s#' , str_replace ( '#' , '\#' , $ match ) ) , $ type ) ) { $ permissions [ ] = $ type ; } } } return array_unique ( $ permissions ) ; }
|
Returns all the resourses in array
|
13,038
|
private function fill ( $ roles , $ resources , $ allow ) { if ( true === is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } if ( true === is_string ( $ resources ) ) { $ resources = [ $ resources ] ; } if ( false === is_array ( $ roles ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ roles ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ resources ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string or array, "%s" given' , __METHOD__ , gettype ( $ resources ) ) , E_USER_ERROR ) ; } if ( false === is_bool ( $ allow ) ) { return trigger_error ( sprintf ( 'Argument 3 passed to %s() must be of the type boolean, "%s" given' , __METHOD__ , gettype ( $ allow ) ) , E_USER_ERROR ) ; } foreach ( $ roles as $ role ) { if ( false === is_string ( $ role ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must contain only strings, "%s" given' , __METHOD__ , gettype ( $ role ) ) , E_USER_ERROR ) ; } if ( false === isset ( $ this -> permissions [ $ role ] ) ) { $ this -> permissions [ $ role ] = [ ] ; } foreach ( $ resources as $ resource ) { if ( false === is_string ( $ resource ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must contain only strings, "%s" given' , __METHOD__ , gettype ( $ resource ) ) , E_USER_ERROR ) ; } $ this -> permissions [ $ role ] [ $ resource ] = $ allow ; } } return $ this ; }
|
Add a new permission entry
|
13,039
|
public function touch ( ) { $ path = $ this -> getFullPath ( ) ; if ( file_exists ( $ path ) ) { if ( ! is_writable ( $ path ) ) Path :: makeWritable ( $ path ) ; } touch ( $ path ) ; Path :: setPermissions ( $ path ) ; }
|
Touch the file updating its permissions
|
13,040
|
public function getMime ( ) { if ( ! $ this -> mime ) { $ type = FileType :: getFromFile ( $ this -> getFullPath ( ) ) ; $ this -> mime = $ type -> getMimeType ( ) ; } return $ this -> mime ; }
|
Return the appropriate mime type for the file
|
13,041
|
public function open ( string $ mode ) { $ read = strpbrk ( $ mode , "r+" ) !== false ; $ write = strpbrk ( $ mode , "waxc+" ) !== false ; $ x = strpbrk ( $ mode , "x" ) !== false ; $ path = $ this -> getFullPath ( ) ; $ fh = @ fopen ( $ path , $ mode ) ; if ( is_resource ( $ fh ) ) return $ fh ; if ( $ x && file_exists ( $ path ) ) throw new IOException ( "File already exists: " . $ path ) ; if ( $ write && ! is_writable ( $ path ) ) throw new IOException ( "File is not writable: " . $ path ) ; if ( $ read && ! is_readable ( $ path ) ) throw new IOException ( "File is not readable: " . $ path ) ; throw new IOException ( "Invalid mode for opening file: " . $ mode ) ; }
|
Open the file for reading or writing throwing informative exceptions when it fails .
|
13,042
|
public function arrayToClassElement ( $ definition ) { $ class = new Classes ( ) ; if ( isset ( $ definition [ 'docblock' ] ) ) { $ docblock = $ this -> arrayToDocblockElement ( $ definition [ 'docblock' ] ) ; $ class -> setDocbloc ( $ docblock ) ; } if ( isset ( $ definition [ 'namespace' ] ) ) { $ class -> setNamespace ( $ definition [ 'namespace' ] ) ; } if ( isset ( $ definition [ 'name' ] ) ) { $ class -> setName ( $ definition [ 'name' ] ) ; } if ( isset ( $ definition [ 'extends' ] ) ) { $ class -> setExtends ( $ definition [ 'extends' ] ) ; } if ( isset ( $ definition [ 'implements' ] ) ) { foreach ( $ definition [ 'implements' ] as $ interface ) { $ class -> addImplements ( $ interface ) ; } } if ( isset ( $ definition [ 'uses' ] ) ) { foreach ( $ definition [ 'uses' ] as $ alias => $ use ) { $ alias = is_string ( $ alias ) ? $ alias : null ; $ class -> addUse ( $ use , $ alias ) ; } } if ( isset ( $ definition [ 'functions' ] ) ) { foreach ( $ definition [ 'functions' ] as $ definition ) { $ function = $ this -> arrayToFunctionElement ( $ definition ) ; $ class -> addFunction ( $ function ) ; } } return $ class ; }
|
Transform an array to a class element object
|
13,043
|
public function arrayToDocblockElement ( array $ definition ) { $ docblock = new Docblock ( ) ; if ( isset ( $ definition [ 'description' ] ) ) { $ docblock -> setDescription ( $ definition [ 'description' ] ) ; } if ( isset ( $ definition [ 'params' ] ) ) { foreach ( $ definition [ 'params' ] as $ param => $ infos ) { $ type = isset ( $ infos [ 'type' ] ) ? $ infos [ 'type' ] : '' ; $ description = isset ( $ infos [ 'description' ] ) ? $ infos [ 'description' ] : '' ; $ docblock -> addVar ( $ param , $ type , $ description ) ; } } if ( isset ( $ definition [ 'return' ] ) ) { $ docblock -> addParam ( 'return' , $ definition [ 'return' ] ) ; } if ( isset ( $ definition [ 'infos' ] ) ) { foreach ( $ definition [ 'infos' ] as $ name => $ value ) { $ docblock -> addParam ( $ name , $ value ) ; } } return $ docblock ; }
|
Returns well formated header with descriptions param return ...
|
13,044
|
public function arrayToFunctionElement ( array $ definition ) { $ function = new Functions ; if ( isset ( $ definition [ 'docblock' ] ) ) { $ docblock = $ this -> arrayToDocblockElement ( $ definition [ 'docblock' ] ) ; $ function -> setDocbloc ( $ docblock ) ; } if ( isset ( $ definition [ 'public' ] ) ) { $ function -> isPublic ( true ) ; } if ( isset ( $ definition [ 'name' ] ) ) { $ function -> setName ( $ definition [ 'name' ] ) ; } if ( isset ( $ definition [ 'params' ] ) ) { foreach ( $ definition [ 'params' ] as $ name => $ type ) { $ function -> addParam ( $ name , $ type ) ; } } if ( isset ( $ definition [ 'content' ] ) ) { $ function -> setContent ( $ definition [ 'content' ] ) ; } return $ function ; }
|
Returns well formated function declaration
|
13,045
|
public static function errToException ( $ turnOn = true ) { if ( ! $ turnOn ) { return set_error_handler ( null ) ; } $ handler = function ( $ errno , $ errStr , $ errFile , $ errLine ) { if ( ! ( error_reporting ( ) & $ errno ) ) { return ; } throw new ErrorException ( $ errStr , 0 , $ errno , $ errFile , $ errLine ) ; } ; return set_error_handler ( $ handler ) ; }
|
Change errors to exceptions .
|
13,046
|
public function & __get ( $ name ) { list ( $ result , $ found ) = $ this -> peridotScanChildren ( $ this , function ( $ childScope , & $ accumulator ) use ( $ name ) { if ( property_exists ( $ childScope , $ name ) ) { $ accumulator = [ $ childScope -> $ name , true , $ childScope ] ; } } ) ; if ( ! $ found ) { throw new DomainException ( "Scope property $name not found" ) ; } return $ result ; }
|
Lookup properties on child scopes .
|
13,047
|
protected function peridotScanChildren ( Scope $ scope , callable $ fn , & $ accumulator = [ ] ) { if ( ! empty ( $ accumulator ) ) { return $ accumulator ; } $ children = $ scope -> peridotGetChildScopes ( ) ; foreach ( $ children as $ childScope ) { $ fn ( $ childScope , $ accumulator ) ; $ this -> peridotScanChildren ( $ childScope , $ fn , $ accumulator ) ; } if ( empty ( $ accumulator ) ) { return [ null , false ] ; } return $ accumulator ; }
|
Scan child scopes and execute a function against each one passing an accumulator reference along .
|
13,048
|
public static function prepareContainer ( $ id ) { if ( array_key_exists ( 'id' , self :: $ container ) ) { return static :: $ container [ $ id ] ; } $ model = ColumnsetModel :: findByPk ( $ id ) ; if ( $ model === null ) { static :: $ container [ $ id ] = null ; return null ; } $ sizes = deserialize ( $ model -> sizes , true ) ; $ container = array ( ) ; foreach ( $ sizes as $ size ) { $ key = 'columnset_' . $ size ; $ columns = deserialize ( $ model -> { $ key } , true ) ; foreach ( $ columns as $ index => $ column ) { if ( isset ( $ container [ $ index ] [ 0 ] ) ) { $ container [ $ index ] [ 0 ] .= ' ' . self :: prepareSize ( $ size , deserialize ( $ column , true ) ) ; } else { $ container [ $ index ] [ 0 ] .= self :: prepareSize ( $ size , deserialize ( $ column , true ) ) ; } } } static :: $ container [ $ id ] = $ container ; return $ container ; }
|
prepare the container which sub columns expects
|
13,049
|
protected static function prepareSize ( $ size , array $ definition ) { $ css = sprintf ( 'col-%s-%s' , $ size , $ definition [ 'width' ] ) ; if ( $ definition [ 'offset' ] ) { $ css .= sprintf ( ' col-%s-offset-%s' , $ size , $ definition [ 'offset' ] ) ; } if ( $ definition [ 'order' ] ) { $ css .= sprintf ( ' col-%s-%s' , $ size , $ definition [ 'order' ] ) ; } return $ css ; }
|
generates the css class defnition for one column
|
13,050
|
public function appendColumnsetIdToPalette ( $ dc ) { if ( $ GLOBALS [ 'TL_CONFIG' ] [ 'subcolumns' ] != 'bootstrap_customizable' ) { return ; } if ( $ dc -> table == 'tl_content' ) { $ model = \ ContentModel :: findByPK ( $ dc -> id ) ; if ( $ model -> sc_type > 0 ) { \ MetaPalettes :: appendFields ( $ dc -> table , 'colsetStart' , 'colset' , array ( 'columnset_id' ) ) ; } } else { $ model = \ ModuleModel :: findByPk ( $ dc -> id ) ; if ( $ model -> sc_type > 0 ) { if ( $ model -> sc_type > 0 ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_module' ] [ 'palettes' ] [ 'subcolumns' ] = str_replace ( 'sc_type,' , 'sc_type,columnset_id,' , $ GLOBALS [ 'TL_DCA' ] [ 'tl_module' ] [ 'palettes' ] [ 'subcolumns' ] ) ; } } } }
|
add column set field to the colsetStart content element . We need to do it dynamically because subcolumns creates its palette dynamically
|
13,051
|
public function appendColumnSizesToPalette ( $ dc ) { $ model = ColumnsetModel :: findByPk ( $ dc -> id ) ; $ sizes = array_merge ( deserialize ( $ model -> sizes , true ) ) ; foreach ( $ sizes as $ size ) { $ field = 'columnset_' . $ size ; \ MetaPalettes :: appendFields ( 'tl_columnset' , 'columnset' , array ( $ field ) ) ; } }
|
Append column sizes fields dynamically to the palettes . Not using
|
13,052
|
public function createColumns ( $ value , $ mcw ) { $ columns = ( int ) $ mcw -> activeRecord -> columns ; $ value = deserialize ( $ value , true ) ; $ count = count ( $ value ) ; if ( $ count == 0 ) { for ( $ i = 0 ; $ i < $ columns ; $ i ++ ) { $ value [ $ i ] [ 'width' ] = floor ( 12 / $ columns ) ; } } elseif ( $ count > $ columns ) { $ count = count ( $ value ) - $ columns ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { array_pop ( $ value ) ; } } else { for ( $ i = 0 ; $ i < ( $ columns - $ count ) ; $ i ++ ) { $ value [ $ i + $ count ] [ 'width' ] = floor ( 12 / $ columns ) ; } } return $ value ; }
|
create a MCW row for each column
|
13,053
|
public function getAllTypes ( $ dc ) { if ( $ GLOBALS [ 'TL_CONFIG' ] [ 'subcolumns' ] != 'bootstrap_customizable' ) { $ sc = new \ tl_content_sc ( ) ; return $ sc -> getAllTypes ( ) ; } $ this -> import ( 'Database' ) ; $ collection = $ this -> Database -> execute ( 'SELECT columns FROM tl_columnset GROUP BY columns ORDER BY columns' ) ; $ types = array ( ) ; while ( $ collection -> next ( ) ) { $ types [ ] = $ collection -> columns ; } return $ types ; }
|
replace subcolumns getAllTypes method to load all created columnsets . There is a fallback provided if not bootstra_customizable is used
|
13,054
|
public function getAllColumnsets ( $ dc ) { $ collection = ColumnsetModel :: findBy ( 'published=1 AND columns' , $ dc -> activeRecord -> sc_type , array ( 'order' => 'title' ) ) ; $ set = array ( ) ; if ( $ collection !== null ) { while ( $ collection -> next ( ) ) { $ set [ $ collection -> id ] = $ collection -> title ; } } return $ set ; }
|
get all columnsets which fits to the selected type
|
13,055
|
public function getService ( $ service ) { foreach ( $ this -> queue as $ extension ) { $ new = call_user_func ( $ extension , $ service , $ this -> container ) ; if ( $ new ) { $ service = $ new ; } } return $ service ; }
|
Gets the extended version of the service .
|
13,056
|
public function update ( array $ collection ) { foreach ( $ collection as $ key => $ value ) { $ this -> collection [ $ key ] = $ value ; } return $ this ; }
|
Update and append to Collection array
|
13,057
|
public function at ( $ index ) { $ return = NULL ; $ index = intval ( $ index ) ; $ data = $ this -> asArray ( ) ; reset ( $ data ) ; if ( $ index < 0 ) { $ index += $ this -> length ( ) ; } $ c = 1 ; while ( $ c <= $ index ) { next ( $ data ) ; $ c ++ ; } $ return = current ( $ data ) ; $ Model = $ this -> buildModel ( $ return ) ; if ( $ Model !== NULL ) { $ return = $ Model ; } return $ return ; }
|
Get a model based on numerical index
|
13,058
|
protected function updateCollection ( ) { $ responseBody = $ this -> Response -> getBody ( ) ; if ( is_array ( $ responseBody ) ) { if ( isset ( $ this -> model ) ) { $ modelIdKey = $ this -> buildModel ( ) -> modelIdKey ( ) ; foreach ( $ responseBody as $ key => $ model ) { if ( isset ( $ model [ $ modelIdKey ] ) ) { $ this -> collection [ $ model [ $ modelIdKey ] ] = $ model ; } else { $ this -> collection [ ] = $ model ; } } } else { $ this -> collection = $ responseBody ; } } }
|
Configures the collection based on the Response Body
|
13,059
|
protected function buildModel ( array $ data = array ( ) ) { $ Model = NULL ; if ( isset ( $ this -> model ) ) { $ Model = new $ this -> model ( ) ; $ Model -> setBaseUrl ( $ this -> getBaseUrl ( ) ) ; if ( $ this -> getAuth ( ) !== NULL ) { $ Model -> setAuth ( $ this -> getAuth ( ) ) ; } if ( ! empty ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ Model -> set ( $ key , $ value ) ; } } } return $ Model ; }
|
Build the ModelEndpoint
|
13,060
|
private function detectPool ( CommandInterface $ command ) { $ commandClass = get_class ( $ command ) ; return $ this -> poolDetector -> detect ( $ commandClass ) ; }
|
Detect correct pool for given command .
|
13,061
|
public static function prefixArrayKeys ( $ array , $ prefix ) { $ prefixedArray = array ( ) ; foreach ( $ array as $ key => $ value ) { $ prefixedArray [ $ prefix . $ key ] = $ value ; } return $ prefixedArray ; }
|
Take an associative array as input and return a new array with all the original keys prefixed by the passed prefix .
|
13,062
|
public static function getAllArrayItemsByKeyPrefix ( $ array , $ prefix , $ stripPrefix = false ) { $ returnValues = array ( ) ; foreach ( $ array as $ key => $ value ) { $ positionOfPrefix = strpos ( $ key , $ prefix ) ; if ( is_numeric ( $ positionOfPrefix ) && $ positionOfPrefix == 0 ) { if ( $ stripPrefix ) $ key = substr ( $ key , strlen ( $ prefix ) ) ; $ returnValues [ $ key ] = $ value ; } } return $ returnValues ; }
|
Find all parameters in the passed array with a key starting with the supplied prefix . Return them as an associative array by key .
|
13,063
|
public static function arrayDiff ( $ array1 , $ array2 ) { return array_udiff ( $ array1 , $ array2 , function ( $ a , $ b ) { if ( is_object ( $ a ) ) { return strcmp ( spl_object_hash ( $ a ) , spl_object_hash ( $ b ) ) ; } else if ( is_array ( $ a ) ) { return ArrayUtils :: arrayDiff ( $ a , $ b ) ; } else { return strcmp ( $ a , $ b ) ; } } ) ; }
|
Diff function for arrays which works with arrays of objects as well as string comparables .
|
13,064
|
public static function recursiveMerge ( $ array1 , $ array2 ) { if ( $ array1 instanceof AssociativeArray ) { $ array1 = $ array1 -> toArray ( ) ; } if ( $ array2 instanceof AssociativeArray ) { $ array2 = $ array2 -> toArray ( ) ; } if ( ArrayUtils :: isAssociative ( $ array1 ) != ArrayUtils :: isAssociative ( $ array2 ) ) { if ( ArrayUtils :: isAssociative ( $ array1 ) ) { $ array1 = array ( $ array1 ) ; } else { $ array2 = array ( $ array2 ) ; } } $ combinedKeys = array_unique ( array_merge ( array_keys ( $ array1 ) , array_keys ( $ array2 ) ) ) ; $ mergedArray = array ( ) ; foreach ( $ combinedKeys as $ key ) { if ( isset ( $ array1 [ $ key ] ) && isset ( $ array2 [ $ key ] ) ) { if ( ( is_array ( $ array1 [ $ key ] ) || $ array1 [ $ key ] instanceof AssociativeArray ) && ( is_array ( $ array2 [ $ key ] ) || $ array2 [ $ key ] instanceof AssociativeArray ) ) { $ mergedArray [ $ key ] = ArrayUtils :: recursiveMerge ( $ array1 [ $ key ] , $ array2 [ $ key ] ) ; } else { $ mergedArray [ $ key ] = $ array1 [ $ key ] ; } } else { $ mergedArray [ $ key ] = isset ( $ array1 [ $ key ] ) ? $ array1 [ $ key ] : $ array2 [ $ key ] ; } } return $ mergedArray ; }
|
Recursively merge array1 and array2 . If keys exist in both arrays at any level take the value from array1 in preference .
|
13,065
|
public static function recursiveDiff ( $ array1 , $ array2 , $ caseInsensitive = true , $ matchingKeysOnly = true ) { if ( $ array1 instanceof AssociativeArray ) { $ array1 = $ array1 -> toArray ( ) ; } if ( $ array2 instanceof AssociativeArray ) { $ array2 = $ array2 -> toArray ( ) ; } $ sharedKeys = array_intersect ( array_keys ( $ array1 ) , array_keys ( $ array2 ) ) ; $ diffArray = array ( ) ; foreach ( $ sharedKeys as $ key ) { if ( ( is_array ( $ array1 [ $ key ] ) || $ array1 [ $ key ] instanceof AssociativeArray ) && ( is_array ( $ array2 [ $ key ] ) || $ array2 [ $ key ] instanceof AssociativeArray ) ) { $ diffArray [ $ key ] = ArrayUtils :: recursiveDiff ( $ array1 [ $ key ] , $ array2 [ $ key ] , $ caseInsensitive , $ matchingKeysOnly ) ; } else { $ value1 = $ caseInsensitive ? strtolower ( $ array1 [ $ key ] ) : $ array1 [ $ key ] ; $ value2 = $ caseInsensitive ? strtolower ( $ array2 [ $ key ] ) : $ array2 [ $ key ] ; if ( $ value1 != $ value2 ) { $ diffArray [ $ key ] = array ( "value1" => $ array1 [ $ key ] , "value2" => $ array2 [ $ key ] ) ; } } } return $ diffArray ; }
|
Return an array of different elements within the 2 arrays . If matching keys only is supplied only elements which exist in both but which are different are included .
|
13,066
|
public static function reduceToElementsWithKey ( $ array , $ key ) { if ( $ array instanceof AssociativeArray ) { $ array = $ array -> toArray ( ) ; } $ targetArray = array ( ) ; foreach ( $ array as $ itemKey => $ value ) { if ( $ itemKey == $ key ) { $ targetArray [ $ key ] = $ value ; } else if ( is_array ( $ value ) || $ value instanceof AssociativeArray ) { $ subArray = ArrayUtils :: reduceToElementsWithKey ( $ value , $ key ) ; if ( sizeof ( $ subArray ) > 0 ) { $ targetArray [ $ itemKey ] = $ subArray ; } } } return $ targetArray ; }
|
Reduce the array to only elements with the passed key at any depth .
|
13,067
|
public static function findElementsByKey ( $ array , $ key , & $ targetArray = null , $ prefix = "" ) { if ( $ array instanceof AssociativeArray ) { $ array = $ array -> toArray ( ) ; } if ( ! $ targetArray ) $ targetArray = array ( ) ; foreach ( $ array as $ itemKey => $ value ) { if ( $ itemKey === $ key ) { $ targetArray [ substr ( $ prefix . "." . $ key , 1 ) ] = $ value ; } else if ( is_array ( $ value ) || $ value instanceof AssociativeArray ) { if ( is_numeric ( $ itemKey ) ) { $ newPrefix = $ prefix . "[" . $ itemKey . "]" ; } else { $ newPrefix = $ prefix . "." . $ itemKey ; } ArrayUtils :: findElementsByKey ( $ value , $ key , $ targetArray , $ newPrefix ) ; } } return $ targetArray ; }
|
Find elements by key .
|
13,068
|
public static function groupElementsByValueKeys ( $ array , $ groupKeys ) { if ( ! is_array ( $ groupKeys ) ) { $ groupKeys = array ( $ groupKeys ) ; } $ newArray = new AssociativeArray ( ) ; foreach ( $ array as $ element ) { $ applyObject = $ newArray ; foreach ( $ groupKeys as $ index => $ groupKey ) { if ( $ index < sizeof ( $ groupKeys ) - 1 ) { $ subArray = $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] ; if ( ! $ subArray ) { $ subArray = new AssociativeArray ( ) ; $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] = $ subArray ; } $ applyObject = $ subArray ; } else { if ( ! is_array ( $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] ) ) { $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] = array ( ) ; } $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] [ ] = $ element ; } } } return $ newArray -> toArray ( ) ; }
|
Group an array of elements by one or more of it s keys . Essentially convert into an indexed array for each key type .
|
13,069
|
protected function & searchTree ( $ key , & $ tree , $ create = false ) { $ found = & $ tree ; $ parts = explode ( $ this -> field_splitter , $ key ) ; while ( null !== ( $ part = array_shift ( $ parts ) ) ) { if ( ! isset ( $ found [ $ part ] ) ) { if ( $ create ) { $ found [ $ part ] = [ ] ; } else { $ bad = null ; return $ bad ; } } $ found = & $ found [ $ part ] ; } return $ found ; }
|
Return a node in an array structure
|
13,070
|
public function addRow ( $ data , $ rowId = null ) { if ( ( $ rowId === null ) && isset ( $ data [ 'id' ] ) ) { $ rowId = $ data [ 'id' ] ; } if ( $ rowId === null ) { $ rowId = count ( $ this -> rows ) ; } $ this -> rows [ $ rowId ] = $ data ; return $ this ; }
|
Add a row .
|
13,071
|
public function addRows ( $ data ) { foreach ( $ data as $ key => $ row ) { $ this -> addRow ( $ row , isset ( $ row [ 'id' ] ) ? $ row [ 'id' ] : $ key ) ; } return $ this ; }
|
Add rows .
|
13,072
|
public function getRow ( $ index ) { $ keys = array_keys ( $ this -> rows ) ; return isset ( $ keys [ $ index ] ) ? $ this -> rows [ $ keys [ $ index ] ] : null ; }
|
Retrieve the row with the given index .
|
13,073
|
public static function asType ( $ type , array $ data ) { $ converter = new TypeStringListConverter ( $ type ) ; $ converter -> setArraySource ( $ data ) ; return new static ( $ converter ) ; }
|
Create arraylist of class
|
13,074
|
public function serializeGenerator ( ) { if ( $ this -> __converter instanceof IListConverter ) { foreach ( $ this -> __converter -> toGenerator ( $ this ) as $ index => $ row ) { yield $ index => $ row ; } } else { foreach ( $ this -> toArray ( ) as $ index => $ row ) { yield $ index => $ row ; } } }
|
Serialize via converter as generator
|
13,075
|
public function setTranslations ( array $ translations ) { $ this -> translations = [ ] ; foreach ( $ translations as $ domain => $ data ) { if ( ! is_array ( $ data ) ) { throw new InvalidArgumentException ( 'Translator translations must be a 3-level array' ) ; } foreach ( $ data as $ locale => $ messages ) { if ( ! is_array ( $ messages ) ) { throw new InvalidArgumentException ( 'Translator translations must be a 3-level array' ) ; } } } $ this -> translations = $ translations ; return $ this ; }
|
Set mapping of additional translations .
|
13,076
|
public function exchangeArray ( array $ array ) { foreach ( $ array as $ key => $ value ) { $ setMethod = 'set' . StaticFilter :: execute ( $ key , 'WordUnderscoreToCamelCase' ) ; if ( method_exists ( $ this , $ setMethod ) ) { $ this -> $ setMethod ( $ value ) ; } } }
|
Exchange properties with values from array
|
13,077
|
public function getArrayCopy ( ) { $ data = [ ] ; foreach ( get_object_vars ( $ this ) as $ key => $ value ) { $ getMethod = 'get' . ucfirst ( $ key ) ; $ arrayKey = StaticFilter :: execute ( $ key , 'WordCamelCaseToUnderscore' ) ; $ arrayKey = StaticFilter :: execute ( $ arrayKey , 'StringToLower' ) ; if ( method_exists ( $ this , $ getMethod ) ) { $ data [ $ arrayKey ] = $ this -> $ getMethod ( ) ; } } return $ data ; }
|
Generate an array copy from property values
|
13,078
|
static public function registerSerializer_ ( string $ mime , $ serializer ) : string { static :: checkSerializerNotRegistered_ ( $ mime ) ; static :: checkSerializer_ ( $ serializer ) ; static :: $ serializers_ [ $ mime ] = $ serializer ; return self :: class ; }
|
Static method registerSerializer_
|
13,079
|
static protected function checkSerializer_ ( $ serializer ) : void { if ( ! ( ( is_object ( $ serializer ) && $ serializer instanceof S \ ASerializer ) or ( is_string ( $ serializer ) && class_exists ( $ serializer ) && isset ( class_parents ( $ serializer ) [ S \ ASerializer :: class ] ) ) ) ) { $ caller = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 2 ) [ 1 ] ; throw new \ TypeError ( "Argument 2 passed to {$caller['class']}{$caller['type']}{$caller['function']}() must be an class extends " . S \ ASerializer :: class . ' or it\'s instance' ) ; } }
|
Static method checkSerializer_
|
13,080
|
static protected function achieveSerializer_ ( string $ mime ) : S \ ASerializer { static :: checkSerializerSupported_ ( $ mime ) ; $ serializer = static :: getSerializer_ ( $ mime ) ; return static :: instantiateSerializer_ ( $ serializer ) ; }
|
Static method achieveSerializer_
|
13,081
|
protected function set_post ( $ post ) { $ this -> post = $ post ; $ this -> id = ( isset ( $ post -> ID ) ) ? $ post -> ID : false ; if ( ! empty ( $ this -> taxonomies ( ) ) ) { foreach ( $ this -> taxonomies ( ) as $ taxonomy ) { $ this -> { $ taxonomy } = $ this -> get_terms ( $ taxonomy , array ( 'fields' => 'all' ) ) ; } } }
|
Sets Post Data .
|
13,082
|
public function featured_image_id ( ) { if ( isset ( $ this -> featured_image_id ) ) { return $ this -> featured_image_id ; } $ this -> featured_image_id = \ get_post_thumbnail_id ( $ this -> post ) ; return $ this -> featured_image_id ; }
|
Returns Featured Image ID .
|
13,083
|
public function featured_image_url ( $ size = 'thumbnail' , $ default = '' ) { $ featured_image = \ get_the_post_thumbnail_url ( $ this -> id ( ) , $ size ) ; return ( false !== $ featured_image ) ? $ featured_image : $ default ; }
|
Returns Featured Image URL .
|
13,084
|
public function parent ( $ only_id = true ) { if ( $ only_id ) { return $ this -> post -> post_parent ; } $ class = get_called_class ( ) ; return new $ class ( $ this -> post -> post_parent ) ; }
|
Returns Post Parent .
|
13,085
|
public function update_meta ( $ meta_key = '' , $ values = '' , $ prev_values = '' ) { return \ update_post_meta ( $ this -> id ( ) , $ meta_key , $ values , $ prev_values ) ; }
|
Updates Post Meta .
|
13,086
|
public function add_meta ( $ meta_key = '' , $ values = '' , $ unique = false ) { return \ add_post_meta ( $ this -> id ( ) , $ meta_key , $ values , $ unique ) ; }
|
Adds Post Meta .
|
13,087
|
public function taxonomies ( ) { if ( ! empty ( $ this -> taxes ) ) { return $ this -> taxes ; } $ taxes = \ get_post_taxonomies ( $ this -> post ) ; $ this -> taxes = $ taxes ; return $ this -> taxes ; }
|
Returns All Post Taxonomies .
|
13,088
|
public function get_terms ( $ taxonomy = '' , $ args = array ( ) ) { if ( isset ( $ this -> { $ taxonomy } ) && empty ( $ args ) ) { return $ this -> { $ taxonomy } ; } else { $ name = $ taxonomy . '_' . md5 ( json_encode ( $ args ) ) ; if ( isset ( $ this -> { $ name } ) ) { return $ this -> { $ name } ; } $ data = \ wp_get_post_terms ( $ this -> id ( ) , $ taxonomy , $ args ) ; $ this -> { $ name } = $ data ; return $ data ; } }
|
Returns All Terms From Post .
|
13,089
|
public function set_terms ( $ terms = array ( ) , $ taxonomy = '' , $ append = false ) { return \ wp_set_post_terms ( $ this -> id ( ) , $ terms , $ taxonomy , $ append ) ; }
|
Sets Given Terms With Tax To The Current Post .
|
13,090
|
public function in ( $ key = '' , $ data = '' , $ default = false ) { if ( is_array ( $ data ) ) { return ( in_array ( $ key , $ data ) ) ? $ key : $ default ; } if ( isset ( $ this -> { $ data } ) ) { return ( in_array ( $ key , $ this -> { $ data } ) ) ? $ key : $ default ; } return $ default ; }
|
Checks if given key is in array
|
13,091
|
protected function doException ( \ Exception $ e ) { $ command = new DefaultConsoleCommand ( ) ; $ command -> data = '"Error #' . $ e -> getCode ( ) . ' - ' . $ e -> getMessage ( ) . '"' ; $ command -> execute ( ) ; $ response = ( new ResponseInjector ) -> build ( ) ; $ response = $ response -> withHeader ( 'status' , ( string ) ( int ) $ command -> result ) ; $ stream = $ response -> getBody ( ) ; $ stream -> write ( $ command -> message ) ; return $ response -> withBody ( $ stream ) ; }
|
Run application with error
|
13,092
|
public static function startNewContext ( string $ name , bool $ inherit = true ) { if ( $ inherit ) { $ current = static :: getInjector ( ) ; $ new_injector = new Injector ( $ current ) ; } else $ new_injector = new Injector ( ) ; return static :: $ injectors [ $ name ] = $ new_injector ; }
|
Start a new injection context . Useful to be able to release all static context to a certain run of the software for example in testing .
|
13,093
|
public static function destroyContext ( string $ name ) { end ( static :: $ injectors ) ; if ( $ name !== key ( static :: $ injectors ) ) throw new DIException ( "Injection context $name is not at top of the stack" ) ; $ injector = array_pop ( static :: $ injectors ) ; }
|
Destroy a context - the injector at the top of the stack is released .
|
13,094
|
public function getHtml ( $ variable , $ default = '' , $ allowed = "" , $ escape = true ) { return ( string ) rawurldecode ( $ this -> get ( $ variable , $ default , $ allowed , $ escape ) ) ; }
|
Same as _get but it rawurldecodes the string
|
13,095
|
public function getString ( $ variable , $ default = '' , $ allowed = "" , $ escape = true ) { return ( string ) strip_tags ( $ this -> getHtml ( $ variable , $ default , $ allowed , $ escape ) ) ; }
|
Same as _getHtml but it also strips tags
|
13,096
|
public function getBool ( $ variable , $ default = false ) { return ( bool ) $ this -> get ( $ variable , $ default , array ( false , true ) , false ) ; }
|
Same as _get but casts return value to bollean
|
13,097
|
public function htmlEncode ( $ string , $ quoteStyle = ENT_QUOTES , $ charset = 'UTF-8' , $ doubleEncode = false ) { return htmlspecialchars ( ( string ) $ string , $ quoteStyle , $ charset , $ doubleEncode ) ; }
|
Replacement for htmlspecialchars
|
13,098
|
public function query ( string $ sql , array $ values = [ ] ) : int { return $ this -> dbConnection -> prepare ( $ sql ) -> execute ( $ values ) -> count ( ) ; }
|
sends a query to the database and returns amount of affected records
|
13,099
|
public function fetchOne ( string $ sql , array $ values = [ ] , int $ columnNumber = 0 ) : string { return $ this -> dbConnection -> prepare ( $ sql ) -> execute ( $ values ) -> fetchOne ( $ columnNumber ) ; }
|
fetch single value from a result set
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.