idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
100 | protected function queryEagerLoadedRelationships ( array $ results , array $ eagerLoads ) : array { $ this -> eagerLoads = $ this -> parseRelations ( $ eagerLoads ) ; return $ this -> eagerLoadRelations ( $ results ) ; } | Launch queries on eager loaded relationships . |
101 | public function eagerLoadRelations ( array $ results ) : array { foreach ( $ this -> eagerLoads as $ name => $ constraints ) { if ( ! in_array ( $ name , $ this -> entityMap -> getRelationships ( ) ) ) { continue ; } if ( strpos ( $ name , '.' ) === false ) { $ results = $ this -> loadRelation ( $ results , $ name , $ ... | Eager load the relationships on a result set . |
102 | protected function loadRelation ( array $ results , string $ name , Closure $ constraints ) : array { $ relation = $ this -> getRelation ( $ name ) ; $ relation -> addEagerConstraints ( $ results ) ; call_user_func ( $ constraints , $ relation ) ; return $ relation -> match ( $ results , $ name ) ; } | Eagerly load the relationship on a set of entities . |
103 | protected function buildUnkeyedResultSet ( array $ results ) : array { $ builder = new EntityBuilder ( $ this -> mapper , array_keys ( $ this -> eagerLoads ) , $ this -> useCache ) ; return array_map ( function ( $ item ) use ( $ builder ) { return $ builder -> build ( $ item ) ; } , $ results ) ; } | Build a result set . |
104 | protected function buildKeyedResultSet ( array $ results , string $ primaryKey ) : array { $ builder = new EntityBuilder ( $ this -> mapper , array_keys ( $ this -> eagerLoads ) , $ this -> useCache ) ; $ keys = array_map ( function ( $ item ) use ( $ primaryKey ) { return $ item [ $ primaryKey ] ; } , $ results ) ; re... | Build a result set keyed by PK . |
105 | public function add ( array $ results ) { $ cachedResults = [ ] ; $ keyColumn = $ this -> entityMap -> getKeyName ( ) ; foreach ( $ results as $ result ) { $ id = $ result [ $ keyColumn ] ; $ cachedResults [ $ id ] = $ this -> rawResult ( $ result ) ; } if ( empty ( $ this -> cache ) ) { $ this -> cache = $ cachedResul... | Add an array of key = > attributes representing the initial state of loaded entities . |
106 | public function get ( string $ id = null ) : array { if ( $ this -> has ( $ id ) ) { return $ this -> cache [ $ id ] ; } return [ ] ; } | Retrieve initial attributes for a single entity . |
107 | protected function mergeCacheResults ( array $ results ) { foreach ( $ results as $ key => $ entity ) { $ this -> cache [ $ key ] = $ entity ; } } | Combine new result set with existing attributes in cache . |
108 | public function cacheLoadedRelationResult ( string $ key , string $ relation , $ results , Relationship $ relationship ) { if ( $ results instanceof EntityCollection ) { $ this -> cacheManyRelationResults ( $ key , $ relation , $ results , $ relationship ) ; } if ( $ results instanceof Mappable ) { $ this -> cacheSingl... | Cache Relation s query result for an entity . |
109 | protected function getCachedRelationship ( string $ relation , $ result , Relationship $ relationship ) { $ pivotColumns = $ relationship -> getPivotAttributes ( ) ; if ( ! array_key_exists ( $ relation , $ this -> pivotAttributes ) ) { $ this -> pivotAttributes [ $ relation ] = $ pivotColumns ; } $ wrapper = $ this ->... | Create a cachedRelationship instance which will hold related entity s hash and pivot attributes if any . |
110 | protected function cacheManyRelationResults ( string $ parentKey , string $ relation , $ results , Relationship $ relationship ) { $ this -> cache [ $ parentKey ] [ $ relation ] = [ ] ; foreach ( $ results as $ result ) { $ cachedRelationship = $ this -> getCachedRelationship ( $ relation , $ result , $ relationship ) ... | Cache a many relationship . |
111 | protected function cacheSingleRelationResult ( string $ parentKey , string $ relation , $ result , Relationship $ relationship ) { $ this -> cache [ $ parentKey ] [ $ relation ] = $ this -> getCachedRelationship ( $ relation , $ result , $ relationship ) ; } | Cache a single relationship . |
112 | protected function getEntityHash ( InternallyMappable $ entity ) : string { $ class = $ entity -> getEntityClass ( ) ; $ mapper = Manager :: getMapper ( $ class ) ; $ keyName = $ mapper -> getEntityMap ( ) -> getKeyName ( ) ; return $ class . '.' . $ entity -> getEntityAttribute ( $ keyName ) ; } | Get Entity s Hash . |
113 | public function refresh ( Aggregate $ entity ) { $ this -> cache [ $ entity -> getEntityKeyValue ( ) ] = $ this -> transform ( $ entity ) ; } | Refresh the cache record for an aggregated entity after a write operation . |
114 | protected function transform ( Aggregate $ aggregatedEntity ) : array { $ baseAttributes = $ aggregatedEntity -> getRawAttributes ( ) ; $ relationAttributes = [ ] ; foreach ( $ this -> entityMap -> getSingleRelationships ( ) as $ relation ) { $ aggregates = $ aggregatedEntity -> getRelationship ( $ relation ) ; if ( co... | Transform an Aggregated Entity into a cache record . |
115 | protected function getPivotValues ( string $ relation , InternallyMappable $ entity ) : array { $ values = [ ] ; $ entityAttributes = $ entity -> getEntityAttributes ( ) ; if ( array_key_exists ( $ relation , $ this -> pivotAttributes ) ) { foreach ( $ this -> pivotAttributes [ $ relation ] as $ attribute ) { if ( arra... | Get pivot attributes for a relation . |
116 | public function match ( array $ results , $ relation ) { $ foreign = $ this -> foreignKey ; $ other = $ this -> otherKey ; $ entities = $ this -> getEager ( ) ; $ dictionary = [ ] ; foreach ( $ entities as $ entity ) { $ entity = $ this -> factory -> make ( $ entity ) ; $ dictionary [ $ entity -> getEntityAttribute ( $... | Match the Results array to an eagerly loaded relation . |
117 | public function map ( $ results , array $ eagerLoads = [ ] , $ useCache = false ) : Collection { $ builder = $ this -> newResultBuilder ( ! $ useCache ) ; if ( $ results instanceof Collection ) { $ results = $ results -> all ( ) ; } if ( ! is_array ( $ results ) ) { throw new InvalidArgumentException ( "Parameter 'resu... | Map results to a Collection . |
118 | protected function newResultBuilder ( bool $ skipCache = false ) : ResultBuilderInterface { $ factory = new ResultBuilderFactory ( ) ; return $ factory -> make ( $ this , $ skipCache ) ; } | Return result builder used by this mapper . |
119 | public function store ( $ entity ) { if ( $ this -> manager -> isTraversable ( $ entity ) ) { return $ this -> storeCollection ( $ entity ) ; } else { return $ this -> storeEntity ( $ entity ) ; } } | Persist an entity or an entity collection into the database . |
120 | protected function storeCollection ( $ entities ) { $ this -> adapter -> beginTransaction ( ) ; foreach ( $ entities as $ entity ) { $ this -> storeEntity ( $ entity ) ; } $ this -> adapter -> commit ( ) ; return $ entities ; } | Store an entity collection inside a single DB Transaction . |
121 | protected function storeEntity ( $ entity ) { $ this -> checkEntityType ( $ entity ) ; $ store = new Store ( $ this -> aggregate ( $ entity ) , $ this -> newQueryBuilder ( ) ) ; return $ store -> execute ( ) ; } | Store a single entity into the database . |
122 | protected function checkEntityType ( $ entity ) { if ( get_class ( $ entity ) != $ this -> entityMap -> getClass ( ) && ! is_subclass_of ( $ entity , $ this -> entityMap -> getClass ( ) ) ) { $ expected = $ this -> entityMap -> getClass ( ) ; $ actual = get_class ( $ entity ) ; throw new InvalidArgumentException ( "Exp... | Check that the entity correspond to the current mapper . |
123 | public function delete ( $ entity ) { if ( $ this -> manager -> isTraversable ( $ entity ) ) { return $ this -> deleteCollection ( $ entity ) ; } else { $ this -> deleteEntity ( $ entity ) ; } } | Delete an entity or an entity collection from the database . |
124 | protected function deleteCollection ( $ entities ) { $ this -> adapter -> beginTransaction ( ) ; foreach ( $ entities as $ entity ) { $ this -> deleteEntity ( $ entity ) ; } $ this -> adapter -> commit ( ) ; return $ entities ; } | Delete an Entity Collection inside a single db transaction . |
125 | protected function deleteEntity ( $ entity ) { $ this -> checkEntityType ( $ entity ) ; $ delete = new Delete ( $ this -> aggregate ( $ entity ) , $ this -> newQueryBuilder ( ) ) ; $ delete -> execute ( ) ; } | Delete a single entity from the database . |
126 | public function fireEvent ( $ event , $ entity , $ halt = true ) { $ eventName = "analogue.{$event}." . $ this -> entityMap -> getClass ( ) ; $ method = $ halt ? 'until' : 'fire' ; if ( ! array_key_exists ( $ event , $ this -> events ) ) { throw new \ LogicException ( "Analogue : Event $event doesn't exist" ) ; } $ eve... | Fire the given event for the entity . |
127 | public function registerEvent ( $ event , $ callback ) { $ name = $ this -> entityMap -> getClass ( ) ; $ this -> dispatcher -> listen ( "analogue.{$event}.{$name}" , $ callback ) ; } | Register an entity event with the dispatcher . |
128 | public function getGlobalScope ( $ scope ) { return array_first ( $ this -> globalScopes , function ( $ key , $ value ) use ( $ scope ) { return $ scope instanceof $ value ; } ) ; } | Get a global scope registered with the modal . |
129 | public function applyGlobalScopes ( $ query ) { foreach ( $ this -> getGlobalScopes ( ) as $ scope ) { $ scope -> apply ( $ query , $ this ) ; } return $ query ; } | Apply all of the global scopes to an Analogue Query builder . |
130 | public function newInstance ( ) { $ class = $ this -> entityMap -> getClass ( ) ; if ( $ this -> entityMap -> useDependencyInjection ( ) ) { return $ this -> newInstanceUsingDependencyInjection ( $ class ) ; } return $ this -> newInstanceUsingInstantiator ( $ class ) ; } | Create a new instance of the mapped entity class . |
131 | public function removeGlobalScopes ( $ query ) { foreach ( $ this -> getGlobalScopes ( ) as $ scope ) { $ scope -> remove ( $ query , $ this ) ; } return $ query ; } | Remove all of the global scopes from an Analogue Query builder . |
132 | public function executeCustomCommand ( $ command , $ entity ) { $ commandClass = $ this -> customCommands [ $ command ] ; if ( $ this -> manager -> isTraversable ( $ entity ) ) { foreach ( $ entity as $ instance ) { $ this -> executeSingleCustomCommand ( $ commandClass , $ instance ) ; } } else { return $ this -> execu... | Execute a custom command on an Entity . |
133 | protected function executeSingleCustomCommand ( $ commandClass , $ entity ) { $ this -> checkEntityType ( $ entity ) ; $ instance = new $ commandClass ( $ this -> aggregate ( $ entity ) , $ this -> newQueryBuilder ( ) ) ; return $ instance -> execute ( ) ; } | Execute a single command instance . |
134 | public function boot ( ) { if ( static :: $ booted ) { return $ this ; } $ dispatcher = new Dispatcher ( ) ; $ connectionProvider = new CapsuleConnectionProvider ( static :: $ capsule ) ; $ illuminate = new IlluminateDriver ( $ connectionProvider ) ; $ driverManager = new DriverManager ( ) ; $ driverManager -> addDrive... | Boot Analogue . |
135 | protected function buildEmbeddedCollection ( array $ rows ) : Collection { return collect ( $ rows ) -> map ( function ( $ attributes ) { return $ this -> buildEmbeddedObject ( $ attributes ) ; } ) ; } | Build an embedded collection and returns it . |
136 | protected function normalizeAsArray ( $ objects ) : array { $ key = $ this -> relation ; if ( ! is_array ( $ objects ) && ! $ objects instanceof Collection ) { throw new MappingException ( "column '$key' should be of type array or collection" ) ; } if ( $ objects instanceof Collection ) { $ objects = $ objects -> all (... | Normalize object as array containing raw attributes . |
137 | protected function getMappable ( $ entity ) : InternallyMappable { if ( $ entity instanceof InternallyMappable ) { return $ entity ; } $ factory = new Factory ( ) ; $ wrappedEntity = $ factory -> make ( $ entity ) ; return $ wrappedEntity ; } | Return internally mappable if not mappable . |
138 | protected function parseRelationships ( ) { foreach ( $ this -> entityMap -> getSingleRelationships ( ) as $ relation ) { $ this -> parseSingleRelationship ( $ relation ) ; } foreach ( $ this -> entityMap -> getManyRelationships ( ) as $ relation ) { $ this -> parseManyRelationship ( $ relation ) ; } } | Parse Every relationships defined on the entity . |
139 | protected function parseForCommonValues ( $ relation ) { if ( ! $ this -> hasAttribute ( $ relation ) ) { $ this -> relationships [ $ relation ] = [ ] ; return false ; } $ value = $ this -> getRelationshipValue ( $ relation ) ; if ( is_null ( $ value ) ) { $ this -> relationships [ $ relation ] = [ ] ; $ this -> needSy... | Parse for values common to single & many relations . |
140 | protected function parseSingleRelationship ( string $ relation ) : bool { if ( ! $ value = $ this -> parseForCommonValues ( $ relation ) ) { return true ; } if ( $ value instanceof Collection || is_array ( $ value ) || $ value instanceof CollectionProxy ) { throw new MappingException ( "Entity's attribute $relation sho... | Parse a single relationship . |
141 | protected function isParentOrRoot ( $ value ) : bool { $ id = spl_object_hash ( $ value ) ; $ root = $ this -> root ? $ this -> root -> getWrappedEntity ( ) -> getObject ( ) : null ; $ parent = $ this -> parent ? $ this -> parent -> getWrappedEntity ( ) -> getObject ( ) : null ; if ( $ parent && ( spl_object_hash ( $ p... | Check if value isn t parent or root in the aggregate . |
142 | protected function parseManyRelationship ( string $ relation ) : bool { if ( ! $ value = $ this -> parseForCommonValues ( $ relation ) ) { return true ; } if ( is_array ( $ value ) || ( ! $ value instanceof CollectionProxy && $ value instanceof Collection ) ) { $ this -> needSync [ ] = $ relation ; } if ( $ value insta... | Parse a many relationship . |
143 | protected function getRelationshipValue ( string $ relation ) { $ value = $ this -> getEntityAttribute ( $ relation ) ; if ( is_scalar ( $ value ) ) { throw new MappingException ( "Entity's attribute $relation should be array, object, collection or null" ) ; } return $ value ; } | Return Entity s relationship attribute . |
144 | protected function createSubAggregates ( $ entities , string $ relation ) : array { $ aggregates = [ ] ; foreach ( $ entities as $ entity ) { $ aggregates [ ] = $ this -> createSubAggregate ( $ entity , $ relation ) ; } return $ aggregates ; } | Create a child aggregated entity . |
145 | protected function createSubAggregate ( $ entity , string $ relation ) : self { $ root = is_null ( $ this -> root ) ? $ this : $ this -> root ; return new self ( $ entity , $ this , $ relation , $ root ) ; } | Create a related subAggregate . |
146 | public function getRelationship ( string $ name ) : array { if ( array_key_exists ( $ name , $ this -> relationships ) ) { return $ this -> relationships [ $ name ] ; } return [ ] ; } | Get a relationship as an aggregated entities array . |
147 | public function getNonExistingRelated ( array $ relationships ) : array { $ nonExisting = [ ] ; foreach ( $ relationships as $ relation ) { if ( $ this -> hasAttribute ( $ relation ) && array_key_exists ( $ relation , $ this -> relationships ) ) { $ nonExisting = array_merge ( $ nonExisting , $ this -> getNonExistingFr... | Get Non existing related entities from several relationships . |
148 | protected function getNonExistingFromRelation ( string $ relation ) : array { $ nonExisting = [ ] ; foreach ( $ this -> relationships [ $ relation ] as $ aggregate ) { if ( ! $ aggregate -> exists ( ) ) { $ nonExisting [ ] = $ aggregate ; } } return $ nonExisting ; } | Get non - existing related entities from a single relation . |
149 | public function syncRelationships ( array $ relationships ) { foreach ( $ relationships as $ relation ) { if ( in_array ( $ relation , $ this -> needSync ) ) { $ this -> synchronize ( $ relation ) ; } } } | Synchronize relationships if needed . |
150 | protected function synchronize ( string $ relation ) { $ actualContent = $ this -> relationships [ $ relation ] ; $ relationshipObject = $ this -> entityMap -> $ relation ( $ this -> getEntityObject ( ) ) ; $ relationshipObject -> setParent ( $ this -> wrappedEntity ) ; $ relationshipObject -> sync ( $ actualContent ) ... | Synchronize a relationship attribute . |
151 | public function getRawAttributes ( ) : array { $ attributes = $ this -> wrappedEntity -> getEntityAttributes ( ) ; foreach ( $ this -> entityMap -> getNonEmbeddedRelationships ( ) as $ relation ) { unset ( $ attributes [ $ relation ] ) ; } if ( $ this -> entityMap -> getInheritanceType ( ) == 'single_table' ) { $ attri... | Get Raw Entity s attributes as they are represented in the database including value objects foreign keys and discriminator column . |
152 | protected function mergeForeignKeysWithAttributes ( array $ foreignKeys , array $ attributes ) : array { $ cachedAttributes = $ this -> getCachedRawAttributes ( ) ; foreach ( $ foreignKeys as $ fkAttributeKey => $ fkAttributeValue ) { if ( ! array_key_exists ( $ fkAttributeKey , $ attributes ) ) { $ attributes [ $ fkAt... | Merge foreign keys and attributes by comparing their current value to the cache and guess the user intent . |
153 | protected function addDiscriminatorColumn ( array $ attributes ) : array { $ discriminatorColumn = $ this -> entityMap -> getDiscriminatorColumn ( ) ; $ entityClass = $ this -> entityMap -> getClass ( ) ; if ( ! array_key_exists ( $ discriminatorColumn , $ attributes ) ) { $ map = $ this -> entityMap -> getDiscriminato... | Add Discriminator Column if it doesn t exist on the actual entity . |
154 | protected function flattenEmbeddables ( array $ attributes ) : array { $ embeddables = $ this -> entityMap -> getEmbeddables ( ) ; foreach ( $ embeddables as $ localKey => $ embed ) { $ valueObject = $ attributes [ $ localKey ] ; unset ( $ attributes [ $ localKey ] ) ; $ valueObjectAttributes = $ valueObject -> getEnti... | Convert Value Objects to raw db attributes . |
155 | protected function getCachedRawAttributes ( array $ columns = null ) : array { $ cachedAttributes = $ this -> getCache ( ) -> get ( $ this -> getEntityKeyValue ( ) ) ; if ( is_null ( $ columns ) ) { return $ cachedAttributes ; } return array_only ( $ cachedAttributes , $ columns ) ; } | Return s entity raw attributes in the state they were at last query . |
156 | protected function getCachedAttribute ( $ key ) { $ cachedAttributes = $ this -> getCache ( ) -> get ( $ this -> getEntityKeyValue ( ) ) ; if ( array_key_exists ( $ key , $ cachedAttributes ) ) { return $ cachedAttributes [ $ key ] ; } } | Return a single attribute from the cache . |
157 | public function getForeignKeyAttributes ( ) : array { $ foreignKeys = [ ] ; foreach ( $ this -> entityMap -> getLocalRelationships ( ) as $ relation ) { if ( $ this -> isNonLoadedProxy ( $ relation ) ) { $ foreignKeys = $ foreignKeys + $ this -> getForeignKeyAttributesFromNonLoadedRelation ( $ relation ) ; continue ; }... | Convert related Entity s attributes to foreign keys . |
158 | protected function getNullForeignKeyFromRelation ( string $ relation ) : array { $ key = $ this -> entityMap -> getLocalKeys ( $ relation ) ; if ( is_array ( $ key ) ) { return $ this -> entityMap -> getEmptyValueForLocalKey ( $ relation ) ; } if ( is_null ( $ key ) ) { throw new MappingException ( "Foreign key for rel... | Get a null foreign key value pair for an empty relationship . |
159 | public function updatePivotRecords ( ) { $ pivots = $ this -> entityMap -> getPivotRelationships ( ) ; foreach ( $ pivots as $ pivot ) { if ( array_key_exists ( $ pivot , $ this -> relationships ) ) { $ this -> updatePivotRelation ( $ pivot ) ; } } } | Update Pivot records on loaded relationships by comparing the values from the Entity Cache to the actual relationship inside the aggregated entity . |
160 | protected function updatePivotRelation ( string $ relation ) { $ hashes = $ this -> getEntityHashesFromRelation ( $ relation ) ; $ cachedAttributes = $ this -> getCachedRawAttributes ( ) ; if ( array_key_exists ( $ relation , $ cachedAttributes ) ) { $ new = array_diff ( $ hashes , array_keys ( $ cachedAttributes [ $ r... | Update Single pivot relationship . |
161 | protected function updatePivotIfDirty ( string $ pivotHash , string $ relation ) { $ aggregate = $ this -> getRelatedAggregateFromHash ( $ pivotHash , $ relation ) ; if ( $ aggregate -> hasAttribute ( 'pivot' ) ) { $ pivot = $ aggregate -> getEntityAttribute ( 'pivot' ) -> getEntityAttributes ( ) ; $ cachedPivotAttribu... | Compare existing pivot record in cache and update it if the pivot attributes are dirty . |
162 | protected function getDirtyAttributes ( array $ actual , array $ cached ) : array { $ dirty = [ ] ; foreach ( $ actual as $ key => $ value ) { if ( ! $ this -> originalIsNumericallyEquivalent ( $ value , $ cached [ $ key ] ) ) { $ dirty [ $ key ] = $ actual [ $ key ] ; } } return $ dirty ; } | Compare two attributes array and return dirty attributes . |
163 | protected function getRelatedAggregatesFromHashes ( array $ hashes , string $ relation ) : array { $ related = [ ] ; foreach ( $ hashes as $ hash ) { $ aggregate = $ this -> getRelatedAggregateFromHash ( $ hash , $ relation ) ; if ( $ aggregate ) { $ related [ ] = $ aggregate ; } } return $ related ; } | Returns an array of related Aggregates from its entity hashes . |
164 | protected function getRelatedAggregateFromHash ( string $ hash , string $ relation ) { foreach ( $ this -> relationships [ $ relation ] as $ aggregate ) { if ( $ aggregate -> getEntityHash ( ) == $ hash ) { return $ aggregate ; } } } | Get related aggregate from its hash . |
165 | protected function getEntityHashesFromRelation ( string $ relation ) : array { return array_map ( function ( Aggregate $ aggregate ) { return $ aggregate -> getEntityHash ( ) ; } , $ this -> relationships [ $ relation ] ) ; } | Return an array of Entity Hashes from a specific relation . |
166 | protected function isActualRelationships ( string $ relation ) : bool { return array_key_exists ( $ relation , $ this -> relationships ) && count ( $ this -> relationships [ $ relation ] ) > 0 ; } | Check the existence of an actual relationship . |
167 | public function getDirtyRawAttributes ( ) : array { $ attributes = $ this -> getRawAttributes ( ) ; $ cachedAttributes = $ this -> getCachedRawAttributes ( array_keys ( $ attributes ) ) ; $ dirty = [ ] ; foreach ( $ attributes as $ key => $ value ) { if ( $ this -> isActualRelation ( $ key ) || $ key == 'pivot' ) { con... | Get Only Raw Entity attributes which have been modified since last query . |
168 | protected function isNonLoadedProxy ( string $ key ) : bool { $ relation = $ this -> getEntityAttribute ( $ key ) ; return $ relation instanceof ProxyInterface && ! $ relation -> isProxyInitialized ( ) ; } | Return true if attribute is a non - loaded proxy . |
169 | public function usesAttributesArray ( ) : bool { if ( $ this -> arrayName === null ) { return false ; } if ( $ this -> attributes === null ) { return false ; } return true ; } | Return true if the Entity has an attributes array property . |
170 | public function getCompiledAttributes ( ) : array { $ key = $ this -> getKeyName ( ) ; $ embeddables = array_keys ( $ this -> getEmbeddables ( ) ) ; $ relationships = $ this -> getRelationships ( ) ; $ attributes = $ this -> getAttributes ( ) ; return array_merge ( [ $ key ] , $ embeddables , $ relationships , $ attrib... | Get all the attribute names for the class including relationships embeddables and primary key . |
171 | public function getProperties ( ) : array { return get_parent_class ( __CLASS__ ) !== false ? array_unique ( array_merge ( $ this -> properties , parent :: getProperties ( ) ) ) : $ this -> properties ; } | Return attributes that should be mapped to class properties . |
172 | public function getEmptyValueForRelationship ( string $ relation ) { if ( $ this -> isSingleRelationship ( $ relation ) ) { return ; } if ( $ this -> isManyRelationship ( $ relation ) ) { return new Collection ( ) ; } throw new MappingException ( "Cannot determine default value of $relation" ) ; } | Return empty value for a given relationship . |
173 | public function getEmptyValueForLocalKey ( string $ relation ) { if ( $ this -> isPolymorphic ( $ relation ) ) { $ key = $ this -> localForeignKeys [ $ relation ] ; return [ $ key [ 'type' ] => null , $ key [ 'id' ] => null , ] ; } if ( $ this -> isManyRelationship ( $ relation ) ) { return [ ] ; } } | Return empty value for a local foreign key . |
174 | public function getLocalKeys ( $ relation ) { return isset ( $ this -> localForeignKeys [ $ relation ] ) ? $ this -> localForeignKeys [ $ relation ] : null ; } | Return the local keys associated to the relationship . |
175 | protected function addSingleRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> singleRelations ) ) { $ this -> singleRelations [ ] = $ relation ; } } | Add a single relation method name once . |
176 | protected function addForeignRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> foreignRelations ) ) { $ this -> foreignRelations [ ] = $ relation ; } } | Add a foreign relation method name once . |
177 | protected function addPolymorphicRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> polymorphicRelations ) ) { $ this -> polymorphicRelations [ ] = $ relation ; } } | Add a polymorphic relation method name once . |
178 | protected function addNonProxyRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> nonProxyRelationships ) ) { $ this -> nonProxyRelationships [ ] = $ relation ; } } | Add a non proxy relation method name once . |
179 | protected function addLocalRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> localRelations ) ) { $ this -> localRelations [ ] = $ relation ; } } | Add a local relation method name once . |
180 | protected function addManyRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> manyRelations ) ) { $ this -> manyRelations [ ] = $ relation ; } } | Add a many relation method name once . |
181 | protected function addPivotRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> pivotRelations ) ) { $ this -> pivotRelations [ ] = $ relation ; } } | Add a pivot relation method name once . |
182 | protected function addEmbeddedRelation ( string $ relation ) { if ( ! in_array ( $ relation , $ this -> embeddedRelations ) ) { $ this -> embeddedRelations [ ] = $ relation ; } } | Add an embedded relation . |
183 | public function embedsOne ( $ parent , string $ relatedClass , string $ relation = null ) : EmbedsOne { if ( is_null ( $ relation ) ) { list ( , $ caller ) = debug_backtrace ( false ) ; $ relation = $ caller [ 'function' ] ; } $ this -> addEmbeddedRelation ( $ relation ) ; $ this -> addNonProxyRelation ( $ relation ) ;... | Define an Embedded Object . |
184 | public function embedsMany ( $ parent , string $ relatedClass , string $ relation = null ) : EmbedsMany { if ( is_null ( $ relation ) ) { list ( , $ caller ) = debug_backtrace ( false ) ; $ relation = $ caller [ 'function' ] ; } $ this -> addEmbeddedRelation ( $ relation ) ; $ this -> addNonProxyRelation ( $ relation )... | Define an Embedded Collection . |
185 | public function initialize ( ) { $ userMethods = $ this -> getCustomMethods ( ) ; if ( count ( $ userMethods ) > 0 ) { $ this -> relationships = $ this -> parseMethodsForRelationship ( $ userMethods ) ; } if ( count ( $ this -> dynamicRelationships ) > 0 ) { $ this -> relationships = $ this -> relationships + $ this ->... | Process EntityMap parsing at initialization time . |
186 | protected function parseMethodsForRelationship ( array $ customMethods ) : array { $ relationships = [ ] ; $ class = new ReflectionClass ( get_class ( $ this ) ) ; $ entityClass = $ this -> getClass ( ) ; foreach ( $ customMethods as $ methodName ) { $ method = $ class -> getMethod ( $ methodName ) ; if ( $ method -> g... | Parse user s class methods for relationships . |
187 | protected function sortRelationshipsByType ( ) { $ entityClass = $ this -> getClass ( ) ; $ entity = unserialize ( sprintf ( 'O:%d:"%s":0:{}' , strlen ( $ entityClass ) , $ entityClass ) ) ; foreach ( $ this -> relationships as $ relation ) { $ this -> $ relation ( $ entity ) ; } } | Sort Relationships methods by type . |
188 | public function getAdapter ( string $ driver , string $ connection = null ) { if ( array_key_exists ( $ driver , $ this -> drivers ) ) { return $ this -> drivers [ $ driver ] -> getAdapter ( $ connection ) ; } } | Get the DBAdapter . |
189 | public function make ( $ object ) { $ manager = Manager :: getInstance ( ) ; $ config = new Configuration ( get_class ( $ object ) ) ; $ hydratorClass = $ config -> createFactory ( ) -> getHydratorClass ( ) ; $ hydrator = new $ hydratorClass ( ) ; if ( $ manager -> isValueObject ( $ object ) ) { $ entityMap = $ manager... | Build the wrapper corresponding to the object s type . |
190 | public function match ( array $ results , $ relation ) { $ entities = $ this -> getEager ( ) ; $ dictionary = $ this -> buildDictionary ( $ entities ) ; $ keyName = $ this -> parentMap -> getKeyName ( ) ; $ cache = $ this -> parentMapper -> getEntityCache ( ) ; $ host = $ this ; return array_map ( function ( $ result )... | Match Eagerly loaded relation to result . |
191 | public function updatePivot ( $ entity ) { $ keyName = $ this -> relatedMap -> getKeyName ( ) ; $ this -> updateExistingPivot ( $ entity -> getEntityAttribute ( $ keyName ) , $ entity -> getEntityAttribute ( 'pivot' ) -> getEntityAttributes ( ) ) ; } | Update Pivot . |
192 | public function createPivots ( $ relatedEntities ) { $ keys = [ ] ; $ attributes = [ ] ; $ keyName = $ this -> relatedMap -> getKeyName ( ) ; foreach ( $ relatedEntities as $ entity ) { $ keys [ ] = $ entity -> getEntityAttribute ( $ keyName ) ; } $ records = $ this -> createAttachRecords ( $ keys , $ attributes ) ; $ ... | Create Pivot Records . |
193 | protected function matchAsAttributes ( array $ attributes ) : array { $ attributesMap = $ this -> getAttributesDictionnary ( ) ; $ originalAttributes = array_only ( $ attributes , $ attributesMap ) ; $ embeddedAttributes = [ ] ; foreach ( $ originalAttributes as $ key => $ value ) { $ embeddedKey = array_search ( $ key... | Transform attributes from the parent entity result into an embedded object and return the updated attributes . |
194 | protected function getAttributesDictionnary ( ) : array { $ embeddedAttributeKeys = $ this -> getEmbeddedObjectAttributes ( ) ; $ attributesMap = [ ] ; foreach ( $ embeddedAttributeKeys as $ key ) { $ attributesMap [ $ key ] = $ this -> getParentAttributeKey ( $ key ) ; } return $ attributesMap ; } | Return a dictionary of attributes key on parent Entity . |
195 | protected function normalizeAsArray ( $ object ) : array { $ wrapper = $ this -> factory -> make ( $ object ) ; $ value = $ wrapper -> getEntityAttributes ( ) ; if ( $ this -> asJson ) { $ value = json_encode ( $ value ) ; } return [ $ this -> relation => $ value ] ; } | Normalize object an array containing raw attributes . |
196 | protected function normalizeAsAttributes ( $ object ) : array { if ( is_null ( $ object ) ) { return $ this -> nullObjectAttributes ( ) ; } $ attributesMap = $ this -> getAttributesDictionnary ( ) ; $ wrapper = $ this -> factory -> make ( $ object ) ; $ normalizedAttributes = [ ] ; foreach ( $ attributesMap as $ embedK... | Normalize object as parent s attributes . |
197 | protected function nullObjectAttributes ( ) : array { $ attributesMap = $ this -> getAttributesDictionnary ( ) ; $ normalizedAttributes = [ ] ; foreach ( $ attributesMap as $ embedKey => $ parentKey ) { $ normalizedAttributes [ $ parentKey ] = null ; } return $ normalizedAttributes ; } | Set all object attributes to null . |
198 | public function execute ( ) { $ entity = $ this -> aggregate -> getEntityObject ( ) ; $ wrappedEntity = $ this -> aggregate -> getWrappedEntity ( ) ; $ mapper = $ this -> aggregate -> getMapper ( ) ; if ( $ mapper -> fireEvent ( 'storing' , $ wrappedEntity ) === false ) { return false ; } $ this -> preStoreProcess ( ) ... | Persist the entity in the database . |
199 | protected function preStoreProcess ( ) { $ localRelationships = $ this -> aggregate -> getEntityMap ( ) -> getLocalRelationships ( ) ; $ this -> createRelatedEntities ( $ localRelationships ) ; $ this -> aggregate -> syncRelationships ( $ localRelationships ) ; } | Run all operations that have to occur before actually storing the entity . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.