vendor/sylius/resource-bundle/src/Bundle/Grid/View/ResourceGridViewFactory.php line 44

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Sylius package.
  4. *
  5. * (c) Paweł Jędrzejewski
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\ResourceBundle\Grid\View;
  12. use Sylius\Bundle\ResourceBundle\Controller\ParametersParserInterface;
  13. use Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration;
  14. use Sylius\Component\Grid\Data\DataProviderInterface;
  15. use Sylius\Component\Grid\Definition\Grid;
  16. use Sylius\Component\Grid\Parameters;
  17. use Sylius\Component\Resource\Metadata\MetadataInterface;
  18. final class ResourceGridViewFactory implements ResourceGridViewFactoryInterface
  19. {
  20. private DataProviderInterface $dataProvider;
  21. private ParametersParserInterface $parametersParser;
  22. public function __construct(DataProviderInterface $dataProvider, ParametersParserInterface $parametersParser)
  23. {
  24. $this->dataProvider = $dataProvider;
  25. $this->parametersParser = $parametersParser;
  26. }
  27. public function create(
  28. Grid $grid,
  29. Parameters $parameters,
  30. MetadataInterface $metadata,
  31. RequestConfiguration $requestConfiguration,
  32. ): ResourceGridView {
  33. $driverConfiguration = $grid->getDriverConfiguration();
  34. $request = $requestConfiguration->getRequest();
  35. $grid->setDriverConfiguration($this->parametersParser->parseRequestValues($driverConfiguration, $request));
  36. return new ResourceGridView($this->dataProvider->getData($grid, $parameters), $grid, $parameters, $metadata, $requestConfiguration);
  37. }
  38. }