change context by Class and service context
This commit is contained in:
@@ -152,6 +152,11 @@ class BaseAction
|
||||
return $securityContext;
|
||||
}
|
||||
|
||||
protected function getContext()
|
||||
{
|
||||
return $this->container->get("thelia.envContext");
|
||||
}
|
||||
|
||||
protected function redirect($url, $status = 302)
|
||||
{
|
||||
$response = new RedirectResponse($url, $status);
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<argument type="service" id="thelia.parser.context"/>
|
||||
</service>
|
||||
|
||||
|
||||
<!--
|
||||
A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations,
|
||||
thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
|
||||
@@ -81,6 +82,8 @@
|
||||
<argument type="service" id="request" />
|
||||
</service>
|
||||
|
||||
<service id="thelia.envContext" class="Thelia\Core\Context"/>
|
||||
|
||||
<!-- Parser context -->
|
||||
|
||||
<service id="thelia.parser.context" class="Thelia\Core\Template\ParserContext" scope="request">
|
||||
|
||||
@@ -34,8 +34,23 @@ class Context
|
||||
self::CONTEXT_FRONT_OFFICE
|
||||
);
|
||||
|
||||
protected $currentContext = self::CONTEXT_FRONT_OFFICE;
|
||||
|
||||
public function isValidContext($context)
|
||||
{
|
||||
return in_array($context, $this->defineContext);
|
||||
}
|
||||
|
||||
public function setContext($context)
|
||||
{
|
||||
if($this->isValidContext($context))
|
||||
{
|
||||
$this->currentContext = $context;
|
||||
}
|
||||
}
|
||||
|
||||
public function getContext()
|
||||
{
|
||||
return $this->currentContext;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class ContainerAwareAdmin implements ContainerAwareInterface {
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$container->get('request')->setContext(Context::CONTEXT_BACK_OFFICE);
|
||||
$container->get('thelia.envContext')->setContext(Context::CONTEXT_BACK_OFFICE);
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user