for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace AmaTeam\ElasticSearch\Entity\Annotation\Listener\Indexing;
use AmaTeam\ElasticSearch\API\Annotation\Document;
use AmaTeam\ElasticSearch\Entity\Annotation\ClassAnnotationListenerInterface;
use AmaTeam\ElasticSearch\Entity\Entity;
use AmaTeam\ElasticSearch\Entity\Indexing\Indexing;
use ReflectionClass;
class DocumentAnnotationListener implements ClassAnnotationListenerInterface
{
public function accept(ReflectionClass $class, Entity $entity, $annotation): void
if (!($annotation instanceof Document)) {
return;
}
$target = Indexing::from($entity->getIndexing())
->setWriteIndices($annotation->writeIndices)
->setReadIndices($annotation->readIndices)
->setType($annotation->type);
$entity
->setIndexing($target)
->setRootLevelDocument(true);