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

Commit 9f8fba3

Browse files
committed
Merge pull request #181 from symfony-cmf/prepare-1.1
Prepare 1.1 release
2 parents 5669d6f + 74bbb75 commit 9f8fba3

File tree

6 files changed

+130
-10
lines changed

6 files changed

+130
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
Changelog
22
=========
33

4-
dev-master
5-
----------
4+
1.1.0
5+
-----
6+
7+
* **2016-03-31**: Added SymfonyContainerParameterTokenProvider for retrieving
8+
path elements from the DI container
9+
10+
1.1.0-RC1
11+
---------
612

713
* Convert non-managed intermediate nodes into AutoRoute documents #165
814

Resources/config/token_providers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parameter key="cmf_routing_auto.token_provider.content_method.class">Symfony\Cmf\Component\RoutingAuto\TokenProvider\ContentMethodProvider</parameter>
99
<parameter key="cmf_routing_auto.token_provider.content_datetime.class">Symfony\Cmf\Component\RoutingAuto\TokenProvider\ContentDateTimeProvider</parameter>
1010
<parameter key="cmf_routing_auto.token_provider.content_locale.class">Symfony\Cmf\Component\RoutingAuto\TokenProvider\ContentLocaleProvider</parameter>
11-
<parameter key="cmf_routing_auto.token_provider.container.class">Symfony\Cmf\Component\RoutingAuto\TokenProvider\SymfonyContainerParameterProvider</parameter>
11+
<parameter key="cmf_routing_auto.token_provider.container.class">Symfony\Cmf\Bundle\RoutingAutoBundle\TokenProvider\SymfonyContainerParameterProvider</parameter>
1212

1313
</parameters>
1414

Tests/Unit/DependencyInjection/CmfRoutingAutoExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setUp()
3030
* implicitly configured.
3131
*
3232
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
33-
* @expectedExceptionMessage No adapter has been configured, you either need to
33+
* @expectedExceptionMessage No adapter has been configured, you either need to
3434
*/
3535
public function testLoad()
3636
{
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2015 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Unit\TokenProvider;
13+
14+
use Symfony\Component\OptionsResolver\OptionsResolver;
15+
use Symfony\Cmf\Bundle\RoutingAutoBundle\TokenProvider\SymfonyContainerParameterProvider;
16+
17+
class SymfonyContainerParameterProviderTest extends \PHPUnit_Framework_TestCase
18+
{
19+
private $uriContext;
20+
private $container;
21+
22+
public function setUp()
23+
{
24+
$this->uriContext = $this->prophesize('Symfony\Cmf\Component\RoutingAuto\UriContext');
25+
$this->container = $this->prophesize('Symfony\Component\DependencyInjection\ContainerInterface');
26+
$this->provider = new SymfonyContainerParameterProvider($this->container->reveal());
27+
}
28+
29+
public function provideParameterValue()
30+
{
31+
return array(
32+
array(array('parameter' => 'foobar'), null),
33+
array(array('foobar' => 'barfoo'), 'InvalidArgumentException'), // This is deliberately generic to preserve BC from SF 2.5 > 2.6
34+
array(array(), 'Symfony\Component\OptionsResolver\Exception\MissingOptionsException'),
35+
);
36+
}
37+
38+
/**
39+
* @dataProvider provideParameterValue
40+
*/
41+
public function testParameterValue($options, $expectedException)
42+
{
43+
if (null !== $expectedException) {
44+
$this->setExpectedException($expectedException);
45+
}
46+
47+
$this->container->getParameter('foobar')->willReturn('barfoo');
48+
49+
$optionsResolver = new OptionsResolver();
50+
$this->provider->configureOptions($optionsResolver);
51+
$options = $optionsResolver->resolve($options);
52+
53+
$res = $this->provider->provideValue($this->uriContext->reveal(), $options);
54+
55+
$this->assertEquals('barfoo', $res);
56+
}
57+
}
58+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2015 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\TokenProvider;
13+
14+
use Symfony\Cmf\Component\RoutingAuto\TokenProviderInterface;
15+
use Symfony\Cmf\Component\RoutingAuto\UriContext;
16+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
17+
use Symfony\Component\DependencyInjection\ContainerInterface;
18+
19+
/**
20+
* Provide values parameters from a Symfony DI container.
21+
*
22+
* @author Daniel Leech <[email protected]>
23+
*/
24+
class SymfonyContainerParameterProvider implements TokenProviderInterface
25+
{
26+
protected $container;
27+
28+
/**
29+
* @param ContainerInterface $container
30+
*/
31+
public function __construct(ContainerInterface $container)
32+
{
33+
$this->container = $container;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function provideValue(UriContext $uriContext, $options)
40+
{
41+
$parameterName = $options['parameter'];
42+
43+
return $this->container->getParameter($parameterName);
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
public function configureOptions(OptionsResolverInterface $optionsResolver)
50+
{
51+
$optionsResolver->setRequired(array(
52+
'parameter',
53+
));
54+
}
55+
}
56+

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
],
1212
"require": {
1313
"php": "^5.3.9|^7.0",
14-
"symfony-cmf/routing-auto": "^1.1@RC",
14+
"symfony-cmf/routing-auto": "^1.1",
1515
"symfony-cmf/routing-bundle": "^1.2.0",
1616
"symfony-cmf/core-bundle": "^1.2",
17-
"aferrandini/urlizer": "1.0.*",
17+
"aferrandini/urlizer": "~1.0.0",
1818
"symfony/config": "^2.2",
19-
"jms/metadata": "1.5.*"
19+
"jms/metadata": "~1.5.0"
2020
},
2121
"require-dev": {
22-
"symfony-cmf/testing": "^1.3@RC",
23-
"symfony-cmf/slugifier-api": "@RC",
22+
"symfony-cmf/testing": "^1.3",
23+
"symfony-cmf/slugifier-api": "^1.0",
2424
"symfony/yaml": "^2.1",
2525
"matthiasnoback/symfony-dependency-injection-test": "~0.6",
26-
"matthiasnoback/symfony-config-test": "0.*",
26+
"matthiasnoback/symfony-config-test": "~0.1",
2727
"doctrine/phpcr-odm": "^1.3",
2828
"phpunit/phpunit": "^4.5",
2929
"symfony/phpunit-bridge": "^2.7"

0 commit comments

Comments
 (0)