public function register(Application $app, array $options = array()) { $config = $app->getConfig(); if (!empty($config[$this->name])) { $fs_twig_loader = new \Twig_Loader_Filesystem(__DIR__ . '/../../../../../../src/' . $config[$this->name]['path']); $loader = new \Twig_Loader_Chain(array($fs_twig_loader)); $twig = new \Twig_Environment($loader); // this extension includes the asset() function $twig->addExtension(new TwigCoreExtension($app)); // the routing extension is required to reference routes in twig templates // e.g <a href="{{ path('Some_route')}}">click</a> $twig->addExtension(new RoutingExtension($app->shared['url.generator'])); if ($app->getProvider('translator') !== null) { $twig->addExtension(new TranslationExtension($app->getProvider('translator'))); } if ($app->getProvider('form')) { $twig_form_templates = array('form_div_layout.html.twig'); $twig_form_engine = new TwigRendererEngine($twig_form_templates); $twig_form_renderer = new TwigRenderer($twig_form_engine, $app->shared['csrf_provider']); $twig->addExtension(new FormExtension($twig_form_renderer)); // add loader for Symfony built-in form templates $reflected = new \ReflectionClass('Symfony\\Bridge\\Twig\\Extension\\FormExtension'); $path = dirname($reflected->getFileName()) . '/../Resources/views/Form'; $loader->addLoader(new \Twig_Loader_Filesystem($path)); } return $twig; } return false; }
public function register(Application $app, array $options = array()) { $secret = $app->getConfig('form.secret'); $app->shared['csrf_provider'] = new DefaultCsrfProvider($secret); $extensions = array(new CsrfExtension($app->shared['csrf_provider']), new HttpFoundationExtension()); $factory = Forms::createFormFactoryBuilder()->addExtensions($extensions)->addTypeExtensions(array())->addTypeGuessers(array())->getFormFactory(); return $factory; }
public function register(Application $app, array $options = array()) { $config = $app->getConfig($this->name); $server = $config['server']; if (empty($server)) { return false; } $connection = new AMQPConnection($server['host'], $server['port'], $server['user'], $server['password']); return $connection; }
public function register(Application $app, array $options = array()) { $config = $app->getConfig($this->name); if (empty($config)) { return false; } $logger = new Logger('rabbitmq'); $handler = new StreamHandler(__DIR__ . '/../../../' . $config['path'], Logger::INFO); $logger->pushHandler($handler); return $logger; }
public function register(Application $app, array $options = array()) { $config = $app->getConfig($this->name); $options += $config; $default_factory = 'Gd'; if (empty($config['factory'])) { $options['factory'] = $default_factory; } $class = sprintf('\\Imagine\\%s\\Imagine', $options['factory']); if (!class_exists($class)) { throw new \RuntimeException($class . ' does not exist.'); } return new $class(); }