Merge branch '2.6' into 2.7

* 2.6:
  CS: fix some license headers
  CS: Ensure there is no code on the same line as the PHP open tag and it is followed by a blankline
  use visited lookup with reference to gain performance
  Replace GET parameters when changed
  [FrameworkBundle][debug:config] added support for dynamic configurations.
  [WebProfiler] Fix partial search on url in list

Conflicts:
	src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php
	src/Symfony/Bridge/Propel1/Form/EventListener/TranslationFormListener.php
This commit is contained in:
Fabien Potencier 2015-03-24 18:00:58 +01:00
commit 26ff514323
18 changed files with 142 additions and 58 deletions

6
.php_cs Normal file
View File

@ -0,0 +1,6 @@
<?php
return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
->setUsingCache(true)
;

View File

@ -14,8 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
/**
* A console command for dumping available configuration reference.
@ -43,36 +41,23 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
protected function findExtension($name)
{
$extension = null;
$bundles = $this->initializeBundles();
foreach ($bundles as $bundle) {
$extension = $bundle->getContainerExtension();
$bundles = $this->getContainer()->get('kernel')->getBundles();
if (preg_match('/Bundle$/', $name)) {
// input is bundle name
if (isset($bundles[$name])) {
$extension = $bundles[$name]->getContainerExtension();
}
if (!$extension) {
throw new \LogicException(sprintf('No extensions with configuration available for "%s"', $name));
}
} else {
foreach ($bundles as $bundle) {
$extension = $bundle->getContainerExtension();
if ($extension && $name === $extension->getAlias()) {
break;
}
$extension = null;
}
if (!$extension) {
throw new \LogicException(sprintf('No extension with alias "%s" is enabled', $name));
if ($extension && ($name === $extension->getAlias() || $name === $bundle->getName())) {
break;
}
}
$this->initializeExtensions($bundles);
if (!$extension) {
$message = sprintf('No extension with alias "%s" is enabled', $name);
if (preg_match('/Bundle$/', $name)) {
$message = sprintf('No extensions with configuration available for "%s"', $name);
}
throw new \LogicException($message);
}
return $extension;
}
@ -88,12 +73,12 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
}
}
private function initializeExtensions($bundles)
private function initializeBundles()
{
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
// as this method is not called when the container is loaded from the cache.
$parameters = $this->getContainer()->getParameterBag()->all();
$container = new ContainerBuilder(new ParameterBag($parameters));
$container = $this->getContainerBuilder();
$bundles = $this->getContainer()->get('kernel')->registerBundles();
foreach ($bundles as $bundle) {
if ($extension = $bundle->getContainerExtension()) {
$container->registerExtension($extension);
@ -101,8 +86,9 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
}
foreach ($bundles as $bundle) {
$bundle = clone $bundle;
$bundle->build($container);
}
return $bundles;
}
}

View File

@ -70,11 +70,7 @@ EOF
}
$extension = $this->findExtension($name);
$kernel = $this->getContainer()->get('kernel');
$method = new \ReflectionMethod($kernel, 'buildContainer');
$method->setAccessible(true);
$container = $method->invoke($kernel);
$container = $this->compileContainer();
$configs = $container->getExtensionConfig($extension->getAlias());
$configuration = $extension->getConfiguration($configs, $container);
@ -94,4 +90,17 @@ EOF
$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
}
private function compileContainer()
{
$kernel = clone $this->getContainer()->get('kernel');
$kernel->boot();
$method = new \ReflectionMethod($kernel, 'buildContainer');
$method->setAccessible(true);
$container = $method->invoke($kernel);
$container->getCompiler()->compile($container);
return $container;
}
}

View File

@ -166,6 +166,10 @@ EOF
*/
protected function getContainerBuilder()
{
if ($this->containerBuilder) {
return $this->containerBuilder;
}
if (!$this->getApplication()->getKernel()->isDebug()) {
throw new \LogicException(sprintf('Debug information about the container is only available in debug mode.'));
}
@ -179,7 +183,7 @@ EOF
$loader = new XmlFileLoader($container, new FileLocator());
$loader->load($cachedFile);
return $container;
return $this->containerBuilder = $container;
}
private function findProperServiceName(InputInterface $input, OutputInterface $output, ContainerBuilder $builder, $name)

View File

