vendor/sylius/resource-bundle/src/Bundle/DependencyInjection/PagerfantaConfiguration.php line 20

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\DependencyInjection;
  12. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  13. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  14. use Symfony\Component\Config\Definition\ConfigurationInterface;
  15. @trigger_error(sprintf('The "%s" class is deprecated since Sylius 1.8. Migrate your Pagerfanta configuration from WhiteOctoberPagerfantaBundle to BabDevPagerfantaBundle, the configuration bridge will be removed in Sylius 2.0.'PagerfantaConfiguration::class), \E_USER_DEPRECATED);
  16. /**
  17.  * Container configuration to bridge the configuration from WhiteOctoberPagerfantaBundle to BabDevPagerfantaBundle
  18.  *
  19.  * @internal
  20.  */
  21. final class PagerfantaConfiguration implements ConfigurationInterface
  22. {
  23.     public const EXCEPTION_STRATEGY_TO_HTTP_NOT_FOUND 'to_http_not_found';
  24.     public function getConfigTreeBuilder(): TreeBuilder
  25.     {
  26.         $treeBuilder = new TreeBuilder('white_october_pagerfanta');
  27.         /** @var ArrayNodeDefinition $rootNode */
  28.         $rootNode $treeBuilder->getRootNode();
  29.         $this->addExceptionsStrategySection($rootNode);
  30.         $rootNode
  31.             ->children()
  32.                 ->scalarNode('default_view')
  33.                     ->defaultValue('default')
  34.                 ->end()
  35.             ->end()
  36.         ;
  37.         return $treeBuilder;
  38.     }
  39.     private function addExceptionsStrategySection(ArrayNodeDefinition $node): void
  40.     {
  41.         $node
  42.             ->children()
  43.                 ->arrayNode('exceptions_strategy')
  44.                     ->addDefaultsIfNotSet()
  45.                     ->children()
  46.                         ->scalarNode('out_of_range_page')->defaultValue(self::EXCEPTION_STRATEGY_TO_HTTP_NOT_FOUND)->end()
  47.                         ->scalarNode('not_valid_current_page')->defaultValue(self::EXCEPTION_STRATEGY_TO_HTTP_NOT_FOUND)->end()
  48.                     ->end()
  49.                 ->end()
  50.             ->end()
  51.         ;
  52.     }
  53. }