Skip to content

Commit

Permalink
Fix the notice errors on the MissingView error page.
Browse files Browse the repository at this point in the history
Also update it to the new style/approach.
  • Loading branch information
markstory committed Dec 6, 2014
1 parent a73dbef commit 9a635f6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
49 changes: 29 additions & 20 deletions src/Template/Error/missing_view.ctp
Expand Up @@ -14,44 +14,53 @@
*/
use Cake\Core\Plugin;
use Cake\Core\Configure;
$namespace = Configure::read('App.namespace');

$pluginPath = Configure::read('App.paths.plugins.0');

$pluginDot = empty($plugin) ? null : $plugin . '.';

if (empty($plugin)) {
$filePath = APP_DIR . DS;
$namespace = $plugin;
}
if (!empty($plugin) && Plugin::loaded($plugin)) {
$filePath = Plugin::classPath($plugin);
}
if (!empty($plugin) && !Plugin::loaded($plugin)) {
$filePath = $pluginPath . h($plugin) . DS . 'src' . DS;
}

$this->layout = 'dev_error';
$this->assign('title', 'Missing View');
$this->assign('templateName', 'missing_view.ctp');

$this->start('subheading');
?>
<h2>Missing View</h2>
<p class="error">
<strong>Error: </strong>
<?= sprintf('<em>%s</em> could not be found.', h($pluginDot . $class)); ?>
<?php
if (!empty($plugin) && !Plugin::loaded($plugin)):
echo sprintf('Make sure your plugin <em>%s</em> is in the %s directory and was loaded.', h($plugin), $pluginPath);
endif;
?>
<?= $this->element('plugin_class_error'); ?>
<em><?= h($pluginDot . $class) ?></em> could not be found.
<?php if (!empty($plugin) && !Plugin::loaded($plugin)): ?>
Make sure your plugin <em><?= h($plugin) ?></em> is in the <?= h($pluginPath) ?> directory and was loaded.
<?php endif ?>
<?= $this->element('plugin_class_error', ['pluginPath' => $pluginPath]) ?>
</p>
<?php $this->end() ?>

<?php $this->start('file') ?>
<p class="error">
<strong>Error: </strong>
<?= sprintf('Create the class <em>%s</em> below in file: %s', h($class), $filePath . 'View' . DS . h($class) . '.php'); ?>
</p>
<pre>
&lt;?php
class <?= h($class); ?> extends View {
<?php
$code = <<<PHP
<?php
namespace {$namespace}\View;
}
</pre>
<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>
use Cake\View\View;
<?= $this->element('exception_stack_trace'); ?>
class {$class}View extends View {
}
PHP;
?>
<div class="code-dump"><?php highlight_string($code) ?></div>
<?php $this->end() ?>
2 changes: 1 addition & 1 deletion src/View/ViewVarsTrait.php
Expand Up @@ -59,7 +59,7 @@ public function getView($viewClass = null) {
$this->viewClass = $viewClass;
$className = App::className($this->viewClass, 'View', 'View');
if (!$className) {
throw new Exception\MissingViewException([$viewClass]);
throw new Exception\MissingViewException(['class' => $viewClass]);
}

if ($this->View && $this->View instanceof $className) {
Expand Down

0 comments on commit 9a635f6

Please sign in to comment.