vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/EventListener/LockingListener.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\CoreBundle\EventListener;
  12. use Doctrine\DBAL\LockMode;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. use Sylius\Component\Resource\Model\VersionedInterface;
  15. use Symfony\Component\EventDispatcher\GenericEvent;
  16. use Webmozart\Assert\Assert;
  17. final class LockingListener
  18. {
  19.     public function __construct(private EntityManagerInterface $manager)
  20.     {
  21.     }
  22.     public function lock(GenericEvent $event): void
  23.     {
  24.         $subject $event->getSubject();
  25.         Assert::isInstanceOf($subjectVersionedInterface::class);
  26.         $this->manager->lock($subjectLockMode::OPTIMISTIC$subject->getVersion());
  27.     }
  28. }