add some phpdoc

This commit is contained in:
Manuel Raynaud
2012-10-18 18:20:24 +02:00
parent 60057f4cc9
commit e15a86b84b
3 changed files with 41 additions and 11 deletions

View File

@@ -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'),
);
}
}

View File

@@ -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 <mraynaud@openstudio.fr>
*/
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(){
}

View File

@@ -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'));