src/V4/Controller/Quote/GetQuotesByProspectAction.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\V4\Controller\Quote;
  4. use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
  5. use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
  6. use App\V4\Controller\AbstractGetSubListAction;
  7. use App\V4\Model\ChildrenAwareInterface;
  8. use App\V4\Model\Quote\Quote;
  9. use App\V4\Voters\QuoteVoter;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\Serializer\Serializer;
  12. use Symfony\Component\Serializer\SerializerInterface;
  13. class GetQuotesByProspectAction extends AbstractGetSubListAction
  14. {
  15.     protected const ENTITY Quote::class;
  16.     protected const KEY_PROSPECT 'prospectId';
  17.     protected const ACCESS_UNLESS_GRANTED QuoteVoter::QUOTE_SHOW_LIST;
  18.     /**
  19.      * @param CollectionDataProviderInterface $collectionDataProvider
  20.      * @param Serializer                      $serializer
  21.      * @param ItemDataProviderInterface       $itemDataProvider
  22.      */
  23.     public function __construct(
  24.         CollectionDataProviderInterface $collectionDataProvider,
  25.         SerializerInterface $serializer,
  26.         ItemDataProviderInterface $itemDataProvider
  27.     ) {
  28.         parent::__construct($collectionDataProvider$serializer$itemDataProvider);
  29.     }
  30.     /**
  31.      * @param Request $request
  32.      *
  33.      * @return array
  34.      */
  35.     protected function getDefaultFilters(Request $request): array
  36.     {
  37.         return [
  38.             self::KEY_PROSPECT => $request->get('id'),
  39.             'status.isWon' => $request->get('status_isWon'),
  40.             ChildrenAwareInterface::FILTER_EXCLUDE_PARENT_ENTITIES => 'true',
  41.         ];
  42.     }
  43. }