Permalink
Browse files

Fixed issue about scope on console

  • Loading branch information...
1 parent 0c555d5 commit 7fdcf63ea796ab89b46e014515608b70d5aadf77 @phiamo phiamo committed Nov 28, 2011
@@ -32,6 +32,7 @@ public function getConfigTreeBuilder()
->end()
->scalarNode('template')
->defaultValue('MopaBootstrapBundle:Topbar:topbar.html.twig')
+ ->cannotBeEmpty()
->end()
->end()
->end()
@@ -4,7 +4,7 @@ parameters:
services:
mopa_bootstrap.topbar_renderer:
class: Mopa\BootstrapBundle\Topbar\Renderer\TopbarRenderer
- arguments: [ @twig, @form.factory, @mopa_bootstrap.topbar.service, %mopa_bootstrap.topbar.template% ]
+ arguments: [ @service_container, %mopa_bootstrap.topbar.template% ]
tags:
# The alias is what is used to retrieve the menu
- { name: knp_menu.renderer, alias: topbar }
@@ -13,8 +13,4 @@ services:
class: Mopa\BootstrapBundle\Twig\TopbarExtension
arguments: [ @mopa_bootstrap.topbar_renderer ]
tags:
- - { name: twig.extension }
-
- mopa_bootstrap.topbar.helper:
- class: Mopa\BootstrapBundle\Twig\Helper
- arguments: [knp_menu.renderer_provider, knp_menu.menu_provider]
+ - { name: twig.extension }
@@ -1,22 +1,23 @@
<?php
namespace Mopa\BootstrapBundle\Topbar\Renderer;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
use Symfony\Component\Form\FormFactoryInterface;
use Mopa\BootstrapBundle\Topbar\TopbarInterface;
use Symfony\Component\Form\AbstractType;
class TopbarRenderer{
+ private $container;
private $template;
private $formFactory;
private $topbar;
private $environment;
- public function __construct(\Twig_Environment $environment, FormFactoryInterface $formFactory, $topbar, $template)
+ public function __construct(ContainerInterface $container, $template)
{
- $this->environment = $environment;
- $this->formFactory = $formFactory;
- $this->topbar = $topbar;
+ $this->container = $container;
$this->template = $template;
}
/**
@@ -29,10 +30,10 @@ public function __construct(\Twig_Environment $environment, FormFactoryInterface
public function renderTopbar(array $options = array())
{
$options = array_merge($this->getTopbarDefaultOptions(), $options);
-
+
$template = $options['template'];
if (!$template instanceof \Twig_Template) {
- $template = $this->environment->loadTemplate($template);
+ $template = $this->container->get('twig')->loadTemplate($template);
}
$topbar = $this->getTopbar($options['topbar']);
$this->createFormView($topbar);
@@ -53,7 +54,7 @@ protected function createFormView(TopbarInterface $topbar){
}
if($formType && $formType instanceof AbstractType){
$topbar->setFormType($formType);
- $form = $this->formFactory->create($formType);
+ $form = $this->container->get('form.factory')->create($formType);
$topbar->setForm($form->createView());
}
return null;
@@ -77,7 +78,7 @@ private function getTopbarDefaultOptions()
{
return array(
'template' => $this->template,
- 'topbar' => $this->topbar
+ 'topbar' => $this->container->get('mopa_bootstrap.topbar.service')
);
}
}

0 comments on commit 7fdcf63

Please sign in to comment.