Skip to content

Commit 9f2e275

Browse files
committed
Merge branch '1.0'
2 parents 3fe37d3 + 1c4b938 commit 9f2e275

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace EzSystems\EzPlatformUserBundle\DependencyInjection\Configuration\Parser;
10+
11+
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\AbstractParser;
12+
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface;
13+
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
14+
15+
/**
16+
* Configuration parser for pagination limits declaration.
17+
*
18+
* Example configuration:
19+
* ```yaml
20+
* ezpublish:
21+
* system:
22+
* default: # configuration per siteaccess or siteaccess group
23+
* pagination:
24+
* user_settings_limit: 10
25+
* ```
26+
*/
27+
class Pagination extends AbstractParser
28+
{
29+
/**
30+
* Adds semantic configuration definition.
31+
*
32+
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
33+
*/
34+
public function addSemanticConfig(NodeBuilder $nodeBuilder)
35+
{
36+
$nodeBuilder
37+
->arrayNode('pagination')
38+
->info('System pagination configuration')
39+
->children()
40+
->scalarNode('user_settings_limit')->isRequired()->end()
41+
->end()
42+
->end();
43+
}
44+
45+
/**
46+
* {@inheritdoc}
47+
*/
48+
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
49+
{
50+
if (empty($scopeSettings['pagination'])) {
51+
return;
52+
}
53+
54+
$settings = $scopeSettings['pagination'];
55+
$keys = [
56+
'user_settings_limit',
57+
];
58+
59+
foreach ($keys as $key) {
60+
if (!isset($settings[$key]) || empty($settings[$key])) {
61+
continue;
62+
}
63+
64+
$contextualizer->setContextualParameter(
65+
sprintf('pagination.%s', $key),
66+
$currentScope,
67+
$settings[$key]
68+
);
69+
}
70+
}
71+
}

src/bundle/EzPlatformUserBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use EzSystems\EzPlatformUserBundle\DependencyInjection\Compiler\UserSetting;
1010
use EzSystems\EzPlatformUserBundle\DependencyInjection\Configuration\Parser\ChangePassword;
11+
use EzSystems\EzPlatformUserBundle\DependencyInjection\Configuration\Parser\Pagination;
1112
use EzSystems\EzPlatformUserBundle\DependencyInjection\Configuration\Parser\UserPreferences;
1213
use EzSystems\EzPlatformUserBundle\DependencyInjection\Configuration\Parser\UserRegistration;
1314
use EzSystems\EzPlatformUserBundle\DependencyInjection\Configuration\Parser\Security;
@@ -26,6 +27,7 @@ public function build(ContainerBuilder $container)
2627
$core = $container->getExtension('ezpublish');
2728
$core->addConfigParser(new Security());
2829
$core->addConfigParser(new ChangePassword());
30+
$core->addConfigParser(new Pagination());
2931
$core->addConfigParser(new UserRegistration());
3032
$core->addConfigParser(new UserPreferences());
3133
$core->addConfigParser(new UserSettingsUpdateView());

src/bundle/Resources/config/ezplatform_default_settings.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ parameters:
5656

5757
# Additional translations e.g. ['en_US', 'nb_NO']
5858
ezsettings.default.user_preferences.additional_translations: []
59+
60+
# Pagination limits
61+
ezsettings.default.pagination.user_settings_limit: 10

0 commit comments

Comments
 (0)