Переглянути джерело

[DependencyInjection] made a bunch of changes to the bundled extensions

Fabien Potencier 15 роки тому
батько
коміт
2f441df2ba

+ 26 - 0
src/Symfony/Components/DependencyInjection/Loader/Extension/DoctrineExtension.php

@@ -24,6 +24,13 @@ use Symfony\Components\DependencyInjection\BuilderConfiguration;
  */
 class DoctrineExtension extends LoaderExtension
 {
+  protected $alias;
+
+  public function setAlias($alias)
+  {
+    $this->alias = $alias;
+  }
+
   /**
    * Loads the DBAL configuration.
    *
@@ -50,6 +57,25 @@ class DoctrineExtension extends LoaderExtension
       }
     }
 
+    $configuration->setAlias('connection', null !== $this->alias ? $this->alias : 'doctrine.dbal.connection');
+
+    return $configuration;
+  }
+
+  /**
+   * Loads the Doctrine ORM configuration.
+   *
+   * @param array $config A configuration array
+   *
+   * @return BuilderConfiguration A BuilderConfiguration instance
+   */
+  public function ormLoad($config)
+  {
+    $configuration = new BuilderConfiguration();
+
+    $loader = new XmlFileLoader(__DIR__.'/xml/doctrine');
+    $configuration->merge($loader->load('orm-1.0.xml'));
+
     return $configuration;
   }
 

+ 1 - 1
src/Symfony/Components/DependencyInjection/Loader/Extension/SwiftMailerExtension.php

@@ -95,7 +95,7 @@ class SwiftMailerExtension extends LoaderExtension
       }
     }
 
-    $configuration->setAlias(isset($config['alias']) ? $config['alias'] : 'mailer', 'swiftmailer.mailer');
+    $configuration->setAlias('mailer', 'swiftmailer.mailer');
 
     return $configuration;
   }

+ 23 - 10
src/Symfony/Components/DependencyInjection/Loader/Extension/SymfonyTemplatingExtension.php

