Skip to content
Snippets Groups Projects
Select Git revision
  • 5fa241c4fefa01531fc4da77403cb44c56af7843
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

rollup.config.js

Blame
  • PersonCollectionDataProvider.php 1.67 KiB
    <?php
    
    declare(strict_types=1);
    
    namespace Dbp\Relay\BasePersonBundle\DataProvider;
    
    use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
    use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
    use Dbp\Relay\BasePersonBundle\API\PersonProviderInterface;
    use Dbp\Relay\BasePersonBundle\Entity\Person;
    use Dbp\Relay\CoreBundle\LocalData\LocalData;
    use Dbp\Relay\CoreBundle\Pagination\Pagination;
    use Dbp\Relay\CoreBundle\Pagination\Paginator;
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    
    final class PersonCollectionDataProvider extends AbstractController implements CollectionDataProviderInterface, RestrictedDataProviderInterface
    {
        public const MAX_NUM_ITEMS_PER_PAGE_DEFAULT = 50;
    
        /** @var PersonProviderInterface */
        private $personProvider;
    
        public function __construct(PersonProviderInterface $personProvider)
        {
            $this->personProvider = $personProvider;
        }
    
        public function supports(string $resourceClass, string $operationName = null, array $context = []): bool
        {
            return Person::class === $resourceClass;
        }
    
        public function getCollection(string $resourceClass, string $operationName = null, array $context = []): Paginator
        {
            $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
    
            $filters = $context['filters'] ?? [];
            $options = [];
    
            if ($search = ($filters['search'] ?? null)) {
                $options[Person::SEARCH_PARAMETER_NAME] = $search;
            }
    
            LocalData::addOptions($options, $filters);
            Pagination::addOptions($options, $filters, self::MAX_NUM_ITEMS_PER_PAGE_DEFAULT);
    
            return $this->personProvider->getPersons($options);
        }
    }