isInitialized() public method

Checks whether this collection has been initialized.
public isInitialized ( ) : boolean
return boolean
Exemplo n.º 1
0
 /**
  * Fixes PersistentCollection state if it wasn't used exactly as we had in mind:
  *  1) sets owner if it was cloned
  *  2) clones collection, sets owner, updates document's property and, if necessary, updates originalData
  *  3) NOP if state is OK
  * Returned collection should be used from now on (only important with 2nd point)
  *
  * @param PersistentCollection $coll
  * @param object $document
  * @param ClassMetadata $class
  * @param string $propName
  * @return PersistentCollection
  */
 private function fixPersistentCollectionOwnership(PersistentCollection $coll, $document, ClassMetadata $class, $propName)
 {
     $owner = $coll->getOwner();
     if ($owner === null) {
         // cloned
         $coll->setOwner($document, $class->fieldMappings[$propName]);
     } elseif ($owner !== $document) {
         // no clone, we have to fix
         if (!$coll->isInitialized()) {
             $coll->initialize();
             // we have to do this otherwise the cols share state
         }
         $newValue = clone $coll;
         $newValue->setOwner($document, $class->fieldMappings[$propName]);
         $class->reflFields[$propName]->setValue($document, $newValue);
         if ($this->isScheduledForUpdate($document)) {
             // @todo following line should be superfluous once collections are stored in change sets
             $this->setOriginalDocumentProperty(spl_object_hash($document), $propName, $newValue);
         }
         return $newValue;
     }
     return $coll;
 }
Exemplo n.º 2
0
 private function fixPersistentCollectionOwnership(PersistentCollection $coll, $document, $class, $propName)
 {
     $owner = $coll->getOwner();
     if ($owner === null) {
         // cloned
         $coll->setOwner($document, $class->fieldMappings[$propName]);
     } elseif ($owner !== $document) {
         // no clone, we have to fix
         if (!$coll->isInitialized()) {
             $coll->initialize();
             // we have to do this otherwise the cols share state
         }
         $newValue = clone $coll;
         $newValue->setOwner($document, $class->fieldMappings[$propName]);
         $class->reflFields[$propName]->setValue($document, $newValue);
         return $newValue;
     }
     return $coll;
 }
 /**
  * {@inheritdoc}
  */
 public function isInitialized()
 {
     return $this->collection->isInitialized();
 }