vendor/shopware/core/Content/Cms/DataResolver/FieldConfig.php line 8

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Cms\DataResolver;
  3. use Shopware\Core\Content\Cms\Exception\UnexpectedFieldConfigValueType;
  4. use Shopware\Core\Framework\Struct\Struct;
  5. class FieldConfig extends Struct
  6. {
  7.     public const SOURCE_STATIC 'static';
  8.     public const SOURCE_MAPPED 'mapped';
  9.     public const SOURCE_DEFAULT 'default';
  10.     public const SOURCE_PRODUCT_STREAM 'product_stream';
  11.     /**
  12.      * @var string
  13.      */
  14.     protected $name;
  15.     /**
  16.      * @var string
  17.      */
  18.     protected $source;
  19.     /**
  20.      * @var array|bool|float|int|string|null
  21.      */
  22.     protected $value;
  23.     /**
  24.      * @param array|bool|float|int|string|null $value
  25.      */
  26.     public function __construct(string $namestring $source$value)
  27.     {
  28.         $this->name $name;
  29.         $this->source $source;
  30.         $this->value $value;
  31.     }
  32.     public function getName(): string
  33.     {
  34.         return $this->name;
  35.     }
  36.     public function getSource(): string
  37.     {
  38.         return $this->source;
  39.     }
  40.     /**
  41.      * @return array|bool|float|int|string|null
  42.      */
  43.     public function getValue()
  44.     {
  45.         return $this->value;
  46.     }
  47.     public function getArrayValue(): array
  48.     {
  49.         if (\is_array($this->value)) {
  50.             return $this->value;
  51.         }
  52.         throw new UnexpectedFieldConfigValueType($this->name'array', \gettype($this->value));
  53.     }
  54.     public function getStringValue(): string
  55.     {
  56.         if (!\is_array($this->value)) {
  57.             return (string) $this->value;
  58.         }
  59.         throw new UnexpectedFieldConfigValueType($this->name'string', \gettype($this->value));
  60.     }
  61.     public function getIntValue(): int
  62.     {
  63.         if (!\is_array($this->value)) {
  64.             return (int) $this->value;
  65.         }
  66.         throw new UnexpectedFieldConfigValueType($this->name'int', \gettype($this->value));
  67.     }
  68.     public function getFloatValue(): float
  69.     {
  70.         if (!\is_array($this->value)) {
  71.             return (float) $this->value;
  72.         }
  73.         throw new UnexpectedFieldConfigValueType($this->name'float', \gettype($this->value));
  74.     }
  75.     public function getBoolValue(): bool
  76.     {
  77.         return (bool) $this->value;
  78.     }
  79.     public function isStatic(): bool
  80.     {
  81.         return $this->source === self::SOURCE_STATIC;
  82.     }
  83.     public function isMapped(): bool
  84.     {
  85.         return $this->source === self::SOURCE_MAPPED;
  86.     }
  87.     public function isProductStream(): bool
  88.     {
  89.         return $this->source === self::SOURCE_PRODUCT_STREAM;
  90.     }
  91.     public function isDefault(): bool
  92.     {
  93.         return $this->source === self::SOURCE_DEFAULT;
  94.     }
  95.     public function getApiAlias(): string
  96.     {
  97.         return 'cms_data_resolver_field_config';
  98.     }
  99. }