| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\DataProvider\Public;
- use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
- use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
- use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
- use App\ApiResources\Public\FederationStructure;
- use App\Entity\Public\PublicEvent;
- use App\Repository\Booking\EventRepository;
- use App\Repository\Organization\OrganizationRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\HttpFoundation\RequestStack;
- class PublicEventDataProvider implements ItemDataProviderInterface, CollectionDataProviderInterface, RestrictedDataProviderInterface
- {
- public function __construct(
- private EventRepository $eventRepository
- ) {}
- public function supports(string $resourceClass, string $operationName = null, array $context = []): bool
- {
- return PublicEvent::class === $resourceClass;
- }
- public function getItem(string $resourceClass, $id, string $operationName = null, array $context = []): ?FederationStructure
- {
- return $this->eventRepository->getAllEvents($id)[0];
- }
- public function getCollection(string $resourceClass, string $operationName = null): ArrayCollection
- {
- return new ArrayCollection($this->eventRepository->getAllEvents());
- }
- }
|