Merge remote branch 'origin/master' into annotations
Conflicts: UPDATE.md
This commit is contained in:
commit
0d0c737630
17
UPDATE.ja.md
17
UPDATE.ja.md
@ -8,6 +8,21 @@
|
||||
PR12 から beta1
|
||||
---------------
|
||||
|
||||
* CSRF シークレットの設定は、\ `secret` という必須のグローバル設定に変更されました(また、このシークレット値は CSRF 以外でも利用されます)
|
||||
|
||||
変更前:
|
||||
|
||||
framework:
|
||||
csrf_protection:
|
||||
secret: S3cr3t
|
||||
|
||||
変更後:
|
||||
|
||||
framework:
|
||||
secret: S3cr3t
|
||||
|
||||
* `File::getWebPath()` メソッドと `File::rename()` メソッドは削除されました。同様に `framework.document_root` コンフィギュレーションも削除されました。
|
||||
|
||||
* `session` のコンフィギュレーションがリファクタリングされました
|
||||
|
||||
* `class` オプションが削除されました(代わりに `session.class` パラメータを使ってください)
|
||||
@ -44,7 +59,7 @@ PR12 から beta1
|
||||
$container->removeDefinition('my_definition');
|
||||
$definition->replaceArgument(0, 'foo');
|
||||
|
||||
* rememberme のコンフィギュレーションで、`token_provider key` サービスIDのサフィックスを指定するのではなく、サービスIDそのものを指定するように変更されました。
|
||||
* rememberme のコンフィギュレーションで、\ `token_provider key` サービスIDのサフィックスを指定するのではなく、サービスIDそのものを指定するように変更されました。
|
||||
|
||||
PR11 から PR12
|
||||
--------------
|
||||
|
47
UPDATE.md
47
UPDATE.md
@ -40,6 +40,7 @@ beta1 to beta2
|
||||
|
||||
/**
|
||||
* @import("Doctrine\ORM\Mapping\*")
|
||||
* @import("Doctrine\ODM\MongoDB\Mapping\*", alias="mongodb")
|
||||
* @import("Symfony\Component\Validator\Constraints\*")
|
||||
* @ignorePhpDoc
|
||||
* @Entity
|
||||
@ -48,6 +49,7 @@ beta1 to beta2
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @mongodb:Id
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
* @Column(type="integer")
|
||||
* @var integer
|
||||
@ -83,6 +85,51 @@ beta1 to beta2
|
||||
*/
|
||||
private $foo;
|
||||
|
||||
* Doctrine event subscribers now use a unique "doctrine.event_subscriber" tag.
|
||||
Doctrine event listeners also use a unique "doctrine.event_listener" tag. To
|
||||
specify a connection, use the optional "connection" attribute.
|
||||
|
||||
Before:
|
||||
|
||||
listener:
|
||||
class: MyEventListener
|
||||
tags:
|
||||
- { name: doctrine.common.event_listener, event: name }
|
||||
- { name: doctrine.dbal.default_event_listener, event: name }
|
||||
subscriber:
|
||||
class: MyEventSubscriber
|
||||
tags:
|
||||
- { name: doctrine.common.event_subscriber }
|
||||
- { name: doctrine.dbal.default_event_subscriber }
|
||||
|
||||
After:
|
||||
|
||||
listener:
|
||||
class: MyEventListener
|
||||
tags:
|
||||
- { name: doctrine.event_listener, event: name } # register for all connections
|
||||
- { name: doctrine.event_listener, event: name, connection: default } # only for the default connection
|
||||
subscriber:
|
||||
class: MyEventSubscriber
|
||||
tags:
|
||||
- { name: doctrine.event_subscriber } # register for all connections
|
||||
- { name: doctrine.event_subscriber, connection: default } # only for the default connection
|
||||
|
||||
* The `doctrine.orm.entity_managers` is now hash of entity manager names/ids pairs:
|
||||
|
||||
Before: array('default', 'foo')
|
||||
After: array('default' => 'doctrine.orm.default_entity_manager', 'foo' => 'doctrine.orm.foo_entity_manager'))
|
||||
|
||||
* Application translations are now stored in the `Resources` directory:
|
||||
|
||||
Before:
|
||||
|
||||
app/translations/catalogue.fr.xml
|
||||
|
||||
After:
|
||||
|
||||
app/Resources/translations/catalogue.fr.xml
|
||||
|
||||
PR12 to beta1
|
||||
-------------
|
||||
|
||||
|
@ -174,13 +174,6 @@ class FormExtension extends \Twig_Extension
|
||||
throw new FormException(sprintf('Unable to render form as none of the following blocks exist: "%s".', implode('", "', $blocks)));
|
||||
}
|
||||
|
||||
protected function getTemplate(FormView $view, $name)
|
||||
{
|
||||
$templates = $this->getTemplates($view);
|
||||
|
||||
return $templates[$name];
|
||||
}
|
||||
|
||||
protected function getTemplates(FormView $view)
|
||||
{
|
||||
// templates are looked for in the following resources:
|
||||
|
@ -44,6 +44,6 @@ class FormThemeNode extends \Twig_Node
|
||||
;
|
||||
}
|
||||
|
||||
$compiler->raw('));');
|
||||
$compiler->raw("));\n");
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,8 @@ class ProxyCacheWarmer implements CacheWarmerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$entityManagers = $this->container->getParameter('doctrine.orm.entity_managers');
|
||||
foreach ($entityManagers as $entityManagerName) {
|
||||
$em = $this->container->get(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName));
|
||||
/* @var $em Doctrine\ORM\EntityManager */
|
||||
foreach ($this->container->getParameter('doctrine.orm.entity_managers') as $id) {
|
||||
$em = $this->container->get($id);
|
||||
$classes = $em->getMetadataFactory()->getAllMetadata();
|
||||
$em->getProxyFactory()->generateProxyClasses($classes);
|
||||
}
|
||||
|
@ -111,12 +111,11 @@ abstract class DoctrineCommand extends Command
|
||||
|
||||
protected function getDoctrineEntityManagers()
|
||||
{
|
||||
$entityManagerNames = $this->container->getParameter('doctrine.orm.entity_managers');
|
||||
$entityManagers = array();
|
||||
foreach ($entityManagerNames as $entityManagerName) {
|
||||
$em = $this->container->get(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName));
|
||||
$entityManagers[] = $em;
|
||||
foreach ($this->container->getParameter('doctrine.orm.entity_managers') as $id) {
|
||||
$entityManagers[] = $this->container->get($id);
|
||||
}
|
||||
|
||||
return $entityManagers;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ EOT
|
||||
$entityGenerator = $this->getEntityGenerator();
|
||||
|
||||
foreach ($metadatas as $metadata) {
|
||||
if ($filterEntity && $metadata->getReflClass()->getShortName() !== $filterEntity) {
|
||||
if ($filterEntity && $metadata->getReflectionClass()->getShortName() !== $filterEntity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -9,55 +9,85 @@ use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||
|
||||
class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
{
|
||||
protected $container;
|
||||
private $container;
|
||||
private $connections;
|
||||
private $eventManagers;
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
foreach ($container->getDefinitions() as $id => $definition) {
|
||||
if (!$definition instanceof DefinitionDecorator || 'doctrine.dbal.connection.event_manager' !== $definition->getParent()) {
|
||||
continue;
|
||||
$this->connections = $container->getParameter('doctrine.dbal.connections');
|
||||
|
||||
foreach ($container->findTaggedServiceIds('doctrine.event_subscriber') as $subscriberId => $instances) {
|
||||
$this->registerSubscriber($subscriberId, $instances);
|
||||
}
|
||||
|
||||
foreach ($container->findTaggedServiceIds('doctrine.event_listener') as $listenerId => $instances) {
|
||||
$this->registerListener($listenerId, $instances);
|
||||
}
|
||||
}
|
||||
|
||||
protected function registerSubscriber($subscriberId, $instances)
|
||||
{
|
||||
$connections = array();
|
||||
foreach ($instances as $attributes) {
|
||||
if (isset($attributes['connection'])) {
|
||||
$connections[] = $attributes['connection'];
|
||||
} else {
|
||||
$connections = array_keys($this->connections);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($connections as $name) {
|
||||
$this->getEventManager($name)->addMethodCall('addEventSubscriber', array(new Reference($subscriberId)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function registerListener($listenerId, $instances)
|
||||
{
|
||||
$connections = array();
|
||||
foreach ($instances as $attributes) {
|
||||
if (!isset($attributes['event'])) {
|
||||
throw new \InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $listenerId));
|
||||
}
|
||||
|
||||
$prefix = substr($id, 0, -strlen('_connection.event_manager'));
|
||||
$this->registerListeners($prefix, $definition);
|
||||
$this->registerSubscribers($prefix, $definition);
|
||||
}
|
||||
}
|
||||
if (isset($attributes['connection'])) {
|
||||
$cs = array($attributes['connection']);
|
||||
} else {
|
||||
$cs = array_keys($this->connections);
|
||||
}
|
||||
|
||||
protected function registerSubscribers($prefix, $definition)
|
||||
{
|
||||
$subscribers = array_merge(
|
||||
$this->container->findTaggedServiceIds('doctrine.common.event_subscriber'),
|
||||
$this->container->findTaggedServiceIds($prefix.'_event_subscriber')
|
||||
);
|
||||
|
||||
foreach ($subscribers as $id => $instances) {
|
||||
$definition->addMethodCall('addEventSubscriber', array(new Reference($id)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function registerListeners($prefix, $definition)
|
||||
{
|
||||
$listeners = array_merge(
|
||||
$this->container->findTaggedServiceIds('doctrine.common.event_listener'),
|
||||
$this->container->findTaggedServiceIds($prefix.'_event_listener')
|
||||
);
|
||||
|
||||
foreach ($listeners as $listenerId => $instances) {
|
||||
$events = array();
|
||||
foreach ($instances as $attributes) {
|
||||
if (isset($attributes['event'])) {
|
||||
$events[] = $attributes['event'];
|
||||
foreach ($cs as $connection) {
|
||||
if (!is_array($connections[$connection])) {
|
||||
$connections[$connection] = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < count($events)) {
|
||||
$definition->addMethodCall('addEventListener', array(
|
||||
$events,
|
||||
new Reference($listenerId),
|
||||
));
|
||||
$connections[$connection][] = $attributes['event'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($connections as $name => $events) {
|
||||
$this->getEventManager($name)->addMethodCall('addEventListener', array(
|
||||
array_unique($events),
|
||||
new Reference($listenerId),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getEventManager($name)
|
||||
{
|
||||
if (null === $this->eventManagers) {
|
||||
$this->eventManagers = array();
|
||||
foreach ($this->connections as $n => $id) {
|
||||
$arguments = $this->container->getDefinition($id)->getArguments();
|
||||
$this->eventManagers[$n] = $this->container->getDefinition((string) $arguments[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->eventManagers[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Doctrine connection "%s" does not exist but is referenced in the "%s" event listener.', $name, $listenerId));
|
||||
}
|
||||
|
||||
return $this->eventManagers[$name];
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class Configuration implements ConfigurationInterface
|
||||
->append($this->getOrmCacheDriverNode('result_cache_driver'))
|
||||
->children()
|
||||
->scalarNode('connection')->end()
|
||||
->scalarNode('class_metadata_factory_name')->defaultValue('%doctrine.orm.class_metadata_factory_name%')->end()
|
||||
->scalarNode('class_metadata_factory_name')->defaultValue('Doctrine\ORM\Mapping\ClassMetadataFactory')->end()
|
||||
->scalarNode('auto_mapping')->defaultFalse()->end()
|
||||
->end()
|
||||
->fixXmlConfig('hydrator')
|
||||
|
@ -71,6 +71,12 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
|
||||
$container->getDefinition('doctrine.dbal.connection_factory')->replaceArgument(0, $config['types']);
|
||||
|
||||
$connections = array();
|
||||
foreach (array_keys($config['connections']) as $name) {
|
||||
$connections[$name] = sprintf('doctrine.dbal.%s_connection', $name);
|
||||
}
|
||||
$container->setParameter('doctrine.dbal.connections', $connections);
|
||||
|
||||
foreach ($config['connections'] as $name => $connection) {
|
||||
$this->loadDbalConnection($name, $connection, $container);
|
||||
}
|
||||
@ -102,7 +108,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
$mysqlSessionInit = new Definition('%doctrine.dbal.events.mysql_session_init.class%');
|
||||
$mysqlSessionInit->setArguments(array($connection['charset']));
|
||||
$mysqlSessionInit->setPublic(false);
|
||||
$mysqlSessionInit->addTag(sprintf('doctrine.dbal.%s_event_subscriber', $name));
|
||||
$mysqlSessionInit->addTag('doctrine.event_subscriber', array('connection' => $name));
|
||||
|
||||
$container->setDefinition(
|
||||
sprintf('doctrine.dbal.%s_connection.events.mysqlsessioninit', $name),
|
||||
@ -142,10 +148,15 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('orm.xml');
|
||||
|
||||
$container->setParameter('doctrine.orm.entity_managers', $entityManagers = array_keys($config['entity_managers']));
|
||||
$entityManagers = array();
|
||||
foreach (array_keys($config['entity_managers']) as $name) {
|
||||
$entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name);
|
||||
}
|
||||
$container->setParameter('doctrine.orm.entity_managers', $entityManagers);
|
||||
|
||||
if (empty($config['default_entity_manager'])) {
|
||||
$config['default_entity_manager'] = reset($entityManagers);
|
||||
$tmp = array_keys($entityManagers);
|
||||
$config['default_entity_manager'] = reset($tmp);
|
||||
}
|
||||
|
||||
$options = array('default_entity_manager', 'auto_generate_proxy_classes', 'proxy_dir', 'proxy_namespace');
|
||||
|
@ -5,7 +5,6 @@
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="doctrine.dbal.default_connection">default</parameter>
|
||||
<parameter key="doctrine.dbal.connection.class">Doctrine\DBAL\Connection</parameter>
|
||||
<parameter key="doctrine.dbal.logger.debug.class">Doctrine\DBAL\Logging\DebugStack</parameter>
|
||||
<parameter key="doctrine.dbal.logger.class">Symfony\Bundle\DoctrineBundle\Logger\DbalLogger</parameter>
|
||||
|
@ -7,7 +7,6 @@
|
||||
<parameters>
|
||||
<parameter key="doctrine.orm.configuration.class">Doctrine\ORM\Configuration</parameter>
|
||||
<parameter key="doctrine.orm.entity_manager.class">Doctrine\ORM\EntityManager</parameter>
|
||||
<parameter key="doctrine.orm.entity_managers" type="collection"></parameter>
|
||||
|
||||
<!-- cache -->
|
||||
<parameter key="doctrine.orm.cache.array.class">Doctrine\Common\Cache\ArrayCache</parameter>
|
||||
@ -26,7 +25,6 @@
|
||||
<parameter key="doctrine.orm.metadata.yml.class">Doctrine\ORM\Mapping\Driver\YamlDriver</parameter>
|
||||
<parameter key="doctrine.orm.metadata.php.class">Doctrine\ORM\Mapping\Driver\PHPDriver</parameter>
|
||||
<parameter key="doctrine.orm.metadata.staticphp.class">Doctrine\ORM\Mapping\Driver\StaticPHPDriver</parameter>
|
||||
<parameter key="doctrine.orm.class_metadata_factory_name">Doctrine\ORM\Mapping\ClassMetadataFactory</parameter>
|
||||
|
||||
<!-- cache warmer -->
|
||||
<parameter key="doctrine.orm.proxy_cache_warmer.class">Symfony\Bundle\DoctrineBundle\CacheWarmer\ProxyCacheWarmer</parameter>
|
||||
|
@ -41,7 +41,7 @@ class ProxyCacheWarmerTest extends \Symfony\Bundle\DoctrineBundle\Tests\TestCase
|
||||
$container->expects($this->at(2))
|
||||
->method('getParameter')
|
||||
->with($this->equalTo('doctrine.orm.entity_managers'))
|
||||
->will($this->returnValue(array('default', 'foo')));
|
||||
->will($this->returnValue(array('default' => 'doctrine.orm.default_entity_manager', 'foo' => 'doctrine.orm.foo_entity_manager')));
|
||||
$container->expects($this->at(3))
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine.orm.default_entity_manager'))
|
||||
|
@ -156,7 +156,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
$this->assertArrayHasKey('doctrine.orm.entity_manager', $definition->getTags());
|
||||
|
||||
$this->assertEquals(array("default"), $container->getParameter('doctrine.orm.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
$this->assertEquals(array('default' => 'doctrine.orm.default_entity_manager'), $container->getParameter('doctrine.orm.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
|
||||
$arguments = $definition->getArguments();
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
|
||||
@ -569,7 +569,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$this->assertEquals(array("em1", "em2"), $container->getParameter('doctrine.orm.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
$this->assertEquals(array('em1' => 'doctrine.orm.em1_entity_manager', 'em2' => 'doctrine.orm.em2_entity_manager'), $container->getParameter('doctrine.orm.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
|
||||
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
|
||||
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
|
||||
|
@ -440,7 +440,7 @@ class FrameworkExtension extends Extension
|
||||
$dirs[] = $dir;
|
||||
}
|
||||
}
|
||||
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/translations')) {
|
||||
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/translations')) {
|
||||
$dirs[] = $dir;
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,8 @@ class RequestListener
|
||||
$request->getMethod(),
|
||||
$request->getHost(),
|
||||
$request->getScheme(),
|
||||
$this->httpPort,
|
||||
$this->httpsPort
|
||||
$request->isSecure() ? $this->httpPort : $request->getPort(),
|
||||
$request->isSecure() ? $request->getPort() : $this->httpsPort
|
||||
);
|
||||
|
||||
if ($session = $request->getSession()) {
|
||||
|
@ -71,6 +71,8 @@
|
||||
<xsd:attribute name="cache-warmer" type="cache_warmer" />
|
||||
<xsd:attribute name="resource" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="http-port" type="xsd:string" />
|
||||
<xsd:attribute name="https-port" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="session">
|
||||
|
@ -19,16 +19,16 @@
|
||||
<target>Значение должно быть пустым</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5">
|
||||
<source>This value should be one of the given choices</source>
|
||||
<target>Значение должно быть одним из предложенных</target>
|
||||
<source>The value you selected is not a valid choice</source>
|
||||
<target>Выбранное Вами значение недопустимо</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6">
|
||||
<source>You should select at least {{ limit }} choices</source>
|
||||
<target>Выберите минимум {{ limit }} возможностей</target>
|
||||
<source>You must select at least {{ limit }} choices</source>
|
||||
<target>Вы должны выбрать хотя бы {{ limit }} вариантов</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7">
|
||||
<source>You should select at most {{ limit }} choices</source>
|
||||
<target>Выберите максимум {{ limit }} возможностей</target>
|
||||
<source>You must select at most {{ limit }} choices</source>
|
||||
<target>Вы должны выбрать не более чем {{ limit }} вариантов</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8">
|
||||
<source>The fields {{ fields }} were not expected</source>
|
||||
@ -126,6 +126,10 @@
|
||||
<source>The two values should be equal</source>
|
||||
<target>Оба значения должны быть одинаковыми</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="32">
|
||||
<source>One or more of the given values is invalid</source>
|
||||
<target>Одно или несколько заданных значений недопустимо</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
@ -32,14 +32,17 @@ class PhpEngine extends BasePhpEngine implements EngineInterface
|
||||
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
|
||||
* @param ContainerInterface $container The DI container
|
||||
* @param LoaderInterface $loader A loader instance
|
||||
* @param GlobalVariables $globals A GlobalVariables instance
|
||||
* @param GlobalVariables|null $globals A GlobalVariables instance or null
|
||||
*/
|
||||
public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals)
|
||||
public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($parser, $loader);
|
||||
$this->addGlobal('app', $globals);
|
||||
|
||||
if (null !== $globals) {
|
||||
$this->addGlobal('app', $globals);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,75 @@
|
||||
<?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;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Bundle\FrameworkBundle\RequestListener;
|
||||
|
||||
class RequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $container;
|
||||
private $router;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$this->router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPortData
|
||||
*/
|
||||
public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort)
|
||||
{
|
||||
$listener = new RequestListener($this->container, $this->router, $defaultHttpPort, $defaultHttpsPort);
|
||||
|
||||
$expectedContext = new RequestContext();
|
||||
$expectedContext->setHttpPort($expectedHttpPort);
|
||||
$expectedContext->setHttpsPort($expectedHttpsPort);
|
||||
$expectedContext->setScheme(0 === strpos($uri, 'https') ? 'https' : 'http');
|
||||
$this->router->expects($this->once())
|
||||
->method('setContext')
|
||||
->with($expectedContext);
|
||||
|
||||
$event = $this->createGetResponseEventForUri($uri);
|
||||
$listener->onCoreRequest($event);
|
||||
}
|
||||
|
||||
public function getPortData()
|
||||
{
|
||||
return array(
|
||||
array(80, 443, 'http://localhost/', 80, 443),
|
||||
array(80, 443, 'http://localhost:90/', 90, 443),
|
||||
array(80, 443, 'https://localhost/', 80, 443),
|
||||
array(80, 443, 'https://localhost:90/', 80, 90),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
*
|
||||
* @return GetResponseEvent
|
||||
*/
|
||||
private function createGetResponseEventForUri($uri)
|
||||
{
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$request = Request::create($uri);
|
||||
$request->attributes->set('_controller', null); // Prevents going in to routing process
|
||||
|
||||
return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
}
|
||||
}
|
@ -32,14 +32,16 @@ class TwigEngine implements EngineInterface
|
||||
*
|
||||
* @param \Twig_Environment $environment A \Twig_Environment instance
|
||||
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
|
||||
* @param GlobalVariables $globals A GlobalVariables instance
|
||||
* @param GlobalVariables|null $globals A GlobalVariables instance or null
|
||||
*/
|
||||
public function __construct(\Twig_Environment $environment, TemplateNameParserInterface $parser, GlobalVariables $globals)
|
||||
public function __construct(\Twig_Environment $environment, TemplateNameParserInterface $parser, GlobalVariables $globals = null)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$this->parser = $parser;
|
||||
|
||||
$environment->addGlobal('app', $globals);
|
||||
if (null !== $globals) {
|
||||
$environment->addGlobal('app', $globals);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@
|
||||
} else {
|
||||
xhr = new ActiveXObject('Microsoft.XMLHTTP');
|
||||
}
|
||||
xhr.open('GET', '{{ url("_wdt", { "token": token }) }}', false);
|
||||
xhr.open('GET', '{{ path("_wdt", { "token": token }) }}', false);
|
||||
xhr.send('');
|
||||
wdt.innerHTML = xhr.responseText;
|
||||
wdt.style.display = 'block';
|
||||
|
@ -103,7 +103,7 @@ class FieldType extends AbstractType
|
||||
|
||||
$class = isset($options['data_class']) ? $options['data_class'] : null;
|
||||
|
||||
// If no data class is set explicitely and an object is passed as data,
|
||||
// If no data class is set explicitly and an object is passed as data,
|
||||
// use the class of that object as data class
|
||||
if (!$class && isset($options['data']) && is_object($options['data'])) {
|
||||
$defaultOptions['data_class'] = $class = get_class($options['data']);
|
||||
|
@ -82,7 +82,7 @@ class UploadedFile extends File
|
||||
}
|
||||
|
||||
$this->path = realpath($path);
|
||||
$this->originalName = $originalName;
|
||||
$this->originalName = basename($originalName);
|
||||
$this->mimeType = $mimeType ?: 'application/octet-stream';
|
||||
$this->size = $size;
|
||||
$this->error = $error ?: UPLOAD_ERR_OK;
|
||||
|
@ -11,12 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Generator;
|
||||
|
||||
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||
|
||||
/**
|
||||
* UrlGeneratorInterface is the interface that all URL generator classes must implements.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface UrlGeneratorInterface
|
||||
interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
{
|
||||
/**
|
||||
* Generates a URL from the given parameters.
|
||||
|
@ -11,12 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Matcher;
|
||||
|
||||
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||
|
||||
/**
|
||||
* UrlMatcherInterface is the interface that all URL matcher classes must implement.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface UrlMatcherInterface
|
||||
interface UrlMatcherInterface extends RequestContextAwareInterface
|
||||
{
|
||||
/**
|
||||
* Tries to match a URL with a set of routes.
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?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\Component\Routing;
|
||||
|
||||
interface RequestContextAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets the request context.
|
||||
*
|
||||
* @param RequestContext $context The context
|
||||
*/
|
||||
function setContext(RequestContext $context);
|
||||
}
|
@ -13,6 +13,7 @@ namespace Symfony\Tests\Component\HttpFoundation\File;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
|
||||
class FileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -94,8 +95,6 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSizeFailing()
|
||||
{
|
||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileException');
|
||||
|
||||
$dir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'directory';
|
||||
$path = $dir.DIRECTORY_SEPARATOR.'test.copy.gif';
|
||||
@unlink($path);
|
||||
@ -103,7 +102,12 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$file = new File($path);
|
||||
@unlink($path);
|
||||
$file->getSize();
|
||||
|
||||
try {
|
||||
$file->getSize();
|
||||
$this->fail('File::getSize should throw an exception.');
|
||||
} catch (FileException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public function testMove()
|
||||
@ -156,8 +160,11 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$file = new File($path);
|
||||
|
||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileException');
|
||||
$file->move($targetPath);
|
||||
try {
|
||||
$file->move($targetPath);
|
||||
$this->fail('File::move should throw an exception.');
|
||||
} catch (FileException $e) {
|
||||
}
|
||||
|
||||
$this->assertFileExists($path);
|
||||
$this->assertFileNotExists($path.$targetPath.'test.gif');
|
||||
|
@ -77,6 +77,19 @@ class UploadedFileTest extends \PHPUnit_Framework_TestCase
|
||||
null
|
||||
);
|
||||
|
||||
$this->assertEquals('test.gif', $file->getName());
|
||||
$this->assertEquals('original.gif', $file->getOriginalName());
|
||||
}
|
||||
|
||||
public function testGetOriginalNameSanitizeFilename()
|
||||
{
|
||||
$file = new UploadedFile(
|
||||
__DIR__.'/Fixtures/test.gif',
|
||||
'../../original.gif',
|
||||
'image/gif',
|
||||
filesize(__DIR__.'/Fixtures/test.gif'),
|
||||
null
|
||||
);
|
||||
|
||||
$this->assertEquals('original.gif', $file->getOriginalName());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user