refactor baseAdminController

This commit is contained in:
Manuel Raynaud
2013-06-20 12:21:58 +02:00
parent 9d5cf4af33
commit e2706515eb
4 changed files with 59 additions and 21 deletions

View File

@@ -0,0 +1,19 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: manu
* Date: 20/06/13
* Time: 12:05
* To change this template use File | Settings | File Templates.
*/
namespace Thelia\Admin\Controller;
class AdminController extends BaseAdminController {
public function indexAction()
{
return $this->render("login.html");
}
}

View File

@@ -35,33 +35,50 @@ use Symfony\Component\DependencyInjection\ContainerAware;
* user is not yet logged in, or back-office home page if the user is logged in.
*
* @author Franck Allimant <franck@cqfdev.fr>
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class BaseAdminController
class BaseAdminController extends ContainerAware
{
protected $parser;
public function __construct($parser) {
$this->parser = $parser;
// FIXME: should be read from config
$this->parser->setTemplate('admin/default');
}
protected function render($templateName, $args = array()) {
/**
* @param $templateName
* @param array $args
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($templateName, $args = array())
{
$args = array('lang' => 'fr');
return $this->parser->render($templateName, $args);
$response = new Response();
return $response->setContent($this->renderRaw($templateName, $args));
}
public function indexAction()
public function renderRaw($templateName, $args = array())
{
$resp = new Response();
$args = array('lang' => 'fr');
$resp->setContent($this->render('login.html'));
return $resp;
return $this->getParser()->render($templateName, $args);
}
/**
* @return \Symfony\Component\HttpFoundation\Request
*/
public function getRequest()
{
return $this->container->get('request');
}
public function getParser()
{
$parser = $this->container->get("thelia.parser");
// FIXME: should be read from config
$parser->setTemplate('admin/default');
return $parser;
}
}

View File

@@ -5,6 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="admin" path="/admin">
<default key="_controller">thelia.admin.base_controller:indexAction</default>
<default key="_controller">Thelia\Admin\Controller\AdminController::indexAction</default>
</route>
</routes>

View File

@@ -8,8 +8,9 @@
</div>
<div id="wrapper" class="container">
{*
{thelia_module action='index_top'}
*}
<div class="hero-unit">
<h1>{intl l='Thelia Back Office'}</h1>
@@ -45,8 +46,9 @@
</ul>
</div>
</div>
{*
{thelia_module action='index_bottom'}
*}
</div>
{include file='includes/footer.inc.html'}