- strpos: documentation ( source)
- get_called_class: documentation ( source)
- str_replace: documentation ( source)
- explode: documentation ( source)
- preg_replace: documentation ( source)
- array_pop: documentation ( source)
<?php
namespace Temple\Modules\Content\Controllers;
class Controller
{
/*
private $request;
public function __construct(Request $request = null)
{
$this->request = $request;
}
protected function getRequest()
{
return $this->request;
}
*/
protected function render($file)
{
if (strpos($file, ':') !== false) {
list($module, $file) = explode(':', $file);
if ($module == 'CoreApp') {
$path = CORE_APP_PATH;
} else {
$path = MODULES_PATH . '/' . $module;
}
} else {
$module = preg_replace('#\\\?Temple\\\Modules\\\([^\\\]+)\\\.*#', '\1', get_called_class());
$path = MODULES_PATH . '/' . $module;
}
$path = str_replace('\\', DIRECTORY_SEPARATOR, $path);
$path .= '/Views/';
$exp = explode('.', $file);
$engine = array_pop($exp);
$type = array_pop($exp);
echo $path . $file;
echo "\n";
}
}
class PagesController extends Controller
{
public function indexAction()
{
//return new Response('Ciao! :)');
}
public function showAction($id)
{
// $page = Page::find($id);
//
// echo $page->category->route->url;
$this->render('show.html.twig');
$this->render('admin/new.html.twig');
$this->render('CoreApp:path/to/file.html.twig');
$this->render('Module:path/to/file.html.twig');
$this->render('file.js.twig');
$this->render('file.json.twig');
$this->render('file.css.twig');
$this->render('file.xml.twig');
}
}
$x = new PagesController();
$x->showAction(4);