change action implementation

This commit is contained in:
Manuel Raynaud
2013-04-16 14:41:03 +02:00
parent 8db01fa856
commit e0aeb8a643
6 changed files with 105 additions and 114 deletions

View File

@@ -47,12 +47,6 @@ class ActionEvent extends Event
*/
protected $action;
/**
*
* @var string
*/
protected $controller;
/**
*
* @param \Symfony\Component\HttpFoundation\Request $request
@@ -80,25 +74,4 @@ class ActionEvent extends Event
{
return $this->request;
}
/**
*
* @param string $controller
*/
public function setController($controller)
{
$this->controller = $controller;
}
public function getController()
{
return $this->controller;
}
public function hasController()
{
return null !== $this->controller;
}
}

View File

@@ -25,25 +25,29 @@ namespace Thelia\Core\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\TheliaEvents;
class RequestListener implements EventSubscriberInterface
{
protected $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function onKernelRequest(GetResponseEvent $event)
{
}
public function onKernelRequest(GetResponseEvent $event)
{
$dispatcher = $event->getDispatcher();
$request = $event->getRequest();
if (false !== $action = $request->get("action")) {
//search corresponding action
$event = new ActionEvent($request, $action);
$dispatcher->dispatch("action.".$action, $event);
}
}
public static function getSubscribedEvents()
{
return array(
KernelEvents::REQUEST => array('onKernelRequest', 30)
);
return array(
KernelEvents::REQUEST => array('onKernelRequest', 0)
);
}
}