ea6a359272
* Upd: Add Symfony 4 Compatibility #SymfonyConHackday2017 * Upd: Configure visibility of services for SF4 * Updated composer to allow Symfony 4.0 * Updated composer to allow Symfony 4.0 * PropelBundle for Symfony 4 * Upd: Travis configuration * Upd: PHP 5 not supported anymore by PHPUnit * Upd: Removing old SF version + PHPUnit correction * * Removed param that was removed in symfony/yaml afb873f * Updated format of object dumping as deprecated tags using colon symfony/yaml 38d3087 * * Added commands to console.xml as symfony no longer auto registers bundle commands * Updated two services to public * * Removed deprecated getMock calls for new createMock calls. * * Add stub for additional abstract method * * Updated schema locator test * reverted unnecessary changes to abstract command and schemal locator * Added fixtures for schema testing. * * Updated schema locator test * reverted unnecessary changes to abstract command and schemal locator * Added fixtures for schema testing. * * Removed unnecessary default for services * Updated readme to reflect symfony version support
87 lines
2.8 KiB
PHP
87 lines
2.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This file is part of the PropelBundle package.
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*
|
|
* @license MIT License
|
|
*/
|
|
|
|
namespace Propel\Bundle\PropelBundle\DependencyInjection;
|
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Definition;
|
|
use Symfony\Component\Config\FileLocator;
|
|
|
|
/**
|
|
* PropelExtension loads the PropelBundle configuration.
|
|
*
|
|
* @author William DURAND <william.durand1@gmail.com>
|
|
*/
|
|
class PropelExtension extends Extension
|
|
{
|
|
/**
|
|
* Loads the Propel configuration.
|
|
*
|
|
* @param array $configs An array of configuration settings
|
|
* @param ContainerBuilder $container A ContainerBuilder instance
|
|
*/
|
|
public function load(array $configs, ContainerBuilder $container)
|
|
{
|
|
$configuration = $this->getConfiguration($configs, $container);
|
|
$config = $this->processConfiguration($configuration, $configs);
|
|
|
|
if (1 === count($config['database']['connections'])) {
|
|
$defaultConnection = array_keys($config['database']['connections'])[0];
|
|
if (!isset($config['runtime']['defaultConnection'])) {
|
|
$config['runtime']['defaultConnection'] = $defaultConnection;
|
|
}
|
|
if (!isset($config['generator']['defaultConnection'])) {
|
|
$config['generator']['defaultConnection'] = $defaultConnection;
|
|
}
|
|
}
|
|
|
|
$container->setParameter('propel.logging', $config['runtime']['logging']);
|
|
$container->setParameter('propel.configuration', $config);
|
|
|
|
// Load services
|
|
if (!$container->hasDefinition('propel')) {
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
|
$loader->load('propel.xml');
|
|
$loader->load('converters.xml');
|
|
$loader->load('security.xml');
|
|
$loader->load('console.xml');
|
|
}
|
|
}
|
|
|
|
public function getConfiguration(array $config, ContainerBuilder $container)
|
|
{
|
|
return new Configuration($container->getParameter('kernel.debug'), $container->getParameter('kernel.root_dir'));
|
|
}
|
|
|
|
/**
|
|
* Returns the base path for the XSD files.
|
|
*
|
|
* @return string The XSD base path
|
|
*/
|
|
public function getXsdValidationBasePath()
|
|
{
|
|
return __DIR__.'/../Resources/config/schema';
|
|
}
|
|
|
|
/**
|
|
* Returns the recommended alias to use in XML.
|
|
*
|
|
* This alias is also the mandatory prefix to use when using YAML.
|
|
*
|
|
* @return string The alias
|
|
*/
|
|
public function getAlias()
|
|
{
|
|
return 'propel';
|
|
}
|
|
}
|