PHP code example of vivait / delayed-event-bundle
1. Go to this page and download the library: Download vivait/delayed-event-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vivait / delayed-event-bundle example snippets
class AcmeTransformer implements TransformerInterface
{
/**
* @param ReflectionProperty $property
* @return bool
*/public function supports(\ReflectionProperty $property) {
$property->getValue();
return is_object($data) && $this->doctrine->contains($data);
}
/**
* @param $data
* @return array
*/public function serialize($data)
{
// Get the ID
$id = $this->doctrine->getMetaData($data)->getIdentifierFieldNames();
$class = get_class($data);
/* @var UnitOfWork $uow */
$uow = $this->doctrine->getUnitOfWork();
$id = $uow->getDocumentIdentifier($data);
return [
$class,
$id
];
}
/**
* @param $data
* @return mixed
*/public function deserialize($data)
{
[$class, $id] = $data;
return $this->doctrine->getRepository($class)->find($id);
}
}