| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- namespace AppBundle\Entity\Product;
- use AppBundle\Annotation\ExportSplitFields;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- /**
- * Equipment composé d'autres Equipments
- * Fais le lien entre un équipement parent et des équipements enfants
- *
- * @Iri("http://schema.org/EquipmentComposition")
- */
- #[ORM\Entity]
- class EquipmentComposition
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['equipmentcomposition', 'equipment_list', 'equipment_details'])]
- private $id;
- /**
- * @var Equipment
- */
- #[ORM\ManyToOne(targetEntity: 'Equipment', inversedBy: 'equipmentComposition')]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['equipmentcomposition'])]
- private $parent;
- /**
- * @var Equipment
- */
- #[ORM\ManyToOne(targetEntity: 'Equipment')]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['equipmentcomposition', 'equipment_list_equipmentcomposition', 'equipment_details_equipmentcomposition'])]
- private $children;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[Assert\Type(type: 'integer', message: 'invalid-integer')]
- #[Assert\NotNull]
- #[Groups(['equipmentcomposition', 'equipment_details_equipmentcomposition'])]
- private $quantity;
- /**
- * @var string
- * @ExportSplitFields({"children.equipmentList.familly","children.brand","children.model"})
- */
- #[Groups(['template'])]
- private $fullLabelTemplate;
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Sets parent.
- *
- * @param Equipment $parent
- *
- * @return $this
- */
- public function setParent(Equipment $parent)
- {
- $this->parent = $parent;
- return $this;
- }
- /**
- * Gets parent.
- *
- * @return Equipment
- */
- public function getParent()
- {
- return $this->parent;
- }
- /**
- * Sets children.
- *
- * @param Equipment $children
- *
- * @return $this
- */
- public function setChildren(Equipment $children)
- {
- $this->children = $children;
- return $this;
- }
- /**
- * Gets children.
- *
- * @return Equipment
- */
- public function getChildren()
- {
- return $this->children;
- }
- /**
- * Sets quantity.
- *
- * @param int $quantity
- *
- * @return $this
- */
- public function setQuantity($quantity)
- {
- $this->quantity = intval($quantity);
- return $this;
- }
- /**
- * Gets quantity.
- *
- * @return int
- */
- public function getQuantity()
- {
- return $this->quantity;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelTemplate()
- {
- $children = $this->getChildren();
- if(empty($children))
- return [];
- return [
- ['value' => $children->getEquipmentList() ? $children->getEquipmentList()->getFamilly() : '', 'translate' => true],
- $children->getBrand(),
- $children->getModel()
- ];
- }
- }
|