From e15a86b84bcfa1dd822939b59f496804c50664e1 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 18 Oct 2012 18:20:24 +0200 Subject: [PATCH] add some phpdoc --- .../Core/EventSubscriber/ViewSubscriber.php | 19 +++++++++---- core/lib/Thelia/Core/Template/Parser.php | 28 +++++++++++++++++-- core/lib/Thelia/Core/TheliaBundle.php | 5 +--- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/core/lib/Thelia/Core/EventSubscriber/ViewSubscriber.php b/core/lib/Thelia/Core/EventSubscriber/ViewSubscriber.php index e1aec22fc..323e15bd6 100644 --- a/core/lib/Thelia/Core/EventSubscriber/ViewSubscriber.php +++ b/core/lib/Thelia/Core/EventSubscriber/ViewSubscriber.php @@ -21,10 +21,20 @@ class ViewSubscriber implements EventSubscriberInterface{ private $parser; + /** + * + * @param \Thelia\Core\Template\ParserInterface $parser + */ public function __construct(ParserInterface $parser) { $this->parser = $parser; } + /** + * + * + * + * @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event + */ public function onKernelView(GetResponseForControllerResultEvent $event){ $content = $this->parser->getContent(); @@ -32,21 +42,20 @@ class ViewSubscriber implements EventSubscriberInterface{ $event->setResponse($content); } 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 */ public static function getSubscribedEvents(){ return array( - KernelEvents::VIEW => array(array('onKernelView', 32)), + KernelEvents::VIEW => array('onKernelView'), ); } } diff --git a/core/lib/Thelia/Core/Template/Parser.php b/core/lib/Thelia/Core/Template/Parser.php index 039d5b90a..1627da3f9 100644 --- a/core/lib/Thelia/Core/Template/Parser.php +++ b/core/lib/Thelia/Core/Template/Parser.php @@ -7,21 +7,41 @@ use Symfony\Component\HttpFoundation\Response; use Thelia\Core\Template\ParserInterface; 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 + */ + class Parser implements ParserInterface { protected $container; + protected $content; + protected $status; + public function __construct(ContainerBuilder $container) { $this->container = $container; } + /** + * + * This method must return a Symfony\Component\HttpFoudation\Response instance or the content of the response + * + */ public function getContent() { - return new Response('toto'); + $this->loadParser(); + + return $this->content; } public function setContent($content) { - + $this->content = $content; } public function getStatus() { @@ -29,6 +49,10 @@ class Parser implements ParserInterface { } public function setStatus($status) { + $this->status = $status; + } + + public function loadParser(){ } diff --git a/core/lib/Thelia/Core/TheliaBundle.php b/core/lib/Thelia/Core/TheliaBundle.php index f19796bbb..107e72f50 100644 --- a/core/lib/Thelia/Core/TheliaBundle.php +++ b/core/lib/Thelia/Core/TheliaBundle.php @@ -53,10 +53,7 @@ class TheliaBundle extends Bundle { */ $container->register('listener.router', 'Symfony\Component\HttpKernel\EventListener\RouterListener') ->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') ->addArgument(new Reference('parser'));