|  | 
|  | 1 | +<?php | 
|  | 2 | +declare(strict_types=1); | 
|  | 3 | + | 
|  | 4 | +/** | 
|  | 5 | + * Pimcore | 
|  | 6 | + * | 
|  | 7 | + * This source file is available under two different licenses: | 
|  | 8 | + * - GNU General Public License version 3 (GPLv3) | 
|  | 9 | + * - Pimcore Commercial License (PCL) | 
|  | 10 | + * Full copyright and license information is available in | 
|  | 11 | + * LICENSE.md which is distributed with this source code. | 
|  | 12 | + * | 
|  | 13 | + *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org) | 
|  | 14 | + *  @license    http://www.pimcore.org/license     GPLv3 and PCL | 
|  | 15 | + */ | 
|  | 16 | + | 
|  | 17 | +namespace Pimcore\Bundle\GenericDataIndexBundle\EventSubscriber; | 
|  | 18 | + | 
|  | 19 | +use Exception; | 
|  | 20 | +use Pimcore\Bundle\GenericDataIndexBundle\Installer; | 
|  | 21 | +use Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\ElementLockServiceInterface; | 
|  | 22 | +use Pimcore\Event\ElementEvents; | 
|  | 23 | +use Pimcore\Event\Model\ElementEvent; | 
|  | 24 | +use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 
|  | 25 | + | 
|  | 26 | +/** | 
|  | 27 | + * @internal | 
|  | 28 | + */ | 
|  | 29 | +final readonly class LockElementSubscriber implements EventSubscriberInterface | 
|  | 30 | +{ | 
|  | 31 | +    public function __construct( | 
|  | 32 | +        private Installer $installer, | 
|  | 33 | +        private ElementLockServiceInterface $lockService, | 
|  | 34 | +    ) { | 
|  | 35 | +    } | 
|  | 36 | + | 
|  | 37 | +    public static function getSubscribedEvents(): array | 
|  | 38 | +    { | 
|  | 39 | +        return [ | 
|  | 40 | +            ElementEvents::POST_ELEMENT_UNLOCK_PROPAGATE => 'updateUnlockPropagate', | 
|  | 41 | +        ]; | 
|  | 42 | +    } | 
|  | 43 | + | 
|  | 44 | +    /** | 
|  | 45 | +     * @throws Exception | 
|  | 46 | +     */ | 
|  | 47 | +    public function updateUnlockPropagate(ElementEvent $event): void | 
|  | 48 | +    { | 
|  | 49 | +        if (!$this->installer->isInstalled()) { | 
|  | 50 | +            return; | 
|  | 51 | +        } | 
|  | 52 | + | 
|  | 53 | +        $this->lockService->unlockPropagate($event->getElement()); | 
|  | 54 | +    } | 
|  | 55 | +} | 
0 commit comments