refactor baseAdminController
This commit is contained in:
19
core/lib/Thelia/Admin/Controller/AdminController.php
Normal file
19
core/lib/Thelia/Admin/Controller/AdminController.php
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.
|
* user is not yet logged in, or back-office home page if the user is logged in.
|
||||||
*
|
*
|
||||||
* @author Franck Allimant <franck@cqfdev.fr>
|
* @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');
|
$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 $this->getParser()->render($templateName, $args);
|
||||||
|
|
||||||
return $resp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,6 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||||
|
|
||||||
<route id="admin" path="/admin">
|
<route id="admin" path="/admin">
|
||||||
<default key="_controller">thelia.admin.base_controller:indexAction</default>
|
<default key="_controller">Thelia\Admin\Controller\AdminController::indexAction</default>
|
||||||
</route>
|
</route>
|
||||||
</routes>
|
</routes>
|
||||||
@@ -8,8 +8,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wrapper" class="container">
|
<div id="wrapper" class="container">
|
||||||
|
{*
|
||||||
{thelia_module action='index_top'}
|
{thelia_module action='index_top'}
|
||||||
|
*}
|
||||||
|
|
||||||
<div class="hero-unit">
|
<div class="hero-unit">
|
||||||
<h1>{intl l='Thelia Back Office'}</h1>
|
<h1>{intl l='Thelia Back Office'}</h1>
|
||||||
@@ -45,8 +46,9 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{*
|
||||||
{thelia_module action='index_bottom'}
|
{thelia_module action='index_bottom'}
|
||||||
|
*}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{include file='includes/footer.inc.html'}
|
{include file='includes/footer.inc.html'}
|
||||||
Reference in New Issue
Block a user