From c2ebd5268ec0194a7b0c19bbc4f07609d743917b Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 24 Feb 2015 12:21:21 +0200 Subject: [PATCH 01/12] Settings configuration updated: - Default manager and repository added in configuration tree - Two new params added - Elasticsearch manager parametrized for ongr_settings.settings_provider in compiler pass from default - Tests fixed --- Controller/SettingsListController.php | 11 ++--- DependencyInjection/Compiler/ProviderPass.php | 5 ++- DependencyInjection/Configuration.php | 8 ++++ DependencyInjection/ONGRSettingsExtension.php | 13 ++++++ README.rst | 43 ------------------- .../config/services/general_settings.yml | 6 +-- Resources/config/services/pair_storage.yml | 2 +- Resources/doc/index.rst | 43 ------------------- .../Compiler/ProviderPassTest.php | 1 + .../Controller/SettingsListControllerTest.php | 21 ++++++++- .../Compiler/ProviderPassTest.php | 3 +- .../DependencyInjection/ConfigurationTest.php | 5 ++- .../SessionlessAuthenticationFactoryTest.php | 2 +- Tests/app/config/config_test.yml | 31 +++++++++++++ .../config/config_test_container_creation.yml | 32 ++++++++++++++ Tests/app/config/parameters_test.yml | 5 ++- .../parameters_test_container_creation.yml | 3 ++ 17 files changed, 133 insertions(+), 101 deletions(-) diff --git a/Controller/SettingsListController.php b/Controller/SettingsListController.php index ae98967..094ea8b 100644 --- a/Controller/SettingsListController.php +++ b/Controller/SettingsListController.php @@ -11,7 +11,7 @@ namespace ONGR\SettingsBundle\Controller; -use ONGR\ElasticsearchBundle\ORM\Manager; +use ONGR\ElasticsearchBundle\ORM\Repository; use ONGR\FilterManagerBundle\Filters\ViewData; use ONGR\FilterManagerBundle\Filters\Widget\Choice\SingleTermChoice; use ONGR\FilterManagerBundle\Filters\Widget\Pager\Pager; @@ -54,9 +54,6 @@ public function listAction(Request $request) */ protected function getListData(Request $request) { - /** @var Manager $manager */ - $manager = $this->container->get('es.manager'); - /** @var FiltersContainer $container */ $container = new FiltersContainer(); @@ -93,8 +90,12 @@ protected function getListData(Request $request) $profile->setField('profile'); $container->set('profile', $profile); + $repositoryName = $this->container->getParameter('ongr_settings.connection.repository'); + /** @var Repository $repository */ + $repository = $this->get($repositoryName); + /** @var FiltersManager $fm */ - $fm = new FiltersManager($container, $manager->getRepository('ONGRSettingsBundle:Setting')); + $fm = new FiltersManager($container, $repository); $fmr = $fm->execute($request); return [ diff --git a/DependencyInjection/Compiler/ProviderPass.php b/DependencyInjection/Compiler/ProviderPass.php index f965d54..07e15f9 100644 --- a/DependencyInjection/Compiler/ProviderPass.php +++ b/DependencyInjection/Compiler/ProviderPass.php @@ -88,8 +88,11 @@ function ($a, $b) { protected function generateProvider(ContainerBuilder $container, $profile) { $id = "ongr_settings.dynamic_provider.{$profile}"; + + $manager = $container->getParameter('ongr_settings.connection.manager'); + $provider = new Definition($container->getParameter('ongr_settings.settings_provider.class'), [$profile]); - $provider->addMethodCall('setManager', [new Reference('es.manager')]); + $provider->addMethodCall('setManager', [new Reference($manager)]); $provider->addTag('ongr_settings.settings_provider', ['profile' => $profile]); $container->setDefinition($id, $provider); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index ce99390..a4bc5e7 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -47,6 +47,14 @@ public function getConfigTreeBuilder() ->defaultValue('ongr-settings') ->info('Index name for settings') ->end() + ->scalarNode('manager') + ->defaultValue('es.manager.settings') + ->info('Elasticsearch manager for settings') + ->end() + ->scalarNode('repository') + ->defaultValue('es.manager.settings.setting') + ->info('Elasticsearch repository for settings') + ->end() ->scalarNode('host') ->info('Address of your settings database') ->defaultValue('127.0.0.1') diff --git a/DependencyInjection/ONGRSettingsExtension.php b/DependencyInjection/ONGRSettingsExtension.php index 1682f0b..a3b1ea0 100644 --- a/DependencyInjection/ONGRSettingsExtension.php +++ b/DependencyInjection/ONGRSettingsExtension.php @@ -33,6 +33,8 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('ongr_settings.connection.index_name', $config['connection']['index_name']); $container->setParameter('ongr_settings.connection.port', $config['connection']['port']); $container->setParameter('ongr_settings.connection.host', $config['connection']['host']); + $container->setParameter('ongr_settings.connection.manager', $config['connection']['manager']); + $container->setParameter('ongr_settings.connection.repository', $config['connection']['repository']); // Set profiles. $container->setParameter('ongr_settings.settings_container.profiles', $config['profiles']); @@ -64,6 +66,17 @@ protected function loadPersonalSettings($config, ContainerBuilder $containerBuil $containerBuilder->setParameter('ongr_settings.settings.settings', $config['settings']); } + /** + * Sets parameters for settings provider. + * + * @param array $config + * @param ContainerBuilder $containerBuilder + */ + protected function loadSettingsProvider($config, ContainerBuilder $containerBuilder) + { + $containerBuilder->setParameter('ongr_settings.settings.categories', $config['categories']); + } + /** * Injects additional General User settings to service container. * diff --git a/README.rst b/README.rst index 0a41831..e0a13ae 100644 --- a/README.rst +++ b/README.rst @@ -122,49 +122,6 @@ You should add an entry to your ``config.yml`` you should add an entry: Using this config, console command below will create an Elasticsearch index called ``settings`` with 2 shards and 0 replicas, after running the console command mentioned above. -If you are planing to use SettingsBundle outside an -`ongr.io `_ platform you should also add following configuration to your ``config.yml``: - -.. code-block:: yaml - - parameters: - ongr_settings.settings_provider_es_manager: es.manager.settings - - services: - ongr_settings.settings_manager: - class: %ongr_settings.settings_manager.class% - arguments: - - @translator - - @event_dispatcher - - @es.manager.settings - - ongr_settings.listener.cookie_profile: - class: %ongr_settings.listener.cookie_profile.class% - calls: - - [ setSettingsContainer, [ @ongr_settings.settings_container ] ] - - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ] - - [ setManager, [ @es.manager.settings ] ] - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } - - ongr_settings.profiles_manager: - class: %ongr_settings.profiles_manager.class% - arguments: - - @es.manager.settings - - ongr_settings.settings_provider: - class: %ongr_settings.profiles_manager.class% - arguments: - - @es.manager.settings - - ongr_settings.pair_storage: - class: %ongr_settings.pair_storage.class% - arguments: - - @es.manager.settings - -.. - - Second - new index in Elasticsearch should be created. This can be done by running a command in console: diff --git a/Resources/config/services/general_settings.yml b/Resources/config/services/general_settings.yml index f015a2c..41be0b7 100644 --- a/Resources/config/services/general_settings.yml +++ b/Resources/config/services/general_settings.yml @@ -15,7 +15,7 @@ services: arguments: - @translator - @event_dispatcher - - @es.manager + - @es.manager.settings ongr_settings.settings_container: class: %ongr_settings.settings_container.class% @@ -39,11 +39,11 @@ services: calls: - [ setSettingsContainer, [ @ongr_settings.settings_container ] ] - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ] - - [ setManager, [ @es.manager ] ] + - [ setManager, [ @es.manager.settings ] ] tags: - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } ongr_settings.profiles_manager: class: %ongr_settings.profiles_manager.class% arguments: - - @es.manager + - @es.manager.settings diff --git a/Resources/config/services/pair_storage.yml b/Resources/config/services/pair_storage.yml index 026a811..ce69e70 100644 --- a/Resources/config/services/pair_storage.yml +++ b/Resources/config/services/pair_storage.yml @@ -5,4 +5,4 @@ services: ongr_settings.pair_storage: class: %ongr_settings.pair_storage.class% arguments: - - @es.manager + - @es.manager.settings diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 0a41831..e0a13ae 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -122,49 +122,6 @@ You should add an entry to your ``config.yml`` you should add an entry: Using this config, console command below will create an Elasticsearch index called ``settings`` with 2 shards and 0 replicas, after running the console command mentioned above. -If you are planing to use SettingsBundle outside an -`ongr.io `_ platform you should also add following configuration to your ``config.yml``: - -.. code-block:: yaml - - parameters: - ongr_settings.settings_provider_es_manager: es.manager.settings - - services: - ongr_settings.settings_manager: - class: %ongr_settings.settings_manager.class% - arguments: - - @translator - - @event_dispatcher - - @es.manager.settings - - ongr_settings.listener.cookie_profile: - class: %ongr_settings.listener.cookie_profile.class% - calls: - - [ setSettingsContainer, [ @ongr_settings.settings_container ] ] - - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ] - - [ setManager, [ @es.manager.settings ] ] - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } - - ongr_settings.profiles_manager: - class: %ongr_settings.profiles_manager.class% - arguments: - - @es.manager.settings - - ongr_settings.settings_provider: - class: %ongr_settings.profiles_manager.class% - arguments: - - @es.manager.settings - - ongr_settings.pair_storage: - class: %ongr_settings.pair_storage.class% - arguments: - - @es.manager.settings - -.. - - Second - new index in Elasticsearch should be created. This can be done by running a command in console: diff --git a/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php b/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php index 1689c01..b77a5ea 100644 --- a/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php +++ b/Tests/Functional/DependencyInjection/Compiler/ProviderPassTest.php @@ -25,6 +25,7 @@ public function testProcess() $container = new ContainerBuilder(); $container->setDefinition('ongr_settings.settings_container', new Definition()); $container->setParameter('ongr_settings.settings_container.profiles', ['default', 'custom']); + $container->setParameter('ongr_settings.connection.manager', 'es.manager'); $container->setParameter( 'ongr_settings.settings_provider.class', 'ONGR\\SettingsBundle\\Settings\\Personal\\Provider\\ManagerAwareSettingProvider.php' diff --git a/Tests/Unit/Controller/SettingsListControllerTest.php b/Tests/Unit/Controller/SettingsListControllerTest.php index 6f60be9..93bcdfb 100644 --- a/Tests/Unit/Controller/SettingsListControllerTest.php +++ b/Tests/Unit/Controller/SettingsListControllerTest.php @@ -39,8 +39,11 @@ public function testListAction() { $container = new ContainerBuilder(); - $container->set('es.manager', $this->getManagerWithRepositoryMock()); + $container->set('es.manager', $this->getRepositoryMock()); $container->set('templating', $this->getTemplateEngine()); + + $container->setParameter('ongr_settings.connection.repository', 'es.manager'); + $container->set('router', $this->getMock('Symfony\\Component\\Routing\\RouterInterface')); $controller = new SettingsListController(); @@ -75,6 +78,22 @@ protected function getManagerWithRepositoryMock() return $managerMock; } + /** + * Returns repository mock. + * + * @return Manager + */ + protected function getRepositoryMock() + { + $repositoryMock = $this->getOrmRepositoryMock(); + $repositoryMock->expects( + $this->once() + )->method('execute') + ->willReturn($this->getDocumentIteratorMock()); + + return $repositoryMock; + } + /** * Returns mock of Document Iterator. * diff --git a/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php b/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php index b9374e0..292a821 100644 --- a/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php +++ b/Tests/Unit/DependencyInjection/Compiler/ProviderPassTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace ONGR\SettingsBundle\Tests\Integration\DependencyInjection\Compiler; +namespace ONGR\SettingsBundle\Tests\Unit\DependencyInjection\Compiler; use ONGR\SettingsBundle\DependencyInjection\Compiler\ProviderPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -29,6 +29,7 @@ public function testProcess() 'ongr_settings.settings_provider.class', 'ONGR\\SettingsBundle\\Settings\\Personal\\Provider\\ManagerAwareSettingProvider' ); + $container->setParameter('ongr_settings.connection.manager', 'es.manager'); $definition = new Definition(); $definition->addTag('ongr_settings.settings_provider', ['profile' => 'custom', 'priority' => 9]); diff --git a/Tests/Unit/DependencyInjection/ConfigurationTest.php b/Tests/Unit/DependencyInjection/ConfigurationTest.php index 585093e..3cbfcdb 100644 --- a/Tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -12,7 +12,6 @@ namespace ONGR\SettingsBundle\Tests\Functional\DependencyInjection; use ONGR\SettingsBundle\DependencyInjection\Configuration; -use ONGR\ElasticsearchBundle\Test\ElasticsearchTestCase; use Symfony\Component\Config\Definition\Processor; class ConfigurationTest extends \PHPUnit_Framework_TestCase @@ -28,6 +27,8 @@ public function configurationData() 'index_name' => 'ongr-settings', 'host' => '127.0.0.1', 'port' => 9200, + 'manager' => 'es.manager.settings', + 'repository' => 'es.manager.settings.setting', ]; // A #0 test default values. @@ -46,6 +47,8 @@ public function configurationData() 'index_name' => 'ongr-test', 'host' => '127.5.0.1', 'port' => 9205, + 'manager' => 'es.manager.settings', + 'repository' => 'es.manager.settings.setting', ]; $out[] = [ ['connection' => $config], diff --git a/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php b/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php index 5a1d903..3ba5c4a 100644 --- a/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php +++ b/Tests/Unit/DependencyInjection/Security/SessionlessAuthenticationFactoryTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace ONGR\SettingsBundle\Tests\Functional\DependencyInjection; +namespace ONGR\SettingsBundle\Tests\Unit\DependencyInjection\Security; use ONGR\ElasticsearchBundle\Test\ElasticsearchTestCase; use ONGR\SettingsBundle\DependencyInjection\Security\SessionlessAuthenticationFactory; diff --git a/Tests/app/config/config_test.yml b/Tests/app/config/config_test.yml index 785cff3..4ca2b64 100644 --- a/Tests/app/config/config_test.yml +++ b/Tests/app/config/config_test.yml @@ -130,6 +130,37 @@ services: calls: - [setManager, [@es.manager]] + ongr_settings.settings_manager: + class: %ongr_settings.settings_manager.class% + arguments: + - @translator + - @event_dispatcher + - @es.manager + + ongr_settings.listener.cookie_profile: + class: %ongr_settings.listener.cookie_profile.class% + calls: + - [ setSettingsContainer, [ @ongr_settings.settings_container ] ] + - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ] + - [ setManager, [ @es.manager ] ] + tags: + - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } + + ongr_settings.profiles_manager: + class: %ongr_settings.profiles_manager.class% + arguments: + - @es.manager + + ongr_settings.settings_provider: + class: %ongr_settings.profiles_manager.class% + arguments: + - @es.manager + + ongr_settings.pair_storage: + class: %ongr_settings.pair_storage.class% + arguments: + - @es.manager + ongr_settings: profiles: [ test1, test2, default, meh ] admin_user: diff --git a/Tests/app/config/config_test_container_creation.yml b/Tests/app/config/config_test_container_creation.yml index 06d2420..63b8929 100644 --- a/Tests/app/config/config_test_container_creation.yml +++ b/Tests/app/config/config_test_container_creation.yml @@ -93,3 +93,35 @@ ongr_elasticsearch: connection: default mappings: - ONGRSettingsBundle + +services: + ongr_settings.settings_manager: + class: %ongr_settings.settings_manager.class% + arguments: + - @translator + - @event_dispatcher + - @es.manager + + ongr_settings.listener.cookie_profile: + class: %ongr_settings.listener.cookie_profile.class% + calls: + - [ setSettingsContainer, [ @ongr_settings.settings_container ] ] + - [ setPersonalSettingsManager, [ @ongr_settings.settings.personal_settings_manager ] ] + - [ setManager, [ @es.manager ] ] + tags: + - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } + + ongr_settings.profiles_manager: + class: %ongr_settings.profiles_manager.class% + arguments: + - @es.manager + + ongr_settings.settings_provider: + class: %ongr_settings.profiles_manager.class% + arguments: + - @es.manager + + ongr_settings.pair_storage: + class: %ongr_settings.pair_storage.class% + arguments: + - @es.manager \ No newline at end of file diff --git a/Tests/app/config/parameters_test.yml b/Tests/app/config/parameters_test.yml index a07da36..398d573 100644 --- a/Tests/app/config/parameters_test.yml +++ b/Tests/app/config/parameters_test.yml @@ -15,4 +15,7 @@ parameters: cdn_url: 'http:%cdn_base_url%' cdn_url_ssl: 'https:%cdn_base_url%' - ongr_settings.environment_variables_pass_test_param: unchanged_param \ No newline at end of file + ongr_settings.environment_variables_pass_test_param: unchanged_param + + ongr_settings.connection.manager: es.manager + ongr_settings.connection.repository: es.manager.setting diff --git a/Tests/app/config/parameters_test_container_creation.yml b/Tests/app/config/parameters_test_container_creation.yml index 6fed0f1..2de525e 100644 --- a/Tests/app/config/parameters_test_container_creation.yml +++ b/Tests/app/config/parameters_test_container_creation.yml @@ -22,3 +22,6 @@ parameters: password: 'foo_password' ongr_settings.authentication.secret: O0EKwvq8Sv30O3ImKdXT7aT + + ongr_settings.connection.manager: es.manager + ongr_settings.connection.repository: es.manager.setting From 3c6a41369fa61ee6884ceffad65f70c17006243a Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 24 Feb 2015 18:46:04 +0200 Subject: [PATCH 02/12] Filters refactored Docs updated UI updated with home button --- Controller/SettingsListController.php | 51 +-------------- DependencyInjection/ONGRSettingsExtension.php | 23 +++++++ README.rst | 2 +- Resources/config/filters_container.yml | 64 +++++++++++++++++++ Resources/doc/index.rst | 2 +- .../views/Settings/inc/navigation.html.twig | 7 +- Resources/views/Settings/settings.html.twig | 10 ++- 7 files changed, 105 insertions(+), 54 deletions(-) create mode 100644 Resources/config/filters_container.yml diff --git a/Controller/SettingsListController.php b/Controller/SettingsListController.php index 094ea8b..184ee3a 100644 --- a/Controller/SettingsListController.php +++ b/Controller/SettingsListController.php @@ -11,14 +11,7 @@ namespace ONGR\SettingsBundle\Controller; -use ONGR\ElasticsearchBundle\ORM\Repository; use ONGR\FilterManagerBundle\Filters\ViewData; -use ONGR\FilterManagerBundle\Filters\Widget\Choice\SingleTermChoice; -use ONGR\FilterManagerBundle\Filters\Widget\Pager\Pager; -use ONGR\FilterManagerBundle\Filters\Widget\Search\MatchSearch; -use ONGR\FilterManagerBundle\Filters\Widget\Sort\Sort; -use ONGR\FilterManagerBundle\Search\FiltersContainer; -use ONGR\FilterManagerBundle\Search\FiltersManager; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -54,49 +47,7 @@ public function listAction(Request $request) */ protected function getListData(Request $request) { - /** @var FiltersContainer $container */ - $container = new FiltersContainer(); - - /** @var Pager $pager */ - $pager = new Pager(); - $pager->setRequestField('page'); - $pager->setCountPerPage(15); - $container->set('pager', $pager); - - /** @var Sort $sort */ - $sort = new Sort(); - $sort->setRequestField('sort'); - $choices = [ - 'nameAsc' => ['label' => 'Name Asc', 'field' => 'name', 'order' => 'asc', 'default' => true], - 'nameDesc' => ['label' => 'Name Desc', 'field' => 'name', 'order' => 'desc', 'default' => false], - ]; - $sort->setChoices($choices); - $container->set('sort', $sort); - - /** @var MatchSearch $search */ - $search = new MatchSearch(); - if ($request->query->has('q')) { - $queryString = $request->query->get('q'); - if (!empty($queryString)) { - $search->setRequestField('q'); - $search->setField('name'); - } - } - $container->set('search', $search); - - /** @var SingleTermChoice $profile */ - $profile = new SingleTermChoice(); - $profile->setRequestField('profile'); - $profile->setField('profile'); - $container->set('profile', $profile); - - $repositoryName = $this->container->getParameter('ongr_settings.connection.repository'); - /** @var Repository $repository */ - $repository = $this->get($repositoryName); - - /** @var FiltersManager $fm */ - $fm = new FiltersManager($container, $repository); - $fmr = $fm->execute($request); + $fmr = $this->get('ongr_settings.filters_manager')->execute($request); return [ 'data' => iterator_to_array($fmr->getResult()), diff --git a/DependencyInjection/ONGRSettingsExtension.php b/DependencyInjection/ONGRSettingsExtension.php index a3b1ea0..631b8f3 100644 --- a/DependencyInjection/ONGRSettingsExtension.php +++ b/DependencyInjection/ONGRSettingsExtension.php @@ -13,7 +13,9 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** @@ -47,11 +49,15 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('services/general_settings.yml'); $loader->load('services/pair_storage.yml'); + $loader->load('filters_container.yml'); + if (isset($config['admin_user'])) { $this->loadPersonalSettings($config['admin_user'], $container); } $this->injectPersonalSettings($container); + + $this->setFiltersManager($container); } /** @@ -77,6 +83,23 @@ protected function loadSettingsProvider($config, ContainerBuilder $containerBuil $containerBuilder->setParameter('ongr_settings.settings.categories', $config['categories']); } + /** + * Sets parameters for filter manager. + * + * @param ContainerBuilder $container + */ + protected function setFiltersManager(ContainerBuilder $container) + { + $definition = new Definition( + 'ONGR\FilterManagerBundle\Search\FiltersManager', + [ + new Reference('ongr_settings.filters_container'), + new Reference( $container->getParameter('ongr_settings.connection.repository') ), + ] + ); + $container->setDefinition('ongr_settings.filters_manager', $definition); + } + /** * Injects additional General User settings to service container. * diff --git a/README.rst b/README.rst index e0a13ae..30fe5f1 100644 --- a/README.rst +++ b/README.rst @@ -117,7 +117,7 @@ You should add an entry to your ``config.yml`` you should add an entry: mappings: - ONGRSettingsBundle -... +.. Using this config, console command below will create an Elasticsearch index called ``settings`` with 2 shards and 0 replicas, after running the console command mentioned above. diff --git a/Resources/config/filters_container.yml b/Resources/config/filters_container.yml new file mode 100644 index 0000000..3f0df8c --- /dev/null +++ b/Resources/config/filters_container.yml @@ -0,0 +1,64 @@ +parameters: + ongr_settings.filter.pager.class: ONGR\FilterManagerBundle\Filters\Widget\Pager\Pager + ongr_settings.filter.pager.request_field: page + ongr_settings.filter.pager.count_per_page: 15 + ongr_settings.filter.pager.max_pages: 99 + + ongr_settings.filter.sort.class: ONGR\FilterManagerBundle\Filters\Widget\Sort\Sort + ongr_settings.filter.sort.request_field: sort + ongr_settings.filter.sort.choices: + nameAsc: + label: "Name Asc" + field: "name" + order: "asc" + default: true + nameDesc: + label: "Name Desc" + field: "name" + order: "desc" + default: false + + ongr_settings.filter.match_search.class: ONGR\FilterManagerBundle\Filters\Widget\Search\MatchSearch + ongr_settings.filter.match_search.request_field: q + ongr_settings.filter.match_search.field: "name" + + ongr_settings.filter.single_term.class: ONGR\FilterManagerBundle\Filters\Widget\Choice\SingleTermChoice + ongr_settings.filter.single_term.profile.request_field: profile + ongr_settings.filter.single_term.profile.field: profile + + + ongr_settings.filters_container.class: ONGR\FilterManagerBundle\Search\FiltersContainer + +services: + ongr_settings.filter.pager: + class: "%ongr_settings.filter.pager.class%" + calls: + - ["setRequestField", ["%ongr_settings.filter.pager.request_field%"]] + - ["setCountPerPage", ["%ongr_settings.filter.pager.count_per_page%"]] + - ["setMaxPages", ["%ongr_settings.filter.pager.max_pages%"]] + + ongr_settings.filter.sort: + class: "%ongr_settings.filter.sort.class%" + calls: + - ["setRequestField", ["%ongr_settings.filter.sort.request_field%"]] + - ["setChoices", ["%ongr_settings.filter.sort.choices%"]] + + ongr_settings.filter.match_search: + class: "%ongr_settings.filter.match_search.class%" + calls: + - ["setRequestField", ["%ongr_settings.filter.match_search.request_field%"]] + - ["setField", ["%ongr_settings.filter.match_search.field%"]] + + ongr_settings.filter.single_term.profile: + class: "%ongr_settings.filter.single_term.class%" + calls: + - ["setRequestField", ["%ongr_settings.filter.single_term.profile.request_field%"]] + - ["setField", ["%ongr_settings.filter.single_term.profile.field%"]] + + ongr_settings.filters_container: + class: "%ongr_settings.filters_container.class%" + calls: + - ["set", ["pager", "@ongr_settings.filter.pager"]] + - ["set", ["sort", "@ongr_settings.filter.sort"]] + - ["set", ["search", "@ongr_settings.filter.match_search"]] + - ["set", ["profile", "@ongr_settings.filter.single_term.profile"]] diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index e0a13ae..30fe5f1 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -117,7 +117,7 @@ You should add an entry to your ``config.yml`` you should add an entry: mappings: - ONGRSettingsBundle -... +.. Using this config, console command below will create an Elasticsearch index called ``settings`` with 2 shards and 0 replicas, after running the console command mentioned above. diff --git a/Resources/views/Settings/inc/navigation.html.twig b/Resources/views/Settings/inc/navigation.html.twig index cb55c6f..74ed5c6 100644 --- a/Resources/views/Settings/inc/navigation.html.twig +++ b/Resources/views/Settings/inc/navigation.html.twig @@ -1,7 +1,7 @@