Merge remote branch 'origin/master' into annotations
Conflicts: UPDATE.md src/Symfony/Bundle/DoctrineBundle/Resources/config/orm.xml src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
This commit is contained in:
commit
f7e03f2d87
110
UPDATE.ja.md
110
UPDATE.ja.md
@ -5,6 +5,116 @@
|
||||
このドキュメントでは、フレームワークの "パブリックな" APIを使っている場合に必要な変更点についてのみ説明しています。
|
||||
フレームワークのコアコードを "ハック" している場合は、変更履歴を注意深く追跡する必要があるでしょう。
|
||||
|
||||
beta1 から beta2
|
||||
----------------
|
||||
|
||||
* ``error_handler`` の設定が削除されました。\ ``ErrorHandler`` クラスは Symfony Standard Edition の ``AppKernel`` で直接管理されるように変更されました。
|
||||
|
||||
* Doctrine のメタデータ用のディレクトリが、\ ``Resources/config/doctrine/metadata/orm/`` から ``Resources/config/doctrine`` に変更され、各ファイルの拡張子が ``.dcm.yml`` から ``.orm.yml`` に変更されました。
|
||||
|
||||
変更前:
|
||||
|
||||
Resources/config/doctrine/metadata/orm/Bundle.Entity.dcm.xml
|
||||
Resources/config/doctrine/metadata/orm/Bundle.Entity.dcm.yml
|
||||
|
||||
変更後:
|
||||
|
||||
Resources/config/doctrine/Bundle.Entity.orm.xml
|
||||
Resources/config/doctrine/Bundle.Entity.orm.yml
|
||||
|
||||
* 新しい Doctrine Registry クラスの導入により、次のパラメータは削除されました(\ `doctrine` サービスのメソッドに置き換えられました)。
|
||||
|
||||
* doctrine.orm.entity_managers
|
||||
* doctrine.orm.default_entity_manager
|
||||
* doctrine.dbal.default_connection
|
||||
|
||||
変更前:
|
||||
|
||||
$container->getParameter('doctrine.orm.entity_managers')
|
||||
$container->getParameter('doctrine.orm.default_entity_manager')
|
||||
$container->getParameter('doctrine.orm.default_connection')
|
||||
|
||||
変更後:
|
||||
|
||||
$container->get('doctrine')->getEntityManagerNames()
|
||||
$container->get('doctrine')->getDefaultEntityManagerName()
|
||||
$container->get('doctrine')->getDefaultConnectionName()
|
||||
|
||||
ただし、これらのメソッドを使わなくても、次のようにして Registry オブジェクトから直接 EntityManager オブジェクトを取得できます。
|
||||
|
||||
変更前:
|
||||
|
||||
$em = $this->get('doctrine.orm.entity_manager');
|
||||
$em = $this->get('doctrine.orm.foobar_entity_manager');
|
||||
|
||||
変更後:
|
||||
|
||||
$em = $this->get('doctrine')->getEntityManager();
|
||||
$em = $this->get('doctrine')->getEntityManager('foobar');
|
||||
|
||||
* `doctrine:generate:entities` コマンドの引数とオプションが変更されました。
|
||||
新しい引数とオプションの詳細は、\ `./app/console doctrine:generate:entities --help` コマンドを実行して確認してください。
|
||||
|
||||
* `doctrine:generate:repositories` コマンドは削除されました。
|
||||
このコマンドに相当する機能は、\ `doctrine:generate:entities` コマンドに統合されました。
|
||||
|
||||
* Doctrine イベントサブスクライバーは、ユニークな "doctrine.event_subscriber" タグを使うように変更されました。
|
||||
また、Doctrine イベントリスナーは、ユニークな "doctrine.event_listener" タグを使うように変更されました。
|
||||
コネクションを指定するには、オプションの "connection" 属性を使ってください。
|
||||
|
||||
変更前:
|
||||
|
||||
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 }
|
||||
|
||||
変更後:
|
||||
|
||||
listener:
|
||||
class: MyEventListener
|
||||
tags:
|
||||
- { name: doctrine.event_listener, event: name } # すべてのコネクションに対して登録
|
||||
- { name: doctrine.event_listener, event: name, connection: default } # デフォルトコネクションにのみ登録
|
||||
subscriber:
|
||||
class: MyEventSubscriber
|
||||
tags:
|
||||
- { name: doctrine.event_subscriber } # すべてのコネクションに対して登録
|
||||
- { name: doctrine.event_subscriber, connection: default } # デフォルトコネクションにのみ登録
|
||||
|
||||
* アプリケーションの翻訳ファイルは、\ `Resources` ディレクトリに保存されるように変更されました。
|
||||
|
||||
変更前:
|
||||
|
||||
app/translations/catalogue.fr.xml
|
||||
|
||||
変更後:
|
||||
|
||||
app/Resources/translations/catalogue.fr.xml
|
||||
|
||||
* "collection" フォームタイプの "modifiable" オプションは、2 つのオプション "allow_add" と "allow_delete" に分割されました。
|
||||
|
||||
変更前:
|
||||
|
||||
$builder->add('tags', 'collection', array(
|
||||
'type' => 'text',
|
||||
'modifiable' => true,
|
||||
));
|
||||
|
||||
変更後:
|
||||
|
||||
$builder->add('tags', 'collection', array(
|
||||
'type' => 'text',
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
));
|
||||
|
||||
PR12 から beta1
|
||||
---------------
|
||||
|
||||
|
82
UPDATE.md
82
UPDATE.md
@ -42,8 +42,6 @@ beta1 to beta2
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ignorePhpDoc
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class MyUser
|
||||
@ -89,6 +87,56 @@ beta1 to beta2
|
||||
*/
|
||||
private $foo;
|
||||
|
||||
* The ``error_handler`` setting has been removed. The ``ErrorHandler`` class
|
||||
is now managed directly by Symfony SE in ``AppKernel``.
|
||||
|
||||
* The Doctrine metadata files has moved from
|
||||
``Resources/config/doctrine/metadata/orm/`` to ``Resources/config/doctrine``
|
||||
and the extension from ``.dcm.yml`` to ``.orm.yml``
|
||||
|
||||
Before:
|
||||
|
||||
Resources/config/doctrine/metadata/orm/Bundle.Entity.dcm.xml
|
||||
Resources/config/doctrine/metadata/orm/Bundle.Entity.dcm.yml
|
||||
|
||||
After:
|
||||
|
||||
Resources/config/doctrine/Bundle.Entity.orm.xml
|
||||
Resources/config/doctrine/Bundle.Entity.orm.yml
|
||||
|
||||
* With the introduction of a new Doctrine Registry class, the following
|
||||
parameters have been removed (replaced by methods on the `doctrine`
|
||||
service):
|
||||
|
||||
* doctrine.orm.entity_managers
|
||||
* doctrine.orm.default_entity_manager
|
||||
* doctrine.dbal.default_connection
|
||||
|
||||
Before:
|
||||
|
||||
$container->getParameter('doctrine.orm.entity_managers')
|
||||
$container->getParameter('doctrine.orm.default_entity_manager')
|
||||
$container->getParameter('doctrine.orm.default_connection')
|
||||
|
||||
After:
|
||||
|
||||
$container->get('doctrine')->getEntityManagerNames()
|
||||
$container->get('doctrine')->getDefaultEntityManagerName()
|
||||
$container->get('doctrine')->getDefaultConnectionName()
|
||||
|
||||
But you don't really need to use these methods anymore, as to get an entity
|
||||
manager, you can now use the registry directly:
|
||||
|
||||
Before:
|
||||
|
||||
$em = $this->get('doctrine.orm.entity_manager');
|
||||
$em = $this->get('doctrine.orm.foobar_entity_manager');
|
||||
|
||||
After:
|
||||
|
||||
$em = $this->get('doctrine')->getEntityManager();
|
||||
$em = $this->get('doctrine')->getEntityManager('foobar');
|
||||
|
||||
* The `doctrine:generate:entities` arguments and options changed. Run
|
||||
`./app/console doctrine:generate:entities --help` for more information about
|
||||
the new syntax.
|
||||
@ -126,11 +174,6 @@ beta1 to beta2
|
||||
- { 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:
|
||||
@ -141,6 +184,27 @@ beta1 to beta2
|
||||
|
||||
app/Resources/translations/catalogue.fr.xml
|
||||
|
||||
* The option "modifiable" of the "collection" form type was split into two
|
||||
options "allow_add" and "allow_delete".
|
||||
|
||||
Before:
|
||||
|
||||
$builder->add('tags', 'collection', array(
|
||||
'type' => 'text',
|
||||
'modifiable' => true,
|
||||
));
|
||||
|
||||
After:
|
||||
|
||||
$builder->add('tags', 'collection', array(
|
||||
'type' => 'text',
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
));
|
||||
|
||||
* Serializer: The NormalizerInterface's `supports()` method has been split in
|
||||
two methods: `supportsNormalization` and `supportsDenormalization`.
|
||||
|
||||
PR12 to beta1
|
||||
-------------
|
||||
|
||||
@ -227,11 +291,11 @@ PR11 to PR12
|
||||
<app:engine>twig</app:engine>
|
||||
<twig:extension>twig.extension.debug</twig:extension>
|
||||
|
||||
* Fixes a critical security issue which allowed all users to switch to
|
||||
* Fixes a critical security issue which allowed all users to switch to
|
||||
arbitrary accounts when the SwitchUserListener was activated. Configurations
|
||||
which do not use the SwitchUserListener are not affected.
|
||||
|
||||
* The Dependency Injection Container now strongly validates the references of
|
||||
* The Dependency Injection Container now strongly validates the references of
|
||||
all your services at the end of its compilation process. If you have invalid
|
||||
references this will result in a compile-time exception instead of a run-time
|
||||
exception (the previous behavior).
|
||||
|
@ -70,7 +70,7 @@ class EntityToIdTransformer implements DataTransformerInterface
|
||||
}
|
||||
|
||||
if (!($entity = $this->choiceList->getEntity($key))) {
|
||||
throw new TransformationFailedException('The entity with key "%s" could not be found', $key);
|
||||
throw new TransformationFailedException(sprintf('The entity with key "%s" could not be found', $key));
|
||||
}
|
||||
|
||||
return $entity;
|
||||
|
@ -27,10 +27,12 @@ class FormExtension extends \Twig_Extension
|
||||
protected $templates;
|
||||
protected $environment;
|
||||
protected $themes;
|
||||
protected $varStack;
|
||||
|
||||
public function __construct(array $resources = array())
|
||||
{
|
||||
$this->themes = new \SplObjectStorage();
|
||||
$this->varStack = new \SplObjectStorage();
|
||||
$this->resources = $resources;
|
||||
}
|
||||
|
||||
@ -156,9 +158,8 @@ class FormExtension extends \Twig_Extension
|
||||
{
|
||||
$templates = $this->getTemplates($view);
|
||||
$blocks = $view->get('types');
|
||||
if ('widget' === $section || 'row' === $section) {
|
||||
array_unshift($blocks, '_'.$view->get('id'));
|
||||
}
|
||||
array_unshift($blocks, '_'.$view->get('id'));
|
||||
|
||||
foreach ($blocks as &$block) {
|
||||
$block = $block.'_'.$section;
|
||||
|
||||
@ -167,7 +168,15 @@ class FormExtension extends \Twig_Extension
|
||||
$view->setRendered();
|
||||
}
|
||||
|
||||
return $templates[$block]->renderBlock($block, array_merge($view->all(), $variables));
|
||||
$this->varStack[$view] = array_replace(
|
||||
$view->all(),
|
||||
isset($this->varStack[$view]) ? $this->varStack[$view] : array(),
|
||||
$variables
|
||||
);
|
||||
|
||||
$html = $templates[$block]->renderBlock($block, $this->varStack[$view]);
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
framework:
|
||||
charset: UTF-8
|
||||
error_handler: null
|
||||
secret: xxxxxxxxxx
|
||||
csrf_protection:
|
||||
enabled: true
|
||||
|
@ -263,11 +263,12 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
}
|
||||
$container->addResource(new FileResource($resource));
|
||||
|
||||
if (($files = glob($dir.'/'.$configPath.'/*.xml')) && count($files)) {
|
||||
$extension = $this->getMappingResourceExtension();
|
||||
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && count($files)) {
|
||||
return 'xml';
|
||||
} elseif (($files = glob($dir.'/'.$configPath.'/*.yml')) && count($files)) {
|
||||
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && count($files)) {
|
||||
return 'yml';
|
||||
} elseif (($files = glob($dir.'/'.$configPath.'/*.php')) && count($files)) {
|
||||
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && count($files)) {
|
||||
return 'php';
|
||||
}
|
||||
|
||||
@ -306,4 +307,11 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getMappingResourceConfigDirectory();
|
||||
|
||||
/**
|
||||
* Extension used by the mapping files.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getMappingResourceExtension();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class ProxyCacheWarmer implements CacheWarmerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->container->getParameter('doctrine.orm.entity_managers') as $id) {
|
||||
foreach ($this->container->get('doctrine')->getEntityManagerNames() as $id) {
|
||||
$em = $this->container->get($id);
|
||||
$classes = $em->getMetadataFactory()->getAllMetadata();
|
||||
$em->getProxyFactory()->generateProxyClasses($classes);
|
||||
|
@ -45,14 +45,7 @@ abstract class DoctrineCommand extends Command
|
||||
|
||||
protected function getEntityManager($name)
|
||||
{
|
||||
$name = $name ?: $this->container->getParameter('doctrine.orm.default_entity_manager');
|
||||
|
||||
$ems = $this->container->getParameter('doctrine.orm.entity_managers');
|
||||
if (!isset($ems[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Could not find Doctrine EntityManager named "%s"', $name));
|
||||
}
|
||||
|
||||
return $this->container->get($ems[$name]);
|
||||
return $this->container->get('doctrine')->getEntityManager($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,14 +56,7 @@ abstract class DoctrineCommand extends Command
|
||||
*/
|
||||
protected function getDoctrineConnection($name)
|
||||
{
|
||||
$name = $name ?: $this->container->getParameter('doctrine.dbal.default_connection');
|
||||
|
||||
$connections = $this->container->getParameter('doctrine.dbal.connections');
|
||||
if (!isset($connections[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $name));
|
||||
}
|
||||
|
||||
return $this->container->get($connections[$name]);
|
||||
return $this->container->get('doctrine')->getConnection($name);
|
||||
}
|
||||
|
||||
protected function findMetadatasByNamespace($namespace)
|
||||
@ -99,7 +85,7 @@ abstract class DoctrineCommand extends Command
|
||||
protected function findAllMetadatas()
|
||||
{
|
||||
$metadatas = array();
|
||||
foreach ($this->container->getParameter('doctrine.orm.entity_managers') as $id) {
|
||||
foreach ($this->container->get('doctrine')->getEntityManagerNames() as $id) {
|
||||
$cmf = new DisconnectedClassMetadataFactory();
|
||||
$cmf->setEntityManager($this->container->get($id));
|
||||
foreach ($cmf->getAllMetadata() as $metadata) {
|
||||
@ -134,7 +120,7 @@ abstract class DoctrineCommand extends Command
|
||||
$pos = strpos($name, ':');
|
||||
$alias = substr($name, 0, $pos);
|
||||
|
||||
foreach ($this->container->getParameter('doctrine.orm.entity_managers') as $id) {
|
||||
foreach ($this->container->get('doctrine')->getEntityManagerNames() as $id) {
|
||||
$em = $this->container->get($id);
|
||||
|
||||
try {
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Tools\EntityRepositoryGenerator;
|
||||
|
||||
/**
|
||||
* Generate entity classes from mapping information
|
||||
@ -30,6 +31,7 @@ class GenerateEntitiesDoctrineCommand extends DoctrineCommand
|
||||
->setName('doctrine:generate:entities')
|
||||
->setDescription('Generate entity classes and method stubs from your mapping information')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'A bundle name, a namespace, or a class name')
|
||||
->addOption('path', null, InputOption::VALUE_REQUIRED, 'The path where to generate entities when it cannot be guessed')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:generate:entities</info> command generates entity classes
|
||||
and method stubs from your mapping information:
|
||||
@ -48,6 +50,13 @@ You have to limit generation of entities:
|
||||
* To a namespace
|
||||
|
||||
<info>./app/console doctrine:generate:entities MyCustomBundle/Entity</info>
|
||||
|
||||
If the entities are not stored in a bundle, and if the classes do not exist,
|
||||
the command has no way to guess where they should be generated. In this case,
|
||||
you must provide the <comment>--path</comment> option:
|
||||
|
||||
<info>./app/console doctrine:generate:entities Blog/Entity --path=src/</info>
|
||||
|
||||
EOT
|
||||
);
|
||||
}
|
||||
@ -58,7 +67,7 @@ EOT
|
||||
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name'));
|
||||
|
||||
$output->writeln(sprintf('Generating entities for bundle "<info>%s</info>"', $bundle->getName()));
|
||||
list($metadatas, $path) = $this->getBundleInfo($bundle);
|
||||
list($metadatas, $namespace, $path) = $this->getBundleInfo($bundle);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$name = strtr($input->getArgument('name'), '/', '\\');
|
||||
|
||||
@ -68,14 +77,15 @@ EOT
|
||||
|
||||
if (class_exists($name)) {
|
||||
$output->writeln(sprintf('Generating entity "<info>%s</info>"', $name));
|
||||
list($metadatas, $path) = $this->getClassInfo($name);
|
||||
list($metadatas, $namespace, $path) = $this->getClassInfo($name, $input->getOption('path'));
|
||||
} else {
|
||||
$output->writeln(sprintf('Generating entities for namespace "<info>%s</info>"', $name));
|
||||
list($metadatas, $path) = $this->getNamespaceInfo($name);
|
||||
list($metadatas, $namespace, $path) = $this->getNamespaceInfo($name, $input->getOption('path'));
|
||||
}
|
||||
}
|
||||
|
||||
$generator = $this->getEntityGenerator();
|
||||
$repoGenerator = new EntityRepositoryGenerator();
|
||||
foreach ($metadatas as $metadata) {
|
||||
$output->writeln(sprintf(' > generating <comment>%s</comment>', $metadata->name));
|
||||
$generator->generate(array($metadata), $path);
|
||||
@ -85,7 +95,7 @@ EOT
|
||||
continue;
|
||||
}
|
||||
|
||||
$generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $path);
|
||||
$repoGenerator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,37 +109,40 @@ EOT
|
||||
|
||||
$path = $this->findBasePathForClass($bundle->getName(), $bundle->getNamespace(), $bundle->getPath());
|
||||
|
||||
return array($metadatas, $path);
|
||||
return array($metadatas, $bundle->getNamespace(), $path);
|
||||
}
|
||||
|
||||
private function getClassInfo($class)
|
||||
private function getClassInfo($class, $path)
|
||||
{
|
||||
if (!$metadatas = $this->findMetadatasByClass($class)) {
|
||||
throw new \RuntimeException(sprintf('Entity "%s" is not a mapped entity.', $class));
|
||||
}
|
||||
|
||||
$r = $metadatas[$class]->getReflectionClass();
|
||||
if (!$r) {
|
||||
throw new \RuntimeException('Unable to determine where to save the "%s" class.', $class);
|
||||
if (class_exists($class)) {
|
||||
$r = $metadatas[$class]->getReflectionClass();
|
||||
$path = $this->findBasePathForClass($class, $r->getNamespacename(), dirname($r->getFilename()));
|
||||
} elseif (!$path) {
|
||||
throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $class));
|
||||
}
|
||||
$path = $this->findBasePathForClass($class, $r->getNamespacename(), dirname($r->getFilename()));
|
||||
|
||||
return array($metadatas, $path);
|
||||
return array($metadatas, $r->getNamespacename(), $path);
|
||||
}
|
||||
|
||||
private function getNamespaceInfo($namespace)
|
||||
private function getNamespaceInfo($namespace, $path)
|
||||
{
|
||||
if (!$metadatas = $this->findMetadatasByNamespace($namespace)) {
|
||||
throw new \RuntimeException(sprintf('Namespace "%s" does not contain any mapped entities.', $namespace));
|
||||
}
|
||||
|
||||
$first = reset($metadatas);
|
||||
$r = $first->getReflectionClass();
|
||||
if (!$r) {
|
||||
throw new \RuntimeException('Unable to determine where to save the "%s" class.', $class);
|
||||
$class = key($metadatas);
|
||||
if (class_exists($class)) {
|
||||
$r = $first->getReflectionClass();
|
||||
$path = $this->findBasePathForClass($namespace, $r->getNamespacename(), dirname($r->getFilename()));
|
||||
} elseif (!$path) {
|
||||
throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $class));
|
||||
}
|
||||
$path = $this->findBasePathForClass($namespace, $r->getNamespacename(), dirname($r->getFilename()));
|
||||
|
||||
return array($metadatas, $path);
|
||||
return array($metadatas, $namespace, $path);
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ EOT
|
||||
$mappingPath = $mappingCode = false;
|
||||
} else {
|
||||
$mappingType = 'yaml' == $mappingType ? 'yml' : $mappingType;
|
||||
$mappingPath = $bundle->getPath().'/Resources/config/doctrine/metadata/orm/'.str_replace('\\', '.', $fullEntityClassName).'.dcm.'.$mappingType;
|
||||
$mappingPath = $bundle->getPath().'/Resources/config/doctrine/'.str_replace('\\', '.', $fullEntityClassName).'.orm.'.$mappingType;
|
||||
$mappingCode = $exporter->exportClassMetadata($class);
|
||||
|
||||
$entityGenerator = $this->getEntityGenerator();
|
||||
|
@ -58,7 +58,7 @@ EOT
|
||||
if ('annotation' === $type) {
|
||||
$destPath .= '/Entity';
|
||||
} else {
|
||||
$destPath .= '/Resources/config/doctrine/metadata/orm';
|
||||
$destPath .= '/Resources/config/doctrine';
|
||||
}
|
||||
if ('yaml' === $type) {
|
||||
$type = 'yml';
|
||||
@ -89,9 +89,9 @@ EOT
|
||||
$className = $class->name;
|
||||
$class->name = $bundle->getNamespace().'\\Entity\\'.$className;
|
||||
if ('annotation' === $type) {
|
||||
$path = $destPath.'/'.$className.'.php';
|
||||
$path = $destPath.'/'.$className.'.orm.php';
|
||||
} else {
|
||||
$path = $destPath.'/'.str_replace('\\', '.', $class->name).'.dcm.'.$type;
|
||||
$path = $destPath.'/'.str_replace('\\', '.', $class->name).'.orm.'.$type;
|
||||
}
|
||||
$output->writeln(sprintf(' > writing <comment>%s</comment>', $path));
|
||||
$code = $exporter->exportClassMetadata($class);
|
||||
|
@ -46,7 +46,7 @@ EOT
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$entityManagerName = $input->getOption('em') ? $input->getOption('em') : $this->container->getParameter('doctrine.orm.default_entity_manager');
|
||||
$entityManagerName = $input->getOption('em') ? $input->getOption('em') : $this->container->get('doctrine')->getDefaultEntityManagerName();
|
||||
|
||||
/* @var $entityManager Doctrine\ORM\EntityManager */
|
||||
$entityManager = $this->getEntityManager($input->getOption('em'));
|
||||
@ -60,7 +60,7 @@ EOT
|
||||
'You do not have any mapped Doctrine ORM entities for any of your bundles. '.
|
||||
'Create a class inside the Entity namespace of any of your bundles and provide '.
|
||||
'mapping information for it with Annotations directly in the classes doc blocks '.
|
||||
'or with XML/YAML in your bundles Resources/config/doctrine/metadata/orm directory.'
|
||||
'or with XML/YAML in your bundles Resources/config/doctrine/ directory.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ abstract class DoctrineCommandHelper
|
||||
*/
|
||||
static public function setApplicationEntityManager(Application $application, $emName)
|
||||
{
|
||||
$em = self::getEntityManager($application, $emName);
|
||||
$em = $application->getKernel()->getContainer()->get('doctrine')->getEntityManager($emName);
|
||||
$helperSet = $application->getHelperSet();
|
||||
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
|
||||
$helperSet->set(new EntityManagerHelper($em), 'em');
|
||||
@ -38,42 +38,8 @@ abstract class DoctrineCommandHelper
|
||||
|
||||
static public function setApplicationConnection(Application $application, $connName)
|
||||
{
|
||||
$connection = self::getDoctrineConnection($application, $connName);
|
||||
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection($connName);
|
||||
$helperSet = $application->getHelperSet();
|
||||
$helperSet->set(new ConnectionHelper($connection), 'db');
|
||||
}
|
||||
|
||||
static protected function getEntityManager(Application $application, $name)
|
||||
{
|
||||
$container = $application->getKernel()->getContainer();
|
||||
|
||||
$name = $name ?: $container->getParameter('doctrine.orm.default_entity_manager');
|
||||
|
||||
$ems = $container->getParameter('doctrine.orm.entity_managers');
|
||||
if (!isset($ems[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Could not find Doctrine EntityManager named "%s"', $name));
|
||||
}
|
||||
|
||||
return $container->get($ems[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a doctrine dbal connection by symfony name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Doctrine\DBAL\Connection
|
||||
*/
|
||||
static protected function getDoctrineConnection(Application $application, $name)
|
||||
{
|
||||
$container = $application->getKernel()->getContainer();
|
||||
|
||||
$name = $name ?: $container->getParameter('doctrine.dbal.default_connection');
|
||||
|
||||
$connections = $container->getParameter('doctrine.dbal.connections');
|
||||
if (!isset($connections[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $name));
|
||||
}
|
||||
|
||||
return $container->get($connections[$name]);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\DataCollector\DataCollector;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Bundle\DoctrineBundle\Logger\DbalLogger;
|
||||
use Symfony\Bundle\DoctrineBundle\Registry;
|
||||
|
||||
/**
|
||||
* DoctrineDataCollector.
|
||||
@ -27,10 +28,10 @@ class DoctrineDataCollector extends DataCollector
|
||||
private $managers;
|
||||
private $logger;
|
||||
|
||||
public function __construct($connections, $managers, DbalLogger $logger = null)
|
||||
public function __construct(Registry $registry, DbalLogger $logger = null)
|
||||
{
|
||||
$this->connections = $connections;
|
||||
$this->managers = $managers;
|
||||
$this->connections = $registry->getConnectionNames();
|
||||
$this->managers = $registry->getEntityManagerNames();
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->connections = $container->getParameter('doctrine.dbal.connections');
|
||||
$this->connections = $container->getDefinition('doctrine')->getArgument(1);
|
||||
|
||||
foreach ($container->findTaggedServiceIds('doctrine.event_subscriber') as $subscriberId => $instances) {
|
||||
$this->registerSubscriber($subscriberId, $instances);
|
||||
|
@ -74,8 +74,8 @@ class Configuration implements ConfigurationInterface
|
||||
'path',
|
||||
'memory',
|
||||
'unix_socket',
|
||||
'wrapper_class', 'wrapper-class', 'wrapperClass',
|
||||
'platform_service', 'platform-service', 'platform-service',
|
||||
'wrapper_class',
|
||||
'platform_service',
|
||||
'charset',
|
||||
'logging'
|
||||
) as $key) {
|
||||
@ -128,22 +128,13 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('platform_service')->end()
|
||||
->scalarNode('charset')->end()
|
||||
->booleanNode('logging')->defaultValue($this->debug)->end()
|
||||
->end()
|
||||
->fixXmlConfig('driver_class', 'driverClass')
|
||||
->children()
|
||||
->scalarNode('driverClass')->end()
|
||||
->end()
|
||||
->fixXmlConfig('options', 'driverOptions')
|
||||
->children()
|
||||
->arrayNode('driverOptions')
|
||||
->scalarNode('driver_class')->end()
|
||||
->scalarNode('wrapper_class')->end()
|
||||
->arrayNode('options')
|
||||
->useAttributeAsKey('key')
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->fixXmlConfig('wrapper_class', 'wrapperClass')
|
||||
->children()
|
||||
->scalarNode('wrapperClass')->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
|
@ -64,10 +64,10 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
$keys = array_keys($config['connections']);
|
||||
$config['default_connection'] = reset($keys);
|
||||
}
|
||||
$this->defaultConnection = $config['default_connection'];
|
||||
|
||||
$container->setAlias('database_connection', sprintf('doctrine.dbal.%s_connection', $config['default_connection']));
|
||||
$container->setAlias('doctrine.dbal.event_manager', new Alias(sprintf('doctrine.dbal.%s_connection.event_manager', $config['default_connection']), false));
|
||||
$container->setParameter('doctrine.dbal.default_connection', $config['default_connection']);
|
||||
$container->setAlias('database_connection', sprintf('doctrine.dbal.%s_connection', $this->defaultConnection));
|
||||
$container->setAlias('doctrine.dbal.event_manager', new Alias(sprintf('doctrine.dbal.%s_connection.event_manager', $this->defaultConnection), false));
|
||||
|
||||
$container->getDefinition('doctrine.dbal.connection_factory')->replaceArgument(0, $config['types']);
|
||||
|
||||
@ -75,7 +75,8 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
foreach (array_keys($config['connections']) as $name) {
|
||||
$connections[$name] = sprintf('doctrine.dbal.%s_connection', $name);
|
||||
}
|
||||
$container->setParameter('doctrine.dbal.connections', $connections);
|
||||
$container->getDefinition('doctrine')->replaceArgument(1, $connections);
|
||||
$container->getDefinition('doctrine')->replaceArgument(3, $this->defaultConnection);
|
||||
|
||||
foreach ($config['connections'] as $name => $connection) {
|
||||
$this->loadDbalConnection($name, $connection, $container);
|
||||
@ -104,7 +105,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
// connection
|
||||
if (isset($connection['charset'])) {
|
||||
if ((isset($connection['driver']) && stripos($connection['driver'], 'mysql') !== false) ||
|
||||
(isset($connection['driverClass']) && stripos($connection['driverClass'], 'mysql') !== false)) {
|
||||
(isset($connection['driver_class']) && stripos($connection['driver_class'], 'mysql') !== false)) {
|
||||
$mysqlSessionInit = new Definition('%doctrine.dbal.events.mysql_session_init.class%');
|
||||
$mysqlSessionInit->setArguments(array($connection['charset']));
|
||||
$mysqlSessionInit->setPublic(false);
|
||||
@ -118,21 +119,41 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($connection['platform_service'])) {
|
||||
$connection['platform'] = new Reference($connection['platform_service']);
|
||||
unset($connection['platform_service']);
|
||||
}
|
||||
$options = $this->getConnectionOptions($connection);
|
||||
|
||||
$container
|
||||
->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new DefinitionDecorator('doctrine.dbal.connection'))
|
||||
->setArguments(array(
|
||||
$connection,
|
||||
$options,
|
||||
new Reference(sprintf('doctrine.dbal.%s_connection.configuration', $name)),
|
||||
new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name)),
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
protected function getConnectionOptions($connection)
|
||||
{
|
||||
$options = $connection;
|
||||
|
||||
if (isset($options['platform_service'])) {
|
||||
$options['platform'] = new Reference($options['platform_service']);
|
||||
unset($options['platform_service']);
|
||||
}
|
||||
|
||||
foreach (array(
|
||||
'options' => 'driverOptions',
|
||||
'driver_class' => 'driverClass',
|
||||
'wrapper_class' => 'wrapperClass',
|
||||
) as $old => $new) {
|
||||
if (isset($options[$old])) {
|
||||
$options[$new] = $options[$old];
|
||||
unset($options[$old]);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the Doctrine ORM configuration.
|
||||
*
|
||||
@ -148,18 +169,19 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('orm.xml');
|
||||
|
||||
$entityManagers = array();
|
||||
$this->entityManagers = array();
|
||||
foreach (array_keys($config['entity_managers']) as $name) {
|
||||
$entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name);
|
||||
$this->entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name);
|
||||
}
|
||||
$container->setParameter('doctrine.orm.entity_managers', $entityManagers);
|
||||
$container->getDefinition('doctrine')->replaceArgument(2, $this->entityManagers);
|
||||
|
||||
if (empty($config['default_entity_manager'])) {
|
||||
$tmp = array_keys($entityManagers);
|
||||
$tmp = array_keys($this->entityManagers);
|
||||
$config['default_entity_manager'] = reset($tmp);
|
||||
}
|
||||
$container->getDefinition('doctrine')->replaceArgument(4, $config['default_entity_manager']);
|
||||
|
||||
$options = array('default_entity_manager', 'auto_generate_proxy_classes', 'proxy_dir', 'proxy_namespace');
|
||||
$options = array('auto_generate_proxy_classes', 'proxy_dir', 'proxy_namespace');
|
||||
foreach ($options as $key) {
|
||||
$container->setParameter('doctrine.orm.'.$key, $config[$key]);
|
||||
}
|
||||
@ -180,7 +202,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
*/
|
||||
protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $container)
|
||||
{
|
||||
if ($entityManager['auto_mapping'] && count($container->getParameter('doctrine.orm.entity_managers')) > 1) {
|
||||
if ($entityManager['auto_mapping'] && count($this->entityManagers) > 1) {
|
||||
throw new \LogicException('You cannot enable "auto_mapping" when several entity managers are defined.');
|
||||
}
|
||||
|
||||
@ -219,22 +241,21 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
}
|
||||
}
|
||||
|
||||
$entityManagerService = sprintf('doctrine.orm.%s_entity_manager', $entityManager['name']);
|
||||
$connectionId = isset($entityManager['connection']) ? sprintf('doctrine.dbal.%s_connection', $entityManager['connection']) : 'database_connection';
|
||||
$eventManagerID = isset($entityManager['connection']) ? sprintf('doctrine.dbal.%s_connection.event_manager', $entityManager['connection']) : 'doctrine.dbal.event_manager';
|
||||
if (!isset($entityManager['connection'])) {
|
||||
$entityManager['connection'] = $this->defaultConnection;
|
||||
}
|
||||
|
||||
$ormEmArgs = array(
|
||||
new Reference($connectionId),
|
||||
new Reference(sprintf('doctrine.orm.%s_configuration', $entityManager['name']))
|
||||
);
|
||||
$ormEmDef = new Definition('%doctrine.orm.entity_manager.class%', $ormEmArgs);
|
||||
$ormEmDef->setFactoryClass('%doctrine.orm.entity_manager.class%');
|
||||
$ormEmDef->setFactoryMethod('create');
|
||||
$container->setDefinition($entityManagerService, $ormEmDef);
|
||||
$container
|
||||
->setDefinition(sprintf('doctrine.orm.%s_entity_manager', $entityManager['name']), new DefinitionDecorator('doctrine.orm.entity_manager.abstract'))
|
||||
->setArguments(array(
|
||||
new Reference(sprintf('doctrine.dbal.%s_connection', $entityManager['connection'])),
|
||||
new Reference(sprintf('doctrine.orm.%s_configuration', $entityManager['name']))
|
||||
))
|
||||
;
|
||||
|
||||
$container->setAlias(
|
||||
sprintf('doctrine.orm.%s_entity_manager.event_manager', $entityManager['name']),
|
||||
new Alias($eventManagerID, false)
|
||||
new Alias(sprintf('doctrine.dbal.%s_connection.event_manager', $entityManager['connection']), false)
|
||||
);
|
||||
}
|
||||
|
||||
@ -294,7 +315,12 @@ class DoctrineExtension extends AbstractDoctrineExtension
|
||||
|
||||
protected function getMappingResourceConfigDirectory()
|
||||
{
|
||||
return 'Resources/config/doctrine/metadata/orm';
|
||||
return 'Resources/config/doctrine';
|
||||
}
|
||||
|
||||
protected function getMappingResourceExtension()
|
||||
{
|
||||
return 'orm';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,63 @@
|
||||
<?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\DoctrineBundle\Mapping\Driver;
|
||||
|
||||
use Doctrine\ORM\Mapping\Driver\XmlDriver as BaseXmlDriver;
|
||||
|
||||
/**
|
||||
* XmlDriver that additionnaly looks for mapping information in a global file.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class XmlDriver extends BaseXmlDriver
|
||||
{
|
||||
protected $_globalFile = 'mapping';
|
||||
protected $_classCache;
|
||||
protected $_fileExtension = '.orm.xml';
|
||||
|
||||
public function isTransient($className)
|
||||
{
|
||||
return !in_array($className, $this->getAllClassNames());
|
||||
}
|
||||
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if (null === $this->_classCache) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
return array_merge(parent::getAllClassNames(), array_keys($this->_classCache));
|
||||
}
|
||||
|
||||
public function getElement($className)
|
||||
{
|
||||
if (null === $this->_classCache) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (!isset($this->_classCache[$className])) {
|
||||
$this->_classCache[$className] = parent::getElement($className);
|
||||
}
|
||||
|
||||
return $this->_classCache[$className];
|
||||
}
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
$this->_classCache = array();
|
||||
foreach ($this->_paths as $path) {
|
||||
if (file_exists($file = $path.'/'.$this->_globalFile.$this->_fileExtension)) {
|
||||
$this->_classCache = array_merge($this->_classCache, $this->_loadMappingFile($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?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\DoctrineBundle\Mapping\Driver;
|
||||
|
||||
use Doctrine\ORM\Mapping\Driver\YamlDriver as BaseYamlDriver;
|
||||
|
||||
/**
|
||||
* YamlDriver that additionnaly looks for mapping information in a global file.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class YamlDriver extends BaseYamlDriver
|
||||
{
|
||||
protected $_globalFile = 'mapping';
|
||||
protected $_classCache;
|
||||
protected $_fileExtension = '.orm.yml';
|
||||
|
||||
public function isTransient($className)
|
||||
{
|
||||
return !in_array($className, $this->getAllClassNames());
|
||||
}
|
||||
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if (null === $this->_classCache) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
return array_merge(parent::getAllClassNames(), array_keys($this->_classCache));
|
||||
}
|
||||
|
||||
public function getElement($className)
|
||||
{
|
||||
if (null === $this->_classCache) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (!isset($this->_classCache[$className])) {
|
||||
$this->_classCache[$className] = parent::getElement($className);
|
||||
}
|
||||
|
||||
return $this->_classCache[$className];
|
||||
}
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
$this->_classCache = array();
|
||||
foreach ($this->_paths as $path) {
|
||||
if (file_exists($file = $path.'/'.$this->_globalFile.$this->_fileExtension)) {
|
||||
$this->_classCache = array_merge($this->_classCache, $this->_loadMappingFile($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
150
src/Symfony/Bundle/DoctrineBundle/Registry.php
Normal file
150
src/Symfony/Bundle/DoctrineBundle/Registry.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?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\DoctrineBundle;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
/**
|
||||
* References all Doctrine connections and entity managers in a given Container.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Registry
|
||||
{
|
||||
private $container;
|
||||
private $connections;
|
||||
private $entityManagers;
|
||||
private $defaultConnection;
|
||||
private $defaultEntityManager;
|
||||
|
||||
public function __construct(ContainerInterface $container, array $connections, array $entityManagers, $defaultConnection, $defaultEntityManager)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->connections = $connections;
|
||||
$this->entityManagers = $entityManagers;
|
||||
$this->defaultConnection = $defaultConnection;
|
||||
$this->defaultEntityManager = $defaultEntityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default connection name.
|
||||
*
|
||||
* @return string The default connection name
|
||||
*/
|
||||
public function getDefaultConnectionName()
|
||||
{
|
||||
return $this->defaultConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the named connection.
|
||||
*
|
||||
* @param string $name The connection name (null for the default one)
|
||||
*
|
||||
* @return Connection
|
||||
*/
|
||||
public function getConnection($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
$name = $this->defaultConnection;
|
||||
}
|
||||
|
||||
if (!isset($this->connections[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Doctrine Connection named "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
return $this->container->get($this->connections[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all connection names.
|
||||
*
|
||||
* @return array An array of connection names
|
||||
*/
|
||||
public function getConnectionNames()
|
||||
{
|
||||
return $this->connections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default entity manager name.
|
||||
*
|
||||
* @return string The default entity manager name
|
||||
*/
|
||||
public function getDefaultEntityManagerName()
|
||||
{
|
||||
return $this->defaultEntityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a named entity manager.
|
||||
*
|
||||
* @param string $name The entity manager name (null for the default one)
|
||||
*
|
||||
* @return EntityManager
|
||||
*/
|
||||
public function getEntityManager($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
$name = $this->defaultEntityManager;
|
||||
}
|
||||
|
||||
if (!isset($this->entityManagers[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Doctrine EntityManager named "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
return $this->container->get($this->entityManagers[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets a named entity manager.
|
||||
*
|
||||
* This method is useful when an entity manager has been closed
|
||||
* because of a rollbacked transaction AND when you think that
|
||||
* it makes sense to get a new one to replace the closed one.
|
||||
*
|
||||
* Be warned that you will get a brand new entity manager as
|
||||
* the existing one is not useable anymore. This means that any
|
||||
* other object with a dependency on this entity manager will
|
||||
* hold an obsolete reference. You can inject the registry instead
|
||||
* to avoid this problem.
|
||||
*
|
||||
* @param string $name The entity manager name (null for the default one)
|
||||
*
|
||||
* @return EntityManager
|
||||
*/
|
||||
public function resetEntityManager($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
$name = $this->defaultEntityManager;
|
||||
}
|
||||
|
||||
if (!isset($this->entityManagers[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Doctrine EntityManager named "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
// force the creation of a new entity manager
|
||||
// if the current one is closed
|
||||
$this->container->set($this->entityManagers[$name], null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all connection names.
|
||||
*
|
||||
* @return array An array of connection names
|
||||
*/
|
||||
public function getEntityManagerNames()
|
||||
{
|
||||
return $this->entityManagers;
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
<parameter key="doctrine.dbal.connection_factory.class">Symfony\Bundle\DoctrineBundle\ConnectionFactory</parameter>
|
||||
<parameter key="doctrine.dbal.events.mysql_session_init.class">Doctrine\DBAL\Event\Listeners\MysqlSessionInit</parameter>
|
||||
<parameter key="doctrine.dbal.events.oracle_session_init.class">Doctrine\DBAL\Event\Listeners\OracleSessionInit</parameter>
|
||||
<parameter key="doctrine.class">Symfony\Bundle\DoctrineBundle\Registry</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
@ -26,8 +27,7 @@
|
||||
|
||||
<service id="data_collector.doctrine" class="%doctrine.data_collector.class%" public="false">
|
||||
<tag name="data_collector" template="DoctrineBundle:Collector:db" id="db" />
|
||||
<argument>%doctrine.dbal.connections%</argument>
|
||||
<argument>%doctrine.orm.entity_managers%</argument>
|
||||
<argument type="service" id="doctrine" />
|
||||
<argument type="service" id="doctrine.dbal.logger" />
|
||||
</service>
|
||||
|
||||
@ -40,5 +40,13 @@
|
||||
<service id="doctrine.dbal.connection.event_manager" class="%doctrine.dbal.connection.event_manager.class%" public="false" abstract="true" />
|
||||
|
||||
<service id="doctrine.dbal.connection.configuration" class="%doctrine.dbal.configuration.class%" public="false" abstract="true" />
|
||||
|
||||
<service id="doctrine" class="%doctrine.class%">
|
||||
<argument type="service" id="service_container" />
|
||||
<argument type="collection" /> <!-- connections -->
|
||||
<argument type="collection" /> <!-- entity managers -->
|
||||
<argument /> <!-- default connection name -->
|
||||
<argument /> <!-- default entity manager name -->
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -21,8 +21,8 @@
|
||||
<parameter key="doctrine.orm.metadata.driver_chain.class">Doctrine\ORM\Mapping\Driver\DriverChain</parameter>
|
||||
<parameter key="doctrine.orm.metadata.annotation.class">Doctrine\ORM\Mapping\Driver\AnnotationDriver</parameter>
|
||||
<parameter key="doctrine.orm.metadata.annotation_reader.class">Annotations\DoctrineReader</parameter>
|
||||
<parameter key="doctrine.orm.metadata.xml.class">Doctrine\ORM\Mapping\Driver\XmlDriver</parameter>
|
||||
<parameter key="doctrine.orm.metadata.yml.class">Doctrine\ORM\Mapping\Driver\YamlDriver</parameter>
|
||||
<parameter key="doctrine.orm.metadata.xml.class">Symfony\Bundle\DoctrineBundle\Mapping\Driver\XmlDriver</parameter>
|
||||
<parameter key="doctrine.orm.metadata.yml.class">Symfony\Bundle\DoctrineBundle\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>
|
||||
|
||||
@ -55,5 +55,7 @@
|
||||
</service>
|
||||
|
||||
<service id="doctrine.orm.configuration" class="%doctrine.orm.configuration.class%" abstract="true" public="false" />
|
||||
|
||||
<service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" factory-class="%doctrine.orm.entity_manager.class%" factory-method="create" abstract="true" />
|
||||
</services>
|
||||
</container>
|
||||
|
@ -29,6 +29,11 @@ class ProxyCacheWarmerTest extends \Symfony\Bundle\DoctrineBundle\Tests\TestCase
|
||||
__DIR__ . "/../DependencyInjection/Fixtures/Bundles/AnnotationsBundle/Entity")
|
||||
);
|
||||
|
||||
$registry = $this->getMockBuilder('Symfony\Bundle\DoctrineBundle\Registry')->disableOriginalConstructor()->getMock();
|
||||
$registry->expects($this->at(0))
|
||||
->method('getEntityManagerNames')
|
||||
->will($this->returnValue(array('default' => 'doctrine.orm.default_entity_manager', 'foo' => 'doctrine.orm.foo_entity_manager')));
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\Container');
|
||||
$container->expects($this->at(0))
|
||||
->method('getParameter')
|
||||
@ -39,9 +44,9 @@ class ProxyCacheWarmerTest extends \Symfony\Bundle\DoctrineBundle\Tests\TestCase
|
||||
->with($this->equalTo('doctrine.orm.auto_generate_proxy_classes'))
|
||||
->will($this->returnValue(false));
|
||||
$container->expects($this->at(2))
|
||||
->method('getParameter')
|
||||
->with($this->equalTo('doctrine.orm.entity_managers'))
|
||||
->will($this->returnValue(array('default' => 'doctrine.orm.default_entity_manager', 'foo' => 'doctrine.orm.foo_entity_manager')));
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine'))
|
||||
->will($this->returnValue($registry));
|
||||
$container->expects($this->at(3))
|
||||
->method('get')
|
||||
->with($this->equalTo('doctrine.orm.default_entity_manager'))
|
||||
|
@ -33,7 +33,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$loader->load(array(array(), array('dbal' => array('default_connection' => 'foo')), array()), $container);
|
||||
|
||||
// doctrine.dbal.default_connection
|
||||
$this->assertEquals('foo', $container->getParameter('doctrine.dbal.default_connection'), '->load() overrides existing configuration options');
|
||||
$this->assertEquals('foo', $container->getDefinition('doctrine')->getArgument(3), '->load() overrides existing configuration options');
|
||||
}
|
||||
|
||||
public function testDbalLoad()
|
||||
@ -119,8 +119,8 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$this->assertEquals('Doctrine\Common\Cache\XcacheCache', $container->getParameter('doctrine.orm.cache.xcache.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\DriverChain', $container->getParameter('doctrine.orm.metadata.driver_chain.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.orm.metadata.annotation.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.orm.metadata.xml.class'));
|
||||
$this->assertEquals('Doctrine\ORM\Mapping\Driver\YamlDriver', $container->getParameter('doctrine.orm.metadata.yml.class'));
|
||||
$this->assertEquals('Symfony\Bundle\DoctrineBundle\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.orm.metadata.xml.class'));
|
||||
$this->assertEquals('Symfony\Bundle\DoctrineBundle\Mapping\Driver\YamlDriver', $container->getParameter('doctrine.orm.metadata.yml.class'));
|
||||
|
||||
$class = new \ReflectionClass($container->getParameter('doctrine.orm.metadata.annotation_reader.class'));
|
||||
$this->assertTrue($class->getName() === 'Doctrine\Common\Annotations\AnnotationReader' || $class->isSubClassOf('Doctrine\Common\Annotations\AnnotationReader'));
|
||||
@ -155,11 +155,11 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass());
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertEquals(array('default' => 'doctrine.orm.default_entity_manager'), $container->getParameter('doctrine.orm.entity_managers'), "Set of the existing EntityManagers names is incorrect.");
|
||||
$this->assertEquals(array('default' => 'doctrine.orm.default_entity_manager'), $container->getDefinition('doctrine')->getArgument(2), "Set of the existing EntityManagers names is incorrect.");
|
||||
|
||||
$arguments = $definition->getArguments();
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]);
|
||||
$this->assertEquals('database_connection', (string) $arguments[0]);
|
||||
$this->assertEquals('doctrine.dbal.default_connection', (string) $arguments[0]);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[1]);
|
||||
$this->assertEquals('doctrine.orm.default_configuration', (string) $arguments[1]);
|
||||
|
||||
@ -197,7 +197,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
new Reference('database_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
));
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$this->assertEquals('create', $definition->getFactoryMethod());
|
||||
|
||||
$this->assertDICConstructorArguments($definition, array(
|
||||
new Reference('database_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration')
|
||||
));
|
||||
}
|
||||
|
||||
@ -347,7 +347,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array())))))), $container);
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setEntityNamespaces',
|
||||
@ -360,7 +362,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array('alias' => 'yml'))))))), $container);
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array('alias' => 'yml')))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_configuration');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'setEntityNamespaces',
|
||||
@ -373,7 +377,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer('YamlBundle');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array())))))), $container);
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('YamlBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', array(
|
||||
@ -387,7 +393,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer('XmlBundle');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('XmlBundle' => array())))))), $container);
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('XmlBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', array(
|
||||
@ -401,7 +409,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer('AnnotationsBundle');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('AnnotationsBundle' => array())))))), $container);
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('AnnotationsBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', array(
|
||||
@ -415,18 +425,21 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer(array('XmlBundle', 'AnnotationsBundle'));
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array(
|
||||
$config1 = $this->getConnectionConfig();
|
||||
$config1['orm'] = array(
|
||||
'auto_generate_proxy_classes' => true,
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array(
|
||||
'default' => array('mappings' => array('AnnotationsBundle' => array()))
|
||||
))),
|
||||
array('orm' => array(
|
||||
'auto_generate_proxy_classes' => false,
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array(
|
||||
'default' => array('mappings' => array('XmlBundle' => array()))
|
||||
)))), $container);
|
||||
));
|
||||
$config2 = $this->getConnectionConfig();
|
||||
$config2['orm'] = array(
|
||||
'auto_generate_proxy_classes' => false,
|
||||
'default_entity_manager' => 'default',
|
||||
'entity_managers' => array(
|
||||
'default' => array('mappings' => array('XmlBundle' => array()))
|
||||
));
|
||||
$loader->load(array($config1, $config2), $container);
|
||||
|
||||
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
|
||||
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', array(
|
||||
@ -543,12 +556,12 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
|
||||
$ymlDef = $container->getDefinition('doctrine.orm.default_yml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($ymlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'YamlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.'metadata')
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'YamlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine')
|
||||
));
|
||||
|
||||
$xmlDef = $container->getDefinition('doctrine.orm.default_xml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($xmlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'XmlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.'metadata')
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'XmlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine')
|
||||
));
|
||||
}
|
||||
|
||||
@ -563,7 +576,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
|
||||
$this->compileContainer($container);
|
||||
|
||||
$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.");
|
||||
$this->assertEquals(array('em1' => 'doctrine.orm.em1_entity_manager', 'em2' => 'doctrine.orm.em2_entity_manager'), $container->getDefinition('doctrine')->getArgument(2), "Set of the existing EntityManagers names is incorrect.");
|
||||
|
||||
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
|
||||
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
|
||||
@ -591,12 +604,12 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
|
||||
$ymlDef = $container->getDefinition('doctrine.orm.em2_yml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($ymlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'YamlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.'metadata')
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'YamlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine')
|
||||
));
|
||||
|
||||
$xmlDef = $container->getDefinition('doctrine.orm.em2_xml_metadata_driver');
|
||||
$this->assertDICConstructorArguments($xmlDef, array(
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'XmlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine'.DIRECTORY_SEPARATOR.'metadata')
|
||||
array(__DIR__ .DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'Bundles'.DIRECTORY_SEPARATOR.'XmlBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'doctrine')
|
||||
));
|
||||
}
|
||||
|
||||
@ -605,7 +618,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container = $this->getContainer('AnnotationsBundle', 'Vendor');
|
||||
$loader = new DoctrineExtension();
|
||||
|
||||
$loader->load(array(array('orm' => array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('AnnotationsBundle' => array())))))), $container);
|
||||
$config = $this->getConnectionConfig();
|
||||
$config['orm'] = array('default_entity_manager' => 'default', 'entity_managers' => array('default' => array('mappings' => array('AnnotationsBundle' => array()))));
|
||||
$loader->load(array($config), $container);
|
||||
|
||||
$calls = $container->getDefinition('doctrine.orm.default_metadata_driver')->getMethodCalls();
|
||||
$this->assertEquals('doctrine.orm.default_annotation_metadata_driver', (string) $calls[0][1][0]);
|
||||
@ -737,4 +752,9 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
protected function getConnectionConfig()
|
||||
{
|
||||
return array('dbal' => array('connections' => array('default' => array('password' => 'foo'))));
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,10 @@
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal />
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<mapping name="YamlBundle" />
|
||||
|
@ -7,7 +7,10 @@
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal />
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<hydrator name="test_hydrator">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator</hydrator>
|
||||
|
@ -7,6 +7,10 @@
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm
|
||||
auto-generate-proxy-classes="false"
|
||||
default-entity-manager="default"
|
||||
|
@ -7,14 +7,18 @@
|
||||
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<connection name="default" dbname="db" />
|
||||
</dbal>
|
||||
|
||||
<orm default-entity-manager="em2">
|
||||
<entity-manager name="em1">
|
||||
<mapping name="AnnotationsBundle" />
|
||||
</entity-manager>
|
||||
<entity-manager name="em2">
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine/metadata" alias="yml" />
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
|
||||
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
|
||||
dir="%kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata"
|
||||
dir="%kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
|
||||
alias="TestAlias"
|
||||
/>
|
||||
</entity-manager>
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
<orm>
|
||||
<mapping name="AnnotationsBundle" />
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine/metadata" alias="yml" />
|
||||
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
|
||||
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
|
||||
dir="%kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata"
|
||||
dir="%kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
|
||||
alias="TestAlias"
|
||||
/>
|
||||
</orm>
|
||||
|
@ -1,5 +1,10 @@
|
||||
doctrine:
|
||||
dbal: ~
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
entity_managers:
|
||||
default:
|
||||
|
@ -1,5 +1,10 @@
|
||||
doctrine:
|
||||
dbal: ~
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
entity_managers:
|
||||
default:
|
||||
|
@ -1,4 +1,10 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: false
|
||||
default_entity_manager: default
|
||||
|
@ -1,4 +1,10 @@
|
||||
doctrine:
|
||||
dbal:
|
||||
default_connection: default
|
||||
connections:
|
||||
default:
|
||||
dbname: db
|
||||
|
||||
orm:
|
||||
default_entity_manager: em2
|
||||
entity_managers:
|
||||
@ -8,10 +14,10 @@ doctrine:
|
||||
em2:
|
||||
mappings:
|
||||
YamlBundle:
|
||||
dir: Resources/config/doctrine/metadata
|
||||
dir: Resources/config/doctrine
|
||||
alias: yml
|
||||
manual:
|
||||
type: xml
|
||||
prefix: Fixtures\Bundles\XmlBundle
|
||||
dir: %kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata
|
||||
dir: %kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine
|
||||
alias: TestAlias
|
||||
|
@ -9,10 +9,10 @@ doctrine:
|
||||
mappings:
|
||||
AnnotationsBundle: ~
|
||||
YamlBundle:
|
||||
dir: Resources/config/doctrine/metadata
|
||||
dir: Resources/config/doctrine
|
||||
alias: yml
|
||||
manual:
|
||||
type: xml
|
||||
prefix: Fixtures\Bundles\XmlBundle
|
||||
dir: %kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine/metadata
|
||||
dir: %kernel.root_dir%/../src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine
|
||||
alias: TestAlias
|
||||
|
@ -83,7 +83,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||
'default' => array(
|
||||
'mappings' => array('YamlBundle' => array(
|
||||
'type' => 'yml',
|
||||
'dir' => __DIR__ . "/DependencyInjection/Fixtures/Bundles/YamlBundle/Resources/config/doctrine/metadata/orm",
|
||||
'dir' => __DIR__ . "/DependencyInjection/Fixtures/Bundles/YamlBundle/Resources/config/doctrine",
|
||||
'prefix' => 'Fixtures\Bundles\YamlBundle',
|
||||
)
|
||||
)
|
||||
|
@ -40,7 +40,6 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('cache_warmer')->defaultValue(!$this->debug)->end()
|
||||
->scalarNode('charset')->end()
|
||||
->scalarNode('secret')->isRequired()->end()
|
||||
->scalarNode('error_handler')->end()
|
||||
->scalarNode('exception_controller')->defaultValue('Symfony\\Bundle\\FrameworkBundle\\Controller\\ExceptionController::showAction')->end()
|
||||
->scalarNode('ide')->defaultNull()->end()
|
||||
->booleanNode('test')->end()
|
||||
|
@ -69,17 +69,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$container->setParameter('kernel.secret', $config['secret']);
|
||||
|
||||
if (isset($config['error_handler'])) {
|
||||
if (false === $config['error_handler']) {
|
||||
$container->getDefinition('error_handler')->setMethodCalls(array());
|
||||
} else {
|
||||
$container
|
||||
->getDefinition('error_handler')->addMethodCall('register', array())
|
||||
->replaceArgument(0, $config['error_handler'])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$container->getDefinition('exception_listener')->replaceArgument(0, $config['exception_controller']);
|
||||
|
||||
if (!empty($config['test'])) {
|
||||
|
@ -34,16 +34,6 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
*/
|
||||
class FrameworkBundle extends Bundle
|
||||
{
|
||||
/**
|
||||
* Boots the Bundle.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if ($this->container->has('error_handler')) {
|
||||
$this->container->get('error_handler');
|
||||
}
|
||||
}
|
||||
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
@ -7,7 +7,6 @@
|
||||
<parameters>
|
||||
<parameter key="event_dispatcher.class">Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher</parameter>
|
||||
<parameter key="http_kernel.class">Symfony\Bundle\FrameworkBundle\HttpKernel</parameter>
|
||||
<parameter key="error_handler.class">Symfony\Component\HttpKernel\Debug\ErrorHandler</parameter>
|
||||
<parameter key="filesystem.class">Symfony\Component\HttpKernel\Util\Filesystem</parameter>
|
||||
<parameter key="cache_warmer.class">Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate</parameter>
|
||||
<parameter key="file_locator.class">Symfony\Component\HttpKernel\Config\FileLocator</parameter>
|
||||
@ -18,10 +17,6 @@
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
|
||||
<service id="error_handler" class="%error_handler.class%">
|
||||
<argument /> <!-- level (null by default) -->
|
||||
</service>
|
||||
|
||||
<service id="http_kernel" class="%http_kernel.class%">
|
||||
<argument type="service" id="event_dispatcher" />
|
||||
<argument type="service" id="service_container" />
|
||||
|
@ -91,16 +91,16 @@ build: 56
|
||||
margin-left:20px;
|
||||
}
|
||||
|
||||
/* fix for Opera not liking empty <li> */
|
||||
.sf-exceptionreset .traces li:after {
|
||||
content: '\00A0'
|
||||
}
|
||||
|
||||
.sf-exceptionreset #logs .traces em
|
||||
.sf-exceptionreset #logs .traces li.error
|
||||
{
|
||||
font-style:normal;
|
||||
color:#AA3333;
|
||||
font-weight: bold;
|
||||
background:#f9ecec;
|
||||
}
|
||||
|
||||
/* fix for Opera not liking empty <li> */
|
||||
.sf-exceptionreset .traces li:after {
|
||||
content: '\00A0'
|
||||
}
|
||||
|
||||
.sf-exceptionreset .trace
|
||||
|
@ -0,0 +1,131 @@
|
||||
<?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>This value should be false</source>
|
||||
<target>Værdien skal være falsk</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2">
|
||||
<source>This value should be true</source>
|
||||
<target>Værdien skal være sand</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3">
|
||||
<source>This value should be of type {{ type }}</source>
|
||||
<target>Værdien skal være af typen {{ type }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4">
|
||||
<source>This value should be blank</source>
|
||||
<target>Værdien skal være blank</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5">
|
||||
<source>This value should be one of the given choices</source>
|
||||
<target>Værdien skal være en af de givne muligheder</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6">
|
||||
<source>You should select at least {{ limit }} choices</source>
|
||||
<target>Du skal vælge mindst {{ limit }} muligheder</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7">
|
||||
<source>You should select at most {{ limit }} choices</source>
|
||||
<target>Du kan højest vælge {{ limit }} muligheder</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8">
|
||||
<source>The fields {{ fields }} were not expected</source>
|
||||
<target>Felterne {{ fields }} var ikke forventet</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9">
|
||||
<source>The fields {{ fields }} are missing</source>
|
||||
<target>Felterne {{ fields }} mangler</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="10">
|
||||
<source>This value is not a valid date</source>
|
||||
<target>Værdien er ikke en gyldig dato</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="11">
|
||||
<source>This value is not a valid datetime</source>
|
||||
<target>Værdien er ikke en gyldig dato og tid</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="12">
|
||||
<source>This value is not a valid email address</source>
|
||||
<target>Værdien er ikke en gyldig e-mail adresse</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="13">
|
||||
<source>The file could not be found</source>
|
||||
<target>Filen kunne ikke findes</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="14">
|
||||
<source>The file is not readable</source>
|
||||
<target>Filen kan ikke læses</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="15">
|
||||
<source>The file is too large ({{ size }}). Allowed maximum size is {{ limit }}</source>
|
||||
<target>Filen er for stor ({{ size }}). Tilladte maksimale størrelse {{ limit }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="16">
|
||||
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}</source>
|
||||
<target>Mimetypen af filen er ugyldig ({{ type }}). Tilladte mimetyper er {{ types }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="17">
|
||||
<source>This value should be {{ limit }} or less</source>
|
||||
<target>Værdien skal være {{ limit }} eller mindre</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="18">
|
||||
<source>This value is too long. It should have {{ limit }} characters or less</source>
|
||||
<target>Værdien er for lang. Den skal have {{ limit }} bogstaver eller mindre</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="19">
|
||||
<source>This value should be {{ limit }} or more</source>
|
||||
<target>Værdien skal være {{ limit }} eller mere</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="20">
|
||||
<source>This value is too short. It should have {{ limit }} characters or more</source>
|
||||
<target>Værdien er for kort. Den skal have {{ limit }} tegn eller flere</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="21">
|
||||
<source>This value should not be blank</source>
|
||||
<target>Værdien må ikke være blank</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="22">
|
||||
<source>This value should not be null</source>
|
||||
<target>Værdien må ikke være tom (null)</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="23">
|
||||
<source>This value should be null</source>
|
||||
<target>Værdien skal være tom (null)</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="24">
|
||||
<source>This value is not valid</source>
|
||||
<target>Værdien er ikke gyldig</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="25">
|
||||
<source>This value is not a valid time</source>
|
||||
<target>Værdien er ikke en gyldig tid</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="26">
|
||||
<source>This value is not a valid URL</source>
|
||||
<target>Værdien er ikke en gyldig URL</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="27">
|
||||
<source>This value should be instance of class {{ class }}</source>
|
||||
<target>Værdien skal være instans af klassen {{ class }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="28">
|
||||
<source>This field group should not contain extra fields</source>
|
||||
<target>Feltgruppen må ikke indeholde ekstra felter</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="29">
|
||||
<source>The uploaded file was too large. Please try to upload a smaller file</source>
|
||||
<target>Den oploadede fil var for stor. Opload venligst en mindre fil</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="30">
|
||||
<source>The CSRF token is invalid</source>
|
||||
<target>CSRF nøglen er ugyldig</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="31">
|
||||
<source>The two values should be equal</source>
|
||||
<target>De to værdier skal være ens</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
@ -0,0 +1,131 @@
|
||||
<?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>This value should be false</source>
|
||||
<target>Väärtus peaks olema väär</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2">
|
||||
<source>This value should be true</source>
|
||||
<target>Väärtus peaks oleme tõene</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3">
|
||||
<source>This value should be of type {{ type }}</source>
|
||||
<target>Väärtus peaks olema {{ type }}-tüüpi</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4">
|
||||
<source>This value should be blank</source>
|
||||
<target>Väärtus peaks olema tühi</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5">
|
||||
<source>This value should be one of the given choices</source>
|
||||
<target>Väärtus peaks olema üks etteantud valikutest</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6">
|
||||
<source>You should select at least {{ limit }} choices</source>
|
||||
<target>Valima peaks vähemalt {{ limit }} valikut</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7">
|
||||
<source>You should select at most {{ limit }} choices</source>
|
||||
<target>Valima peaks mitte rohkem kui {{ limit }} valikut</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8">
|
||||
<source>The fields {{ fields }} were not expected</source>
|
||||
<target>Väljad {{ fields }} olid ootamatud</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9">
|
||||
<source>The fields {{ fields }} are missing</source>
|
||||
<target>Väljad {{ fields }} on puudu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="10">
|
||||
<source>This value is not a valid date</source>
|
||||
<target>Väärtus pole korrektne kuupäev</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="11">
|
||||
<source>This value is not a valid datetime</source>
|
||||
<target>Väärtus pole korrektne kuupäev ja kellaeg</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="12">
|
||||
<source>This value is not a valid email address</source>
|
||||
<target>Väärtus pole korrektne e-maili aadress</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="13">
|
||||
<source>The file could not be found</source>
|
||||
<target>Faili ei leita</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="14">
|
||||
<source>The file is not readable</source>
|
||||
<target>Fail ei ole loetav</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="15">
|
||||
<source>The file is too large ({{ size }}). Allowed maximum size is {{ limit }}</source>
|
||||
<target>Fail on liiga suur ({{ size }}). Suurim lubatud suurus on {{ limit }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="16">
|
||||
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}</source>
|
||||
<target>Faili sisutüüp on vigane ({{ type }}). Lubatud sisutüübid on {{ types }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="17">
|
||||
<source>This value should be {{ limit }} or less</source>
|
||||
<target>Väärtus peaks olema {{ limit }} või vähem</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="18">
|
||||
<source>This value is too long. It should have {{ limit }} characters or less</source>
|
||||
<target>Väärtus on liiga pikk. Pikkus peaks olema {{ limit }} tähemärki või vähem</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="19">
|
||||
<source>This value should be {{ limit }} or more</source>
|
||||
<target>Väärtus peaks olema {{ limit }} või rohkem</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="20">
|
||||
<source>This value is too short. It should have {{ limit }} characters or more</source>
|
||||
<target>Väärtus on liiga lühike. Pikkus peaks olema {{ limit }} tähemärki või rohkem</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="21">
|
||||
<source>This value should not be blank</source>
|
||||
<target>Väärtus ei tohiks olla tühi</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="22">
|
||||
<source>This value should not be null</source>
|
||||
<target>Väärtus ei tohiks olla 'null'</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="23">
|
||||
<source>This value should be null</source>
|
||||
<target>Väärtus peaks olema 'null'</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="24">
|
||||
<source>This value is not valid</source>
|
||||
<target>Väärtus on vigane</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="25">
|
||||
<source>This value is not a valid time</source>
|
||||
<target>Väärtus pole korrektne aeg</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="26">
|
||||
<source>This value is not a valid URL</source>
|
||||
<target>Väärtus pole korrektne URL</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="27">
|
||||
<source>This value should be instance of class {{ class }}</source>
|
||||
<target>Väärtus peaks olema klassi {{ class }} isend</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="28">
|
||||
<source>This field group should not contain extra fields</source>
|
||||
<target>Väljade grupp ei tohiks sisalda lisaväljasid</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="29">
|
||||
<source>The uploaded file was too large. Please try to upload a smaller file</source>
|
||||
<target>Üleslaaditud fail oli liiga suur. Palun proovi uuesti väiksema failiga</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="30">
|
||||
<source>The CSRF token is invalid. Please try to resubmit the form</source>
|
||||
<target>CSRF-märgis on vigane. Palun proovi vormi uuesti esitada</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="31">
|
||||
<source>The two values should be equal</source>
|
||||
<target>Väärtused peaksid olema võrdsed</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
@ -4,23 +4,23 @@
|
||||
<body>
|
||||
<trans-unit id="1">
|
||||
<source>This value should be false</source>
|
||||
<target>Deze waarde zou niet waar moeten zijn</target>
|
||||
<target>Deze waarde mag niet waar zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2">
|
||||
<source>This value should be true</source>
|
||||
<target>Deze waarde zou waar moeten zijn</target>
|
||||
<target>Deze waarde moet waar zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3">
|
||||
<source>This value should be of type {{ type }}</source>
|
||||
<target>Deze waarde zou van het type {{ type }} moeten zijn</target>
|
||||
<target>Deze waarde moet van het type {{ type }} zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4">
|
||||
<source>This value should be blank</source>
|
||||
<target>Deze waarde zou leeg moeten zijn</target>
|
||||
<target>Deze waarde moet leeg zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5">
|
||||
<source>This value should be one of the given choices</source>
|
||||
<target>Deze waarde zou een van de gegeven opties moeten zijn</target>
|
||||
<target>Deze waarde moet een van de gegeven opties zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6">
|
||||
<source>You should select at least {{ limit }} choices</source>
|
||||
@ -56,11 +56,11 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="14">
|
||||
<source>The file is not readable</source>
|
||||
<target>Het bestand niet leesbaar</target>
|
||||
<target>Het bestand is niet leesbaar</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="15">
|
||||
<source>The file is too large ({{ size }}). Allowed maximum size is {{ limit }}</source>
|
||||
<target>Het bestand is te groot({{ size }}). Toegestane maximum grootte is {{ limit }}</target>
|
||||
<target>Het bestand is te groot ({{ size }}). Toegestane maximum grootte is {{ limit }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="16">
|
||||
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}</source>
|
||||
@ -68,19 +68,19 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="17">
|
||||
<source>This value should be {{ limit }} or less</source>
|
||||
<target>Deze waarde zou {{ limit }} of minder moeten zijn</target>
|
||||
<target>Deze waarde moet {{ limit }} of minder zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="18">
|
||||
<source>This value is too long. It should have {{ limit }} characters or less</source>
|
||||
<target>Deze waarde is te lang. Het zou {{ limit }} karakters of minder moeten hebben</target>
|
||||
<target>Deze waarde is te lang. Hij mag maximaal {{ limit }} tekens bevatten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="19">
|
||||
<source>This value should be {{ limit }} or more</source>
|
||||
<target>Deze waarde zou {{ limit }} of meer moeten zijn</target>
|
||||
<target>Deze waarde moet {{ limit }} of meer zijn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="20">
|
||||
<source>This value is too short. It should have {{ limit }} characters or more</source>
|
||||
<target>Deze waarde is te kort. Het zou {{ limit }} karakters of meer moeten hebben</target>
|
||||
<target>Deze waarde is te kort. Hij moet tenminste {{ limit }} tekens bevatten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="21">
|
||||
<source>This value should not be blank</source>
|
||||
@ -112,7 +112,7 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="28">
|
||||
<source>This field group should not contain extra fields</source>
|
||||
<target>Deze veld groep mag geen extra velden bevatten</target>
|
||||
<target>Deze veldgroep mag geen extra velden bevatten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="29">
|
||||
<source>The uploaded file was too large. Please try to upload a smaller file</source>
|
||||
@ -120,7 +120,7 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="30">
|
||||
<source>The CSRF token is invalid</source>
|
||||
<target>Het CSRF token is ongeldig</target>
|
||||
<target>De CSRF-token is ongeldig</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="31">
|
||||
<source>The two values should be equal</source>
|
||||
|
@ -0,0 +1,131 @@
|
||||
<?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>This value should be false</source>
|
||||
<target>Este valor deveria ser falso</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2">
|
||||
<source>This value should be true</source>
|
||||
<target>Este valor deveria ser verdadeiro</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3">
|
||||
<source>This value should be of type {{ type }}</source>
|
||||
<target>Este valor deveria ser do tipo {{ type }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4">
|
||||
<source>This value should be blank</source>
|
||||
<target>Este valor deveria ser vazio</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5">
|
||||
<source>This value should be one of the given choices</source>
|
||||
<target>Este valor deveria ser um das opções exibidas</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6">
|
||||
<source>You should select at least {{ limit }} choices</source>
|
||||
<target>Você deveria selecionar {{ limit }} opções no mínimo</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7">
|
||||
<source>You should select at most {{ limit }} choices</source>
|
||||
<target>Você deveria selecionar {{ limit }} opções no máximo</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8">
|
||||
<source>The fields {{ fields }} were not expected</source>
|
||||
<target>Os campos {{ fields }} não eram esperados</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9">
|
||||
<source>The fields {{ fields }} are missing</source>
|
||||
<target>Os campos {{ fields }} estão ausentes</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="10">
|
||||
<source>This value is not a valid date</source>
|
||||
<target>Este valor não é uma data válida</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="11">
|
||||
<source>This value is not a valid datetime</source>
|
||||
<target>Este valor não é uma data e hora válida</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="12">
|
||||
<source>This value is not a valid email address</source>
|
||||
<target>Este valor não é um endereço de e-mail válido</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="13">
|
||||
<source>The file could not be found</source>
|
||||
<target>O arquivo não pode ser encontrado</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="14">
|
||||
<source>The file is not readable</source>
|
||||
<target>O arquivo não pode ser lido</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="15">
|
||||
<source>The file is too large ({{ size }}). Allowed maximum size is {{ limit }}</source>
|
||||
<target>O arquivo é muito grande ({{ size }}). O tamanho máximo permitido é {{ limit }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="16">
|
||||
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}</source>
|
||||
<target>O tipo mime do arquivo é inválido ({{ type }}). Os tipos mime permitidos são {{ types }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="17">
|
||||
<source>This value should be {{ limit }} or less</source>
|
||||
<target>Este valor deveria ser {{ limit }} ou menos</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="18">
|
||||
<source>This value is too long. It should have {{ limit }} characters or less</source>
|
||||
<target>O valor é muito longo. Deveria ter {{ limit }} caracteres ou menos</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="19">
|
||||
<source>This value should be {{ limit }} or more</source>
|
||||
<target>Este valor deveria ser {{ limit }} ou mais</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="20">
|
||||
<source>This value is too short. It should have {{ limit }} characters or more</source>
|
||||
<target>O valor é muito curto. Deveria ter {{ limit }} caracteres ou mais</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="21">
|
||||
<source>This value should not be blank</source>
|
||||
<target>Este valor não deveria ser vazio</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="22">
|
||||
<source>This value should not be null</source>
|
||||
<target>Este valor não deveria ser nulo</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="23">
|
||||
<source>This value should be null</source>
|
||||
<target>Este valor deveria ser nulo</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="24">
|
||||
<source>This value is not valid</source>
|
||||
<target>Este valor não é válido</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="25">
|
||||
<source>This value is not a valid time</source>
|
||||
<target>Este valor não é uma hora válida</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="26">
|
||||
<source>This value is not a valid URL</source>
|
||||
<target>Este valor não é um URL válido</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="27">
|
||||
<source>This value should be instance of class {{ class }}</source>
|
||||
<target>Este valor deveria ser uma instância da classe {{ class }}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="28">
|
||||
<source>This field group should not contain extra fields</source>
|
||||
<target>Este grupo de campos não deveria conter campos adicionais</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="29">
|
||||
<source>The uploaded file was too large. Please try to upload a smaller file</source>
|
||||
<target>O arquivo enviado é muito grande. Por favor, tente enviar um mais pequeno</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="30">
|
||||
<source>The CSRF token is invalid</source>
|
||||
<target>O token CSRF é inválido</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="31">
|
||||
<source>The two values should be equal</source>
|
||||
<target>Os dois valores deveriam ser iguais</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
@ -1,12 +1,6 @@
|
||||
<ol class="traces">
|
||||
{% for log in logs %}
|
||||
<li>
|
||||
{% if log.priorityName in ['EMERG', 'ERR', 'CRIT', 'ALERT', 'ERROR', 'CRITICAL'] %}
|
||||
<em>{{ log.priorityName }}</em>
|
||||
{% else %}
|
||||
{{ log.priorityName }}
|
||||
{% endif %}
|
||||
|
||||
<li{% if log.priorityName in ['EMERG', 'ERR', 'CRIT', 'ALERT', 'ERROR', 'CRITICAL'] %} class="error"{% endif %}>
|
||||
{{ log.message }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php if (!$form->hasParent() || !$form->getParent()->hasParent()): ?>
|
||||
<input type="hidden"
|
||||
<?php echo $view['form']->attributes() ?>
|
||||
name="<?php echo $view->escape($name) ?>"
|
||||
value="<?php echo $view->escape($value) ?>"
|
||||
<?php if ($read_only): ?>disabled="disabled"<?php endif ?>
|
||||
/>
|
||||
<?php endif ?>
|
@ -8,4 +8,5 @@
|
||||
|
||||
<?php echo $view['form']->widget($form['token']) ?>
|
||||
<?php echo $view['form']->widget($form['name']) ?>
|
||||
<?php echo $view['form']->widget($form['originalName']) ?>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php echo str_replace('{{ widget }}',
|
||||
$view['form']->render('FrameworkBundle:Form:number_widget.html.php'),
|
||||
$view['form']->render($form, 'FrameworkBundle:Form:number_widget.html.php'),
|
||||
$money_pattern
|
||||
) ?>
|
||||
|
@ -1 +1 @@
|
||||
<?php echo $view['form']->render('FrameworkBundle:Form:number_widget.html.php') ?> %
|
||||
<?php echo $view['form']->render($form, 'FrameworkBundle:Form:number_widget.html.php') ?> %
|
||||
|
@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset={{ _charset }}"/>
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>{% block title '' %}</title>
|
||||
<link href="{{ asset('bundles/framework/css/exception_layout.css') }}" rel="stylesheet" type="text/css" media="all" />
|
||||
<link href="{{ asset('bundles/framework/css/exception.css') }}" rel="stylesheet" type="text/css" media="all" />
|
||||
|
@ -28,11 +28,14 @@ class FormHelper extends Helper
|
||||
|
||||
protected $engine;
|
||||
|
||||
protected $varStack = array();
|
||||
protected $varStack;
|
||||
|
||||
protected $viewStack = array();
|
||||
|
||||
public function __construct(EngineInterface $engine)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->varStack = new \SplObjectStorage();
|
||||
}
|
||||
|
||||
public function attributes()
|
||||
@ -40,8 +43,9 @@ class FormHelper extends Helper
|
||||
$html = '';
|
||||
$attr = array();
|
||||
|
||||
if (count($this->varStack) > 0) {
|
||||
$vars = end($this->varStack);
|
||||
if (count($this->viewStack) > 0) {
|
||||
$view = end($this->viewStack);
|
||||
$vars = $this->varStack[$view];
|
||||
|
||||
if (isset($vars['attr'])) {
|
||||
$attr = $vars['attr'];
|
||||
@ -101,9 +105,8 @@ class FormHelper extends Helper
|
||||
{
|
||||
$template = null;
|
||||
$blocks = $view->get('types');
|
||||
if ('widget' === $section || 'row' === $section) {
|
||||
array_unshift($blocks, '_'.$view->get('id'));
|
||||
}
|
||||
array_unshift($blocks, '_'.$view->get('id'));
|
||||
|
||||
foreach ($blocks as &$block) {
|
||||
$block = $block.'_'.$section;
|
||||
$template = $this->lookupTemplate($block);
|
||||
@ -121,19 +124,22 @@ class FormHelper extends Helper
|
||||
$view->setRendered();
|
||||
}
|
||||
|
||||
return $this->render($template, array_merge($view->all(), $variables));
|
||||
return $this->render($view, $template, $variables);
|
||||
}
|
||||
|
||||
public function render($template, array $variables = array())
|
||||
public function render(FormView $view, $template, array $variables = array())
|
||||
{
|
||||
array_push($this->varStack, array_merge(
|
||||
count($this->varStack) > 0 ? end($this->varStack) : array(),
|
||||
$this->varStack[$view] = array_replace(
|
||||
$view->all(),
|
||||
isset($this->varStack[$view]) ? $this->varStack[$view] : array(),
|
||||
$variables
|
||||
));
|
||||
);
|
||||
|
||||
$html = $this->engine->render($template, end($this->varStack));
|
||||
array_push($this->viewStack, $view);
|
||||
|
||||
array_pop($this->varStack);
|
||||
$html = $this->engine->render($template, $this->varStack[$view]);
|
||||
|
||||
array_pop($this->viewStack);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -18,9 +18,12 @@ class StubTemplateNameParser implements TemplateNameParserInterface
|
||||
{
|
||||
private $root;
|
||||
|
||||
public function __construct($root)
|
||||
private $rootCustom;
|
||||
|
||||
public function __construct($root, $rootCustom)
|
||||
{
|
||||
$this->root = $root;
|
||||
$this->rootCustom = $rootCustom;
|
||||
}
|
||||
|
||||
public function parse($name)
|
||||
@ -28,6 +31,8 @@ class StubTemplateNameParser implements TemplateNameParserInterface
|
||||
$parts = explode(':', $name);
|
||||
$name = $parts[count($parts)-1];
|
||||
|
||||
return new TemplateReference($this->root.'/'.$name, 'php');
|
||||
$path = ($name{0} === '_' ? $this->rootCustom : $this->root).'/'.$name;
|
||||
|
||||
return new TemplateReference($path, 'php');
|
||||
}
|
||||
}
|
@ -33,7 +33,8 @@ class FormHelperTest extends AbstractDivLayoutTest
|
||||
parent::setUp();
|
||||
|
||||
$root = realpath(__DIR__.'/../../../Resources/views/Form');
|
||||
$templateNameParser = new StubTemplateNameParser($root);
|
||||
$rootCustom = realpath(__DIR__.'/Resources');
|
||||
$templateNameParser = new StubTemplateNameParser($root, $rootCustom);
|
||||
$loader = new FilesystemLoader(array());
|
||||
$engine = new PhpEngine($templateNameParser, $loader);
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
<div id="container">
|
||||
<?php echo $view['form']->render($form, 'FrameworkBundle:Form:text_widget.html.php') ?>
|
||||
</div>
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\MonologBundle\Logger;
|
||||
use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* FirePHPHandler.
|
||||
@ -32,6 +33,22 @@ class FirePHPHandler extends BaseFirePHPHandler
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* Adds the headers to the response once it's created
|
||||
*/
|
||||
public function onCoreResponse(FilterResponseEvent $event)
|
||||
{
|
||||
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->response = $event->getResponse();
|
||||
foreach ($this->headers as $header => $content) {
|
||||
$this->response->headers->set($header, $content);
|
||||
}
|
||||
$this->headers = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -43,16 +60,4 @@ class FirePHPHandler extends BaseFirePHPHandler
|
||||
$this->headers[$header] = $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the headers to the response once it's created
|
||||
*/
|
||||
public function onCoreResponse(FilterResponseEvent $event)
|
||||
{
|
||||
$this->response = $event->getResponse();
|
||||
foreach ($this->headers as $header => $content) {
|
||||
$this->response->headers->set($header, $content);
|
||||
}
|
||||
$this->headers = array();
|
||||
}
|
||||
}
|
||||
|
@ -74,13 +74,6 @@
|
||||
{{ block('field_widget') }}
|
||||
{% endblock hidden_widget %}
|
||||
|
||||
{% block csrf_widget %}
|
||||
{% if not form.hasParent or not form.getParent.hasParent %}
|
||||
{% set type = type|default('hidden') %}
|
||||
{{ block('field_widget') }}
|
||||
{% endif %}
|
||||
{% endblock csrf_widget %}
|
||||
|
||||
{% block hidden_row %}
|
||||
{{ form_widget(form) }}
|
||||
{% endblock hidden_row %}
|
||||
@ -221,6 +214,7 @@
|
||||
{{ form_widget(form.file) }}
|
||||
{{ form_widget(form.token) }}
|
||||
{{ form_widget(form.name) }}
|
||||
{{ form_widget(form.originalName) }}
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
{% endblock file_widget %}
|
||||
|
@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>{% block title 'Profiler' %}</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{{ asset('bundles/webprofiler/favicon.ico') }}" />
|
||||
{% block head %}
|
||||
|
@ -285,7 +285,7 @@ abstract class Client
|
||||
$process = new PhpProcess($this->getScript($request));
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
|
||||
throw new \RuntimeException($process->getErrorOutput());
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class Cookie
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($name, $value, $expires = null, $path = '/', $domain = '', $secure = false, $httponly = false)
|
||||
public function __construct($name, $value, $expires = null, $path = '/', $domain = '', $secure = false, $httponly = true)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
|
@ -0,0 +1,62 @@
|
||||
<?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\ClassLoader;
|
||||
|
||||
/**
|
||||
* Checks that the class is actually declared in the included file.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class DebugUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
/**
|
||||
* Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
|
||||
*/
|
||||
static public function enable()
|
||||
{
|
||||
if (!is_array($functions = spl_autoload_functions())) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
spl_autoload_unregister($function);
|
||||
}
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
|
||||
$loader = new static();
|
||||
$loader->registerNamespaceFallback($function[0]->getNamespaceFallback());
|
||||
$loader->registerPrefixFallback($function[0]->getPrefixFallback());
|
||||
$loader->registerNamespaces($function[0]->getNamespaces());
|
||||
$loader->registerPrefixes($function[0]->getPrefixes());
|
||||
|
||||
$function[0] = $loader;
|
||||
}
|
||||
|
||||
spl_autoload_register($function);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
require $file;
|
||||
|
||||
if (!class_exists($class, false) && !interface_exists($class, false)) {
|
||||
throw new \Exception(sprintf('The autoloader expected class "%s" to be defined in file "%s". You probably have a typo in the namespace or the class name.', $class, $file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Config\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\Exception\DuplicateKeyException;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
|
||||
@ -193,8 +195,11 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
foreach ($this->children as $name => $child) {
|
||||
if (!array_key_exists($name, $value)) {
|
||||
if ($child->isRequired()) {
|
||||
$msg = sprintf('The node at path "%s.%s" must be configured.', $this->getPath(), $name);
|
||||
throw new InvalidConfigurationException($msg);
|
||||
$msg = sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath());
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
if ($child->hasDefaultValue()) {
|
||||
@ -223,11 +228,14 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_array($value) && (!$this->allowFalse || false !== $value)) {
|
||||
throw new InvalidTypeException(sprintf(
|
||||
$ex = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected array, but got %s',
|
||||
$this->getPath(),
|
||||
gettype($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,7 +264,10 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
// if extra fields are present, throw exception
|
||||
if (count($value) && !$this->ignoreExtraKeys) {
|
||||
$msg = sprintf('Unrecognized options "%s" under "%s"', implode(', ', array_keys($value)), $this->getPath());
|
||||
throw new InvalidConfigurationException($msg);
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath().'.'.reset($value));
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
@ -309,13 +320,16 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
// no conflict
|
||||
if (!array_key_exists($k, $leftSide)) {
|
||||
if (!$this->allowNewKeys) {
|
||||
throw new InvalidConfigurationException(sprintf(
|
||||
$ex = new InvalidConfigurationException(sprintf(
|
||||
'You are not allowed to define new elements for path "%s". '
|
||||
.'Please define all elements for this path in one config file. '
|
||||
.'If you are trying to overwrite an element, make sure you redefine it '
|
||||
.'with the same name.',
|
||||
$this->getPath()
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$leftSide[$k] = $v;
|
||||
|
@ -26,11 +26,14 @@ class BooleanNode extends ScalarNode
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_bool($value)) {
|
||||
throw new InvalidTypeException(sprintf(
|
||||
$ex = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected boolean, but got %s.',
|
||||
$this->getPath(),
|
||||
gettype($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,4 +19,15 @@ namespace Symfony\Component\Config\Definition\Exception;
|
||||
*/
|
||||
class InvalidConfigurationException extends Exception
|
||||
{
|
||||
private $path;
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
@ -161,7 +161,10 @@ class PrototypedArrayNode extends ArrayNode
|
||||
|
||||
if (count($value) < $this->minNumberOfElements) {
|
||||
$msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements);
|
||||
throw new InvalidConfigurationException($msg);
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
@ -186,7 +189,10 @@ class PrototypedArrayNode extends ArrayNode
|
||||
if (null !== $this->keyAttribute && is_array($v)) {
|
||||
if (!isset($v[$this->keyAttribute]) && is_int($k)) {
|
||||
$msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath());
|
||||
throw new InvalidConfigurationException($msg);
|
||||
$ex = new InvalidConfigurationException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
} else if (isset($v[$this->keyAttribute])) {
|
||||
$k = $v[$this->keyAttribute];
|
||||
|
||||
@ -203,7 +209,10 @@ class PrototypedArrayNode extends ArrayNode
|
||||
|
||||
if (array_key_exists($k, $normalized)) {
|
||||
$msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath());
|
||||
throw new DuplicateKeyException($msg);
|
||||
$ex = new DuplicateKeyException($msg);
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,11 +258,14 @@ class PrototypedArrayNode extends ArrayNode
|
||||
// no conflict
|
||||
if (!array_key_exists($k, $leftSide)) {
|
||||
if (!$this->allowNewKeys) {
|
||||
throw new InvalidConfigurationException(sprintf(
|
||||
$ex = new InvalidConfigurationException(sprintf(
|
||||
'You are not allowed to define new elements for path "%s". ' .
|
||||
'Please define all elements for this path in one config file.',
|
||||
$this->getPath()
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$leftSide[$k] = $v;
|
||||
|
@ -34,11 +34,14 @@ class ScalarNode extends VariableNode
|
||||
protected function validateType($value)
|
||||
{
|
||||
if (!is_scalar($value) && null !== $value) {
|
||||
throw new InvalidTypeException(sprintf(
|
||||
$ex = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected scalar, but got %s.',
|
||||
$this->getPath(),
|
||||
gettype($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
@ -84,11 +84,14 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface
|
||||
protected function finalizeValue($value)
|
||||
{
|
||||
if (!$this->allowEmptyValue && empty($value)) {
|
||||
throw new InvalidConfigurationException(sprintf(
|
||||
$ex = new InvalidConfigurationException(sprintf(
|
||||
'The path "%s" cannot contain an empty value, but got %s.',
|
||||
$this->getPath(),
|
||||
json_encode($value)
|
||||
));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -698,6 +698,20 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
}
|
||||
}
|
||||
|
||||
$properties = $this->resolveServices($this->getParameterBag()->resolveValue($definition->getProperties()));
|
||||
$outsideClass = new \ReflectionClass($service);
|
||||
foreach ($properties as $name => $value) {
|
||||
$class = $outsideClass;
|
||||
do {
|
||||
if ($class->hasProperty($name)) {
|
||||
$property = $class->getProperty($name);
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($service, $value);
|
||||
continue 2;
|
||||
}
|
||||
} while (false !== $class = $class->getParentClass());
|
||||
}
|
||||
|
||||
if ($callable = $definition->getConfigurator()) {
|
||||
if (is_array($callable) && is_object($callable[0]) && $callable[0] instanceof Reference) {
|
||||
$callable[0] = $this->get((string) $callable[0]);
|
||||
|
@ -49,9 +49,8 @@ class SortableIterator extends \ArrayIterator
|
||||
throw new \InvalidArgumentException(sprintf('The SortableIterator takes a \Closure or a valid built-in sort algorithm as an argument (%s given).', $sort));
|
||||
}
|
||||
|
||||
$array = new \ArrayObject(iterator_to_array($iterator));
|
||||
$array->uasort($sort);
|
||||
parent::__construct(iterator_to_array($iterator));
|
||||
|
||||
parent::__construct($array);
|
||||
$this->uasort($sort);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\Type;
|
||||
use Symfony\Component\Form\AbstractExtension;
|
||||
use Symfony\Component\Validator\ValidatorInterface;
|
||||
use Symfony\Component\HttpFoundation\File\TemporaryStorage;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
class ArrayToBooleanChoicesTransformer implements DataTransformerInterface
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\Util\FormUtil;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
class ArrayToChoicesTransformer implements DataTransformerInterface
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,6 @@ class FileToArrayTransformer implements DataTransformerInterface
|
||||
if (null === $file || '' === $file) {
|
||||
return array(
|
||||
'file' => '',
|
||||
'token' => '',
|
||||
'name' => '',
|
||||
);
|
||||
}
|
||||
|
||||
@ -37,8 +35,6 @@ class FileToArrayTransformer implements DataTransformerInterface
|
||||
|
||||
return array(
|
||||
'file' => $file,
|
||||
'token' => '',
|
||||
'name' => '',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
class ScalarToBooleanChoicesTransformer implements DataTransformerInterface
|
||||
|
@ -12,9 +12,9 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\EventListener;
|
||||
|
||||
use Symfony\Component\Form\Events;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Event\FilterDataEvent;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\File\TemporaryStorage;
|
||||
|
||||
@ -40,15 +40,22 @@ class FixFileUploadListener implements EventSubscriberInterface
|
||||
public function onBindClientData(FilterDataEvent $event)
|
||||
{
|
||||
$form = $event->getForm();
|
||||
$data = $event->getData();
|
||||
|
||||
// TODO should be disableable
|
||||
if (null === $data) {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
// TESTME
|
||||
$data = array_merge(array(
|
||||
if (!is_array($data)) {
|
||||
throw new UnexpectedTypeException($data, 'array');
|
||||
}
|
||||
|
||||
$data = array_replace(array(
|
||||
'file' => '',
|
||||
'token' => '',
|
||||
'name' => '',
|
||||
), $event->getData());
|
||||
'originalName' => '',
|
||||
), $data);
|
||||
|
||||
// Newly uploaded file
|
||||
if ($data['file'] instanceof UploadedFile && $data['file']->isValid()) {
|
||||
@ -56,14 +63,15 @@ class FixFileUploadListener implements EventSubscriberInterface
|
||||
$directory = $this->storage->getTempDir($data['token']);
|
||||
$data['file']->move($directory);
|
||||
$data['name'] = $data['file']->getName();
|
||||
$data['originalName'] = $data['file']->getOriginalName();
|
||||
}
|
||||
|
||||
// Existing uploaded file
|
||||
if (!$data['file'] && $data['token'] && $data['name']) {
|
||||
$path = $this->storage->getTempDir($data['token']) . DIRECTORY_SEPARATOR . $data ['name'];
|
||||
$path = $this->storage->getTempDir($data['token']) . DIRECTORY_SEPARATOR . $data['name'];
|
||||
|
||||
if (file_exists($path)) {
|
||||
$data['file'] = new File($path);
|
||||
$data['file'] = new UploadedFile($path, $data['originalName'], null, null, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,14 @@ class ResizeFormListener implements EventSubscriberInterface
|
||||
/**
|
||||
* @var Boolean
|
||||
*/
|
||||
private $resizeOnBind;
|
||||
private $allowAdd;
|
||||
|
||||
public function __construct(FormFactoryInterface $factory, $type, $resizeOnBind = false)
|
||||
public function __construct(FormFactoryInterface $factory, $type, $allowAdd = false, $allowDelete = false)
|
||||
{
|
||||
$this->factory = $factory;
|
||||
$this->type = $type;
|
||||
$this->resizeOnBind = $resizeOnBind;
|
||||
$this->allowAdd = $allowAdd;
|
||||
$this->allowDelete = $allowDelete;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
@ -71,7 +72,7 @@ class ResizeFormListener implements EventSubscriberInterface
|
||||
|
||||
// First remove all rows except for the prototype row
|
||||
foreach ($form as $name => $child) {
|
||||
if (!($this->resizeOnBind && '$$name$$' === $name)) {
|
||||
if (!($this->allowAdd && '$$name$$' === $name)) {
|
||||
$form->remove($name);
|
||||
}
|
||||
}
|
||||
@ -86,10 +87,6 @@ class ResizeFormListener implements EventSubscriberInterface
|
||||
|
||||
public function preBind(DataEvent $event)
|
||||
{
|
||||
if (!$this->resizeOnBind) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form = $event->getForm();
|
||||
$data = $event->getData();
|
||||
|
||||
@ -102,28 +99,28 @@ class ResizeFormListener implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
// Remove all empty rows except for the prototype row
|
||||
foreach ($form as $name => $child) {
|
||||
if (!isset($data[$name]) && '$$name$$' !== $name) {
|
||||
$form->remove($name);
|
||||
if ($this->allowDelete) {
|
||||
foreach ($form as $name => $child) {
|
||||
if (!isset($data[$name]) && '$$name$$' !== $name) {
|
||||
$form->remove($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add all additional rows
|
||||
foreach ($data as $name => $value) {
|
||||
if (!$form->has($name)) {
|
||||
$form->add($this->factory->createNamed($this->type, $name, null, array(
|
||||
'property_path' => '['.$name.']',
|
||||
)));
|
||||
if ($this->allowAdd) {
|
||||
foreach ($data as $name => $value) {
|
||||
if (!$form->has($name)) {
|
||||
$form->add($this->factory->createNamed($this->type, $name, null, array(
|
||||
'property_path' => '['.$name.']',
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onBindNormData(FilterDataEvent $event)
|
||||
{
|
||||
if (!$this->resizeOnBind) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form = $event->getForm();
|
||||
$data = $event->getData();
|
||||
|
||||
@ -135,9 +132,11 @@ class ResizeFormListener implements EventSubscriberInterface
|
||||
throw new UnexpectedTypeException($data, 'array or \Traversable');
|
||||
}
|
||||
|
||||
foreach ($data as $name => $child) {
|
||||
if (!$form->has($name)) {
|
||||
unset($data[$name]);
|
||||
if ($this->allowDelete) {
|
||||
foreach ($data as $name => $child) {
|
||||
if (!$form->has($name)) {
|
||||
unset($data[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
|
||||
class BirthdayType extends AbstractType
|
||||
{
|
||||
|
@ -13,13 +13,15 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
|
||||
|
||||
class CollectionType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
if ($options['modifiable'] && $options['prototype']) {
|
||||
if ($options['allow_add'] && $options['prototype']) {
|
||||
$builder->add('$$name$$', $options['type'], array(
|
||||
'property_path' => false,
|
||||
'required' => false,
|
||||
@ -27,15 +29,24 @@ class CollectionType extends AbstractType
|
||||
}
|
||||
|
||||
$listener = new ResizeFormListener($builder->getFormFactory(),
|
||||
$options['type'], $options['modifiable']);
|
||||
$options['type'], $options['allow_add'], $options['allow_delete']);
|
||||
|
||||
$builder->addEventSubscriber($listener);
|
||||
$builder->addEventSubscriber($listener)
|
||||
->setAttribute('allow_add', $options['allow_add'])
|
||||
->setAttribute('allow_delete', $options['allow_delete']);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form)
|
||||
{
|
||||
$view->set('allow_add', $form->getAttribute('allow_add'));
|
||||
$view->set('allow_delete', $form->getAttribute('allow_delete'));
|
||||
}
|
||||
|
||||
public function getDefaultOptions(array $options)
|
||||
{
|
||||
return array(
|
||||
'modifiable' => false,
|
||||
'allow_add' => false,
|
||||
'allow_delete' => false,
|
||||
'prototype' => true,
|
||||
'type' => 'text',
|
||||
);
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Locale\Locale;
|
||||
|
||||
class CountryType extends AbstractType
|
||||
|
@ -12,8 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
|
||||
class EmailType extends AbstractType
|
||||
{
|
||||
|
@ -20,7 +20,6 @@ use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
|
||||
use Symfony\Component\Form\Extension\Core\Validator\DefaultValidator;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\Validator\ValidatorInterface;
|
||||
|
||||
class FieldType extends AbstractType
|
||||
{
|
||||
|
@ -14,9 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\Extension\Core\EventListener\FixFileUploadListener;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain;
|
||||
use Symfony\Component\Form\ReversedTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\FileToStringTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\FileToArrayTransformer;
|
||||
@ -45,7 +43,8 @@ class FileType extends AbstractType
|
||||
->addEventSubscriber(new FixFileUploadListener($this->storage), 10)
|
||||
->add('file', 'field')
|
||||
->add('token', 'hidden')
|
||||
->add('name', 'hidden');
|
||||
->add('name', 'hidden')
|
||||
->add('originalName', 'hidden');
|
||||
}
|
||||
|
||||
public function buildViewBottomUp(FormView $view, FormInterface $form)
|
||||
|
@ -15,9 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
class FormType extends AbstractType
|
||||
{
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
|
||||
class HiddenType extends AbstractType
|
||||
{
|
||||
|
@ -12,9 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
|
||||
class TextType extends AbstractType
|
||||
{
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
|
||||
class TextareaType extends AbstractType
|
||||
{
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\Extension\Core\ChoiceList\TimezoneChoiceList;
|
||||
|
||||
class TimezoneType extends AbstractType
|
||||
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Form\Extension\Csrf\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
|
||||
class FormTypeCsrfExtension extends AbstractTypeExtension
|
||||
{
|
||||
@ -34,7 +36,19 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
||||
$csrfOptions['csrf_provider'] = $options['csrf_provider'];
|
||||
}
|
||||
|
||||
$builder->add($options['csrf_field_name'], 'csrf', $csrfOptions);
|
||||
$builder->add($options['csrf_field_name'], 'csrf', $csrfOptions)
|
||||
->setAttribute('csrf_field_name', $options['csrf_field_name']);
|
||||
}
|
||||
}
|
||||
|
||||
public function buildViewBottomUp(FormView $view, FormInterface $form)
|
||||
{
|
||||
if ($view->hasParent() && $form->hasAttribute('csrf_field_name')) {
|
||||
$name = $form->getAttribute('csrf_field_name');
|
||||
|
||||
if (isset($view[$name])) {
|
||||
unset($view[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,16 +14,10 @@ namespace Symfony\Component\Form;
|
||||
use Symfony\Component\Form\Event\DataEvent;
|
||||
use Symfony\Component\Form\Event\FilterDataEvent;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\MissingOptionsException;
|
||||
use Symfony\Component\Form\Exception\AlreadyBoundException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Exception\DanglingFieldException;
|
||||
use Symfony\Component\Form\Exception\FieldDefinitionException;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\FileBag;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* Form represents a form.
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Guess\Guess;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
|
@ -50,6 +50,8 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
|
||||
|
||||
function getData();
|
||||
|
||||
function getNormData();
|
||||
|
||||
function getClientData();
|
||||
|
||||
function isBound();
|
||||
|
@ -147,7 +147,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
|
||||
public function offsetUnset($name)
|
||||
{
|
||||
throw new \BadMethodCallException('Not supported');
|
||||
unset($this->children[$name]);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
|
@ -26,7 +26,7 @@ class Cookie
|
||||
protected $secure;
|
||||
protected $httpOnly;
|
||||
|
||||
public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = false)
|
||||
public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
|
||||
{
|
||||
// from PHP source code
|
||||
if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
|
||||
|
@ -71,7 +71,8 @@ class UploadedFile extends File
|
||||
* @throws FileException If file_uploads is disabled
|
||||
* @throws FileNotFoundException If the file does not exist
|
||||
*/
|
||||
public function __construct($path, $originalName, $mimeType, $size, $error, $moved = false)
|
||||
public function __construct($path, $originalName, $mimeType = null,
|
||||
$size = null, $error = null, $moved = false)
|
||||
{
|
||||
if (!ini_get('file_uploads')) {
|
||||
throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path')));
|
||||
|
@ -413,7 +413,7 @@ class Request
|
||||
|
||||
public function getPort()
|
||||
{
|
||||
return $this->server->get('SERVER_PORT');
|
||||
return $this->headers->get('X-Forwarded-Port') ?: $this->server->get('SERVER_PORT');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,8 +501,8 @@ class Request
|
||||
$parts[] = $segment;
|
||||
$order[] = $segment;
|
||||
} else {
|
||||
$tmp = explode('=', urldecode($segment), 2);
|
||||
$parts[] = urlencode($tmp[0]).'='.urlencode($tmp[1]);
|
||||
$tmp = explode('=', rawurldecode($segment), 2);
|
||||
$parts[] = rawurlencode($tmp[0]).'='.rawurlencode($tmp[1]);
|
||||
$order[] = $tmp[0];
|
||||
}
|
||||
}
|
||||
|
@ -31,18 +31,25 @@ class ErrorHandler
|
||||
private $level;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Register the error handler.
|
||||
*
|
||||
* @param integer $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable)
|
||||
*
|
||||
* @return The registered error handler
|
||||
*/
|
||||
public function __construct($level = null)
|
||||
static public function register($level = null)
|
||||
{
|
||||
$this->level = null === $level ? error_reporting() : $level;
|
||||
$handler = new static();
|
||||
$handler->setLevel($level);
|
||||
|
||||
set_error_handler(array($handler, 'handle'));
|
||||
|
||||
return $handler;
|
||||
}
|
||||
|
||||
public function register()
|
||||
public function setLevel($level)
|
||||
{
|
||||
set_error_handler(array($this, 'handle'));
|
||||
$this->level = null === $level ? error_reporting() : $level;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,12 @@ class ExceptionListener
|
||||
$request = $event->getRequest();
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->err(sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage()));
|
||||
$message = sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage());
|
||||
if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
|
||||
$this->logger->crit($message);
|
||||
} else {
|
||||
$this->logger->err($message);
|
||||
}
|
||||
} else {
|
||||
error_log(sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine()));
|
||||
}
|
||||
@ -77,7 +82,7 @@ class ExceptionListener
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
|
||||
if (null !== $this->logger) {
|
||||
if ($exception instanceof HttpExceptionInterface && $exception->getStatusCode() >= 500) {
|
||||
if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
|
||||
$this->logger->crit($message);
|
||||
} else {
|
||||
$this->logger->err($message);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user