creating new ContainerAware class fixing context on it

This commit is contained in:
Manuel Raynaud
2013-08-12 10:07:37 +02:00
parent 8d1cd1019b
commit 88f8e22408
5 changed files with 92 additions and 4 deletions

View File

@@ -236,7 +236,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
{
$successUrl = $form->getSuccessUrl();
if ($this->securityContext->getContext() === SecurityContext::CONTEXT_FRONT_OFFICE) {
if ($this->getSecurityContext(SecurityContext::CONTEXT_BACK_OFFICE)->getUser() === null) {
$this->processSuccessfullFrontEndLogin($event, $user, $form, $sendLoginEvent);
} else {
$successUrl = str_replace("__ID__", $user->getId(), $successUrl);
@@ -252,7 +252,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
// Success -> store user in security context
$this->getFrontSecurityContext()->setUser($user);
if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event);
if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event);
}

View File

@@ -23,9 +23,9 @@
namespace Thelia\Admin\Controller;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\DependencyInjection\ContainerAware;
use Thelia\Form\BaseForm;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\HttpKernelInterface;

View File

@@ -1,4 +1,25 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Controller;

View File

@@ -0,0 +1,53 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Core\Security\SecurityContext;
class ContainerAware implements ContainerAwareInterface {
/**
* @var ContainerInterface
*
* @api
*/
protected $container;
/**
* Sets the Container.
*
* @param ContainerInterface|null $container A ContainerInterface instance or null
*
* @api
*/
public function setContainer(ContainerInterface $container = null)
{
$container->get('request')->setContext(SecurityContext::CONTEXT_BACK_OFFICE);
$this->container = $container;
}
}

View File

@@ -23,9 +23,13 @@
namespace Thelia\Core\HttpFoundation;
use Symfony\Component\HttpFoundation\Request as BaseRequest;
use Thelia\Core\Security\SecurityContext;
class Request extends BaseRequest{
class Request extends BaseRequest
{
protected $context = SecurityContext::CONTEXT_FRONT_OFFICE;
public function getProductId()
{
@@ -48,4 +52,14 @@ class Request extends BaseRequest{
return $uri . $additionalQs;
}
public function setContext($context)
{
$this->context = $context;
}
public function getContext()
{
return $this->context;
}
}