vendor/coreshop/core-shop/src/CoreShop/Bundle/IndexBundle/Factory/ListingFactory.php line 35

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * CoreShop
  5.  *
  6.  * This source file is available under two different licenses:
  7.  *  - GNU General Public License version 3 (GPLv3)
  8.  *  - CoreShop Commercial License (CCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  * @copyright  Copyright (c) CoreShop GmbH (https://www.coreshop.org)
  13.  * @license    https://www.coreshop.org/license     GPLv3 and CCL
  14.  *
  15.  */
  16. namespace CoreShop\Bundle\IndexBundle\Factory;
  17. use CoreShop\Component\Index\Factory\ListingFactoryInterface;
  18. use CoreShop\Component\Index\Listing\ListingInterface;
  19. use CoreShop\Component\Index\Model\IndexInterface;
  20. use CoreShop\Component\Index\Worker\WorkerInterface;
  21. use CoreShop\Component\Registry\ServiceRegistryInterface;
  22. use Symfony\Component\Intl\Exception\InvalidArgumentException;
  23. class ListingFactory implements ListingFactoryInterface
  24. {
  25.     public function __construct(
  26.         private ServiceRegistryInterface $workerServiceRegistry,
  27.     ) {
  28.     }
  29.     public function createList(IndexInterface $index): ListingInterface
  30.     {
  31.         $worker $index->getWorker();
  32.         if (!$this->workerServiceRegistry->has($worker)) {
  33.             throw new InvalidArgumentException(sprintf('%s Worker not found'$worker));
  34.         }
  35.         /**
  36.          * @var WorkerInterface $worker
  37.          */
  38.         $worker $this->workerServiceRegistry->get($worker);
  39.         return $worker->getList($index);
  40.     }
  41. }