Merge branch '2.5' into 2.6

* 2.5:
  Update filesystem readme.md to include exists method
  Add machine readable events
  [HttpKernel][2.6] Adding support for invokable controllers in the RequestDataCollector
  fixed typo
  [Translations] Added missing Hebrew language trans-unit sources
  [DependencyInjection] inlined factory not referenced
  Fixed case for empty folder
  Fixed whitespace control for password form widget
  [Routing] correctly initialize condition as string
This commit is contained in:
Fabien Potencier 2014-11-16 18:28:09 +01:00
commit e7067cb771
20 changed files with 426 additions and 7 deletions

View File

@ -8,8 +8,8 @@ UPGRADE FROM 2.x to 3.0
* `registerNamespaces()` -> `addPrefixes()`
* `registerPrefixes()` -> `addPrefixes()`
* `registerNamespaces()` -> `addPrefix()`
* `registerPrefixes()` -> `addPrefix()`
* `registerNamespace()` -> `addPrefix()`
* `registerPrefix()` -> `addPrefix()`
* `getNamespaces()` -> `getPrefixes()`
* `getNamespaceFallbacks()` -> `getFallbackDirs()`
* `getPrefixFallbacks()` -> `getFallbackDirs()`

View File

@ -162,7 +162,7 @@
{% block password_widget -%}
{% set type = type|default('password') %}
{{ block('form_widget_simple') }}
{{- block('form_widget_simple') -}}
{%- endblock password_widget %}
{% block hidden_widget -%}

View File

@ -26,6 +26,8 @@ final class ConsoleEvents
* The event listener method receives a Symfony\Component\Console\Event\ConsoleCommandEvent
* instance.
*
* @Event
*
* @var string
*/
const COMMAND = 'console.command';
@ -37,6 +39,8 @@ final class ConsoleEvents
* The event listener method receives a Symfony\Component\Console\Event\ConsoleTerminateEvent
* instance.
*
* @Event
*
* @var string
*/
const TERMINATE = 'console.terminate';
@ -49,6 +53,8 @@ final class ConsoleEvents
* a Symfony\Component\Console\Event\ConsoleExceptionEvent
* instance.
*
* @Event
*
* @var string
*/
const EXCEPTION = 'console.exception';

View File

@ -114,6 +114,10 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
$this->processArguments($argument->getArguments());
$this->processArguments($argument->getMethodCalls());
$this->processArguments($argument->getProperties());
if ($argument->getFactoryService()) {
$this->processArguments(array(new Reference($argument->getFactoryService())));
}
}
}
}

View File

@ -144,6 +144,10 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
return false;
}
if (count($ids) > 1 && $definition->getFactoryService()) {
return false;
}
return $container->getDefinition(reset($ids))->getScope() === $definition->getScope();
}
}

View File

