- <?php
- namespace App\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use ApiPlatform\Core\Annotation\ApiFilter;
- use App\Entity\Traits\TimestampableEntity;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Repository\CreditCategoryRepository;
- use App\Entity\Interfaces\ClientMappedInterface;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
- use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
- use Locastic\ApiPlatformTranslationBundle\Model\AbstractTranslatable;
- use Locastic\ApiPlatformTranslationBundle\Model\TranslationInterface;
- /**
-  * @ApiResource(
-  *      attributes={"security"="is_granted('ROLE_SUPER_ADMIN')", "filters"={"translation.groups"}},
-  *      normalizationContext={"groups"={"CreditCategory:Read"}, "skip_null_values"=false},
-  *      denormalizationContext={"groups"={"CreditCategory:Write"}},
-  *      collectionOperations={
-  *          "get"={
-  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')",
-  *              "pagination_enabled"=false
-  *          },
-  *          "get_for_public_page"={
-  *              "route_name"="api_pub_credit_categories_get_for_public_page_collection",
-  *              "method"="GET",
-  *              "security"="is_granted('PUBLIC_ACCESS')",
-  *              "normalization_context"={"groups"={"CreditCategory:PRead"}, "skip_null_values"=false},
-  *              "pagination_enabled"=false
-  *          },
-  *          "post"
-  *      },
-  *      itemOperations={
-  *          "get",
-  *          "put",
-  *          "patch",
-  *          "delete"
-  *     }
-  * )
-  * @ApiFilter(SearchFilter::class, properties={"id": "exact", "client.id": "exact", "translations.name": "partial"})
-  * @ApiFilter(OrderFilter::class, properties={"ord": "ASC", "translations.name"})
-  * @ORM\Entity(repositoryClass=CreditCategoryRepository::class)
-  */
- class CreditCategory extends AbstractTranslatable implements ClientMappedInterface
- {
-     /**
-      * Hook timestampable behavior
-      * updates createdAt, updatedAt fields
-      */
-     use TimestampableEntity;
-     /**
-      * @ORM\OneToMany(targetEntity="CreditCategoryTranslation", mappedBy="translatable", fetch="EXTRA_LAZY", indexBy="locale", cascade={"PERSIST"}, orphanRemoval=true)
-      *
-      * @Groups({"CreditCategory:Write", "CreditCategoryTranslationGroup"})
-      * @Assert\Valid()
-      */
-     protected $translations;
-     /**
-      * @Groups({"CreditCategory:Read", "CreditCategory:PRead", "Conference:Read", "Conference:PRead", "ElCourse:Read", "ElCourse:PRead", "Certificate:Read"})
-      */
-     private $name;
-     /**
-      * @ORM\Id
-      * @ORM\GeneratedValue
-      * @ORM\Column(type="integer")
-      * @Groups({"CreditCategory:Read", "CreditCategory:PRead"})
-      */
-     private $id;
-     /**
-      * @ORM\ManyToOne(targetEntity=Client::class)
-      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
-      * @Groups({"CreditCategory:Read", "CreditCategory:Write"})
-      */
-     private $client;
-     public function __construct()
-     {
-         parent::__construct();
-     }
-     protected function createTranslation(): TranslationInterface
-     {
-         return new CreditCategoryTranslation();
-     }
-     public function getName(): ?string
-     {
-         return $this->getTranslation()->getName();
-     }
-     public function setName(string $name): self
-     {
-         $this->getTranslation()->setName($name);
-         return $this;
-     }
-     public function getId(): ?int
-     {
-         return $this->id;
-     }
-     public function getClient(): ?Client
-     {
-         return $this->client;
-     }
-     public function setClient(?Client $client): self
-     {
-         $this->client = $client;
-         return $this;
-     }
- }
-