Skip to content

Commit 9a635f6

Browse files
committed
Fix the notice errors on the MissingView error page.
Also update it to the new style/approach.
1 parent a73dbef commit 9a635f6

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

src/Template/Error/missing_view.ctp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,53 @@
1414
*/
1515
use Cake\Core\Plugin;
1616
use Cake\Core\Configure;
17+
$namespace = Configure::read('App.namespace');
1718

1819
$pluginPath = Configure::read('App.paths.plugins.0');
19-
2020
$pluginDot = empty($plugin) ? null : $plugin . '.';
21+
2122
if (empty($plugin)) {
2223
$filePath = APP_DIR . DS;
24+
$namespace = $plugin;
2325
}
2426
if (!empty($plugin) && Plugin::loaded($plugin)) {
2527
$filePath = Plugin::classPath($plugin);
2628
}
2729
if (!empty($plugin) && !Plugin::loaded($plugin)) {
2830
$filePath = $pluginPath . h($plugin) . DS . 'src' . DS;
2931
}
32+
33+
$this->layout = 'dev_error';
34+
$this->assign('title', 'Missing View');
35+
$this->assign('templateName', 'missing_view.ctp');
36+
37+
$this->start('subheading');
3038
?>
31-
<h2>Missing View</h2>
32-
<p class="error">
3339
<strong>Error: </strong>
34-
<?= sprintf('<em>%s</em> could not be found.', h($pluginDot . $class)); ?>
35-
<?php
36-
if (!empty($plugin) && !Plugin::loaded($plugin)):
37-
echo sprintf('Make sure your plugin <em>%s</em> is in the %s directory and was loaded.', h($plugin), $pluginPath);
38-
endif;
39-
?>
40-
<?= $this->element('plugin_class_error'); ?>
40+
<em><?= h($pluginDot . $class) ?></em> could not be found.
41+
<?php if (!empty($plugin) && !Plugin::loaded($plugin)): ?>
42+
Make sure your plugin <em><?= h($plugin) ?></em> is in the <?= h($pluginPath) ?> directory and was loaded.
43+
<?php endif ?>
44+
<?= $this->element('plugin_class_error', ['pluginPath' => $pluginPath]) ?>
4145
</p>
46+
<?php $this->end() ?>
47+
48+
<?php $this->start('file') ?>
4249
<p class="error">
4350
<strong>Error: </strong>
4451
<?= sprintf('Create the class <em>%s</em> below in file: %s', h($class), $filePath . 'View' . DS . h($class) . '.php'); ?>
4552
</p>
46-
<pre>
47-
&lt;?php
48-
class <?= h($class); ?> extends View {
53+
<?php
54+
$code = <<<PHP
55+
<?php
56+
namespace {$namespace}\View;
4957
50-
}
51-
</pre>
52-
<p class="notice">
53-
<strong>Notice: </strong>
54-
<?= sprintf('If you want to customize this error message, create %s', APP_DIR . DS . 'Template' . DS . 'Error' . DS . 'missing_view.ctp'); ?>
55-
</p>
58+
use Cake\View\View;
5659
57-
<?= $this->element('exception_stack_trace'); ?>
60+
class {$class}View extends View {
61+
62+
}
63+
PHP;
64+
?>
65+
<div class="code-dump"><?php highlight_string($code) ?></div>
66+
<?php $this->end() ?>

src/View/ViewVarsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getView($viewClass = null) {
5959
$this->viewClass = $viewClass;
6060
$className = App::className($this->viewClass, 'View', 'View');
6161
if (!$className) {
62-
throw new Exception\MissingViewException([$viewClass]);
62+
throw new Exception\MissingViewException(['class' => $viewClass]);
6363
}
6464

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

0 commit comments

Comments
 (0)