Doctrine\ODM\MongoDB\PersistentCollection::setDirty PHP Method

setDirty() public method

Sets a boolean flag, indicating whether this collection is dirty.
public setDirty ( boolean $dirty )
$dirty boolean Whether the collection should be marked dirty or not.
    public function setDirty($dirty)
    {
        $this->isDirty = $dirty;
    }

Usage Example

Example #1
0
 /**
  * Get a documents actual data, flattening all the objects to arrays.
  *
  * @param object $document
  * @return array
  */
 public function getDocumentActualData($document)
 {
     $class = $this->dm->getClassMetadata(get_class($document));
     $actualData = array();
     foreach ($class->reflFields as $name => $refProp) {
         $mapping = $class->fieldMappings[$name];
         $value = $refProp->getValue($document);
         if (isset($mapping['file']) && !$value instanceof GridFSFile) {
             $value = new GridFSFile($value);
             $class->reflFields[$name]->setValue($document, $value);
             $actualData[$name] = $value;
         } elseif (($class->isCollectionValuedReference($name) || $class->isCollectionValuedEmbed($name)) && $value !== null && !$value instanceof PersistentCollection) {
             // If $actualData[$name] is not a Collection then use an ArrayCollection.
             if (!$value instanceof Collection) {
                 $value = new ArrayCollection($value);
             }
             // Inject PersistentCollection
             $coll = new PersistentCollection($value, $this->dm, $this, $this->cmd);
             $coll->setOwner($document, $mapping);
             $coll->setDirty(!$value->isEmpty());
             $class->reflFields[$name]->setValue($document, $coll);
             $actualData[$name] = $coll;
         } else {
             if (!$class->isIdentifier($name) || $class->isIdGeneratorNone()) {
                 $actualData[$name] = $value;
             }
         }
     }
     return $actualData;
 }
All Usage Examples Of Doctrine\ODM\MongoDB\PersistentCollection::setDirty