@@ -25,6 +25,19 @@ use Symfony\Components\DependencyInjection\Reference;
  */
 class SymfonyTemplatingExtension extends LoaderExtension
 {
+  protected $defaultHelpers = array();
+  protected $alias;
+
+  public function setAlias($alias)
+  {
+    $this->alias = $alias;
+  }
+
+  public function setDefaultHelpers(array $defaultHelpers)
+  {
+    $this->defaultHelpers = $defaultHelpers;
+  }
+
   /**
    * Loads the templating configuration.
    *
@@ -32,8 +45,10 @@ class SymfonyTemplatingExtension extends LoaderExtension
    *
    *      <symfony:templating path="/path/to/templates" cache="/path/to/cache">
    *        <symfony:loader>symfony.templating.loader.filesystem</symfony:loader>
-   *        <symfony:helper>symfony.templating.helper.javascripts</symfony:helper>
-   *        <symfony:helper>symfony.templating.helper.stylesheets</symfony:helper>
+   *        <symfony:helpers>
+   *          symfony.templating.helper.javascripts
+   *          symfony.templating.helper.stylesheets
+   *        </symfony:helpers>
    *      </symfony:templating>
    *
    * @param array $config A configuration array
@@ -81,21 +96,17 @@ class SymfonyTemplatingExtension extends LoaderExtension
     }
 
     // helpers
-    if (isset($config['helper']))
+    if (array_key_exists('helpers', $config))
     {
       $helpers = array();
-      $ids = is_array($config['helper']) ? $config['helper'] : array($config['helper']);
-      foreach ($ids as $id)
+      foreach (explode("\n", $config['helpers']) as $helper)
       {
-        $helpers[] = new Reference($id);
+        $helpers[] = new Reference(trim($helper));
       }
     }
     else
     {
-      $helpers = null === $config['helper'] ? array() : array(
-        new Reference('symfony.templating.helper.javascripts'),
-        new Reference('symfony.templating.helper.stylesheets'),
-      );
+      $helpers = $this->defaultHelpers;
     }
 
     $configuration->getDefinition('symfony.templating.helperset')->addArgument($helpers);
@@ -109,6 +120,8 @@ class SymfonyTemplatingExtension extends LoaderExtension
       $configuration->setParameter('symfony.templating.loader.cache.path', $config['cache']);
     }
 
+    $configuration->setAlias('templating', null !== $this->alias ? $this->alias : 'symfony.templating.engine');
+
     return $configuration;
   }
 

+ 4 - 0
src/Symfony/Components/DependencyInjection/Loader/Extension/ZendExtension.php

@@ -52,6 +52,8 @@ class ZendExtension extends LoaderExtension
       $configuration->setParameter('zend.logger.path', $config['path']);
     }
 
+    $configuration->setAlias('logger', 'zend.logger');
+
     return $configuration;
   }
 
@@ -117,6 +119,8 @@ class ZendExtension extends LoaderExtension
       }
     }
 
+    $configuration->setAlias('mail', 'zend.mail');
+
     return $configuration;
   }
 

+ 3 - 1
src/Symfony/Components/DependencyInjection/Loader/Extension/xml/doctrine/dbal-1.0.xml

@@ -22,14 +22,16 @@
         <argument key="password">%doctrine.dbal.password%</argument>
         <argument key="host">%doctrine.dbal.host%</argument>
         <argument key="driverClass">%doctrine.dbal.driver.class%</argument>
+        <!--
         <argument key="wrapperClass">%doctrine.dbal.wrapper.class%</argument>
+        //-->
       </argument>
       <argument type="service" id="doctrine.dbal.configuration" />
       <argument type="service" id="doctrine.dbal.event_manager" />
     </service>
 
     <service id="doctrine.dbal.configuration" class="%doctrine.dbal.configuration.class%">
-      <call method="setSqlLogger"><argument type="service" id="doctrine.dbal.logger" /></call>
+      <call method="setSqlLogger"><argument type="service" id="doctrine.dbal.logger" on-invalid="ignore" /></call>
     </service>
 
     <service id="doctrine.dbal.logger.debug" class="Doctrine\DBAL\Logging\DebugStack" />

+ 24 - 0
src/Symfony/Components/DependencyInjection/Loader/Extension/xml/doctrine/orm-1.0.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" ?>
+
+<container xmlns="http://www.symfony-project.org/schema/dic/services"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">
+
+  <services>
+    <service id="doctrine.orm.manager" class="Doctrine\ORM\EntityManager" constructor="create">
+      <argument type="service" id="connection" />
+      <argument type="service" id="doctrine.orm.configuration" />
+    </service>
+
+    <service id="doctrine.orm.configuration" class="Doctrine\ORM\Configuration">
+      <!--
+      <call method="setMetadataCacheImpl"><argument type="service" id="doctrine.orm.cache" /></call>
+      <call method="setQueryCacheImpl"><argument type="service" id="doctrine.orm.cache" /></call>
+      //-->
+      <call method="setProxyDir"><argument>%kernel.cache_dir%/doctrine/Proxies</argument></call>
+      <call method="setProxyNamespace"><argument>Proxies</argument></call>
+    </service>
+
+    <service id="doctrine.orm.cache" class="Doctrine\Common\Cache\ApcCache" />
+  </services>
+</container>

+ 3 - 3
src/Symfony/Components/DependencyInjection/Loader/Extension/xml/symfony/templating-1.0.xml

@@ -25,17 +25,17 @@
 
     <service id="symfony.templating.loader.filesystem" class="%symfony.templating.loader.filesystem.class%">
       <argument>%symfony.templating.loader.filesystem.path%</argument>
-      <call method="setDebugger"><argument type="service" id="symfony.templating.debugger" /></call>
+      <call method="setDebugger"><argument type="service" id="symfony.templating.debugger" on-invalid="ignore" /></call>
     </service>
 
     <service id="symfony.templating.loader.cache" class="%symfony.templating.loader.cache.class%">
       <argument type="service" id="symfony.templating.loader.wrapped" />
       <argument>%symfony.templating.loader.cache.path%</argument>
-      <call method="setDebugger"><argument type="service" id="symfony.templating.debugger" /></call>
+      <call method="setDebugger"><argument type="service" id="symfony.templating.debugger" on-invalid="ignore" /></call>
     </service>
 
     <service id="symfony.templating.loader.chain" class="%symfony.templating.loader.chain.class%">
-      <call method="setDebugger"><argument type="service" id="symfony.templating.debugger" /></call>
+      <call method="setDebugger"><argument type="service" id="symfony.templating.debugger" on-invalid="ignore" /></call>
     </service>
 
     <service id="symfony.templating.helper.javascripts" class="%symfony.templating.helper.javascripts.class%" />

+ 0 - 2
src/Symfony/Components/DependencyInjection/Loader/Extension/xml/zend/logger-1.0.xml

@@ -26,7 +26,5 @@
     <service id="zend.logger.filter" class="Zend_Log_Filter_Priority">
       <argument>%zend.logger.priority%</argument>
     </service>
-
-    <service id="logger" alias="zend.logger" />
   </services>
 </container>

+ 9 - 1
src/Symfony/Components/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd

@@ -107,7 +107,7 @@
     <xsd:attribute name="type" type="parameter_type" />
     <xsd:attribute name="id" type="xsd:string" />
     <xsd:attribute name="key" type="xsd:string" />
-    <xsd:attribute name="on-invalid" type="xsd:string" />
+    <xsd:attribute name="on-invalid" type="invalid_sequence" />
   </xsd:complexType>
 
   <xsd:complexType name="argument" mixed="true">
@@ -147,6 +147,14 @@
     </xsd:restriction>
   </xsd:simpleType>
 
+  <xsd:simpleType name="invalid_sequence">
+    <xsd:restriction base="xsd:string">
+      <xsd:enumeration value="null" />
+      <xsd:enumeration value="ignore" />
+      <xsd:enumeration value="exception" />
+    </xsd:restriction>
+  </xsd:simpleType>
+
   <xsd:simpleType name="boolean">
     <xsd:restriction base="xsd:string">
       <xsd:pattern value="(%.+%|true|false)" />

+ 2 - 0
src/Symfony/Components/DependencyInjection/Loader/schema/dic/swiftmailer/swiftmailer-1.0.xsd

@@ -21,6 +21,8 @@
 
     <xsd:attribute name="transport" type="xsd:string" />
     <xsd:attribute name="delivery_strategy" type="delivery_strategy" />
+    <xsd:attribute name="username" type="xsd:string" />
+    <xsd:attribute name="password" type="xsd:string" />
   </xsd:complexType>
 
   <xsd:complexType name="spool">

+ 1 - 1
src/Symfony/Components/DependencyInjection/Loader/schema/dic/symfony/symfony-1.0.xsd

@@ -10,7 +10,7 @@
   <xsd:complexType name="templating">
     <xsd:sequence>
       <xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
-      <xsd:element name="helper" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
+      <xsd:element name="helpers" type="xsd:string" minOccurs="0" maxOccurs="1" />
     </xsd:sequence>
 
     <xsd:attribute name="path" type="xsd:string" />