custom/plugins/MoorlForms/src/Core/Content/Element/Selection/ElementSelectionExtension.php line 36

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace MoorlForms\Core\Content\Element\Selection;
  3. use MoorlForms\Core\Content\Element\ElementCollection;
  4. use MoorlForms\Core\Content\Element\ElementEntity;
  5. use MoorlForms\Core\Content\Element\Type\ElementTypeExtension;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. use Shopware\Core\System\SystemConfig\SystemConfigService;
  9. use Symfony\Component\HttpFoundation\Request;
  10. class ElementSelectionExtension implements ElementSelectionInterface
  11. {
  12.     protected SalesChannelContext $salesChannelContext;
  13.     protected SystemConfigService $systemConfigService;
  14.     protected Request $request;
  15.     public function getName(): string
  16.     {
  17.         return "";
  18.     }
  19.     public function getOptions(): array
  20.     {
  21.         return [];
  22.     }
  23.     public function validate(ElementEntity $element, ?array $tree null): void
  24.     {
  25.     }
  26.     public function init(ElementEntity $elementElementCollection $elements): void
  27.     {
  28.     }
  29.     protected function createOption(Entity $itemstring $parentId, ?string &$afterId null): ElementEntity
  30.     {
  31.         /** @var ElementEntity $new */
  32.         $new ElementEntity::createFrom($item);
  33.         $new->setType(ElementTypeExtension::BRANCH_OPTION);
  34.         $new->setTechnicalName($item->getId());
  35.         $new->setParentId($parentId);
  36.         $new->setAfterId($afterId);
  37.         $new->setId(md5($item->getId().$parentId));
  38.         $afterId $new->getId();
  39.         return $new;
  40.     }
  41.     public function jsonSerialize(): array
  42.     {
  43.         return [
  44.             'name' => $this->getName(),
  45.             'options' => $this->getOptions()
  46.         ];
  47.     }
  48.     /**
  49.      * @param SalesChannelContext $salesChannelContext
  50.      */
  51.     public function setSalesChannelContext(SalesChannelContext $salesChannelContext): void
  52.     {
  53.         $this->salesChannelContext $salesChannelContext;
  54.     }
  55.     /**
  56.      * @param SystemConfigService $systemConfigService
  57.      */
  58.     public function setSystemConfigService(SystemConfigService $systemConfigService): void
  59.     {
  60.         $this->systemConfigService $systemConfigService;
  61.     }
  62.     /**
  63.      * @param Request $request
  64.      */
  65.     public function setRequest(Request $request): void
  66.     {
  67.         $this->request $request;
  68.     }
  69. }