Merge pull request #3744 from markstory/2.6-missing-views

2.6 Improve missing view error pages
This commit is contained in:
José Lorenzo Rodríguez 2014-06-19 20:40:02 +02:00
commit 5f81a745c4
3 changed files with 33 additions and 20 deletions

View file

@ -21,10 +21,23 @@
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The layout file %s can not be found or does not exist.', '<em>' . h($file) . '</em>'); ?> <?php echo __d('cake_dev', 'The layout file %s can not be found or does not exist.', '<em>' . h($file) . '</em>'); ?>
</p> </p>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <p>
<?php echo __d('cake_dev', 'Confirm you have created the file: %s', '<em>' . h($file) . '</em>'); ?> <?php echo __d('cake_dev', 'Confirm you have created the file: %s', h($file)); ?>
in one of the following paths:
</p> </p>
<ul>
<?php
$paths = $this->_paths($this->plugin);
foreach ($paths as $path):
if (strpos($path, CORE_PATH) !== false) {
continue;
}
echo sprintf('<li>%s%s</li>', h($path), h($file));
endforeach;
?>
</ul>
<p class="notice"> <p class="notice">
<strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong>
<?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_layout.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_layout.ctp'); ?>

View file

@ -1,7 +1,5 @@
<?php <?php
/** /**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* *
@ -21,10 +19,23 @@
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The view for %1$s%2$s was not found.', '<em>' . h(Inflector::camelize($this->request->controller)) . 'Controller::</em>', '<em>' . h($this->request->action) . '()</em>'); ?> <?php echo __d('cake_dev', 'The view for %1$s%2$s was not found.', '<em>' . h(Inflector::camelize($this->request->controller)) . 'Controller::</em>', '<em>' . h($this->request->action) . '()</em>'); ?>
</p> </p>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <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> </p>
<ul>
<?php
$paths = $this->_paths($this->plugin);
foreach ($paths as $path):
if (strpos($path, CORE_PATH) !== false) {
continue;
}
echo sprintf('<li>%s%s</li>', h($path), h($file));
endforeach;
?>
</ul>
<p class="notice"> <p class="notice">
<strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong>
<?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_view.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_view.ctp'); ?>

View file

@ -1008,18 +1008,7 @@ class View extends Object {
} }
} }
} }
$defaultPath = $paths[0]; throw new MissingViewException(array('file' => $name . $this->ext));
if ($this->plugin) {
$pluginPaths = App::path('plugins');
foreach ($paths as $path) {
if (strpos($path, $pluginPaths[0]) === 0) {
$defaultPath = $path;
break;
}
}
}
throw new MissingViewException(array('file' => $defaultPath . $name . $this->ext));
} }
/** /**
@ -1072,7 +1061,7 @@ class View extends Object {
} }
} }
} }
throw new MissingLayoutException(array('file' => $paths[0] . $file . $this->ext)); throw new MissingLayoutException(array('file' => $file . $this->ext));
} }
/** /**