Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
Add 26.2: Exposing an API for Conferences
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 13, 2022
1 parent 970baff commit d13e0b2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Entity/Conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,48 @@

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\ConferenceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\String\Slugger\SluggerInterface;

#[ORM\Entity(repositoryClass: ConferenceRepository::class)]
#[UniqueEntity('slug')]
#[ApiResource(
collectionOperations: ['get' => ['normalization_context' => ['groups' => 'conference:list']]],
itemOperations: ['get' => ['normalization_context' => ['groups' => 'conference:item']]],
order: ['year' => 'DESC', 'city' => 'ASC'],
paginationEnabled: false,
)]
class Conference
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['conference:list', 'conference:item'])]
private $id;

#[ORM\Column(type: 'string', length: 255)]
#[Groups(['conference:list', 'conference:item'])]
private $city;

#[ORM\Column(type: 'string', length: 4)]
#[Groups(['conference:list', 'conference:item'])]
private $year;

#[ORM\Column(type: 'boolean')]
#[Groups(['conference:list', 'conference:item'])]
private $isInternational;

#[ORM\OneToMany(mappedBy: 'conference', targetEntity: Comment::class, orphanRemoval: true)]
private $comments;

#[ORM\Column(type: 'string', length: 255, unique: true)]
#[Groups(['conference:list', 'conference:item'])]
private $slug;

public function __construct()
Expand Down

0 comments on commit d13e0b2

Please sign in to comment.