@ -79,6 +79,28 @@ class AnalyzeServiceReferencesPassTest extends \PHPUnit_Framework_TestCase
$this->assertSame($ref, $refs[0]->getValue());
}
public function testProcessDetectsReferencesFromInlinedFactoryDefinitions()
{
$container = new ContainerBuilder();
$container
->register('a')
;
$factory = new Definition();
$factory->setFactoryService('a');
$container
->register('b')
->addArgument($factory)
;
$graph = $this->process($container);
$this->assertTrue($graph->hasNode('a'));
$this->assertCount(1, $refs = $graph->getNode('a')->getInEdges());
}
public function testProcessDoesNotSaveDuplicateReferences()
{
$container = new ContainerBuilder();

View File

@ -110,6 +110,84 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
$this->assertSame($a, $inlinedArguments[0]);
}
public function testProcessInlinesPrivateFactoryReference()
{
$container = new ContainerBuilder();
$container->register('a')->setPublic(false);
$b = $container
->register('b')
->setPublic(false)
->setFactoryService('a')
;
$container
->register('foo')
->setArguments(array(
$ref = new Reference('b'),
));
$this->process($container);
$inlinedArguments = $container->getDefinition('foo')->getArguments();
$this->assertSame($b, $inlinedArguments[0]);
}
public function testProcessDoesNotInlinePrivateFactoryIfReferencedMultipleTimesWithinTheSameDefinition()
{
$container = new ContainerBuilder();
$container
->register('a')
;
$container
->register('b')
->setPublic(false)
->setFactoryService('a')
;
$container
->register('foo')
->setArguments(array(
$ref1 = new Reference('b'),
$ref2 = new Reference('b'),
))
;
$this->process($container);
$args = $container->getDefinition('foo')->getArguments();
$this->assertSame($ref1, $args[0]);
$this->assertSame($ref2, $args[1]);
}
public function testProcessDoesNotInlineReferenceWhenUsedByInlineFactory()
{
$container = new ContainerBuilder();
$container
->register('a')
;
$container
->register('b')
->setPublic(false)
->setFactoryService('a')
;
$inlineFactory = new Definition();
$inlineFactory->setPublic(false);
$inlineFactory->setFactoryService('b');
$container
->register('foo')
->setArguments(array(
$ref = new Reference('b'),
$inlineFactory,
))
;
$this->process($container);
$args = $container->getDefinition('foo')->getArguments();
$this->assertSame($ref, $args[0]);
}
public function testProcessInlinesOnlyIfSameScope()
{
$container = new ContainerBuilder();

View File

@ -405,6 +405,10 @@ class Filesystem
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
}
if ($this->exists($originDir)) {
$this->mkdir($targetDir);
}
foreach ($iterator as $file) {
$target = str_replace($originDir, $targetDir, $file->getPathname());

View File

@ -18,6 +18,8 @@ $filesystem->touch($files, $time = null, $atime = null);
$filesystem->remove($files);
$filesystem->exists($files);
$filesystem->chmod($files, $mode, $umask = 0000, $recursive = false);
$filesystem->chown($files, $user, $recursive = false);

View File

@ -847,6 +847,21 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFalse($this->filesystem->exists($targetPath.'directory'.DIRECTORY_SEPARATOR.'file1'));
}
public function testMirrorCreatesEmptyDirectory()
{
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
mkdir($sourcePath);
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
$this->filesystem->mirror($sourcePath, $targetPath);
$this->assertTrue(is_dir($targetPath));
$this->filesystem->remove($sourcePath);
}
public function testMirrorCopiesLinks()
{
$this->markAsSkippedIfSymlinkIsMissing();

View File

@ -15,31 +15,52 @@ namespace Symfony\Component\Form;
*/
final class FormEvents
{
/**
* @Event
*/
const PRE_SUBMIT = 'form.pre_bind';
/**
* @Event
*/
const SUBMIT = 'form.bind';
/**
* @Event
*/
const POST_SUBMIT = 'form.post_bind';
/**
* @Event
*/
const PRE_SET_DATA = 'form.pre_set_data';
/**
* @Event
*/
const POST_SET_DATA = 'form.post_set_data';
/**
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
* {@link PRE_SUBMIT} instead.
*
* @Event
*/
const PRE_BIND = 'form.pre_bind';
/**
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
* {@link SUBMIT} instead.
*
* @Event
*/
const BIND = 'form.bind';
/**
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
* {@link POST_SUBMIT} instead.
*
* @Event
*/
const POST_BIND = 'form.post_bind';

View File

@ -11,8 +11,8 @@
<target>הקובץ שהועלה גדול מדי. נסה להעלות קובץ קטן יותר.</target>
</trans-unit>
<trans-unit id="30">
<source>The CSRF token is invalid.</source>
<target>אסימון CSRF אינו חוקי.</target>
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>אסימון CSRF אינו חוקי. אנא נסה לשלוח שוב את הטופס.</target>
</trans-unit>
</body>
</file>

View File

@ -147,6 +147,14 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
'file' => $r->getFilename(),
'line' => $r->getStartLine(),
);
} elseif (is_object($controller)) {
$r = new \ReflectionClass($controller);
$this->data['controller'] = array(
'class' => $r->getName(),
'method' => null,
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
);
} else {
$this->data['controller'] = (string) $controller ?: 'n/a';
}

View File

