src/V4/Model/Listing/Listing.php line 87

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Listing;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Model\IriNormalizableInterface;
  6. use App\Model\NormalizeAsIRITrait;
  7. use App\Model\Traits\ImportableObjectTrait;
  8. use App\V4\Model\ListingItem\ListingItem;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * @ApiResource(
  15.  *     shortName="V4/Listing",
  16.  *     attributes={
  17.  *         "api_allow_update": true
  18.  *     },
  19.  *     collectionOperations={
  20.  *         "get": {
  21.  *             "normalization_context": {
  22.  *                  "groups": {"listing:list"}
  23.  *             },
  24.  *         },
  25.  *         "get_form": {
  26.  *             "method": "GET",
  27.  *             "path": "/v4/listings/form",
  28.  *             "controller": App\V4\Controller\Listing\GetListingFormAction::class
  29.  *         },
  30.  *         "post_listing": {
  31.  *             "method": "POST",
  32.  *             "deserialize": false,
  33.  *             "write": false,
  34.  *             "controller": "App\V4\Controller\Listing\ListingDataPersisterAction",
  35.  *             "path": "/v4/listings",
  36.  *             "input_formats": {
  37.  *                 "multipart": {"multipart/form-data"}
  38.  *             },
  39.  *             "normalization_context": {
  40.  *                  "groups": {"listing:read"}
  41.  *             },
  42.  *             "denormalization_context": {
  43.  *                  "groups": {}
  44.  *             }
  45.  *         },
  46.  *     },
  47.  *     itemOperations={
  48.  *        "get": {
  49.  *             "normalization_context": {
  50.  *                  "groups": {"listing:list"}
  51.  *             },
  52.  *         },
  53.  *         "get_form": {
  54.  *             "method": "GET",
  55.  *             "path": "/v4/listings/{id}/form",
  56.  *             "controller": App\V4\Controller\Listing\GetListingFormAction::class,
  57.  *         },
  58.  *         "put_listing": {
  59.  *             "method": "POST",
  60.  *             "deserialize": false,
  61.  *             "write": false,
  62.  *             "controller": "App\V4\Controller\Listing\ListingDataPersisterAction",
  63.  *             "path": "/v4/listings/{id}",
  64.  *             "input_formats": {
  65.  *                 "multipart": {"multipart/form-data"}
  66.  *             },
  67.  *             "normalization_context": {
  68.  *                  "groups": {"listing:read"}
  69.  *             },
  70.  *             "denormalization_context": {
  71.  *                  "groups": {}
  72.  *             }
  73.  *         },
  74.  *         "delete_listing": {
  75.  *             "method": "DELETE",
  76.  *             "deserialize": false,
  77.  *             "write": false,
  78.  *             "controller": "App\V4\Controller\Listing\ListingDataPersisterAction",
  79.  *             "path": "/v4/listings/{id}",
  80.  *         }
  81.  *     }
  82.  * )
  83.  */
  84. class Listing implements IriNormalizableInterface
  85. {
  86.     use ImportableObjectTrait;
  87.     use NormalizeAsIRITrait;
  88.     const CODE_LISTING_ORIGIN 'Origine';
  89.     const CODE_LISTING_TYPE 'Type';
  90.     const CODE_LISTING_FORM_JURIDIQUE 'Forme Juridique';
  91.     const CODE_LISTING_STRUCTURE_TYPE 'Structure Type';
  92.     const CODE_LISTING_WORKFORCE 'Workforce';
  93.     const CODE_LISTING_NAF 'Naf';
  94.     const CODE_LISTING_TVA 'TVA';
  95.     const CODE_LISTING_SERVICE 'Service';
  96.     const CODE_LISTING_POTENTIAL 'Potential';
  97.     const CODE_LISTING_CIVILITY 'Civility';
  98.     const CODE_LISTING_QUOTE_SECTION 'QuoteSection';
  99.     const NAME_LISTING_QUOTE_SECTION 'Section Devis';
  100.     /**
  101.      * @ApiProperty(identifier=true)
  102.      *
  103.      * @var string
  104.      *
  105.      * @Groups({"listing:list", "listing:read"})
  106.      */
  107.     private $id;
  108.     /**
  109.      * @var string
  110.      *
  111.      * @Assert\NotNull()
  112.      *
  113.      * @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
  114.      */
  115.     private $code;
  116.     /**
  117.      * @var string
  118.      *
  119.      * @Assert\NotNull()
  120.      *
  121.      * @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
  122.      */
  123.     private $name;
  124.     /**
  125.      * @var string
  126.      *
  127.      * @Groups({"listing:list", "listing:read", "listing:write"})
  128.      */
  129.     private $customerId;
  130.     /**
  131.      * @var bool
  132.      *
  133.      * @Assert\NotNull()
  134.      *
  135.      * @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
  136.      */
  137.     private $isActive true;
  138.     /**
  139.      * @var ListingItem[]|ArrayCollection
  140.      *
  141.      * @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
  142.      */
  143.     private $listingItems;
  144.     /**
  145.      * @var array
  146.      */
  147.     private $fields = [];
  148.     public function __construct()
  149.     {
  150.         $this->listingItems = new ArrayCollection();
  151.     }
  152.     /**
  153.      * @return string|null
  154.      */
  155.     public function getId(): ?string
  156.     {
  157.         return $this->id;
  158.     }
  159.     /**
  160.      * @param string|null $id
  161.      *
  162.      * @return Listing
  163.      */
  164.     public function setId(?string $id): self
  165.     {
  166.         $this->id $id;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return string|null
  171.      */
  172.     public function getCode(): ?string
  173.     {
  174.         return $this->code;
  175.     }
  176.     /**
  177.      * @param string|null $code
  178.      *
  179.      * @return Listing
  180.      */
  181.     public function setCode(?string $code): self
  182.     {
  183.         $this->code $code;
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return string|null
  188.      */
  189.     public function getName(): ?string
  190.     {
  191.         return $this->name;
  192.     }
  193.     /**
  194.      * @param string|null $name
  195.      *
  196.      * @return Listing
  197.      */
  198.     public function setName(?string $name): self
  199.     {
  200.         $this->name $name;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return string|null
  205.      */
  206.     public function getCustomerId(): ?string
  207.     {
  208.         return $this->customerId;
  209.     }
  210.     /**
  211.      * @param string|null $customerId
  212.      *
  213.      * @return Listing
  214.      */
  215.     public function setCustomerId(?string $customerId): self
  216.     {
  217.         $this->customerId $customerId;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return bool
  222.      */
  223.     public function getIsActive(): bool
  224.     {
  225.         return $this->isActive;
  226.     }
  227.     /**
  228.      * @param bool $isActive
  229.      *
  230.      * @return Listing
  231.      */
  232.     public function setIsActive(bool $isActive): self
  233.     {
  234.         $this->isActive $isActive;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @param ListingItem $listingItem
  239.      *
  240.      * @return Listing
  241.      */
  242.     public function addListingItem(ListingItem $listingItem): self
  243.     {
  244.         if (!$this->listingItems->contains($listingItem)) {
  245.             $this->listingItems[] = $listingItem;
  246.         }
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return ListingItem[]|Collection
  251.      */
  252.     public function getListingItems(): Collection
  253.     {
  254.         return $this->listingItems;
  255.     }
  256.     /**
  257.      * @param ListingItem $listingItem
  258.      *
  259.      * @return Listing
  260.      */
  261.     public function removeListingItem(ListingItem $listingItem): self
  262.     {
  263.         if (!$this->listingItems->contains($listingItem)) {
  264.             $this->listingItems->removeElement($listingItem);
  265.         }
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return array|null
  270.      */
  271.     public function getFields(): ?array
  272.     {
  273.         return $this->fields;
  274.     }
  275.     /**
  276.      * @param array|null $fields
  277.      *
  278.      * @return Listing
  279.      */
  280.     public function setFields(?array $fields): self
  281.     {
  282.         $this->fields $fields;
  283.         return $this;
  284.     }
  285.     /**
  286.      * @return string
  287.      */
  288.     public function __toString(): string
  289.     {
  290.         return $this->getId() ?? '';
  291.     }
  292. }