Skip to content

Commit

Permalink
support candidates limit
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Mar 31, 2014
1 parent b6729db commit a1205ec
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/CmfRoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
$container->setParameter($this->getAlias() . '.dynamic.locales', $locales);
$container->setParameter($this->getAlias() . '.dynamic.auto_locale_pattern', $config['auto_locale_pattern']);
}
$container->setParameter($this->getAlias() . '.dynamic.limit_candidates', $config['limit_candidates']);

$loader->load('routing-dynamic.xml');

Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public function getConfigTreeBuilder()
->arrayNode('locales')
->prototype('scalar')->end()
->end()
->scalarNode('limit_candidates')->defaultValue(20)->end()

This comment has been minimized.

Copy link
@lsmith77

lsmith77 Mar 31, 2014

Member

wouldn't that be an integerNode()?

This comment has been minimized.

Copy link
@wouterj

wouterj Mar 31, 2014

Member

Indeed

->booleanNode('match_implicit_locale')->defaultValue(true)->end()
->booleanNode('auto_locale_pattern')->defaultValue(false)->end()
->end()
Expand Down
5 changes: 3 additions & 2 deletions Doctrine/Phpcr/PrefixCandidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ class PrefixCandidates extends Candidates
* $locales. This must be the same
* document manager as the RouteProvider
* is using.
* @param int $limit Limit to candidates generated per prefix.
*/
public function __construct(array $prefixes, array $locales = array(), ManagerRegistry $doctrine = null)
public function __construct(array $prefixes, array $locales = array(), ManagerRegistry $doctrine = null, $limit = 20)
{
parent::__construct($locales);
parent::__construct($locales, $limit);
$this->setPrefixes($prefixes);
$this->doctrine = $doctrine;
}
Expand Down
1 change: 1 addition & 0 deletions Resources/config/provider-orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<service id="cmf_routing.orm_candidates" class="%cmf_routing.orm_candidates.class%">
<argument>%cmf_routing.dynamic.locales%</argument>
<argument>%cmf_routing.dynamic.limit_candidates%</argument>
</service>

<service id="cmf_routing.route_provider" class="%cmf_routing.route_entity_provider%">
Expand Down
1 change: 1 addition & 0 deletions Resources/config/provider-phpcr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<argument>%cmf_routing.dynamic.persistence.phpcr.route_basepaths%</argument>
<argument>%cmf_routing.dynamic.locales%</argument>
<argument type="service" id="doctrine_phpcr"/>
<argument>%cmf_routing.dynamic.limit_candidates%</argument>
<call method="setManagerName"><argument>%cmf_routing.dynamic.persistence.phpcr.manager_name%</argument></call>
</service>

Expand Down
1 change: 1 addition & 0 deletions Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function testSupportsAllConfigFormats()
'uri_filter_regexp' => '',
'route_filters_by_id' => array(),
'locales' => array('en', 'fr'),
'limit_candidates' => true,

This comment has been minimized.

Copy link
@wouterj

wouterj Mar 31, 2014

Member

Value should be 20, shouldn't it?

This comment has been minimized.

Copy link
@dbu

dbu via email Apr 1, 2014

Author Member
'auto_locale_pattern' => true,
'match_implicit_locale' => true,
),
Expand Down

0 comments on commit a1205ec

Please sign in to comment.