Skip to content

Commit

Permalink
fixed DI
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Sep 26, 2016
1 parent 02dcd7f commit f992538
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -24,7 +24,6 @@ before_script:

script:
- vendor/phpunit/phpunit/phpunit $PHPUNIT_FLAGS
- mkdir ota
- bin/xsd2php convert tests/config.yml tests/JmsSerializer/OTA/otaxml/OTA_AirAvailRQ.xsd -vv

after_script:
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Convert.php
Expand Up @@ -49,16 +49,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
$src = $input->getArgument('src');

$schemas = [];
$reader = $this->container->get('goetas.xsd2php.schema_reader');
$reader = $this->container->get('goetas_webservices.xsd2php.schema_reader');
foreach ($src as $file) {
$schemas[] = $reader->readFile($file);
}

foreach (['php', 'jms'] as $type) {
$converter = $this->container->get('goetas.xsd2php.converter.' . $type);
$converter = $this->container->get('goetas_webservices.xsd2php.converter.' . $type);
$items = $converter->convert($schemas);

$writer = $this->container->get('goetas.xsd2php.writer.' . $type);
$writer = $this->container->get('goetas_webservices.xsd2php.writer.' . $type);
$writer->write($items);
}
return count($items) ? 0 : 255;
Expand Down
16 changes: 8 additions & 8 deletions src/DependencyInjection/Xsd2PhpExtension.php
Expand Up @@ -20,23 +20,23 @@ public function load(array $configs, ContainerBuilder $container)
$config = array_merge($config, $subConfig);
}

$definition = $container->getDefinition('goetas.xsd2php.naming_convention.' . $config['naming_strategy']);
$container->setDefinition('goetas.xsd2php.naming_convention', $definition);
$definition = $container->getDefinition('goetas_webservices.xsd2php.naming_convention.' . $config['naming_strategy']);
$container->setDefinition('goetas_webservices.xsd2php.naming_convention', $definition);


$schemaReader = $container->getDefinition('goetas.xsd2php.schema_reader');
$schemaReader = $container->getDefinition('goetas_webservices.xsd2php.schema_reader');
foreach ($config['known_locations'] as $namespace => $location) {
$schemaReader->addMethodCall('addKnownSchemaLocation', [$namespace, $location]);
}

foreach (['php', 'jms'] as $type) {
$definition = $container->getDefinition('goetas.xsd2php.path_generator.' . $type . '.' . $config['path_generator']);
$container->setDefinition('goetas.xsd2php.path_generator.' . $type, $definition);
$definition = $container->getDefinition('goetas_webservices.xsd2php.path_generator.' . $type . '.' . $config['path_generator']);
$container->setDefinition('goetas_webservices.xsd2php.path_generator.' . $type, $definition);

$pathGenerator = $container->getDefinition('goetas.xsd2php.path_generator.' . $type);
$pathGenerator = $container->getDefinition('goetas_webservices.xsd2php.path_generator.' . $type);
$pathGenerator->addMethodCall('setTargets', [$config['destinations_' . $type]]);

$converter = $container->getDefinition('goetas.xsd2php.converter.' . $type);
$converter = $container->getDefinition('goetas_webservices.xsd2php.converter.' . $type);
foreach ($config['namespaces'] as $xml => $php) {
$converter->addMethodCall('addNamespace', [$xml, self::sanitizePhp($php)]);
}
Expand All @@ -47,7 +47,7 @@ public function load(array $configs, ContainerBuilder $container)
}
}

$container->setParameter('xsd2php.config', $config);
$container->setParameter('goetas_webservices.xsd2php.config', $config);
}

protected static function sanitizePhp($ns)
Expand Down
40 changes: 20 additions & 20 deletions src/Resources/config/services.xml
Expand Up @@ -3,56 +3,56 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="goetas.xsd2php.naming_convention.short" public="false"
<service id="goetas_webservices.xsd2php.naming_convention.short" public="false"
class="GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy"/>
<service id="goetas.xsd2php.naming_convention.long" public="false"
<service id="goetas_webservices.xsd2php.naming_convention.long" public="false"
class="GoetasWebservices\Xsd\XsdToPhp\Naming\LongNamingStrategy"/>

