vendor/shopware/platform/src/Core/Profiling/Entity/EntityReaderProfiler.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\EntityCollection;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Read\EntityReaderInterface;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  8. use Symfony\Component\Stopwatch\Stopwatch;
  9. class EntityReaderProfiler implements EntityReaderInterface
  10. {
  11.     /**
  12.      * @var EntityReaderInterface
  13.      */
  14.     private $decorated;
  15.     /**
  16.      * @var Stopwatch
  17.      */
  18.     private $stopwatch;
  19.     public function __construct(EntityReaderInterface $decoratedStopwatch $stopwatch)
  20.     {
  21.         $this->decorated $decorated;
  22.         $this->stopwatch $stopwatch;
  23.     }
  24.     public function read(EntityDefinition $definitionCriteria $criteriaContext $context): EntityCollection
  25.     {
  26.         $title $criteria->getTitle() ?? $definition->getEntityName();
  27.         $this->stopwatch->start('read:' $title);
  28.         $data $this->decorated->read($definition$criteria$context);
  29.         $this->stopwatch->stop('read:' $title);
  30.         return $data;
  31.     }
  32. }