@ -29,6 +29,8 @@ final class KernelEvents
* receives a Symfony\Component\HttpKernel\Event\GetResponseEvent
* instance.
*
* @Event
*
* @var string
*
* @api
@ -43,6 +45,8 @@ final class KernelEvents
* a Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent
* instance.
*
* @Event
*
* @var string
*
* @api
@ -58,6 +62,8 @@ final class KernelEvents
* Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
* instance.
*
* @Event
*
* @var string
*
* @api
@ -72,6 +78,8 @@ final class KernelEvents
* request. The event listener method receives a
* Symfony\Component\HttpKernel\Event\FilterControllerEvent instance.
*
* @Event
*
* @var string
*
* @api
@ -86,6 +94,8 @@ final class KernelEvents
* replied. The event listener method receives a
* Symfony\Component\HttpKernel\Event\FilterResponseEvent instance.
*
* @Event
*
* @var string
*
* @api
@ -99,6 +109,8 @@ final class KernelEvents
* The event listener method receives a
* Symfony\Component\HttpKernel\Event\PostResponseEvent instance.
*
* @Event
*
* @var string
*/
const TERMINATE = 'kernel.terminate';

View File

@ -59,6 +59,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
// make sure we always match the line number
$r1 = new \ReflectionMethod($this, 'testControllerInspection');
$r2 = new \ReflectionMethod($this, 'staticControllerMethod');
$r3 = new \ReflectionClass($this);
// test name, callable, expected
$controllerTests = array(
array(
@ -132,6 +133,17 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
'line' => 'n/a',
),
),
array(
'Invokable controller',
$this,
array(
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
'method' => null,
'file' => __FILE__,
'line' => $r3->getStartLine(),
),
),
);
$c = new RequestDataCollector();
@ -202,4 +214,9 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
{
throw new \LogicException('Unexpected method call');
}
public function __invoke()
{
throw new \LogicException('Unexpected method call');
}
}

View File

