vendor/shopware/core/Profiling/Entity/EntitySearcherProfiler.php line 36

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Profiling\Entity;
  3. use Shopware\Core\Framework\Context;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearcherInterface;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\IdSearchResult;
  8. use Symfony\Component\Stopwatch\Stopwatch;
  9. class EntitySearcherProfiler implements EntitySearcherInterface
  10. {
  11.     /**
  12.      * @var EntitySearcherInterface
  13.      */
  14.     private $decorated;
  15.     /**
  16.      * @var Stopwatch
  17.      */
  18.     private $stopwatch;
  19.     public function __construct(EntitySearcherInterface $decoratedStopwatch $stopwatch)
  20.     {
  21.         $this->decorated $decorated;
  22.         $this->stopwatch $stopwatch;
  23.     }
  24.     public function search(EntityDefinition $definitionCriteria $criteriaContext $context): IdSearchResult
  25.     {
  26.         $title $criteria->getTitle() ?? $definition->getEntityName();
  27.         $this->stopwatch->start('search:' $title);
  28.         $data $this->decorated->search($definition$criteria$context);
  29.         $this->stopwatch->stop('search:' $title);
  30.         return $data;
  31.     }
  32. }