src/Entity/SpecialTitle.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use ApiPlatform\Core\Annotation\ApiFilter;
  5. use App\Entity\Traits\TimestampableEntity;
  6. use App\Repository\SpecialTitleRepository;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. use App\Entity\Interfaces\ClientMappedInterface;
  9. use App\Entity\Interfaces\ElasticUpdateInterface;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  13. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  14. use Locastic\ApiPlatformTranslationBundle\Model\AbstractTranslatable;
  15. use Locastic\ApiPlatformTranslationBundle\Model\TranslationInterface;
  16. /**
  17.  * @ApiResource(
  18.  *      attributes={"security"="is_granted('ROLE_OPERATOR')", "filters"={"translation.groups"}},
  19.  *      normalizationContext={"groups"={"SpecialTitle:Read"}, "skip_null_values"=false},
  20.  *      denormalizationContext={"groups"={"SpecialTitle:Write"}},
  21.  *      collectionOperations={
  22.  *          "get"={"security"="is_granted('IS_AUTHENTICATED_FULLY')"},
  23.  *          "get_for_public_page"={
  24.  *              "route_name"="api_pub_special_titles_get_for_public_page_collection",
  25.  *              "method"="GET",
  26.  *              "security"="is_granted('PUBLIC_ACCESS')",
  27.  *              "normalization_context"={"groups"={"SpecialTitle:PRead"}, "skip_null_values"=false}
  28.  *          },
  29.  *          "post"
  30.  *      },
  31.  *      itemOperations={
  32.  *          "get"={"security"="is_granted('IS_CLIENT_OPR', object)"},
  33.  *          "put"={"security"="is_granted('IS_CLIENT_OPR', object)"},
  34.  *          "patch"={"security"="is_granted('IS_CLIENT_OPR', object)"},
  35.  *          "delete"={"security"="is_granted('IS_CLIENT_OPR', object)"}
  36.  *     }
  37.  * )
  38.  * @ApiFilter(SearchFilter::class, properties={"id": "exact", "client.id": "exact", "translations.name": "partial", "country": "exact"})
  39.  * @ApiFilter(OrderFilter::class, properties={"ord": "ASC", "translations.name", "id"})
  40.  * @ORM\Entity(repositoryClass=SpecialTitleRepository::class)
  41.  */
  42. class SpecialTitle extends AbstractTranslatable implements ClientMappedInterfaceElasticUpdateInterface
  43. {
  44.     /**
  45.      * Hook timestampable behavior
  46.      * updates createdAt, updatedAt fields
  47.      */
  48.     use TimestampableEntity;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity="SpecialTitleTranslation", mappedBy="translatable", fetch="EXTRA_LAZY", indexBy="locale", cascade={"PERSIST"}, orphanRemoval=true)
  51.      *
  52.      * @Groups({"SpecialTitle:Write", "SpecialTitleTranslationGroup", "User:EL"})
  53.      * @Assert\Valid()
  54.      */
  55.     protected $translations;
  56.     /**
  57.      * @Groups({"SpecialTitle:Read", "SpecialTitle:PRead", "User:Read", "User:Get-Admin","User:Write","User:Me", "User:Attendee-List", "User:Attendee-List-O", "User:Change-Profile", "User:Get-Limited","Session:Select","VideoGalleryHistory:Read" , "JobQueue:Read", "AccessLog:Read", "EventLog:Read", "WatchTime:Read", "CommonComment:Read", "CommonCommentLike:Read", "SessionQuestionLike:Read", "NewsfeedLike:Read", "SessionReaction:Read", "SessionComment:Read", "Session:Read", "DocFile:Read", "Session:PRead", "Conference:Read", "Conference:PRead", "ElCourse:PRead", "Session:Agenda", "Newsfeed:Read", "NewsfeedComment:Read", "ChatThread:Read", "ChatMessage:Read", "Session:VideoLibrary", "VoteResult:Read", "VoteResult:Exp", "SessionQuestion:Read", "Meeting:Read", "MeetingBooking:Read", "Import:Read", "SessionQuestion:Exp", "VoucherCode:Read", "ElCourse:Read", "ElTask:Read", "VideoLibrary:Read", "ElExamAttempt:Read", "ElExamAnswer:Read", "ElCourseJoin:Read", "ElTaskAttempt:Read", "ElExamAttempt:Read", "VideoGallery:Read", "VideoGallery:Read-Public", "VideoGallery:PRead", "SurveyResult:Read", "User:PRead", "Certificate:Read", "User:Assign-List", "Company:Read"})
  58.      */
  59.     private $name;
  60.     /**
  61.      * @ORM\Id
  62.      * @ORM\GeneratedValue
  63.      * @ORM\Column(type="integer")
  64.      * @Groups({"SpecialTitle:Read", "SpecialTitle:PRead", "User:Exp", "User:Read", "User:Get-Admin","User:Write","User:Me", "User:Attendee-List", "User:Attendee-List-O", "User:Change-Profile", "User:Get-Limited","Session:Select","VideoGalleryHistory:Read" , "JobQueue:Read", "AccessLog:Read", "EventLog:Read", "WatchTime:Read", "CommonComment:Read", "CommonCommentLike:Read", "SessionQuestionLike:Read", "NewsfeedLike:Read", "SessionReaction:Read", "SessionComment:Read", "Session:Read", "DocFile:Read", "Session:PRead", "Conference:Read", "Conference:PRead", "ElCourse:PRead", "Session:Agenda", "Newsfeed:Read", "NewsfeedComment:Read", "ChatThread:Read", "ChatMessage:Read", "Session:VideoLibrary", "VoteResult:Read", "VoteResult:Exp", "SessionQuestion:Read", "Meeting:Read", "MeetingBooking:Read", "Import:Read", "SessionQuestion:Exp", "VoucherCode:Read", "ElCourse:Read", "ElTask:Read", "VideoLibrary:Read", "ElExamAttempt:Read", "ElExamAnswer:Read", "ElCourseJoin:Read", "ElTaskAttempt:Read", "ElExamAttempt:Read", "VideoGallery:Read", "VideoGallery:Read-Public", "VideoGallery:PRead", "SurveyResult:Read", "User:PRead", "Certificate:Read", "User:Assign-List"})
  65.      */
  66.     private $id;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity=Client::class)
  69.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  70.      * @Groups({"SpecialTitle:Write"})
  71.      */
  72.     private $client;
  73.     /**
  74.      * @ORM\Column(type="string", length=32, nullable=true)
  75.      * @Groups({"SpecialTitle:Read", "SpecialTitle:Write", "SpecialTitle:PRead"})
  76.      */
  77.     private $country;
  78.     /**
  79.      * @ORM\Column(type="string", length=16, nullable=true)
  80.      * @Groups({"User:EL", "SpecialTitle:Read", "SpecialTitle:Write", "SpecialTitle:PRead", "User:Read", "User:Get-Admin","User:Write","User:Me", "User:Attendee-List", "User:Attendee-List-O", "User:Change-Profile", "User:Get-Limited","Session:Select","VideoGalleryHistory:Read" , "JobQueue:Read", "AccessLog:Read", "EventLog:Read", "WatchTime:Read", "CommonComment:Read", "CommonCommentLike:Read", "SessionQuestionLike:Read", "NewsfeedLike:Read", "SessionReaction:Read", "SessionComment:Read", "Session:Read", "DocFile:Read", "Session:PRead", "Conference:Read", "Conference:PRead", "ElCourse:PRead", "Session:Agenda", "Newsfeed:Read", "NewsfeedComment:Read", "ChatThread:Read", "ChatMessage:Read", "Session:VideoLibrary", "VoteResult:Read", "VoteResult:Exp", "SessionQuestion:Read", "Meeting:Read", "MeetingBooking:Read", "Import:Read", "SessionQuestion:Exp", "VoucherCode:Read", "ElCourse:Read", "ElTask:Read", "VideoLibrary:Read", "ElExamAttempt:Read", "ElExamAnswer:Read", "ElCourseJoin:Read", "ElTaskAttempt:Read", "ElExamAttempt:Read", "VideoGallery:Read", "VideoGallery:Read-Public", "VideoGallery:PRead", "SurveyResult:Read", "User:PRead", "Certificate:Read", "User:Assign-List", "Company:Read"})
  81.      */
  82.     private $color;
  83.     /**
  84.      * @ORM\Column(type="string", length=16, nullable=true)
  85.      * @Groups({"User:EL", "SpecialTitle:Read", "SpecialTitle:Write", "SpecialTitle:PRead", "User:Read", "User:Get-Admin","User:Write","User:Me", "User:Attendee-List", "User:Attendee-List-O", "User:Change-Profile", "User:Get-Limited","Session:Select","VideoGalleryHistory:Read" , "JobQueue:Read", "AccessLog:Read", "EventLog:Read", "WatchTime:Read", "CommonComment:Read", "CommonCommentLike:Read", "SessionQuestionLike:Read", "NewsfeedLike:Read", "SessionReaction:Read", "SessionComment:Read", "Session:Read", "DocFile:Read", "Session:PRead", "Conference:Read", "Conference:PRead", "ElCourse:PRead", "Session:Agenda", "Newsfeed:Read", "NewsfeedComment:Read", "ChatThread:Read", "ChatMessage:Read", "Session:VideoLibrary", "VoteResult:Read", "VoteResult:Exp", "SessionQuestion:Read", "Meeting:Read", "MeetingBooking:Read", "Import:Read", "SessionQuestion:Exp", "VoucherCode:Read", "ElCourse:Read", "ElTask:Read", "VideoLibrary:Read", "ElExamAttempt:Read", "ElExamAnswer:Read", "ElCourseJoin:Read", "ElTaskAttempt:Read", "ElExamAttempt:Read", "VideoGallery:Read", "VideoGallery:Read-Public", "VideoGallery:PRead", "SurveyResult:Read", "User:PRead", "Certificate:Read", "User:Assign-List", "Company:Read"})
  86.      */
  87.     private $textColor;
  88.     /**
  89.      * @ORM\ManyToOne(targetEntity=CommonCategory::class, inversedBy="specialTitles")
  90.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  91.      * @Groups({"SpecialTitle:Read", "SpecialTitle:Write"})
  92.      */
  93.     private $newsfeedCategory;
  94.     protected function createTranslation(): TranslationInterface
  95.     {
  96.         return new SpecialTitleTranslation();
  97.     }
  98.     public function addTranslation(TranslationInterface $translation): void
  99.     {
  100.         $this->setUpdatedAt(new \DateTime());
  101.         parent::addTranslation($translation);
  102.     }
  103.     public function getName(): ?string
  104.     {
  105.         return $this->getTranslation()->getName();
  106.     }
  107.     public function setName(string $name): self
  108.     {
  109.         $this->getTranslation()->setName($name);
  110.         return $this;
  111.     }
  112.     public function getId(): ?int
  113.     {
  114.         return $this->id;
  115.     }
  116.     public function getClient(): ?Client
  117.     {
  118.         return $this->client;
  119.     }
  120.     public function setClient(?Client $client): self
  121.     {
  122.         $this->client $client;
  123.         return $this;
  124.     }
  125.     public function getCountry(): ?string
  126.     {
  127.         return $this->country;
  128.     }
  129.     public function setCountry(?string $country): self
  130.     {
  131.         $this->country $country;
  132.         return $this;
  133.     }
  134.     public function getQueueInfo(): array
  135.     {
  136.         return [
  137.             'type' => 'SpecialTitle',
  138.             'id' => $this->getId()
  139.         ];
  140.     }
  141.     public function getColor(): ?string
  142.     {
  143.         return $this->color;
  144.     }
  145.     public function setColor(?string $color): self
  146.     {
  147.         $this->color $color;
  148.         return $this;
  149.     }
  150.     public function getTextColor(): ?string
  151.     {
  152.         return $this->textColor;
  153.     }
  154.     public function setTextColor(?string $textColor): self
  155.     {
  156.         $this->textColor $textColor;
  157.         return $this;
  158.     }
  159.     public function getNewsfeedCategory(): ?CommonCategory
  160.     {
  161.         return $this->newsfeedCategory;
  162.     }
  163.     public function setNewsfeedCategory(?CommonCategory $newsfeedCategory): self
  164.     {
  165.         $this->newsfeedCategory $newsfeedCategory;
  166.         return $this;
  167.     }
  168. }