Neos\Flow\Persistence\Generic\Session::isDirty PHP Method

isDirty() public method

Checks whether the given property was changed in the object since it was reconstituted. Returns TRUE for unknown objects in all cases!
public isDirty ( object $object, string $propertyName ) : boolean
$object object
$propertyName string
return boolean
    public function isDirty($object, $propertyName)
    {
        if ($this->isReconstitutedEntity($object) === false) {
            return true;
        }
        if (property_exists($object, 'Flow_Persistence_LazyLoadingObject_thawProperties')) {
            return false;
        }
        $currentValue = ObjectAccess::getProperty($object, $propertyName, true);
        $cleanData =& $this->reconstitutedEntitiesData[$this->getIdentifierByObject($object)]['properties'][$propertyName];
        if ($currentValue instanceof LazySplObjectStorage && !$currentValue->isInitialized() || $currentValue === null && $cleanData['value'] === null) {
            return false;
        }
        if ($cleanData['multivalue']) {
            return $this->isMultiValuedPropertyDirty($cleanData, $currentValue);
        } else {
            return $this->isSingleValuedPropertyDirty($cleanData['type'], $cleanData['value'], $currentValue);
        }
    }

Usage Example

 /**
  *
  * @param string $identifier The object's identifier
  * @param object $object The object to work on
  * @param array $properties The properties to collect (as per class schema)
  * @param boolean $dirty A dirty flag that is passed by reference and set to TRUE if a dirty property was found
  * @return array
  */
 protected function collectProperties($identifier, $object, array $properties, &$dirty)
 {
     $propertyData = [];
     foreach ($properties as $propertyName => $propertyMetaData) {
         $propertyValue = $this->checkPropertyValue($object, $propertyName, $propertyMetaData);
         // handle all objects now, because even clean ones need to be traversed
         // as dirty checking is not recursive
         if ($propertyValue instanceof PersistenceMagicInterface) {
             if ($this->persistenceSession->isDirty($object, $propertyName)) {
                 $dirty = true;
                 $this->flattenValue($identifier, $object, $propertyName, $propertyMetaData, $propertyData);
             } else {
                 $this->persistObject($propertyValue, $identifier);
             }
         } elseif ($this->persistenceSession->isDirty($object, $propertyName)) {
             $dirty = true;
             $this->flattenValue($identifier, $object, $propertyName, $propertyMetaData, $propertyData);
         }
     }
     return $propertyData;
 }
All Usage Examples Of Neos\Flow\Persistence\Generic\Session::isDirty