@ -64,7 +64,7 @@ class Route implements \Serializable
/**
* @var string
*/
private $condition;
private $condition = '';
/**
* Constructor.
@ -84,7 +84,7 @@ class Route implements \Serializable
*
* @api
*/
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = null)
public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '')
{
$this->setPath($path);
$this->setDefaults($defaults);

View File

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>An authentication exception occurred.</source>
<target>An authentication exception occurred.</target>
</trans-unit>
<trans-unit id="2">
<source>Authentication credentials could not be found.</source>
<target>Authentication credentials could not be found.</target>
</trans-unit>
<trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source>
<target>Authentication request could not be processed due to a system problem.</target>
</trans-unit>
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>Invalid credentials.</target>
</trans-unit>
<trans-unit id="5">
<source>Cookie has already been used by someone else.</source>
<target>Cookie has already been used by someone else.</target>
</trans-unit>
<trans-unit id="6">
<source>Not privileged to request the resource.</source>
<target>Not privileged to request the resource.</target>
</trans-unit>
<trans-unit id="7">
<source>Invalid CSRF token.</source>
<target>Invalid CSRF token.</target>
</trans-unit>
<trans-unit id="8">
<source>Digest nonce has expired.</source>
<target>Digest nonce has expired.</target>
</trans-unit>
<trans-unit id="9">
<source>No authentication provider found to support the authentication token.</source>
<target>No authentication provider found to support the authentication token.</target>
</trans-unit>
<trans-unit id="10">
<source>No session available, it either timed out or cookies are not enabled.</source>
<target>No session available, it either timed out or cookies are not enabled.</target>
</trans-unit>
<trans-unit id="11">
<source>No token could be found.</source>
<target>No token could be found.</target>
</trans-unit>
<trans-unit id="12">
<source>Username could not be found.</source>
<target>Username could not be found.</target>
</trans-unit>
<trans-unit id="13">
<source>Account has expired.</source>
<target>Account has expired.</target>
</trans-unit>
<trans-unit id="14">
<source>Credentials have expired.</source>
<target>Credentials have expired.</target>
</trans-unit>
<trans-unit id="15">
<source>Account is disabled.</source>
<target>Account is disabled.</target>
</trans-unit>
<trans-unit id="16">
<source>Account is locked.</source>
<target>Account is locked.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -20,6 +20,8 @@ final class SecurityEvents
* The event listener method receives a
* Symfony\Component\Security\Http\Event\InteractiveLoginEvent instance.
*
* @Event
*
* @var string
*/
const INTERACTIVE_LOGIN = 'security.interactive_login';
@ -31,6 +33,8 @@ final class SecurityEvents
* The event listener method receives a
* Symfony\Component\Security\Http\Event\SwitchUserEvent instance.
*
* @Event
*
* @var string
*/
const SWITCH_USER = 'security.switch_user';

View File

@ -0,0 +1,71 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>An authentication exception occurred.</source>
<target>An authentication exception occurred.</target>
</trans-unit>
<trans-unit id="2">
<source>Authentication credentials could not be found.</source>
<target>Authentication credentials could not be found.</target>
</trans-unit>
<trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source>
<target>Authentication request could not be processed due to a system problem.</target>
</trans-unit>
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>Invalid credentials.</target>
</trans-unit>
<trans-unit id="5">
<source>Cookie has already been used by someone else.</source>
<target>Cookie has already been used by someone else.</target>
</trans-unit>
<trans-unit id="6">
<source>Not privileged to request the resource.</source>
<target>Not privileged to request the resource.</target>
</trans-unit>
<trans-unit id="7">
<source>Invalid CSRF token.</source>
<target>Invalid CSRF token.</target>
</trans-unit>
<trans-unit id="8">
<source>Digest nonce has expired.</source>
<target>Digest nonce has expired.</target>
</trans-unit>
<trans-unit id="9">
<source>No authentication provider found to support the authentication token.</source>
<target>No authentication provider found to support the authentication token.</target>
</trans-unit>
<trans-unit id="10">
<source>No session available, it either timed out or cookies are not enabled.</source>
<target>No session available, it either timed out or cookies are not enabled.</target>
</trans-unit>
<trans-unit id="11">
<source>No token could be found.</source>
<target>No token could be found.</target>
</trans-unit>
<trans-unit id="12">
<source>Username could not be found.</source>
<target>Username could not be found.</target>
</trans-unit>
<trans-unit id="13">
<source>Account has expired.</source>
<target>Account has expired.</target>
</trans-unit>
<trans-unit id="14">
<source>Credentials have expired.</source>
<target>Credentials have expired.</target>
</trans-unit>
<trans-unit id="15">
<source>Account is disabled.</source>
<target>Account is disabled.</target>
</trans-unit>
<trans-unit id="16">
<source>Account is locked.</source>
<target>Account is locked.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -222,6 +222,86 @@
<source>Unsupported card type or invalid card number.</source>
<target>סוג הכרטיס אינו נתמך או לא חוקי.</target>
</trans-unit>
<trans-unit id="59">
<source>This is not a valid International Bank Account Number (IBAN).</source>
<target>This is not a valid International Bank Account Number (IBAN).</target>
</trans-unit>
<trans-unit id="60">
<source>This value is not a valid ISBN-10.</source>
<target>This value is not a valid ISBN-10.</target>
</trans-unit>
<trans-unit id="61">
<source>This value is not a valid ISBN-13.</source>
<target>This value is not a valid ISBN-13.</target>
</trans-unit>
<trans-unit id="62">
<source>This value is neither a valid ISBN-10 nor a valid ISBN-13.</source>
<target>This value is neither a valid ISBN-10 nor a valid ISBN-13.</target>
</trans-unit>
<trans-unit id="63">
<source>This value is not a valid ISSN.</source>
<target>This value is not a valid ISSN.</target>
</trans-unit>
<trans-unit id="64">
<source>This value is not a valid currency.</source>
<target>This value is not a valid currency.</target>
</trans-unit>
<trans-unit id="65">
<source>This value should be equal to {{ compared_value }}.</source>
<target>This value should be equal to {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="66">
<source>This value should be greater than {{ compared_value }}.</source>
<target>This value should be greater than {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="67">
<source>This value should be greater than or equal to {{ compared_value }}.</source>
<target>This value should be greater than or equal to {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="68">
<source>This value should be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>This value should be identical to {{ compared_value_type }} {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="69">
<source>This value should be less than {{ compared_value }}.</source>
<target>This value should be less than {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="70">
<source>This value should be less than or equal to {{ compared_value }}.</source>
<target>This value should be less than or equal to {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="71">
<source>This value should not be equal to {{ compared_value }}.</source>
<target>This value should not be equal to {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="72">
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</target>
</trans-unit>
<trans-unit id="78">
<source>An empty file is not allowed.</source>
<target>An empty file is not allowed.</target>
</trans-unit>
</body>
</file>
</xliff>