propel-bundle/PropelBundle.php

77 lines
2.4 KiB
PHP
Raw Normal View History

2010-10-28 14:41:03 +02:00
<?php
2011-08-30 23:29:49 +02:00
/**
* 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\PropelBundle;
2010-10-28 14:41:03 +02:00
2012-04-20 15:24:52 +02:00
use Symfony\Bridge\Propel1\DependencyInjection\Security\UserProvider\PropelFactory;
2010-10-28 14:41:03 +02:00
use Symfony\Component\HttpKernel\Bundle\Bundle;
2011-01-22 16:15:43 +01:00
use Symfony\Component\DependencyInjection\ContainerBuilder;
2010-10-28 14:41:03 +02:00
2011-04-07 10:01:30 +02:00
/**
* PropelBundle
*
* @author William DURAND <william.durand1@gmail.com>
*/
2010-10-28 14:41:03 +02:00
class PropelBundle extends Bundle
{
2011-04-07 10:01:30 +02:00
/**
* {@inheritdoc}
*/
2010-10-28 14:41:03 +02:00
public function boot()
{
require_once $this->container->getParameter('propel.path').'/runtime/lib/Propel.php';
if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) {
set_include_path($this->container->getParameter('kernel.root_dir').'/..'.PATH_SEPARATOR.
$this->container->getParameter('propel.phing_path').PATH_SEPARATOR.
$this->container->getParameter('propel.phing_path').'/classes'.PATH_SEPARATOR.
get_include_path());
2010-10-28 14:41:03 +02:00
}
2011-04-06 18:19:13 +02:00
if (!\Propel::isInit()) {
\Propel::setConfiguration($this->container->get('propel.configuration'));
2011-04-05 21:21:05 +02:00
2011-04-06 18:19:13 +02:00
if ($this->container->getParameter('propel.logging')) {
$config = $this
->container
->get('propel.configuration')
;
$config->setParameter('debugpdo.logging.methods', array(
'PropelPDO::exec',
'PropelPDO::query',
'PropelPDO::prepare',
'DebugPDOStatement::execute',
), false);
$config->setParameter('debugpdo.logging.details', array(
'time' => array('enabled' => true),
'mem' => array('enabled' => true),
'connection' => array('enabled' => true),
));
2011-04-06 18:19:13 +02:00
\Propel::setLogger($this->container->get('propel.logger'));
}
2011-04-05 21:21:05 +02:00
2011-04-06 18:19:13 +02:00
\Propel::initialize();
}
2011-01-22 16:15:43 +01:00
}
2012-04-20 15:24:52 +02:00
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
if ($container->hasExtension('security')) {
$container->getExtension('security')->addUserProviderFactory(new PropelFactory('propel', 'propel.security.user.provider'));
}
}
2010-10-28 14:41:03 +02:00
}