Skip to content

Commit

Permalink
Merge branch '2.3' into 2.5
Browse files Browse the repository at this point in the history
* 2.3:
  Update filesystem readme.md to include exists method
  Add machine readable events
  fixed typo
  [Translations] Added missing Hebrew language trans-unit sources
  [DependencyInjection] inlined factory not referenced
  Fixed case for empty folder
  • Loading branch information
fabpot committed Nov 16, 2014
2 parents af4f959 + 83c6ead commit 679911c
Show file tree
Hide file tree
Showing 16 changed files with 398 additions and 4 deletions.
4 changes: 2 additions & 2 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Console/ConsoleEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -49,6 +53,8 @@ final class ConsoleEvents
* a Symfony\Component\Console\Event\ConsoleExceptionEvent
* instance.
*
* @Event
*
* @var string
*/
const EXCEPTION = 'console.exception';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ private function processArguments(array $arguments)
$this->processArguments($argument->getArguments());
$this->processArguments($argument->getMethodCalls());
$this->processArguments($argument->getProperties());

if ($argument->getFactoryService()) {
$this->processArguments(array(new Reference($argument->getFactoryService())));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ private function isInlineableDefinition(ContainerBuilder $container, $id, Defini
return false;
}

if (count($ids) > 1 && $definition->getFactoryService()) {
return false;
}

return $container->getDefinition(reset($ids))->getScope() === $definition->getScope();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ public function testProcessDetectsReferencesFromInlinedDefinitions()
$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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,84 @@ public function testProcessInlinesIfMultipleReferencesButAllFromTheSameDefinitio
$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();
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
$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());

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,21 @@ public function testMirrorCopiesFilesAndDirectoriesRecursively()
$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();
Expand Down
21 changes: 21 additions & 0 deletions src/Symfony/Component/Form/FormEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,52 @@
*/
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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/HttpKernel/KernelEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ final class KernelEvents
* receives a Symfony\Component\HttpKernel\Event\GetResponseEvent
* instance.
*
* @Event
*
* @var string
*
* @api
Expand All @@ -43,6 +45,8 @@ final class KernelEvents
* a Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent
* instance.
*
* @Event
*
* @var string
*
* @api
Expand All @@ -58,6 +62,8 @@ final class KernelEvents
* Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
* instance.
*
* @Event
*
* @var string
*
* @api
Expand All @@ -72,6 +78,8 @@ final class KernelEvents
* request. The event listener method receives a
* Symfony\Component\HttpKernel\Event\FilterControllerEvent instance.
*
* @Event
*
* @var string
*
* @api
Expand All @@ -86,6 +94,8 @@ final class KernelEvents
* replied. The event listener method receives a
* Symfony\Component\HttpKernel\Event\FilterResponseEvent instance.
*
* @Event
*
* @var string
*
* @api
Expand All @@ -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';
Expand Down
Loading

0 comments on commit 679911c

Please sign in to comment.