Ejemplo n.º 1
0
 /** @override */
 public static function init($em, $reader)
 {
     $listener = new \Gedmo\SoftDeleteable\SoftDeleteableListener();
     $listener->setAnnotationReader($reader);
     $em->getEventManager()->addEventSubscriber($listener);
     $em->getConfiguration()->addFilter('soft-deleteable', 'Gedmo\\SoftDeleteable\\Filter\\SoftDeleteableFilter');
 }
Ejemplo n.º 2
0
 /**
  * Gets the 'doctrine.dbal.default_connection' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Doctrine\DBAL\Connection A Doctrine\DBAL\Connection instance
  */
 protected function getDoctrine_Dbal_DefaultConnectionService()
 {
     $a = $this->get('annotation_reader');
     $b = new \Doctrine\DBAL\Logging\LoggerChain();
     $b->addLogger(new \Symfony\Bridge\Doctrine\Logger\DbalLogger($this->get('monolog.logger.doctrine', ContainerInterface::NULL_ON_INVALID_REFERENCE), $this->get('debug.stopwatch', ContainerInterface::NULL_ON_INVALID_REFERENCE)));
     $b->addLogger($this->get('doctrine.dbal.logger.profiling.default'));
     $c = new \Doctrine\DBAL\Configuration();
     $c->setSQLLogger($b);
     $d = new \Gedmo\SoftDeleteable\SoftDeleteableListener();
     $d->setAnnotationReader($a);
     $e = new \Gedmo\Sortable\SortableListener();
     $e->setAnnotationReader($a);
     $f = new \Gedmo\Sluggable\SluggableListener();
     $f->setAnnotationReader($a);
     $g = new \Gedmo\Timestampable\TimestampableListener();
     $g->setAnnotationReader($a);
     $h = new \Symfony\Bridge\Doctrine\ContainerAwareEventManager($this);
     $h->addEventSubscriber($d);
     $h->addEventSubscriber($this->get('bigfoot_context.subscriber.doctrine'));
     $h->addEventSubscriber($e);
     $h->addEventSubscriber($f);
     $h->addEventSubscriber($this->get('stof_doctrine_extensions.listener.blameable'));
     $h->addEventSubscriber($g);
     $h->addEventSubscriber($this->get('stof_doctrine_extensions.listener.translatable'));
     $h->addEventListener(array(0 => 'onFlush', 1 => 'postPersist', 2 => 'postUpdate', 3 => 'postRemove'), $this->get('bigfoot_core.doctrine_listener'));
     $h->addEventListener(array(0 => 'loadClassMetadata'), $this->get('doctrine.orm.default_listeners.attach_entity_listeners'));
     return $this->services['doctrine.dbal.default_connection'] = $this->get('doctrine.dbal.connection_factory')->createConnection(array('driver' => 'pdo_sqlite', 'host' => NULL, 'port' => NULL, 'dbname' => NULL, 'user' => NULL, 'password' => NULL, 'charset' => 'UTF8', 'path' => $this->targetDirs[3] . '/app/database/sf3_database.sqlite', 'driverOptions' => array(), 'defaultTableOptions' => array()), $c, $h, array());
 }
 private static function configureListener($listener, Reader $reader)
 {
     switch ($listener) {
         case 'timestampable':
             $listener = new \Gedmo\Timestampable\TimestampableListener();
             $listener->setAnnotationReader($reader);
             return $listener;
         case 'soft-deleteable':
             $listener = new \Gedmo\SoftDeleteable\SoftDeleteableListener();
             $listener->setAnnotationReader($reader);
             return $listener;
     }
 }
Ejemplo n.º 4
0
    $settings = $c->get('settings');
    $logger = new \Monolog\Logger($settings['logger']['name']);
    $logger->pushProcessor(new \Monolog\Processor\UidProcessor());
    $logger->pushHandler(new \Monolog\Handler\StreamHandler($settings['logger']['path'], \Monolog\Logger::DEBUG));
    return $logger;
};
// Doctrine
$container['em'] = function ($c) {
    $cache = new Doctrine\Common\Cache\ArrayCache();
    $annotationReader = new Doctrine\Common\Annotations\AnnotationReader();
    $cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);
    $evm = new Doctrine\Common\EventManager();
    $timestampableListener = new Gedmo\Timestampable\TimestampableListener();
    $timestampableListener->setAnnotationReader($cachedAnnotationReader);
    $evm->addEventSubscriber($timestampableListener);
    $softDeleteableListener = new Gedmo\SoftDeleteable\SoftDeleteableListener();
    $softDeleteableListener->setAnnotationReader($cachedAnnotationReader);
    $evm->addEventSubscriber($softDeleteableListener);
    $settings = $c->get('settings');
    $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($settings['doctrine']['meta']['entity_path'], $settings['doctrine']['meta']['auto_generate_proxies'], $settings['doctrine']['meta']['proxy_dir'], $cache, false);
    $config->addFilter('soft-deleteable', 'Gedmo\\SoftDeleteable\\Filter\\SoftDeleteableFilter');
    $entityManager = \Doctrine\ORM\EntityManager::create($settings['doctrine']['connection'], $config, $evm);
    $entityManager->getFilters()->enable('soft-deleteable');
    return $entityManager;
};
// -----------------------------------------------------------------------------
// Action factories
// -----------------------------------------------------------------------------
$container['App\\Action\\HomeAction'] = function ($c) {
    return new App\Action\HomeAction($c->get('router'));
};