src/Entity/CompanyDeliveryAddress.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6.  * @ORM\Entity
  7.  */
  8. class CompanyDeliveryAddress extends CompanyAddress
  9. {
  10.     /**
  11.      * @ORM\ManyToOne(
  12.      *     targetEntity="Company",
  13.      *     inversedBy="deliveryAddresses"
  14.      * )
  15.      * @ORM\JoinColumn(
  16.      *     name="company_id",
  17.      *     referencedColumnName="id",
  18.      *     onDelete="cascade"
  19.      * )
  20.      * @Assert\NotNull
  21.      *
  22.      * @var Company
  23.      */
  24.     protected Company $company;
  25.     /**
  26.      * @param Company $company
  27.      */
  28.     public function __construct(Company $company)
  29.     {
  30.         $this->setCompany($company);
  31.         parent::__construct($company->getName());
  32.     }
  33.     /**
  34.      * @return Company
  35.      */
  36.     public function getCompany(): Company
  37.     {
  38.         return $this->company;
  39.     }
  40.     /**
  41.      * @return string
  42.      */
  43.     public function getType(): string
  44.     {
  45.         return 'delivery';
  46.     }
  47.     /**
  48.      * @param Company $company
  49.      */
  50.     public function setCompany(Company $company): void
  51.     {
  52.         $this->company $company;
  53.         $this->populate($company);
  54.     }
  55. }