pass container to thelialoop smarty plugin then to baseloop

This commit is contained in:
Etienne Roudeix
2013-09-09 18:15:49 +02:00
parent 04d8990990
commit c5f30baba5
4 changed files with 31 additions and 19 deletions

View File

@@ -146,11 +146,7 @@
<service id="smarty.plugin.thelialoop" class="Thelia\Core\Template\Smarty\Plugins\TheliaLoop" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="request" />
<argument type="service" id="event_dispatcher"/>
<argument type="service" id="thelia.securityContext"/>
<argument type="service" id="service_container" />
<call method="setLoopList">
<argument>%thelia.parser.loops%</argument>
</call>

View File

@@ -23,6 +23,7 @@
namespace Thelia\Core\Template\Element;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
@@ -52,6 +53,9 @@ abstract class BaseLoop
*/
protected $securityContext;
/** @var ContainerInterface Service Container */
protected $container = null;
protected $args;
public $countable = true;
@@ -61,15 +65,15 @@ abstract class BaseLoop
/**
* Create a new Loop
*
* @param Request $request
* @param EventDispatcherInterface $dispatcher
* @param SecurityContext $securityContext
* @param ContainerInterface $container
*/
public function __construct(Request $request, EventDispatcherInterface $dispatcher, SecurityContext $securityContext)
public function __construct(ContainerInterface $container)
{
$this->request = $request;
$this->dispatcher = $dispatcher;
$this->securityContext = $securityContext;
$this->container = $container;
$this->request = $container->get('request');
$this->dispatcher = $container->get('event_dispatcher');
$this->securityContext = $container->get('thelia.securityContext');
$this->args = $this->getArgDefinitions()->addArguments($this->getDefaultArgs(), false);
}

View File

@@ -23,6 +23,7 @@
namespace Thelia\Core\Template\Smarty\Plugins;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
@@ -44,14 +45,22 @@ class TheliaLoop extends AbstractSmartyPlugin
protected $dispatcher;
protected $securityContext;
/** @var ContainerInterface Service Container */
protected $container = null;
protected $loopstack = array();
protected $varstack = array();
public function __construct(Request $request, EventDispatcherInterface $dispatcher, SecurityContext $securityContext)
/**
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->request = $request;
$this->dispatcher = $dispatcher;
$this->securityContext = $securityContext;
$this->container = $container;
$this->request = $container->get('request');
$this->dispatcher = $container->get('event_dispatcher');
$this->securityContext = $container->get('thelia.securityContext');
}
/**
@@ -315,9 +324,7 @@ class TheliaLoop extends AbstractSmartyPlugin
}
$loop = $class->newInstance(
$this->request,
$this->dispatcher,
$this->securityContext
$this->container
);
$loop->initializeArgs($smartyParams);

View File

@@ -71,4 +71,9 @@ class Cart extends BaseCart
->findOne()
;
}
public function getTaxedAmount()
{
}
}