Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 8928354

Browse files
committed
Implemented options
1 parent b093827 commit 8928354

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

AutoRoute/UrlGenerator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\Adapter\AdapterInterface;
66
use Metadata\MetadataFactoryInterface;
7+
use Symfony\Component\OptionsResolver\OptionsResolver;
78

89
/**
910
* Class which handles URL generation and conflict resolution
@@ -45,7 +46,13 @@ public function generateUrl($document)
4546
$tokens = array();
4647
foreach ($tokenProviderConfigs as $name => $options) {
4748
$tokenProvider = $this->serviceRegistry->getTokenProvider($options['name']);
48-
$tokens['{' . $name . '}'] = $tokenProvider->provideValue($document, $options);
49+
50+
// I can see the utility of making this a singleton, but it is a massive
51+
// code smell to have this in a base class and be also part of the interface
52+
$optionsResolver = new OptionsResolver();
53+
$tokenProvider->configureOptions($optionsResolver);
54+
55+
$tokens['{' . $name . '}'] = $tokenProvider->provideValue($document, $optionsResolver->resolve($options['options']));
4956
}
5057

5158
$urlSchema = $metadata->getUrlSchema();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Blog:
22
url_schema: /test/blog/{blog_title}
33
token_providers:
4-
blog_title: [ content_method, [ method: getTitle ] ]
4+
blog_title: [content_method, { method: getTitle } ]

0 commit comments

Comments
 (0)