<service id="goetas.xsd2php.schema_reader" public="true" class="GoetasWebservices\XML\XSDReader\SchemaReader">
<service id="goetas_webservices.xsd2php.schema_reader" public="true" class="GoetasWebservices\XML\XSDReader\SchemaReader">
<argument type="service" id="logger"/>
</service>

<service synthetic="true" public="false" id="goetas.xsd2php.naming_convention"/>
<service synthetic="true" public="false" id="goetas_webservices.xsd2php.naming_convention"/>
<service synthetic="true" id="logger"/>

<service id="goetas.xsd2php.converter.php" class="GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter">
<argument id="goetas.xsd2php.naming_convention" type="service"/>
<service id="goetas_webservices.xsd2php.converter.php" class="GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter">
<argument id="goetas_webservices.xsd2php.naming_convention" type="service"/>
<call method="setLogger">
<argument type="service" id="logger"></argument>
</call>
</service>

<service id="goetas.xsd2php.converter.jms" class="GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter">
<argument id="goetas.xsd2php.naming_convention" type="service"/>
<service id="goetas_webservices.xsd2php.converter.jms" class="GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter">
<argument id="goetas_webservices.xsd2php.naming_convention" type="service"/>
<call method="setLogger">
<argument type="service" id="logger"></argument>
</call>
</service>

<service synthetic="true" id="goetas.xsd2php.path_generator.php"/>
<service synthetic="true" id="goetas.xsd2php.path_generator.jms"/>
<service synthetic="true" id="goetas_webservices.xsd2php.path_generator.php"/>
<service synthetic="true" id="goetas_webservices.xsd2php.path_generator.jms"/>

<service id="goetas.xsd2php.path_generator.php.psr4" public="false"
<service id="goetas_webservices.xsd2php.path_generator.php.psr4" public="false"
class="GoetasWebservices\Xsd\XsdToPhp\Php\PathGenerator\Psr4PathGenerator"></service>
<service id="goetas.xsd2php.path_generator.jms.psr4" public="false"
<service id="goetas_webservices.xsd2php.path_generator.jms.psr4" public="false"
class="GoetasWebservices\Xsd\XsdToPhp\Jms\PathGenerator\Psr4PathGenerator"></service>

<service id="goetas.xsd2php.writer.php" class="GoetasWebservices\Xsd\XsdToPhp\Writer\PHPWriter">
<argument id="goetas.xsd2php.class_writer.php" type="service"/>
<argument id="goetas.xsd2php.php.class_generator" type="service"/>
<service id="goetas_webservices.xsd2php.writer.php" class="GoetasWebservices\Xsd\XsdToPhp\Writer\PHPWriter">
<argument id="goetas_webservices.xsd2php.class_writer.php" type="service"/>
<argument id="goetas_webservices.xsd2php.php.class_generator" type="service"/>
<argument id="logger" type="service"/>
</service>

<service id="goetas.xsd2php.class_writer.php" class="GoetasWebservices\Xsd\XsdToPhp\Writer\PHPClassWriter">
<argument id="goetas.xsd2php.path_generator.php" type="service"/>
<service id="goetas_webservices.xsd2php.class_writer.php" class="GoetasWebservices\Xsd\XsdToPhp\Writer\PHPClassWriter">
<argument id="goetas_webservices.xsd2php.path_generator.php" type="service"/>
<argument id="logger" type="service"/>
</service>

<service id="goetas.xsd2php.php.class_generator"
<service id="goetas_webservices.xsd2php.php.class_generator"
class="GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator"></service>

<service id="goetas.xsd2php.writer.jms" class="GoetasWebservices\Xsd\XsdToPhp\Writer\JMSWriter">
<argument id="goetas.xsd2php.path_generator.jms" type="service"/>
<service id="goetas_webservices.xsd2php.writer.jms" class="GoetasWebservices\Xsd\XsdToPhp\Writer\JMSWriter">
<argument id="goetas_webservices.xsd2php.path_generator.jms" type="service"/>
<argument id="logger" type="service"/>
</service>

Expand Down

0 comments on commit f992538

Please sign in to comment.