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

getCleanStateOfProperty() public method

If nothing is found, NULL is returned.
public getCleanStateOfProperty ( object $object, string $propertyName ) : mixed
$object object
$propertyName string
return mixed
    public function getCleanStateOfProperty($object, $propertyName)
    {
        if ($this->isReconstitutedEntity($object) === false) {
            return null;
        }
        $identifier = $this->getIdentifierByObject($object);
        if (!isset($this->reconstitutedEntitiesData[$identifier]['properties'][$propertyName])) {
            return null;
        }
        return $this->reconstitutedEntitiesData[$identifier]['properties'][$propertyName];
    }

Usage Example

 /**
  * Remove any unreferenced non aggregate root entity
  *
  * @param object $object
  * @param string $propertyName
  * @param array $propertyMetaData
  * @return void
  */
 protected function removeDeletedReference($object, $propertyName, $propertyMetaData)
 {
     $previousValue = $this->persistenceSession->getCleanStateOfProperty($object, $propertyName);
     if ($previousValue !== null && is_array($previousValue) && isset($previousValue['value']['identifier']) && $this->reflectionService->getClassSchema($propertyMetaData['type'])->getModelType() === ClassSchema::MODELTYPE_ENTITY && $this->reflectionService->getClassSchema($propertyMetaData['type'])->isAggregateRoot() === false) {
         $object = $this->persistenceSession->getObjectByIdentifier($previousValue['value']['identifier']);
         if (!$this->visitedDuringPersistence->contains($object)) {
             $this->removeEntity($object);
         }
     }
 }