Skip to content
Permalink
Browse files

Add custom error page for missing cell errors.

Refs #3945
  • Loading branch information...
markstory committed Jul 23, 2014
1 parent ad401ec commit df8294dfda0ecc05623a110aa48cb6374cef2c58
Showing with 48 additions and 3 deletions.
  1. +44 −0 src/Template/Error/missing_cell_view.ctp
  2. +1 −1 src/Template/Error/missing_view.ctp
  3. +3 −2 src/View/Cell.php
@@ -0,0 +1,44 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 0.10.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Utility\Inflector;
?>
<h2>Missing Cell View</h2>
<p class="error">
<strong>Error: </strong>
<?= sprintf('The view for <em>%sCell</em> was not found.', h(Inflector::camelize($name))); ?>
</p>

<p>
<?php echo __d('cake_dev', 'Confirm you have created the file: "%s"', h($file . $this->_ext)); ?>
in one of the following paths:
</p>
<ul>
<?php
$paths = $this->_paths($this->plugin);
foreach ($paths as $path):
if (strpos($path, CORE_PATH) !== false) {
continue;
}
echo sprintf('<li>%sCell/%s/%s</li>', h($path), h($name), h($file . $this->_ext));
endforeach;
?>
</ul>

<p class="notice">
<strong>Notice: </strong>
<?= sprintf('If you want to customize this error message, create %s', APP_DIR . DS . 'Template' . DS . 'Error' . DS . 'missing_view.ctp'); ?>
</p>

<?= $this->element('exception_stack_trace'); ?>
@@ -21,7 +21,7 @@ use Cake\Utility\Inflector;
</p>

<p>
<?php echo __d('cake_dev', 'Confirm you have created the file: %s', h($file)); ?>
<?php echo __d('cake_dev', 'Confirm you have created the file: "%s"', h($file)); ?>
in one of the following paths:
</p>
<ul>
@@ -149,12 +149,13 @@ public function render($template = null) {
$this->View->layout = false;
$className = explode('\\', get_class($this));
$className = array_pop($className);
$this->View->subDir = 'Cell' . DS . substr($className, 0, strpos($className, 'Cell'));
$name = substr($className, 0, strpos($className, 'Cell'));
$this->View->subDir = 'Cell' . DS . $name;
try {
return $this->View->render($template);
} catch (MissingViewException $e) {
throw new MissingCellViewException(['file' => $template]);
throw new MissingCellViewException(['file' => $template, 'name' => $name]);
}
}

0 comments on commit df8294d

Please sign in to comment.
You can’t perform that action at this time.