add some phpdoc
This commit is contained in:
@@ -21,10 +21,20 @@ class ViewSubscriber implements EventSubscriberInterface{
|
|||||||
|
|
||||||
private $parser;
|
private $parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param \Thelia\Core\Template\ParserInterface $parser
|
||||||
|
*/
|
||||||
public function __construct(ParserInterface $parser) {
|
public function __construct(ParserInterface $parser) {
|
||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
|
||||||
|
*/
|
||||||
public function onKernelView(GetResponseForControllerResultEvent $event){
|
public function onKernelView(GetResponseForControllerResultEvent $event){
|
||||||
$content = $this->parser->getContent();
|
$content = $this->parser->getContent();
|
||||||
|
|
||||||
@@ -32,21 +42,20 @@ class ViewSubscriber implements EventSubscriberInterface{
|
|||||||
$event->setResponse($content);
|
$event->setResponse($content);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$event->setResponse(new Response($this->parser->getContent(), $this->parser->getStatus()));
|
$event->setResponse(new Response($content, $this->parser->getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//$event->setResponse(($content = $this->parser->getContent() instanceof Response) ?: new Response($this->parser->getContent(), $this->parser->getStatus()) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* Register the method to execute in this class for a specific event (here the kernel.view event)
|
||||||
*
|
*
|
||||||
* @return array The event names to listen to
|
* @return array The event names to listen to
|
||||||
*/
|
*/
|
||||||
public static function getSubscribedEvents(){
|
public static function getSubscribedEvents(){
|
||||||
return array(
|
return array(
|
||||||
KernelEvents::VIEW => array(array('onKernelView', 32)),
|
KernelEvents::VIEW => array('onKernelView'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,21 +7,41 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Thelia\Core\Template\ParserInterface;
|
use Thelia\Core\Template\ParserInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Master class of Thelia's parser. The loop mechnism depends of this parser
|
||||||
|
*
|
||||||
|
* From this class all the parser is lunch
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
class Parser implements ParserInterface {
|
class Parser implements ParserInterface {
|
||||||
|
|
||||||
protected $container;
|
protected $container;
|
||||||
|
|
||||||
|
protected $content;
|
||||||
|
protected $status;
|
||||||
|
|
||||||
public function __construct(ContainerBuilder $container) {
|
public function __construct(ContainerBuilder $container) {
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This method must return a Symfony\Component\HttpFoudation\Response instance or the content of the response
|
||||||
|
*
|
||||||
|
*/
|
||||||
public function getContent() {
|
public function getContent() {
|
||||||
return new Response('toto');
|
$this->loadParser();
|
||||||
|
|
||||||
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContent($content) {
|
public function setContent($content) {
|
||||||
|
$this->content = $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatus() {
|
public function getStatus() {
|
||||||
@@ -29,6 +49,10 @@ class Parser implements ParserInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setStatus($status) {
|
public function setStatus($status) {
|
||||||
|
$this->status = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadParser(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,10 +53,7 @@ class TheliaBundle extends Bundle {
|
|||||||
*/
|
*/
|
||||||
$container->register('listener.router', 'Symfony\Component\HttpKernel\EventListener\RouterListener')
|
$container->register('listener.router', 'Symfony\Component\HttpKernel\EventListener\RouterListener')
|
||||||
->setArguments(array(new Reference('matcher')));
|
->setArguments(array(new Reference('matcher')));
|
||||||
|
|
||||||
/**
|
|
||||||
* @TODO think how to use kernel.view event for templating. In most of case (in Thelia) controller doesn't return a Response instance
|
|
||||||
*/
|
|
||||||
$container->register('listener.view','Thelia\Core\EventSubscriber\ViewSubscriber')
|
$container->register('listener.view','Thelia\Core\EventSubscriber\ViewSubscriber')
|
||||||
->addArgument(new Reference('parser'));
|
->addArgument(new Reference('parser'));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user