@ -13,8 +13,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Depe
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
class TestExtension extends Extension
class TestExtension extends Extension implements PrependExtensionInterface
{
private $customConfig;
@ -27,6 +28,14 @@ class TestExtension extends Extension
$config = $this->processConfiguration($configuration, $configs);
}
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
$container->prependExtensionConfig('test', array('custom' => 'foo'));
}
/**
* {@inheritdoc}
*/

View File

@ -0,0 +1,51 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Tester\CommandTester;
/**
* @group functional
*/
class ConfigDebugCommandTest extends WebTestCase
{
private $application;
protected function setUp()
{
$kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml'));
$this->application = new Application($kernel);
$this->application->doRun(new ArrayInput(array()), new NullOutput());
}
public function testDumpBundleName()
{
$tester = $this->createCommandTester();
$ret = $tester->execute(array('name' => 'TestBundle'));
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('custom: foo', $tester->getDisplay());
}
/**
* @return CommandTester
*/
private function createCommandTester()
{
$command = $this->application->find('debug:config');
return new CommandTester($command);
}
}

View File

@ -35,7 +35,7 @@ class ConfigDumpReferenceCommandTest extends WebTestCase
$tester = $this->createCommandTester();
$ret = $tester->execute(array('name' => 'TestBundle'));
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('test:', $tester->getDisplay());
$this->assertContains(' custom:', $tester->getDisplay());
}

View File

@ -77,7 +77,7 @@ class PhpStringTokenParser
if ('\'' === $str[$bLength]) {
return str_replace(
array('\\\\', '\\\''),
array( '\\', '\''),
array('\\', '\''),
substr($str, $bLength + 1, -1)
);
} else {

View File

@ -15,7 +15,7 @@
</select>
<div class="clear-fix"></div>
<label for="url">URL</label>
<input type="url" name="url" id="url" value="{{ url }}" placeholder="e.g. {{ request.baseUrl }}">
<input type="text" name="url" id="url" value="{{ url }}" placeholder="e.g. {{ request.baseUrl }}">
<div class="clear-fix"></div>
<label for="token">Token</label>
<input type="text" name="token" id="token" value="{{ token }}" placeholder="e.g. 1f321b">

View File

@ -1241,7 +1241,7 @@ EOF;
*
* @return bool
*/
private function hasReference($id, array $arguments, $deep = false, array $visited = array())
private function hasReference($id, array $arguments, $deep = false, array &$visited = array())
{
foreach ($arguments as $argument) {
if (is_array($argument)) {

View File

@ -197,9 +197,18 @@ class Form extends Link implements \ArrayAccess
{
$uri = parent::getUri();
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')) && $queryString = http_build_query($this->getValues(), null, '&')) {
$sep = false === strpos($uri, '?') ? '?' : '&';
$uri .= $sep.$queryString;
if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
$query = parse_url($uri, PHP_URL_QUERY);
$currentParameters = array();
if ($query) {
parse_str($query, $currentParameters);
}
$queryString = http_build_query(array_merge($currentParameters, $this->getValues()), null, '&');
$pos = strpos($uri, '?');
$base = false === $pos ? $uri : substr($uri, 0, $pos);
$uri = rtrim($base.'?'.$queryString, '?');
}
return $uri;

View File

@ -593,6 +593,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
array(),
'/foo?bar=bar&foo=foo',
),
array(
'replaces query values with the form values',
'<form action="/foo?bar=bar"><input type="text" name="bar" value="foo" /><input type="submit" /></form>',
array(),
'/foo?bar=foo',
),
array(
'returns an empty URI if the action is empty',
'<form><input type="submit" /></form>',

View File

@ -2,12 +2,12 @@
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Extension\Core\ChoiceList;

View File

@ -1,4 +1,5 @@
<?php
/*
* This file is part of the Symfony package.
*

View File

@ -3,7 +3,7 @@
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.

View File

@ -1,4 +1,5 @@
<?php
/*
* This file is part of the Symfony package.
*

View File

@ -1,4 +1,5 @@
<?php
/*
* This file is part of the Symfony package.
*

View File

@ -1,9 +1,4 @@
<?php
namespace Symfony\Component\Security\Http\RememberMe;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
/*
* This file is part of the Symfony package.
@ -14,6 +9,12 @@ use Symfony\Component\HttpFoundation\Request;
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Http\RememberMe;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
/**
* Interface that needs to be implemented by classes which provide remember-me
* capabilities.