src/Entity/Channel/CompanyContact.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Common\Contact;
  4. use App\Enum\Serialization\CompanyContactSerializationGroups;
  5. use App\Enum\Serialization\ReverseSyncSerializationGroups;
  6. use App\Repository\Channel\CompanyContactRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  9. use Nellapp\Bundle\SDKBundle\Channel\Entity\CompanyContact\CompanyContactInterface;
  10. use Nellapp\Bundle\SDKBundle\Channel\Entity\CompanyContact\CompanyContactMethodTrait;
  11. use Nellapp\Bundle\SDKBundle\ReverseSync\Entity\ReverseSyncableInterface;
  12. use Nellapp\Bundle\SDKBundle\ReverseSync\EntityKeys;
  13. use Symfony\Component\Serializer\Annotation as Serial;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. #[
  16.     ORM\Entity(repositoryClassCompanyContactRepository::class),
  17.     ORM\Table(name'channel_company_contacts')
  18. ]
  19. class CompanyContact implements CompanyContactInterfaceReverseSyncableInterface
  20. {
  21.     use CompanyContactMethodTrait;
  22.     #[
  23.         ORM\Id,
  24.         ORM\GeneratedValue(strategy'NONE'),
  25.         ORM\Column(type'string'length36)
  26.     ]
  27.     #[Serial\Groups([
  28.         CompanyContactSerializationGroups::COLLECTION,
  29.         CompanyContactSerializationGroups::DETAIL,
  30.         ReverseSyncSerializationGroups::REVERSE_SYNC,
  31.     ])]
  32.     private ?string $id null;
  33.     #[ORM\Column(type'json')]
  34.     #[Serial\Groups([
  35.         ReverseSyncSerializationGroups::REVERSE_SYNC,
  36.     ])]
  37.     private array $behaviors = [];
  38.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'companyContacts')]
  39.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  40.     #[IdGroups([ReverseSyncSerializationGroups::REVERSE_SYNC])]
  41.     private Company $company;
  42.     #[ORM\ManyToOne(targetEntityChannelContact::class, inversedBy'companyContacts')]
  43.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  44.     #[IdGroups([ReverseSyncSerializationGroups::REVERSE_SYNC])]
  45.     #[Assert\Valid()]
  46.     private ChannelContact $channelContact;
  47.     public function __construct()
  48.     {
  49.         $this->initCompanyContactMethod();
  50.     }
  51.     public static function getReverseSyncKey(): string
  52.     {
  53.          return EntityKeys::COMPANY_CONTACT;
  54.     }
  55.     public function __toString()
  56.     {
  57.         return $this->channelContact->getContact()->getFullName() ?? '';
  58.     }
  59. }