PHP code example of 3slab / vdm-library-doctrine-transport-bundle
1. Go to this page and download the library: Download 3slab/vdm-library-doctrine-transport-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/ */
3slab / vdm-library-doctrine-transport-bundle example snippets
/**
* @ORM\Id()
*/
private $id;
$repo->findOneBy([ 'code' => $yourEntity->getCode(), 'hash' => $yourEntity->getHash() ])
$repo->findOneBy([ 'label' => $yourEntity->getLibelle(), 'hash' => $yourEntity->hash() ])
// Foo
$repo->findOneBy([ 'code' => $foo->getCode(), 'label' => $foo->getLibelle(), 'hash' => $foo->hash() ]);
// Bar
$repo->find($bar->getId());
// Baz
$repo->findOneBy([ 'reference' => $baz->getReference() ]);
namespace App\Executor\Doctrine;
use Vdm\Bundle\LibraryDoctrineTransportBundle\Executor\AbstractDoctrineExecutor;
use Vdm\Bundle\LibraryBundle\Model\Message;
class CustomDoctrineExecutor extends AbstractDoctrineExecutor
{
public function execute(Message $message): void
{
if (!$this->manager) {
throw new NoConnectionException('No connection was defined.');
}
$entityMetadatas = $message->getMetadatasByKey('entity');
$entityMetadata = array_shift($entityMetadatas);
$entityClass = $entityMetadata->getValue();
$entity = $this->serializer->denormalize($message->getPayload(), $entityClass);
$entity = $this->matchEntity($entity);
$this->manager->persist($entity);
$this->manager->flush();
}
}