src/Entity/VehicleManufacturer.php line 30
<?phpnamespace App\Entity;use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use App\Repository\VehicleManufacturerRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\String\Slugger\AsciiSlugger;#[ApiResource(operations: [new Get(),new GetCollection()],normalizationContext: ['groups' => ['manufacturer:read']],order: ['name' => 'ASC'],security: "is_granted('PUBLIC_ACCESS')",)]#[ApiFilter(BooleanFilter::class, properties: ['vehicles.visible'])]#[ApiFilter(SearchFilter::class, properties: ['vehicles.kind' => 'exact' ])]#[ORM\Entity(repositoryClass: VehicleManufacturerRepository::class)]class VehicleManufacturer{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['vehicle:read', 'manufacturer:read'])]private ?int $id = null;#[Groups(['vehicle:read', 'manufacturer:read'])]#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\OneToMany(mappedBy: 'manufacturer', targetEntity: Vehicle::class)]private Collection $vehicles;#[Groups(['vehicle:read', 'manufacturer:read'])]#[ORM\Column(length: 255, unique: true)]private ?string $url = null;#[ORM\OneToMany(mappedBy: 'vehicleManufacturer', targetEntity: Blog::class)]private Collection $blogs;#[ORM\OneToMany(mappedBy: 'vehicleManufacturer', targetEntity: VehicleModel::class)]private Collection $vehicleModels;public function __construct(){$this->vehicles = new ArrayCollection();$this->blogs = new ArrayCollection();$this->vehicleModels = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;$this->setUrl($name);return $this;}/*** @return Collection<int, Vehicle>*/public function getVehicles(): Collection{return $this->vehicles;}public function addVehicle(Vehicle $vehicle): self{if (!$this->vehicles->contains($vehicle)) {$this->vehicles->add($vehicle);$vehicle->setManufacturer($this);}return $this;}public function removeVehicle(Vehicle $vehicle): self{if ($this->vehicles->removeElement($vehicle)) {// set the owning side to null (unless already changed)if ($vehicle->getManufacturer() === $this) {$vehicle->setManufacturer(null);}}return $this;}public function getUrl(): ?string{return $this->url;}public function setUrl(string $url): self{$slugger = new AsciiSlugger('cs');$slug = $slugger->slug($url, '-')->lower();$this->url = $slug->toString();return $this;}/*** @return Collection<int, Blog>*/public function getBlogs(): Collection{return $this->blogs;}public function addBlog(Blog $blog): self{if (!$this->blogs->contains($blog)) {$this->blogs->add($blog);$blog->setVehicleManufacturer($this);}return $this;}public function removeBlog(Blog $blog): self{if ($this->blogs->removeElement($blog)) {// set the owning side to null (unless already changed)if ($blog->getVehicleManufacturer() === $this) {$blog->setVehicleManufacturer(null);}}return $this;}/*** @return Collection<int, VehicleModel>*/public function getVehicleModels(): Collection{return $this->vehicleModels;}public function addVehicleModel(VehicleModel $vehicleModel): self{if (!$this->vehicleModels->contains($vehicleModel)) {$this->vehicleModels->add($vehicleModel);$vehicleModel->setVehicleManufacturer($this);}return $this;}public function removeVehicleModel(VehicleModel $vehicleModel): self{if ($this->vehicleModels->removeElement($vehicleModel)) {// set the owning side to null (unless already changed)if ($vehicleModel->getVehicleManufacturer() === $this) {$vehicleModel->setVehicleManufacturer(null);}}return $this;}}