vendor/shopware/core/Content/Cms/Aggregate/CmsSlot/CmsSlotEntity.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Cms\Aggregate\CmsSlot;
  3. use Shopware\Core\Content\Cms\Aggregate\CmsBlock\CmsBlockEntity;
  4. use Shopware\Core\Content\Cms\DataResolver\FieldConfig;
  5. use Shopware\Core\Content\Cms\DataResolver\FieldConfigCollection;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  7. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  8. use Shopware\Core\Framework\DataAbstractionLayer\EntityCustomFieldsTrait;
  9. use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
  10. use Shopware\Core\Framework\Struct\Struct;
  11. class CmsSlotEntity extends Entity
  12. {
  13.     use EntityIdTrait;
  14.     use EntityCustomFieldsTrait;
  15.     /**
  16.      * @var string
  17.      */
  18.     protected $type;
  19.     /**
  20.      * @var string
  21.      */
  22.     protected $slot;
  23.     /**
  24.      * @var CmsBlockEntity|null
  25.      */
  26.     protected $block;
  27.     /**
  28.      * @var string
  29.      */
  30.     protected $blockId;
  31.     /**
  32.      * @var array|null
  33.      */
  34.     protected $config;
  35.     /**
  36.      * @var FieldConfigCollection|null
  37.      *
  38.      * @internal
  39.      */
  40.     protected $fieldConfig;
  41.     /**
  42.      * @var EntityCollection|null
  43.      */
  44.     protected $translations;
  45.     /**
  46.      * @var Struct|null
  47.      */
  48.     protected $data;
  49.     /**
  50.      * @var bool
  51.      */
  52.     protected $locked;
  53.     public function getType(): string
  54.     {
  55.         return $this->type;
  56.     }
  57.     public function setType(string $type): void
  58.     {
  59.         $this->type $type;
  60.     }
  61.     public function getSlot(): string
  62.     {
  63.         return $this->slot;
  64.     }
  65.     public function setSlot(string $slot): void
  66.     {
  67.         $this->slot $slot;
  68.     }
  69.     public function getBlock(): ?CmsBlockEntity
  70.     {
  71.         return $this->block;
  72.     }
  73.     public function setBlock(CmsBlockEntity $block): void
  74.     {
  75.         $this->block $block;
  76.     }
  77.     public function getBlockId(): string
  78.     {
  79.         return $this->blockId;
  80.     }
  81.     public function setBlockId(string $blockId): void
  82.     {
  83.         $this->blockId $blockId;
  84.     }
  85.     public function getConfig(): ?array
  86.     {
  87.         return $this->config;
  88.     }
  89.     public function setConfig(array $config): void
  90.     {
  91.         $this->config $config;
  92.         $this->fieldConfig null;
  93.     }
  94.     public function getTranslations(): ?EntityCollection
  95.     {
  96.         return $this->translations;
  97.     }
  98.     public function setTranslations(EntityCollection $translations): void
  99.     {
  100.         $this->translations $translations;
  101.     }
  102.     public function getData(): ?Struct
  103.     {
  104.         return $this->data;
  105.     }
  106.     public function setData(Struct $data): void
  107.     {
  108.         $this->data $data;
  109.     }
  110.     public function getLocked(): bool
  111.     {
  112.         return $this->locked;
  113.     }
  114.     public function setLocked(bool $locked): void
  115.     {
  116.         $this->locked $locked;
  117.     }
  118.     public function getFieldConfig(): FieldConfigCollection
  119.     {
  120.         if ($this->fieldConfig) {
  121.             return $this->fieldConfig;
  122.         }
  123.         $collection = new FieldConfigCollection();
  124.         $config $this->getTranslation('config') ?? [];
  125.         foreach ($config as $key => $value) {
  126.             $collection->add(
  127.                 new FieldConfig($key$value['source'], $value['value'])
  128.             );
  129.         }
  130.         return $this->fieldConfig $collection;
  131.     }
  132.     public function setFieldConfig(FieldConfigCollection $fieldConfig): void
  133.     {
  134.         $this->fieldConfig $fieldConfig;
  135.     }
  136. }