src/AtechNet/CoreBundle/Entity/ProductModelConfigFieldValue.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping\Column;
  4. use Doctrine\ORM\Mapping\Entity;
  5. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  6. use Doctrine\ORM\Mapping\JoinColumn;
  7. use Doctrine\ORM\Mapping\ManyToOne;
  8. use App\AtechNet\CoreBundle\Enum\UnitList;
  9. use Doctrine\ORM\Mapping\Table as Table;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * ProductModelConfigFieldValue
  13.  *
  14.  * @Table(name="product_model_config_field_values")
  15.  * @Entity
  16.  * @HasLifecycleCallbacks
  17.  */
  18. class ProductModelConfigFieldValue extends AbstractSignedEntity
  19. {
  20.     /**
  21.      * @var ProductModel
  22.      *
  23.      * @ManyToOne(targetEntity="ProductModel", inversedBy="productModelConfigFieldValues")
  24.      * @JoinColumn(name="product_model_id", referencedColumnName="id")
  25.      */
  26.     private ProductModel $productModel;
  27.     /**
  28.      * @var V2Attribute
  29.      *
  30.      * @Assert\NotNull
  31.      *
  32.      * @ManyToOne(targetEntity="V2Attribute", inversedBy="additionalFields")
  33.      * @JoinColumn(name="v2_attribute_id", referencedColumnName="id")
  34.      */
  35.     private $v2Attribute;
  36.     /**
  37.      * @var string
  38.      *
  39.      * @Assert\NotNull
  40.      *
  41.      * @Column(name="field_value", type="text")
  42.      */
  43.     private $fieldValue;
  44.     /**
  45.      * @var int
  46.      *
  47.      * @Column(name="unit", type="integer", nullable=true)
  48.      */
  49.     private $fieldValueUnit;
  50.     /**
  51.      * @return ProductModel
  52.      */ 
  53.     public function getProductModel(): ProductModel
  54.     {
  55.         return $this->productModel;
  56.     }
  57.     /**
  58.      * @param ProductModel $productModel
  59.      */ 
  60.     public function setProductModel(ProductModel $productModel): void
  61.     {
  62.         $this->productModel = $productModel;
  63.     }
  64.     /**
  65.      * @return V2Attribute
  66.      */
  67.     public function getV2Attribute()
  68.     {
  69.         return $this->v2Attribute;
  70.     }
  71.     /**
  72.      * @param V2Attribute $vV2Attribute
  73.      */
  74.     public function setV2Attribute(V2Attribute $v2Attribute)
  75.     {
  76.         $this->v2Attribute = $v2Attribute;
  77.     }
  78.     /**
  79.      * @return string
  80.      */
  81.     public function getFieldValue()
  82.     {
  83.         return $this->fieldValue;
  84.     }
  85.     /**
  86.      * @param string $fieldValue
  87.      */
  88.     public function setFieldValue(string $fieldValue)
  89.     {
  90.         $this->fieldValue = $fieldValue;
  91.     }
  92.     /**
  93.      * @return string[]
  94.      */
  95.     public static function getUnitList(): array
  96.     {
  97.         return UnitList::getChoices();
  98.     }
  99.     /**
  100.      * @return UnitList|null
  101.      */
  102.     public function getUnit(): ?UnitList
  103.     {
  104.         return $this->fieldValueUnit ? UnitList::from($this->fieldValueUnit) : null;
  105.     }
  106.     /**
  107.      * @param UnitList|null
  108.      */
  109.     public function setUnit(?UnitList $fieldValueUnit)
  110.     {
  111.         $this->fieldValueUnit = $fieldValueUnit?->value;
  112.     }
  113. }