Skip to content

Commit

Permalink
No need for that TemplatesService::_render() function anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jun 1, 2014
1 parent f54f03a commit 00040e5
Showing 1 changed file with 14 additions and 34 deletions.
48 changes: 14 additions & 34 deletions src/controllers/TemplatesController.php
Expand Up @@ -14,7 +14,15 @@ class TemplatesController extends BaseController
*/
public function actionRender($template, array $variables = array())
{
$this->_render($template, $variables);
// Does that template exist?
if (craft()->templates->doesTemplateExist($template))
{
$this->renderTemplate($template, $variables);
}
else
{
throw new HttpException(404);
}
}

/**
Expand All @@ -30,23 +38,23 @@ public function actionOffline()
}

// Output the offline template
$this->_render('offline');
$this->renderTemplate('offline');
}

/**
* Renders the Manual Update notification template.
*/
public function actionManualUpdateNotification()
{
$this->_render('_special/dbupdate');
$this->renderTemplate('_special/dbupdate');
}

/**
* Renders the Manual Update template.
*/
public function actionManualUpdate()
{
$this->_render('updates/_go', array(
$this->renderTemplate('updates/_go', array(
'handle' => craft()->request->getSegment(2)
));
}
Expand All @@ -56,7 +64,7 @@ public function actionManualUpdate()
*/
public function actionBreakpointUpdateNotification()
{
$this->_render('_special/breakpointupdate', array(
$this->renderTemplate('_special/breakpointupdate', array(
'minBuild' => CRAFT_MIN_BUILD_REQUIRED,
'minBuildURL' => CRAFT_MIN_BUILD_URL,
'targetVersion' => CRAFT_VERSION,
Expand Down Expand Up @@ -89,7 +97,7 @@ public function actionRequirementsCheck()
}
else
{
$this->_render('_special/cantrun', array('reqCheck' => $reqCheck));
$this->renderTemplate('_special/cantrun', array('reqCheck' => $reqCheck));
craft()->end();
}

Expand Down Expand Up @@ -155,32 +163,4 @@ public function actionRenderError()
}
}
}

/**
* Renders a template, sets the mime type header, etc..
*
* @access private
* @param string $template
* @param array|null $variables
* @throws HttpException
* @throws TemplateLoaderException|\Exception
*/
private function _render($template, $variables = array())
{
try
{
$this->renderTemplate($template, $variables);
}
catch (TemplateLoaderException $e)
{
if ($e->template == $template)
{
throw new HttpException(404);
}
else
{
throw $e;
}
}
}
}

0 comments on commit 00040e5

Please sign in to comment.