Neos\Flow\Persistence\AbstractPersistenceManager::convertObjectToIdentityArray PHP Метод

convertObjectToIdentityArray() публичный Метод

Converts the given object into an array containing the identity of the domain object.
public convertObjectToIdentityArray ( object $object ) : array
$object object The object to be converted
Результат array The identity array in the format array('__identity' => '...')
    public function convertObjectToIdentityArray($object)
    {
        $identifier = $this->getIdentifierByObject($object);
        if ($identifier === null) {
            throw new Exception\UnknownObjectException(sprintf('Tried to convert an object of type "%s" to an identity array, but it is unknown to the Persistence Manager.', get_class($object)), 1302628242);
        }
        return ['__identity' => $identifier];
    }

Usage Example

 /**
  * @test
  * @expectedException \Neos\Flow\Persistence\Exception\UnknownObjectException
  */
 public function convertObjectToIdentityArrayThrowsExceptionIfIdentityForTheGivenObjectCantBeDetermined()
 {
     $someObject = new \stdClass();
     $this->abstractPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($someObject)->will($this->returnValue(null));
     $this->abstractPersistenceManager->convertObjectToIdentityArray($someObject);
 }