[ZendBundle] removed translator support
This commit is contained in:
parent
b890c3429d
commit
6317ddfbe1
@ -39,10 +39,6 @@ class ZendExtension extends Extension
|
||||
if (isset($config['logger'])) {
|
||||
$this->registerLoggerConfiguration($config, $container);
|
||||
}
|
||||
|
||||
if (isset($config['translator'])) {
|
||||
$this->registerTranslatorConfiguration($config, $container);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,44 +80,6 @@ class ZendExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the translator configuration.
|
||||
*
|
||||
* Usage example:
|
||||
*
|
||||
* <zend:translator locale="en" adapter="Zend\Translator\Adapter\Xliff" />
|
||||
*
|
||||
* @param array $config An array of configuration settings
|
||||
* @param ContainerBuilder $container A ContainerBuilder instance
|
||||
*/
|
||||
protected function registerTranslatorConfiguration($config, ContainerBuilder $container)
|
||||
{
|
||||
$config = $config['translator'];
|
||||
|
||||
if (!$container->hasDefinition('zend.translator')) {
|
||||
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
|
||||
$loader->load('translator.xml');
|
||||
$container->setAlias('translator', 'zend.translator');
|
||||
}
|
||||
|
||||
if (isset($config['locale'])) {
|
||||
$container->setParameter('zend.translator.locale', $config['locale']);
|
||||
}
|
||||
|
||||
if (isset($config['adapter'])) {
|
||||
$container->setParameter('zend.translator.adapter', $config['adapter']);
|
||||
}
|
||||
|
||||
if (isset($config['translation']) && is_array($config['translation'])) {
|
||||
foreach ($config['translation'] as $locale => $catalogue) {
|
||||
if ($locale == $container->getParameter('zend.translator.locale')) {
|
||||
$container->setParameter('zend.translator.catalogue', $catalogue);
|
||||
}
|
||||
$container->findDefinition('zend.translator')->addMethodCall('addTranslation', array($catalogue, $locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base path for the XSD files.
|
||||
*
|
||||
|
@ -10,7 +10,6 @@
|
||||
<xsd:complexType name="config">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="logger" type="logger" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="translator" type="translator" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
@ -40,17 +39,4 @@
|
||||
<xsd:enumeration value="7" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:complexType name="translator">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="translation" type="translation" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="locale" type="xsd:string" />
|
||||
<xsd:attribute name="adapter" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="translation">
|
||||
<xsd:attribute name="key" type="xsd:string" />
|
||||
<xsd:attribute name="catalog" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:schema>
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?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">
|
||||
|
||||
<parameters>
|
||||
<parameter key="zend.translator.class">Zend\Translator\Translator</parameter>
|
||||
<parameter key="zend.translator.adapter" type="constant">Zend\Translator\Translator::AN_ARRAY</parameter>
|
||||
<parameter key="zend.translator.catalogue" type="constant">null</parameter>
|
||||
<parameter key="zend.translator.locale">en</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="zend.translator" class="%zend.translator.class%">
|
||||
<argument>%zend.translator.adapter%</argument>
|
||||
<argument>%zend.translator.catalogue%</argument>
|
||||
<argument>%zend.translator.locale%</argument>
|
||||
<argument type="collection">
|
||||
<argument key="log" type="service" id="zend.logger" on-invalid="ignore" />
|
||||
</argument>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
@ -28,13 +28,5 @@ class ZendExtensionTest extends TestCase
|
||||
|
||||
$loader->configLoad(array('logger' => array('priority' => 3)), $container);
|
||||
$this->assertEquals(3, $container->getParameter('zend.logger.priority'), '->loggerLoad() overrides existing configuration options');
|
||||
|
||||
// translator
|
||||
$loader->configLoad(array('translator' => array()), $container);
|
||||
$this->assertEquals('Zend\\Translator\\Translator', $container->getParameter('zend.translator.class'), '->i18nLoad() loads the translator.xml file if not already loaded');
|
||||
|
||||
$loader->configLoad(array('translator' => array('adapter' => 'Zend\\Translator\\Translator::AN_XLIFF', 'locale' => 'fr')), $container);
|
||||
$this->assertEquals('Zend\\Translator\\Translator::AN_XLIFF', $container->getParameter('zend.translator.adapter'), '->i18nLoad() overrides existing configuration options');
|
||||
$this->assertEquals('fr', $container->getParameter('zend.translator.locale'), '->i18nLoad() overrides existing configuration options');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user