idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
20,600 | public function append ( $ fields ) { if ( is_array ( $ fields ) ) { foreach ( $ fields as $ key => $ value ) { $ this -> column ( $ key , $ value ) ; } } else { foreach ( $ fields -> fields ( ) as $ name ) { $ this -> column ( $ name , $ fields -> column ( $ name ) ) ; } } return $ this ; } | Appends additional fields to the schema . Will overwrite existing fields if a conflicts arise . |
20,601 | public function virtuals ( $ attribute = null ) { $ fields = [ ] ; foreach ( $ this -> _columns as $ name => $ field ) { if ( empty ( $ field [ 'virtual' ] ) ) { continue ; } $ fields [ ] = $ name ; } return $ fields ; } | Gets all virtual fields . |
20,602 | public function belongsTo ( $ name , $ to , $ config = [ ] ) { $ defaults = [ 'to' => $ to , 'relation' => 'belongsTo' ] ; $ config += $ defaults ; return $ this -> bind ( $ name , $ config ) ; } | Sets a BelongsTo relation . |
20,603 | public function hasMany ( $ name , $ to , $ config = [ ] ) { $ defaults = [ 'to' => $ to , 'relation' => 'hasMany' ] ; $ config += $ defaults ; return $ this -> bind ( $ name , $ config ) ; } | Sets a hasMany relation . |
20,604 | public function hasOne ( $ name , $ to , $ config = [ ] ) { $ defaults = [ 'to' => $ to , 'relation' => 'hasOne' ] ; $ config += $ defaults ; return $ this -> bind ( $ name , $ config ) ; } | Sets a hasOne relation . |
20,605 | public function hasManyThrough ( $ name , $ through , $ using , $ config = [ ] ) { $ defaults = [ 'through' => $ through , 'using' => $ using , 'relation' => 'hasManyThrough' ] ; $ config += $ defaults ; return $ this -> bind ( $ name , $ config ) ; } | Sets a hasManyThrough relation . |
20,606 | public function unbind ( $ name ) { if ( ! isset ( $ this -> _relations [ $ name ] ) ) { return ; } unset ( $ this -> _relations [ $ name ] ) ; unset ( $ this -> _relationships [ $ name ] ) ; } | Unbinds a relation . |
20,607 | public function relation ( $ name ) { if ( isset ( $ this -> _relationships [ $ name ] ) ) { return $ this -> _relationships [ $ name ] ; } if ( ! isset ( $ this -> _relations [ $ name ] ) ) { throw new ORMException ( "Relationship `{$name}` not found." ) ; } $ config = $ this -> _relations [ $ name ] ; $ relationship = $ config [ 'relation' ] ; unset ( $ config [ 'relation' ] ) ; $ relation = $ this -> _classes [ $ relationship ] ; return $ this -> _relationships [ $ name ] = new $ relation ( $ config + [ 'name' => $ name , 'conventions' => $ this -> _conventions ] ) ; } | Returns a relationship instance . |
20,608 | public function relations ( $ embedded = false ) { $ result = [ ] ; foreach ( $ this -> _relations as $ field => $ config ) { if ( ! $ config [ 'embedded' ] || $ embedded ) { $ result [ ] = $ field ; } } return $ result ; } | Returns an array of external relation names . |
20,609 | public function hasRelation ( $ name , $ embedded = null ) { if ( ! isset ( $ this -> _relations [ $ name ] ) ) { return false ; } $ relation = $ this -> _relations [ $ name ] ; if ( $ embedded === null ) { return true ; } return $ embedded === $ relation [ 'embedded' ] ; } | Checks if a relation exists . |
20,610 | public function embed ( & $ collection , $ relations , $ options = [ ] ) { $ expanded = [ ] ; $ relations = $ this -> expand ( $ relations ) ; $ tree = $ this -> treeify ( $ relations ) ; $ habtm = [ ] ; foreach ( $ tree as $ name => $ subtree ) { $ rel = $ this -> relation ( $ name ) ; if ( $ rel -> type ( ) === 'hasManyThrough' ) { $ habtm [ ] = $ name ; continue ; } $ to = $ rel -> to ( ) ; $ query = empty ( $ relations [ $ name ] ) ? [ ] : $ relations [ $ name ] ; if ( is_callable ( $ query ) ) { $ options [ 'query' ] [ 'handler' ] = $ query ; } else { $ options [ 'query' ] = $ query ; } $ related = $ rel -> embed ( $ collection , $ options ) ; $ subrelations = [ ] ; foreach ( $ relations as $ path => $ value ) { if ( preg_match ( '~^' . $ name . '\.(.*)$~' , $ path , $ matches ) ) { $ subrelations [ $ matches [ 1 ] ] = $ value ; } } if ( $ subrelations ) { $ to :: definition ( ) -> embed ( $ related , $ subrelations , $ options ) ; } } foreach ( $ habtm as $ name ) { $ rel = $ this -> relation ( $ name ) ; $ related = $ rel -> embed ( $ collection , $ options ) ; } } | Eager loads relations . |
20,611 | public function expand ( $ relations ) { if ( is_string ( $ relations ) ) { $ relations = [ $ relations ] ; } $ relations = Set :: normalize ( $ relations ) ; foreach ( $ relations as $ path => $ value ) { $ num = strpos ( $ path , '.' ) ; $ name = $ num !== false ? substr ( $ path , 0 , $ num ) : $ path ; $ rel = $ this -> relation ( $ name ) ; if ( $ rel -> type ( ) !== 'hasManyThrough' ) { continue ; } $ relPath = $ rel -> through ( ) . '.' . $ rel -> using ( ) . ( $ num !== false ? '.' . substr ( $ path , $ num + 1 ) : '' ) ; if ( ! isset ( $ relations [ $ relPath ] ) ) { $ relations [ $ relPath ] = $ relations [ $ path ] ; } } return $ relations ; } | Expands all hasManyThrough relations into their full path . |
20,612 | public function treeify ( $ embed ) { if ( ! $ embed ) { return [ ] ; } $ embed = Set :: expand ( Set :: normalize ( ( array ) $ embed ) , [ 'affix' => 'embed' ] ) ; $ result = [ ] ; foreach ( $ embed as $ relName => $ value ) { if ( ! isset ( $ this -> _relations [ $ relName ] ) ) { continue ; } if ( $ this -> _relations [ $ relName ] [ 'relation' ] === 'hasManyThrough' ) { $ rel = $ this -> relation ( $ relName ) ; if ( ! isset ( $ result [ $ rel -> through ( ) ] [ 'embed' ] [ $ rel -> using ( ) ] ) ) { $ result [ $ rel -> through ( ) ] [ 'embed' ] [ $ rel -> using ( ) ] = $ value ; } } $ result [ $ relName ] = $ value ; } return $ result ; } | Returns a nested tree representation of embed option . |
20,613 | public function cast ( $ field = null , $ data = [ ] , $ options = [ ] ) { $ defaults = [ 'parent' => null , 'basePath' => null , 'exists' => null , 'defaults' => true ] ; $ options += $ defaults ; $ options [ 'class' ] = $ this -> reference ( ) ; if ( $ field !== null ) { $ name = $ options [ 'basePath' ] ? $ options [ 'basePath' ] . '.' . $ field : ( string ) $ field ; } else { $ name = $ options [ 'basePath' ] ; } if ( $ name === null ) { return $ this -> _cast ( $ name , $ data , $ options ) ; } foreach ( [ $ name , preg_replace ( '~[^.]*$~' , '*' , $ name , 1 ) ] as $ entry ) { if ( isset ( $ this -> _relations [ $ entry ] ) ) { return $ this -> _relationCast ( $ field , $ entry , $ data , $ options ) ; } if ( isset ( $ this -> _columns [ $ entry ] ) ) { return $ this -> _columnCast ( $ field , $ entry , $ data , $ options ) ; } } if ( $ this -> locked ( ) ) { return $ data ; } if ( is_array ( $ data ) ) { $ options [ 'class' ] = Document :: class ; $ options [ 'basePath' ] = $ name ; if ( isset ( $ data [ 0 ] ) ) { return $ this -> _castArray ( $ name , $ data , $ options ) ; } else { return $ this -> _cast ( $ name , $ data , $ options ) ; } } return $ data ; } | Cast data according to the schema definition . |
20,614 | protected function _relationCast ( $ field , $ name , $ data , $ options ) { $ options = $ this -> _relations [ $ name ] + $ options ; $ options [ 'basePath' ] = $ options [ 'embedded' ] ? $ name : null ; $ options [ 'schema' ] = $ options [ 'embedded' ] ? $ this : null ; if ( $ options [ 'relation' ] !== 'hasManyThrough' ) { $ options [ 'class' ] = $ options [ 'to' ] ; } else { $ through = $ this -> relation ( $ name ) ; $ options [ 'class' ] = $ through -> to ( ) ; } if ( $ field ) { return $ options [ 'array' ] ? $ this -> _castArray ( $ name , $ data , $ options ) : $ this -> _cast ( $ name , $ data , $ options ) ; } if ( ! isset ( $ this -> _columns [ $ name ] ) ) { return $ data ; } $ column = $ this -> _columns [ $ name ] ; return $ this -> convert ( 'cast' , $ column [ 'type' ] , $ data , $ column , $ options ) ; } | Casting helper for relations . |
20,615 | protected function _columnCast ( $ field , $ name , $ data , $ options ) { $ column = $ this -> _columns [ $ name ] ; if ( ! empty ( $ column [ 'setter' ] ) ) { $ data = $ column [ 'setter' ] ( $ options [ 'parent' ] , $ data , $ name ) ; } if ( $ column [ 'array' ] && $ field ) { return $ this -> _castArray ( $ name , $ data , $ options ) ; } return $ this -> convert ( 'cast' , $ column [ 'type' ] , $ data , $ column ) ; } | Casting helper for columns . |
20,616 | public function _cast ( $ name , $ data , $ options ) { if ( $ data === null ) { return ; } if ( $ data instanceof Document ) { return $ data ; } $ class = ltrim ( $ options [ 'class' ] , '\\' ) ; $ config = [ 'schema' => $ class === Document :: class ? $ this : null , 'basePath' => $ options [ 'basePath' ] , 'exists' => $ options [ 'exists' ] , 'defaults' => $ options [ 'defaults' ] ] ; if ( isset ( $ options [ 'config' ] ) ) { $ config = Set :: extend ( $ config , $ options [ 'config' ] ) ; } $ column = isset ( $ this -> _columns [ $ name ] ) ? $ this -> _columns [ $ name ] : [ ] ; if ( ! empty ( $ column [ 'format' ] ) ) { $ data = $ this -> convert ( 'cast' , $ column [ 'format' ] , $ data , $ column , $ config ) ; } return $ class :: create ( $ data ? $ data : [ ] , $ config ) ; } | Casting helper for entities . |
20,617 | public function _castArray ( $ name , $ data , $ options ) { $ options [ 'type' ] = isset ( $ options [ 'relation' ] ) && $ options [ 'relation' ] === 'hasManyThrough' ? 'through' : 'set' ; $ class = ltrim ( $ options [ 'class' ] , '\\' ) ; $ classes = $ class :: classes ( ) ; $ collection = $ classes [ $ options [ 'type' ] ] ; if ( $ data instanceof $ collection ) { return $ data ; } $ isThrough = $ options [ 'type' ] === 'through' ; $ isDocument = $ class === Document :: class ; $ config = [ 'schema' => $ isDocument ? $ this : $ class :: definition ( ) , 'basePath' => $ isDocument ? $ name : null , 'meta' => isset ( $ options [ 'meta' ] ) ? $ options [ 'meta' ] : [ ] , 'exists' => $ options [ 'exists' ] , 'defaults' => $ options [ 'defaults' ] ] ; if ( isset ( $ options [ 'config' ] ) ) { $ config = Set :: extend ( $ config , $ options [ 'config' ] ) ; } $ column = isset ( $ this -> _columns [ $ name ] ) ? $ this -> _columns [ $ name ] : [ ] ; if ( ! empty ( $ column [ 'format' ] ) && $ data !== null ) { $ type = $ column [ 'format' ] ; $ data = $ this -> convert ( 'cast' , $ type , $ data , $ column , $ config ) ; } if ( $ isThrough ) { $ config [ 'parent' ] = $ options [ 'parent' ] ; $ config [ 'through' ] = $ options [ 'through' ] ; $ config [ 'using' ] = $ options [ 'using' ] ; $ config [ 'data' ] = $ data ; } else { $ config [ 'data' ] = $ data ? : [ ] ; } return new $ collection ( $ config ) ; } | Casting helper for arrays . |
20,618 | public function format ( $ mode , $ name , $ data ) { if ( $ mode === 'cast' ) { throw new InvalidArgumentException ( "Use `Schema::cast()` to perform casting." ) ; } if ( ! isset ( $ this -> _columns [ $ name ] ) ) { return $ this -> convert ( $ mode , '_default_' , $ data , [ ] ) ; } $ column = $ this -> _columns [ $ name ] ; $ isNull = $ data === null ; $ type = $ isNull ? 'null' : $ this -> type ( $ name ) ; if ( ! $ column [ 'array' ] ) { $ data = $ this -> convert ( $ mode , $ type , $ data , $ column ) ; } else { $ data = Collection :: format ( $ mode , $ data ) ; } if ( ! $ isNull && ! empty ( $ column [ 'format' ] ) ) { $ data = $ this -> convert ( $ mode , $ column [ 'format' ] , $ data , $ column ) ; } return $ data ; } | Formats a value according to a field definition . |
20,619 | public function convert ( $ mode , $ type , $ data , $ column = [ ] , $ options = [ ] ) { $ formatter = null ; $ type = $ data === null ? 'null' : $ type ; if ( isset ( $ this -> _formatters [ $ mode ] [ $ type ] ) ) { $ formatter = $ this -> _formatters [ $ mode ] [ $ type ] ; } elseif ( isset ( $ this -> _formatters [ $ mode ] [ '_default_' ] ) ) { $ formatter = $ this -> _formatters [ $ mode ] [ '_default_' ] ; } return $ formatter ? $ formatter ( $ data , $ column , $ options ) : $ data ; } | Formats a value according to its type . |
20,620 | public function saveRelation ( $ instance , $ types , $ options = [ ] ) { $ defaults = [ 'embed' => [ ] ] ; $ options += $ defaults ; $ types = ( array ) $ types ; $ collection = $ instance instanceof Document ? [ $ instance ] : $ instance ; $ success = true ; foreach ( $ collection as $ entity ) { foreach ( $ types as $ type ) { foreach ( $ options [ 'embed' ] as $ relName => $ value ) { if ( ! ( $ rel = $ this -> relation ( $ relName ) ) || $ rel -> type ( ) !== $ type ) { continue ; } $ success = $ success && $ rel -> save ( $ entity , $ value ? $ value + $ options : $ options ) ; } } } return $ success ; } | Save data related to relations . |
20,621 | public function getField ( $ key ) { $ resolved = $ this -> getResolved ( ) ; if ( ! $ resolved instanceof EntryInterface ) { return null ; } return $ resolved -> getField ( $ key ) ; } | Gets an individual field value or null if the field is not defined . |
20,622 | public function appendTab ( $ str = null , $ tabNum = 1 ) { $ tab = "" ; for ( $ i = 0 ; $ i < $ tabNum ; $ i ++ ) { $ tab .= "\t" ; } $ this -> appendLine ( $ tab . $ str ) ; } | append line with tab symbol |
20,623 | public function filterByHasAttributeAvValue ( $ hasAttributeAvValue = null , $ comparison = null ) { if ( is_array ( $ hasAttributeAvValue ) ) { $ useMinMax = false ; if ( isset ( $ hasAttributeAvValue [ 'min' ] ) ) { $ this -> addUsingAlias ( AttributeTypeTableMap :: HAS_ATTRIBUTE_AV_VALUE , $ hasAttributeAvValue [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ hasAttributeAvValue [ 'max' ] ) ) { $ this -> addUsingAlias ( AttributeTypeTableMap :: HAS_ATTRIBUTE_AV_VALUE , $ hasAttributeAvValue [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( AttributeTypeTableMap :: HAS_ATTRIBUTE_AV_VALUE , $ hasAttributeAvValue , $ comparison ) ; } | Filter the query on the has_attribute_av_value column |
20,624 | public function filterByIsMultilingualAttributeAvValue ( $ isMultilingualAttributeAvValue = null , $ comparison = null ) { if ( is_array ( $ isMultilingualAttributeAvValue ) ) { $ useMinMax = false ; if ( isset ( $ isMultilingualAttributeAvValue [ 'min' ] ) ) { $ this -> addUsingAlias ( AttributeTypeTableMap :: IS_MULTILINGUAL_ATTRIBUTE_AV_VALUE , $ isMultilingualAttributeAvValue [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ isMultilingualAttributeAvValue [ 'max' ] ) ) { $ this -> addUsingAlias ( AttributeTypeTableMap :: IS_MULTILINGUAL_ATTRIBUTE_AV_VALUE , $ isMultilingualAttributeAvValue [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( AttributeTypeTableMap :: IS_MULTILINGUAL_ATTRIBUTE_AV_VALUE , $ isMultilingualAttributeAvValue , $ comparison ) ; } | Filter the query on the is_multilingual_attribute_av_value column |
20,625 | public function filterByPattern ( $ pattern = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ pattern ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ pattern ) ) { $ pattern = str_replace ( '*' , '%' , $ pattern ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( AttributeTypeTableMap :: PATTERN , $ pattern , $ comparison ) ; } | Filter the query on the pattern column |
20,626 | public function filterByImageRatio ( $ imageRatio = null , $ comparison = null ) { if ( is_array ( $ imageRatio ) ) { $ useMinMax = false ; if ( isset ( $ imageRatio [ 'min' ] ) ) { $ this -> addUsingAlias ( AttributeTypeTableMap :: IMAGE_RATIO , $ imageRatio [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ imageRatio [ 'max' ] ) ) { $ this -> addUsingAlias ( AttributeTypeTableMap :: IMAGE_RATIO , $ imageRatio [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( AttributeTypeTableMap :: IMAGE_RATIO , $ imageRatio , $ comparison ) ; } | Filter the query on the image_ratio column |
20,627 | public function filterByAttributeTypeI18n ( $ attributeTypeI18n , $ comparison = null ) { if ( $ attributeTypeI18n instanceof \ AttributeType \ Model \ AttributeTypeI18n ) { return $ this -> addUsingAlias ( AttributeTypeTableMap :: ID , $ attributeTypeI18n -> getId ( ) , $ comparison ) ; } elseif ( $ attributeTypeI18n instanceof ObjectCollection ) { return $ this -> useAttributeTypeI18nQuery ( ) -> filterByPrimaryKeys ( $ attributeTypeI18n -> getPrimaryKeys ( ) ) -> endUse ( ) ; } else { throw new PropelException ( 'filterByAttributeTypeI18n() only accepts arguments of type \AttributeType\Model\AttributeTypeI18n or Collection' ) ; } } | Filter the query by a related \ AttributeType \ Model \ AttributeTypeI18n object |
20,628 | public function useAttributeTypeI18nQuery ( $ relationAlias = null , $ joinType = 'LEFT JOIN' ) { return $ this -> joinAttributeTypeI18n ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'AttributeTypeI18n' , '\AttributeType\Model\AttributeTypeI18nQuery' ) ; } | Use the AttributeTypeI18n relation AttributeTypeI18n object |
20,629 | public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof \ AttributeType \ Model \ AttributeTypeI18nQuery ) { return $ criteria ; } $ query = new \ AttributeType \ Model \ AttributeTypeI18nQuery ( ) ; if ( null !== $ modelAlias ) { $ query -> setModelAlias ( $ modelAlias ) ; } if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; } | Returns a new ChildAttributeTypeI18nQuery object . |
20,630 | private function validate ( ) { if ( null === $ this -> provider ) { throw new MissingProviderException ( 'A provider must be set for converting a currency' ) ; } if ( null === $ this -> from || null === $ this -> to ) { throw new \ RuntimeException ( 'from and to parameters must be provided' ) ; } } | Verify if the conversation can be done . |
20,631 | public function set ( $ path , $ value ) { if ( ! $ this -> zookeeper -> exists ( $ path ) ) { $ this -> makePath ( $ path ) ; $ this -> makeNode ( $ path , $ value ) ; } else { $ this -> zookeeper -> set ( $ path , $ value ) ; } } | Set a node to a value . If the node doesn t exist yet it is created . Existing values of the node are overwritten |
20,632 | public function makePath ( $ path , $ value = '' ) { $ parts = explode ( '/' , $ path ) ; $ parts = array_filter ( $ parts ) ; $ subpath = '' ; while ( count ( $ parts ) > 1 ) { $ subpath .= '/' . array_shift ( $ parts ) ; if ( ! $ this -> zookeeper -> exists ( $ subpath ) ) { $ this -> makeNode ( $ subpath , $ value ) ; } } } | Equivalent of mkdir - p on ZooKeeper |
20,633 | public function makeNode ( $ path , $ value , array $ params = array ( ) ) { if ( empty ( $ params ) ) { $ params = array ( array ( 'perms' => \ Zookeeper :: PERM_ALL , 'scheme' => 'world' , 'id' => 'anyone' , ) ) ; } return $ this -> zookeeper -> create ( $ path , $ value , $ params ) ; } | Create a node on ZooKeeper at the given path |
20,634 | public function get ( $ path ) { if ( ! $ this -> zookeeper -> exists ( $ path ) ) { return null ; } return $ this -> zookeeper -> get ( $ path ) ; } | Get the value for the node |
20,635 | public function getChildren ( $ path ) { if ( strlen ( $ path ) > 1 && preg_match ( '@/$@' , $ path ) ) { $ path = substr ( $ path , 0 , - 1 ) ; } return $ this -> zookeeper -> getChildren ( $ path ) ; } | List the children of the given path i . e . the name of the directories within the current node if any |
20,636 | public function deleteNode ( $ path ) { if ( ! $ this -> zookeeper -> exists ( $ path ) ) { return null ; } else { return $ this -> zookeeper -> delete ( $ path ) ; } } | Delete the node if it does not have any children |
20,637 | public function watch ( $ path , $ callback ) { if ( ! is_callable ( $ callback ) ) { return null ; } if ( $ this -> zookeeper -> exists ( $ path ) ) { if ( ! isset ( $ this -> callback [ $ path ] ) ) { $ this -> callback [ $ path ] = array ( ) ; } if ( ! in_array ( $ callback , $ this -> callback [ $ path ] ) ) { $ this -> callback [ $ path ] [ ] = $ callback ; return $ this -> zookeeper -> get ( $ path , array ( $ this , 'watchCallback' ) ) ; } } } | Wath a given path |
20,638 | public function watchCallback ( $ event_type , $ stat , $ path ) { if ( ! isset ( $ this -> callback [ $ path ] ) ) { return null ; } foreach ( $ this -> callback [ $ path ] as $ callback ) { $ this -> zookeeper -> get ( $ path , array ( $ this , 'watchCallback' ) ) ; return call_user_func ( $ callback ) ; } } | Wath event callback warper |
20,639 | public function loadNode ( $ path ) { $ list = @ $ this -> zookeeper -> getChildren ( $ path ) ; if ( ! empty ( $ list ) ) { $ data = [ ] ; foreach ( $ list as $ key ) { $ value = $ this -> zookeeper -> get ( $ path . '/' . $ key ) ; if ( ! empty ( $ value ) ) { $ data [ $ key ] = $ value ; } else { $ data [ $ key ] = $ this -> loadNode ( $ path . '/' . $ key ) ; } } return $ data ; } else { $ value = @ $ this -> zookeeper -> get ( $ path ) ; return $ value ; } } | return treed - config or string |
20,640 | public function config ( $ config = [ ] ) { $ defaults = [ 'conventions' => [ 'source' => function ( $ class ) { $ basename = substr ( strrchr ( $ class , '\\' ) , 1 ) ; return Inflector :: underscore ( $ basename ) ; } , 'key' => function ( ) { return 'id' ; } , 'reference' => function ( $ class ) { $ pos = strrpos ( $ class , '\\' ) ; $ basename = substr ( $ class , $ pos !== false ? $ pos + 1 : 0 ) ; return Inflector :: underscore ( Inflector :: singularize ( $ basename ) ) . '_id' ; } , 'references' => function ( $ class ) { $ pos = strrpos ( $ class , '\\' ) ; $ basename = substr ( $ class , $ pos !== false ? $ pos + 1 : 0 ) ; return Inflector :: underscore ( Inflector :: singularize ( $ basename ) ) . '_ids' ; } , 'field' => function ( $ class ) { $ pos = strrpos ( $ class , '\\' ) ; $ basename = substr ( $ class , $ pos !== false ? $ pos + 1 : 0 ) ; return Inflector :: underscore ( Inflector :: singularize ( $ basename ) ) ; } , 'multiple' => function ( $ name ) { return Inflector :: pluralize ( $ name ) ; } , 'single' => function ( $ name ) { return Inflector :: singularize ( $ name ) ; } ] ] ; $ config = Set :: extend ( $ defaults , $ config ) ; $ this -> _conventions = $ config [ 'conventions' ] ; } | Configures the schema class . |
20,641 | public function get ( $ name = null ) { if ( ! $ name ) { return $ this -> _conventions ; } if ( ! isset ( $ this -> _conventions [ $ name ] ) ) { throw new ORMException ( "Convention for `'{$name}'` doesn't exists." ) ; } return $ this -> _conventions [ $ name ] ; } | Gets a specific or all convention rules . |
20,642 | public function apply ( $ name ) { $ params = func_get_args ( ) ; array_shift ( $ params ) ; $ convention = $ this -> get ( $ name ) ; return call_user_func_array ( $ convention , $ params ) ; } | Applies a specific convention rules . |
20,643 | public function toArray ( ) { return [ 'name' => $ this -> name , 'label' => $ this -> label , 'description' => $ this -> description , 'sandboxed' => $ this -> sandboxed , 'supports_inline_execution' => $ this -> supportsInlineExecution , ] ; } | The configuration handler interface for this script type |
20,644 | public function junction ( $ boolean = null ) { if ( func_num_args ( ) ) { $ this -> _junction = $ boolean ; return $ this ; } return $ this -> _junction ; } | Sets the behavior of associative entities . If a hasMany relation is marked as a junction table associative entities will be removed once a foreign key is unsetted . When a hasMany relation is not marked as a junction table associative entities will simply have their foreign key unsetted . |
20,645 | public function saveIfExists ( array $ options = [ ] ) : bool { if ( $ this -> exists === false ) { return false ; } return $ this -> save ( $ options ) ; } | Save the model to the database if exists . |
20,646 | public function saveIfExistsOrFail ( array $ options = [ ] ) : bool { if ( $ this -> exists === false ) { return false ; } return $ this -> saveOrFail ( $ options ) ; } | Save the model to the database using transaction if exists . |
20,647 | protected function loadRawOrder ( $ tmpSubTier ) { $ nID = $ tmpSubTier [ 0 ] ; $ this -> nodesRawIndex [ $ nID ] = sizeof ( $ this -> nodesRawOrder ) ; $ this -> nodesRawOrder [ ] = $ nID ; if ( sizeof ( $ tmpSubTier [ 1 ] ) > 0 ) { foreach ( $ tmpSubTier [ 1 ] as $ deeper ) { $ this -> loadRawOrder ( $ deeper ) ; } } return true ; } | Cache tree s standard Pre - Order Traversal |
20,648 | public function prevNode ( $ nID ) { $ nodeOverride = $ this -> movePrevOverride ( $ nID ) ; if ( $ nodeOverride > 0 ) { return $ nodeOverride ; } if ( ! isset ( $ this -> nodesRawIndex [ $ nID ] ) ) { return - 3 ; } $ prevNodeInd = $ this -> nodesRawIndex [ $ nID ] - 1 ; if ( $ prevNodeInd < 0 || ! isset ( $ this -> nodesRawOrder [ $ prevNodeInd ] ) ) { return - 3 ; } $ prevNodeID = $ this -> nodesRawOrder [ $ prevNodeInd ] ; return $ prevNodeID ; } | Locate previous node in standard Pre - Order Traversal |
20,649 | public function nextNode ( $ nID ) { if ( $ nID <= 0 || ! isset ( $ this -> nodesRawIndex [ $ nID ] ) ) { return - 3 ; } $ this -> runCurrNode ( $ nID ) ; $ nodeOverride = $ this -> moveNextOverride ( $ nID ) ; if ( $ nodeOverride > 0 ) { return $ nodeOverride ; } $ nextNodeInd = $ this -> nodesRawIndex [ $ nID ] + 1 ; if ( ! isset ( $ this -> nodesRawOrder [ $ nextNodeInd ] ) ) { return - 3 ; } $ nextNodeID = $ this -> nodesRawOrder [ $ nextNodeInd ] ; return $ nextNodeID ; } | Locate next node in standard Pre - Order Traversal |
20,650 | public function nextNodeSibling ( $ nID ) { if ( ! $ this -> hasNode ( $ nID ) || $ this -> allNodes [ $ nID ] -> parentID <= 0 ) { return - 3 ; } $ nodeOverride = $ this -> moveNextOverride ( $ nID ) ; if ( $ nodeOverride > 0 ) { return $ nodeOverride ; } $ nextSibling = SLNode :: where ( 'NodeTree' , $ this -> treeID ) -> where ( 'NodeParentID' , $ this -> allNodes [ $ nID ] -> parentID ) -> where ( 'NodeParentOrder' , ( 1 + $ this -> allNodes [ $ nID ] -> parentOrd ) ) -> select ( 'NodeID' ) -> first ( ) ; if ( $ nextSibling && isset ( $ nextSibling -> NodeID ) ) { return $ nextSibling -> NodeID ; } return $ this -> nextNodeSibling ( $ this -> allNodes [ $ nID ] -> parentID ) ; } | Locate the next node outside this node s descendants |
20,651 | public function updateCurrNode ( $ nID = - 3 ) { if ( $ nID > 0 ) { if ( ! isset ( $ GLOBALS [ "SL" ] -> formTree -> TreeID ) ) { if ( ! $ this -> sessInfo ) { $ this -> createNewSess ( ) ; } $ this -> sessInfo -> SessCurrNode = $ nID ; $ this -> sessInfo -> save ( ) ; if ( $ GLOBALS [ "SL" ] -> coreTblAbbr ( ) != '' && isset ( $ this -> sessData -> dataSets [ $ GLOBALS [ "SL" ] -> coreTbl ] ) ) { $ this -> sessData -> currSessData ( $ nID , $ GLOBALS [ "SL" ] -> coreTbl , $ GLOBALS [ "SL" ] -> coreTblAbbr ( ) . 'SubmissionProgress' , 'update' , $ nID ) ; } } $ this -> currNodeSubTier = $ this -> loadNodeSubTier ( $ nID ) ; $ this -> loadNodeDataBranch ( $ nID ) ; } return true ; } | Updates currNode without checking if this is a branch node |
20,652 | public function setParameters ( array $ parameters , $ append = false ) { if ( ! $ append ) { $ this -> parameters = $ parameters ; } else { foreach ( $ parameters as $ field => $ value ) { $ this -> setParameter ( $ field , $ value ) ; } } } | Set many GET or POST parameters |
20,653 | public function getHeader ( $ field ) { if ( ! isset ( $ this -> headers [ $ field ] ) ) { return null ; } return is_array ( $ this -> headers [ $ field ] ) ? implode ( ',' , $ this -> headers [ $ field ] ) : $ this -> headers [ $ field ] ; } | Return one field from header |
20,654 | public function getHeaders ( ) { $ headerFields = array_keys ( $ this -> headers ) ; $ result = array ( ) ; foreach ( $ headerFields as $ field ) { $ result [ ] = sprintf ( '%s: %s' , $ field , $ this -> getHeader ( $ field ) ) ; } return $ result ; } | Return the HTTP header |
20,655 | public function setHeaders ( array $ headers , $ append = false ) { if ( ! $ append ) { $ this -> headers = $ headers ; } else { foreach ( $ headers as $ field => $ value ) { $ this -> setHeader ( $ field , $ value ) ; } } } | Set or reset the headers |
20,656 | public function send ( Request $ request ) { $ curl = $ this -> prepareRequest ( $ request ) ; $ data = curl_exec ( $ curl ) ; if ( false === $ data ) { $ errorMsg = curl_error ( $ curl ) ; $ errorNo = curl_errno ( $ curl ) ; throw new \ RuntimeException ( $ errorMsg , $ errorNo ) ; } $ data = $ this -> filterRawResponse ( $ data ) ; return $ this -> prepareResponse ( $ data , curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ) ; } | Send the given HTTP request by using this adapter |
20,657 | protected function prepareRequest ( Request $ request ) { $ curl = curl_init ( ) ; $ options = array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_HEADER => true , CURLOPT_CONNECTTIMEOUT_MS => 1000 , CURLOPT_TIMEOUT_MS => 3000 , CURLOPT_CUSTOMREQUEST => $ request -> getMethod ( ) , CURLOPT_URL => $ request -> getUri ( ) , CURLOPT_HTTPHEADER => $ request -> getHeaders ( ) , CURLOPT_HTTPGET => false , CURLOPT_NOBODY => false , CURLOPT_POST => false , CURLOPT_POSTFIELDS => null , ) ; switch ( $ request -> getMethod ( ) ) { case Request :: METHOD_HEAD : $ options [ CURLOPT_NOBODY ] = true ; $ query = http_build_query ( $ request -> getParameters ( ) ) ; if ( ! empty ( $ query ) ) { $ options [ CURLOPT_URL ] = $ request -> getUri ( ) . '?' . $ query ; } break ; case Request :: METHOD_GET : $ options [ CURLOPT_HTTPGET ] = true ; $ query = http_build_query ( $ request -> getParameters ( ) ) ; if ( ! empty ( $ query ) ) { $ options [ CURLOPT_URL ] = $ request -> getUri ( ) . '?' . $ query ; } break ; case Request :: METHOD_POST : case Request :: METHOD_PUT : $ options [ CURLOPT_POST ] = true ; $ options [ CURLOPT_POSTFIELDS ] = http_build_query ( $ request -> getParameters ( ) ) ; break ; } curl_setopt_array ( $ curl , $ options ) ; return $ curl ; } | Prepare cURL with the given request |
20,658 | protected function prepareResponse ( $ data , $ code ) { $ rawHeaders = array ( ) ; $ rawContent = null ; $ lines = preg_split ( '/(\\r?\\n)/' , $ data , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; for ( $ i = 0 , $ count = count ( $ lines ) ; $ i < $ count ; $ i += 2 ) { $ line = $ lines [ $ i ] ; if ( ! empty ( $ line ) ) { $ rawHeaders [ ] = $ line ; } else { $ rawContent = implode ( '' , array_slice ( $ lines , $ i + 2 ) ) ; break ; } } $ headers = $ this -> prepareHeaders ( $ rawHeaders ) ; return new Response ( $ rawContent , $ code , $ headers ) ; } | Generate the response object out of the raw response |
20,659 | protected function prepareHeaders ( array $ rawHeaders ) { $ headers = array ( ) ; foreach ( $ rawHeaders as $ rawHeader ) { if ( strpos ( $ rawHeader , ':' ) ) { $ data = explode ( ':' , $ rawHeader ) ; $ headers [ $ data [ 0 ] ] [ ] = trim ( $ data [ 1 ] ) ; } } return $ headers ; } | Returns the header as an associated array |
20,660 | public static function valueOf ( $ code = self :: NONE ) { if ( self :: isValidCode ( $ code ) ) { $ details = self :: getDetails ( $ code ) ; $ code = $ details [ 'code' ] ; $ isoStatus = $ details [ 'isoStatus' ] ; $ decimalDigits = $ details [ 'decimalDigits' ] ; $ name = $ details [ 'name' ] ; return new Currency ( $ code , $ isoStatus , $ decimalDigits , $ name ) ; } else { throw new \ InvalidArgumentException ( 'Unknown currency code \'' . $ code . '\'.' ) ; } } | Creates a new instance for the given code . |
20,661 | public static function isValidCode ( $ code ) { if ( array_key_exists ( $ code , self :: getInfoForCurrencies ( ) ) ) { return true ; } elseif ( array_key_exists ( $ code , self :: getInfoForCurrenciesWithoutCurrencyCode ( ) ) ) { return true ; } elseif ( array_key_exists ( $ code , self :: getInfoForCurrenciesWithUnofficialCode ( ) ) ) { return true ; } elseif ( array_key_exists ( $ code , self :: getInfoForCurrenciesWithHistoricalCode ( ) ) ) { return true ; } else { return false ; } } | Is the given code valid? |
20,662 | public static function getDetails ( $ code ) { $ infos = self :: getInfoForCurrencies ( ) ; if ( array_key_exists ( $ code , $ infos ) ) { return $ infos [ $ code ] ; } $ infos = self :: getInfoForCurrenciesWithoutCurrencyCode ( ) ; if ( array_key_exists ( $ code , $ infos ) ) { return $ infos [ $ code ] ; } $ infos = self :: getInfoForCurrenciesWithUnofficialCode ( ) ; if ( array_key_exists ( $ code , $ infos ) ) { return $ infos [ $ code ] ; } $ infos = self :: getInfoForCurrenciesWithHistoricalCode ( ) ; if ( array_key_exists ( $ code , $ infos ) ) { return $ infos [ $ code ] ; } throw new \ InvalidArgumentException ( 'Unknown \$code: ' . $ code ) ; } | Get details about a given ISO Currency . |
20,663 | public static function getInfoForCurrenciesWithoutCurrencyCode ( ) { return array ( self :: WITHOUT_CURRENCY_CODE_GGP => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_GGP , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Guernsey pound' , ) , self :: WITHOUT_CURRENCY_CODE_JEP => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_JEP , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Jersey pound' , ) , self :: WITHOUT_CURRENCY_CODE_IMP => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_IMP , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Isle of Man pound also Manx pound' , ) , self :: WITHOUT_CURRENCY_CODE_KRI => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_KRI , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Kiribati dollar' , ) , self :: WITHOUT_CURRENCY_CODE_SLS => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_SLS , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Somaliland shilling' , ) , self :: WITHOUT_CURRENCY_CODE_PRB => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_PRB , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Transnistrian ruble' , ) , self :: WITHOUT_CURRENCY_CODE_TVD => array ( 'code' => self :: WITHOUT_CURRENCY_CODE_TVD , 'isoStatus' => self :: ISO_STATUS_WITHOUT_CURRENCY_CODE , 'decimalDigits' => 2 , 'name' => 'Tuvalu dollar' , ) ) ; } | Get details about all Currencies without ISO Code . |
20,664 | public function round ( $ decimalDigits = null , $ mode = self :: ROUND_HALF_AWAY_FROM_ZERO ) { if ( null === $ decimalDigits ) { $ decimalDigits = $ this -> currency -> getDecimalDigits ( ) ; } $ factor = bcpow ( '10' , $ decimalDigits , self :: BCSCALE ) ; $ amount = bcmul ( $ this -> amount , $ factor , self :: BCSCALE ) ; switch ( $ mode ) { case self :: ROUND_UP : $ result = self :: roundUp ( $ amount ) ; break ; case self :: ROUND_DOWN : $ result = self :: roundDown ( $ amount ) ; break ; case self :: ROUND_TOWARDS_ZERO : $ result = self :: roundTowardsZero ( $ amount ) ; break ; case self :: ROUND_AWAY_FROM_ZERO : $ result = self :: roundAwayFromZero ( $ amount ) ; break ; case self :: ROUND_HALF_UP : $ result = self :: roundHalfUp ( $ amount ) ; break ; case self :: ROUND_HALF_DOWN : $ result = self :: roundHalfDown ( $ amount ) ; break ; case self :: ROUND_HALF_TOWARDS_ZERO : $ result = self :: roundHalfTowardsZero ( $ amount ) ; break ; case self :: ROUND_HALF_AWAY_FROM_ZERO : $ result = self :: roundHalfAwayFromZero ( $ amount ) ; break ; case self :: ROUND_HALF_TO_EVEN : $ result = self :: roundHalfToEven ( $ amount ) ; break ; case self :: ROUND_HALF_TO_ODD : $ result = self :: roundHalfToOdd ( $ amount ) ; break ; default : throw new \ InvalidArgumentException ( 'Unknown rounding mode \'' . $ mode . '\'' ) ; } $ result = bcdiv ( $ result , $ factor , self :: BCSCALE ) ; return self :: valueOf ( $ result , $ this -> currency ) ; } | Round to a given number of decimal digits using a given mode . |
20,665 | private static function discardDecimalDigitsZero ( $ amount , $ minimumDecimalDigits = 0 ) { if ( false !== strpos ( $ amount , '.' ) ) { while ( '0' == substr ( $ amount , - 1 ) ) { $ amount = substr ( $ amount , 0 , - 1 ) ; } if ( '.' == substr ( $ amount , - 1 ) ) { $ amount = substr ( $ amount , 0 , - 1 ) ; } } if ( $ minimumDecimalDigits > 0 ) { if ( false === strpos ( $ amount , '.' ) ) { $ amount .= '.' ; } $ currentDecimalDigits = strlen ( substr ( $ amount , strpos ( $ amount , '.' ) + 1 ) ) ; $ minimumDecimalDigits -= $ currentDecimalDigits ; while ( $ minimumDecimalDigits > 0 ) { $ amount .= '0' ; $ minimumDecimalDigits -- ; } } return $ amount ; } | Remove trailing zeros up to and including the decimal point . |
20,666 | private static function roundToNearestIntegerIgnoringTies ( $ amount ) { $ relevantDigit = substr ( self :: roundTowardsZero ( bcmul ( $ amount , '10' , self :: BCSCALE ) ) , - 1 ) ; $ result = null ; switch ( $ relevantDigit ) { case '0' : case '1' : case '2' : case '3' : case '4' : $ result = self :: roundTowardsZero ( $ amount ) ; break ; case '5' : $ result = null ; break ; case '6' : case '7' : case '8' : case '9' : $ result = self :: roundAwayFromZero ( $ amount ) ; break ; } return $ result ; } | Round towards the nearest integer but return null if there s a tie so specialized methods can break it differently . |
20,667 | private static function roundHalfUp ( $ amount ) { $ result = self :: roundToNearestIntegerIgnoringTies ( $ amount ) ; if ( null == $ result ) { $ result = self :: roundToNearestIntegerIgnoringTies ( bcadd ( $ amount , '0.1' , self :: BCSCALE ) ) ; } return $ result ; } | If the fraction of the amount is exactly 0 . 5 then return the amount + 0 . 5 . |
20,668 | private static function roundHalfDown ( $ amount ) { $ result = self :: roundToNearestIntegerIgnoringTies ( $ amount ) ; if ( null == $ result ) { $ result = self :: roundToNearestIntegerIgnoringTies ( bcsub ( $ amount , '0.1' , self :: BCSCALE ) ) ; } return $ result ; } | If the fraction of the amount is exactly 0 . 5 then return the amount - 0 . 5 . |
20,669 | private static function roundHalfTowardsZero ( $ amount ) { if ( 0 <= bccomp ( $ amount , '0' , self :: BCSCALE ) ) { $ result = self :: roundHalfDown ( $ amount ) ; } else { $ result = self :: roundHalfUp ( $ amount ) ; } return $ result ; } | If the fraction of the amount is exactly 0 . 5 then return the amount - 0 . 5 if the amount is positive and return the amount + 0 . 5 if the amount is negative . |
20,670 | private static function roundHalfAwayFromZero ( $ amount ) { if ( 0 <= bccomp ( $ amount , '0' , self :: BCSCALE ) ) { $ result = self :: roundHalfUp ( $ amount ) ; } else { $ result = self :: roundHalfDown ( $ amount ) ; } return $ result ; } | If the fraction of the amount is exactly 0 . 5 then return the amount + 0 . 5 if the amount is positive and return the amount - 0 . 5 if the amount is negative . |
20,671 | private static function roundHalfToEven ( $ amount ) { $ result = self :: roundToNearestIntegerIgnoringTies ( $ amount ) ; if ( null == $ result ) { $ truncated = self :: roundHalfTowardsZero ( $ amount ) ; if ( 0 == bcmod ( $ truncated , '2' ) ) { $ result = $ truncated ; } else { $ result = self :: roundHalfAwayFromZero ( $ amount ) ; } } return $ result ; } | If the fraction of the amount is 0 . 5 then return the even integer nearest to the amount . |
20,672 | public static function zero ( Currency $ currency = null ) { if ( null === $ currency ) { $ currency = Currency :: valueOf ( Currency :: NONE ) ; } return self :: valueOf ( '0' , $ currency ) ; } | Creates a new instance with zero amount and Currency None or optional . |
20,673 | public static function noCurrency ( $ amount = null ) { if ( null === $ amount ) { $ amount = '0' ; } return self :: valueOf ( strval ( $ amount ) , Currency :: valueOf ( Currency :: NONE ) ) ; } | Creates a new instance with amount zero or optional and Currency None . |
20,674 | public function compare ( Money $ money ) { return bccomp ( $ this -> amount , $ money -> getAmount ( ) , self :: BCSCALE ) ; } | Compares this moneys amount with the given ones and returns 0 if they are equal 1 if this amount is larger than the given ones - 1 otherwise . This method explicitly disregards the Currency! |
20,675 | public function equals ( Money $ money ) { if ( ! $ this -> currency -> equals ( $ money -> getCurrency ( ) ) ) { return false ; } return ( 0 == $ this -> compare ( $ money ) ) ; } | Are these to money equal? |
20,676 | public function modulus ( $ modulus ) { if ( ! is_numeric ( $ modulus ) ) { throw new \ InvalidArgumentException ( 'Modulus must be numeric' ) ; } $ amount = bcmod ( $ this -> amount , strval ( $ modulus ) ) ; return self :: valueOf ( $ amount , $ this -> currency ) ; } | Calculates the modulus of this money . |
20,677 | public function squareRoot ( ) { $ amount = bcsqrt ( $ this -> amount , self :: BCSCALE ) ; return self :: valueOf ( $ amount , $ this -> currency ) ; } | Calculates the square root of this money . |
20,678 | public function projectName ( ) { $ name = $ this -> name ( ) ; if ( null === $ name ) { return null ; } $ atoms = explode ( static :: NAME_SEPARATOR , $ name ) ; return array_pop ( $ atoms ) ; } | Get the project name without the vendor prefix . |
20,679 | public function vendorName ( ) { $ name = $ this -> name ( ) ; if ( null === $ name ) { return null ; } $ atoms = explode ( static :: NAME_SEPARATOR , $ name ) ; array_pop ( $ atoms ) ; if ( count ( $ atoms ) < 1 ) { return null ; } return implode ( static :: NAME_SEPARATOR , $ atoms ) ; } | Get the vendor name without the project suffix . |
20,680 | public function allPsr4SourcePaths ( ) { $ autoloadPsr4Paths = array ( ) ; foreach ( $ this -> autoloadPsr4 ( ) as $ namespace => $ paths ) { $ autoloadPsr4Paths = array_merge ( $ autoloadPsr4Paths , $ paths ) ; } return $ autoloadPsr4Paths ; } | Get an array of all source paths containing PSR - 4 conformant code . |
20,681 | public function allPsr0SourcePaths ( ) { $ autoloadPsr0Paths = array ( ) ; foreach ( $ this -> autoloadPsr0 ( ) as $ namespace => $ paths ) { $ autoloadPsr0Paths = array_merge ( $ autoloadPsr0Paths , $ paths ) ; } return $ autoloadPsr0Paths ; } | Get an array of all source paths containing PSR - 0 conformant code . |
20,682 | public function allSourcePaths ( ) { return array_merge ( $ this -> allPsr4SourcePaths ( ) , $ this -> allPsr0SourcePaths ( ) , $ this -> autoloadClassmap ( ) , $ this -> autoloadFiles ( ) , $ this -> includePath ( ) ) ; } | Get an array of all source paths for this package . |
20,683 | public function allToArray ( ) { $ config = [ ] ; try { foreach ( $ this -> findAll ( ) as $ object ) { $ key = $ object -> key_name ; if ( $ object -> group_name != 'config' ) { $ config [ $ object -> group_name ] [ $ key ] = $ object -> value ; } else { $ config [ $ key ] = $ object -> value ; } } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) ) ; } return $ config ; } | Build Settings Array . |
20,684 | public function theFollowingRecordsInTheRepository ( $ entity , YamlStringNode $ records ) { $ manager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ accessor = new PropertyAccessor ( ) ; foreach ( $ records -> toArray ( ) as $ record ) { $ instance = new $ entity ( ) ; foreach ( $ record as $ prop => $ value ) { $ accessor -> setValue ( $ instance , $ prop , $ value ) ; } $ manager -> persist ( $ instance ) ; } $ manager -> flush ( ) ; } | Use a YAML syntax to populate a repository with multiple records |
20,685 | public function grabInFromRepositoryFirstRecordsOrderedByMatching ( $ variable , $ repo , $ limitAndOffset = null , $ orderBy = null , YamlStringNode $ criteria = null ) { if ( strpos ( $ limitAndOffset , ':' ) !== false ) { list ( $ limit , $ offset ) = explode ( ':' , $ limitAndOffset ) ; } else { $ limit = $ limitAndOffset ; $ offset = null ; } if ( is_string ( $ orderBy ) ) { list ( $ field , $ order ) = explode ( ':' , $ orderBy ) ; $ orderBy = [ $ field => $ order ] ; } $ records = $ this -> getDoctrine ( ) -> getRepository ( $ repo ) -> findBy ( $ criteria ? $ criteria -> toArray ( ) : [ ] , $ orderBy , $ limit , $ offset ) ; $ this -> storage -> setValue ( $ variable , $ records ) ; } | Grab a set of records from database in a temp variable inside the storage in order to use latter in an expression |
20,686 | static function create ( \ Plasma \ DriverFactoryInterface $ factory , string $ uri , array $ options = array ( ) ) : \ Plasma \ ClientInterface { return ( new static ( $ factory , $ uri , $ options ) ) ; } | Creates a client with the specified factory and options . |
20,687 | function checkinConnection ( \ Plasma \ DriverInterface $ driver ) : void { if ( $ driver -> getConnectionState ( ) !== \ Plasma \ DriverInterface :: CONNECTION_UNUSABLE && ! $ this -> goingAway ) { $ this -> connections -> add ( $ driver ) ; $ this -> busyConnections -> delete ( $ driver ) ; } } | Checks a connection back in if usable and not closing . |
20,688 | function beginTransaction ( int $ isolation = \ Plasma \ TransactionInterface :: ISOLATION_COMMITTED ) : \ React \ Promise \ PromiseInterface { if ( $ this -> goingAway ) { return \ React \ Promise \ reject ( ( new \ Plasma \ Exception ( 'Client is closing all connections' ) ) ) ; } $ connection = $ this -> getOptimalConnection ( ) ; return $ connection -> beginTransaction ( $ this , $ isolation ) -> then ( null , function ( \ Throwable $ error ) use ( & $ connection ) { $ this -> checkinConnection ( $ connection ) ; throw $ error ; } ) ; } | Begins a transaction . Resolves with a Transaction instance . |
20,689 | function execute ( string $ query , array $ params = array ( ) ) : \ React \ Promise \ PromiseInterface { if ( $ this -> goingAway ) { return \ React \ Promise \ reject ( ( new \ Plasma \ Exception ( 'Client is closing all connections' ) ) ) ; } $ connection = $ this -> getOptimalConnection ( ) ; return $ connection -> execute ( $ this , $ query , $ params ) -> then ( function ( $ value ) use ( & $ connection ) { $ this -> checkinConnection ( $ connection ) ; return $ value ; } , function ( \ Throwable $ error ) use ( & $ connection ) { $ this -> checkinConnection ( $ connection ) ; throw $ error ; } ) ; } | Prepares and executes a query . Resolves with a QueryResultInterface instance . This is equivalent to prepare - > execute - > close . If you need to execute a query multiple times prepare the query manually for performance reasons . |
20,690 | function close ( ) : \ React \ Promise \ PromiseInterface { if ( $ this -> goingAway ) { return $ this -> goingAway ; } $ deferred = new \ React \ Promise \ Deferred ( ) ; $ this -> goingAway = $ deferred -> promise ( ) ; $ closes = array ( ) ; foreach ( $ this -> connections -> all ( ) as $ conn ) { $ closes [ ] = $ conn -> close ( ) ; $ this -> connections -> delete ( $ conn ) ; } foreach ( $ this -> busyConnections -> all ( ) as $ conn ) { $ closes [ ] = $ conn -> close ( ) ; $ this -> busyConnections -> delete ( $ conn ) ; } \ React \ Promise \ all ( $ closes ) -> then ( array ( $ deferred , 'resolve' ) , array ( $ deferred , 'reject' ) ) ; return $ this -> goingAway ; } | Closes all connections gracefully after processing all outstanding requests . |
20,691 | function quit ( ) : void { if ( $ this -> goingAway ) { return ; } $ this -> goingAway = \ React \ Promise \ resolve ( ) ; foreach ( $ this -> connections -> all ( ) as $ conn ) { $ conn -> quit ( ) ; $ this -> connections -> delete ( $ conn ) ; } foreach ( $ this -> busyConnections -> all ( ) as $ conn ) { $ conn -> quit ( ) ; $ this -> busyConnections -> delete ( $ conn ) ; } } | Forcefully closes the connection without waiting for any outstanding requests . This will reject all oustanding requests . |
20,692 | function runQuery ( \ Plasma \ QueryBuilderInterface $ query ) : \ React \ Promise \ PromiseInterface { if ( $ this -> goingAway ) { return \ React \ Promise \ reject ( ( new \ Plasma \ Exception ( 'Client is closing all connections' ) ) ) ; } $ connection = $ this -> getOptimalConnection ( ) ; try { return $ connection -> runQuery ( $ this , $ query ) ; } catch ( \ Throwable $ e ) { $ this -> checkinConnection ( $ connection ) ; throw $ e ; } } | Runs the given querybuilder on an underlying driver instance . The driver CAN throw an exception if the given querybuilder is not supported . An example would be a SQL querybuilder and a Cassandra driver . |
20,693 | function createReadCursor ( string $ query , array $ params = array ( ) ) : \ React \ Promise \ PromiseInterface { if ( $ this -> goingAway ) { return \ React \ Promise \ reject ( ( new \ Plasma \ Exception ( 'Client is closing all connections' ) ) ) ; } $ connection = $ this -> getOptimalConnection ( ) ; try { return $ connection -> createReadCursor ( $ this , $ query , $ params ) ; } catch ( \ Throwable $ e ) { $ this -> checkinConnection ( $ connection ) ; throw $ e ; } } | Creates a new cursor to seek through SELECT query results . |
20,694 | protected function getOptimalConnection ( ) : \ Plasma \ DriverInterface { if ( \ count ( $ this -> connections ) === 0 ) { $ connection = $ this -> createNewConnection ( ) ; $ this -> busyConnections -> add ( $ connection ) ; return $ connection ; } $ this -> connections -> rewind ( ) ; $ connection = $ this -> connections -> current ( ) ; $ backlog = $ connection -> getBacklogLength ( ) ; $ state = $ connection -> getBusyState ( ) ; foreach ( $ this -> connections as $ conn ) { $ cbacklog = $ conn -> getBacklogLength ( ) ; $ cstate = $ conn -> getBusyState ( ) ; if ( $ cbacklog === 0 && $ conn -> getConnectionState ( ) === \ Plasma \ DriverInterface :: CONNECTION_OK && $ cstate == \ Plasma \ DriverInterface :: STATE_IDLE ) { $ this -> connections -> delete ( $ conn ) ; $ this -> busyConnections -> add ( $ conn ) ; return $ conn ; } if ( $ backlog > $ cbacklog || $ state > $ cstate ) { $ connection = $ conn ; $ backlog = $ cbacklog ; $ state = $ cstate ; } } if ( $ this -> getConnectionCount ( ) < $ this -> options [ 'connections.max' ] ) { $ connection = $ this -> createNewConnection ( ) ; } $ this -> connections -> delete ( $ connection ) ; $ this -> busyConnections -> add ( $ connection ) ; return $ connection ; } | Get the optimal connection . |
20,695 | protected function createNewConnection ( ) : \ Plasma \ DriverInterface { $ connection = $ this -> factory -> createDriver ( ) ; $ connection -> on ( 'eventRelay' , function ( string $ eventName , ... $ args ) use ( & $ connection ) { $ args [ ] = $ connection ; $ this -> emit ( $ eventName , $ args ) ; } ) ; $ connection -> on ( 'close' , function ( ) use ( & $ connection ) { $ this -> connections -> delete ( $ connection ) ; $ this -> busyConnections -> delete ( $ connection ) ; $ this -> emit ( 'close' , array ( $ connection ) ) ; } ) ; $ connection -> on ( 'error' , function ( \ Throwable $ error ) use ( & $ connection ) { $ this -> emit ( 'error' , array ( $ error , $ connection ) ) ; } ) ; $ connection -> connect ( $ this -> uri ) -> then ( function ( ) use ( & $ connection ) { $ this -> connections -> add ( $ connection ) ; $ this -> busyConnections -> delete ( $ connection ) ; } , function ( \ Throwable $ error ) use ( & $ connection ) { $ this -> connections -> delete ( $ connection ) ; $ this -> busyConnections -> delete ( $ connection ) ; $ this -> emit ( 'error' , array ( $ error , $ connection ) ) ; } ) ; return $ connection ; } | Create a new connection . |
20,696 | protected function validateOptions ( array $ options ) { $ validator = \ CharlotteDunois \ Validation \ Validator :: make ( $ options , array ( 'connections.max' => 'integer|min:1' , 'connections.lazy' => 'boolean' ) ) ; $ validator -> throw ( \ InvalidArgumentException :: class ) ; } | Validates the given options . |
20,697 | public function onAfterWrite ( ) { if ( ! self :: $ indexing ) return ; $ stage = null ; if ( $ this -> owner -> hasMethod ( 'canBeVersioned' ) && $ this -> owner -> canBeVersioned ( $ this -> owner -> baseTable ( ) ) ) { $ stage = Versioned :: current_stage ( ) ; } if ( $ this -> canShowInSearch ( ) ) { $ this -> owner -> LastEdited = date ( 'Y-m-d H:i:s' ) ; $ this -> reindex ( $ stage ) ; } } | Index after every write ; this lets us search on Draft data as well as live data |
20,698 | public function reindex ( $ stage = null ) { if ( $ this -> owner -> ParentID > 0 ) { $ parent = $ this -> owner -> Parent ( ) ; if ( is_null ( $ parent ) || ( $ parent === false ) ) { return ; } } if ( ( ClassInfo :: baseDataClass ( $ this -> owner ) === 'SiteTree' ) && SiteTree :: has_extension ( 'SiteTreePermissionIndexExtension' ) && SiteTree :: has_extension ( 'SolrSearchPermissionIndexExtension' ) && ClassInfo :: exists ( 'QueuedJob' ) ) { $ indexing = new SolrSiteTreePermissionIndexJob ( $ this -> owner , $ stage ) ; singleton ( 'QueuedJobService' ) -> queueJob ( $ indexing ) ; } else { $ this -> searchService -> index ( $ this -> owner , $ stage ) ; } } | Index the current data object for a particular stage . |
20,699 | public function setEmailAddress ( $ email_user , $ lang = 'en' ) { $ action = "set_email_user" ; $ options = array ( 'email_user' => $ email_user , 'lang' => $ lang , 'sid_token' => $ this -> sid_token ) ; return $ this -> client -> post ( $ action , $ options ) ; } | Change users email address |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.