Skip to content
Permalink
Browse files

Move View\Error to View\Exception.

  • Loading branch information...
ADmad committed Aug 30, 2014
1 parent cb83b3f commit c1b5187c8b71d15ae8c561d47500dfba3408fc07
@@ -25,7 +25,7 @@
use Cake\Network\Response;
use Cake\Routing\Router;
use Cake\Utility\Inflector;
use Cake\View\Error\MissingViewException;
use Cake\View\Exception\MissingViewException;
use Exception;
/**
@@ -20,8 +20,8 @@
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Utility\Inflector;
use Cake\View\Error\MissingCellViewException;
use Cake\View\Error\MissingViewException;
use Cake\View\Exception\MissingCellViewException;
use Cake\View\Exception\MissingViewException;
use Cake\View\ViewVarsTrait;
/**
@@ -143,7 +143,7 @@ public function __construct(Request $request = null, Response $response = null,
* @param string $template Custom template name to render. If not provided (null), the last
* value will be used. This value is automatically set by `CellTrait::cell()`.
* @return void
* @throws \Cake\View\Error\MissingCellViewException When a MissingViewException is raised during rendering.
* @throws \Cake\View\Exception\MissingCellViewException When a MissingViewException is raised during rendering.
*/
public function render($template = null) {
if ($template !== null && strpos($template, '/') === false) {
@@ -52,7 +52,7 @@ trait CellTrait {
* `cell('TagCloud::smallList', ['a1' => 'v1', 'a2' => 'v2'])` maps to `View\Cell\TagCloud::smallList(v1, v2)`
* @param array $options Options for Cell's constructor
* @return \Cake\View\Cell The cell instance
* @throws \Cake\View\Error\MissingCellException If Cell class was not found.
* @throws \Cake\View\Exception\MissingCellException If Cell class was not found.
* @throws \BadMethodCallException If Cell class does not specified cell action.
*/
public function cell($cell, array $data = [], array $options = []) {
@@ -68,7 +68,7 @@ public function cell($cell, array $data = [], array $options = []) {
$className = App::className($pluginAndCell, 'View/Cell', 'Cell');
if (!$className) {
throw new Error\MissingCellException(array('className' => $pluginAndCell . 'Cell'));
throw new Exception\MissingCellException(array('className' => $pluginAndCell . 'Cell'));
}
$cell = $this->_createCell($className, $action, $plugin, $options);
@@ -12,7 +12,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\View\Error;
namespace Cake\View\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\View\Error;
namespace Cake\View\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\View\Error;
namespace Cake\View\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\View\Error;
namespace Cake\View\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\View\Error;
namespace Cake\View\Exception;
use Cake\Core\Exception\Exception;
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\View\Error;
namespace Cake\View\Exception;
use Cake\Core\Exception\Exception;
@@ -15,8 +15,8 @@
namespace Cake\View;
use Cake\Core\App;
use Cake\Event\EventManagerTrait;
use Cake\Core\ObjectRegistry;
use Cake\Event\EventManagerTrait;
use Cake\View\View;
/**
@@ -51,7 +51,7 @@ public function __construct(View $view) {
*
* @param string $helper The helper name to be loaded
* @return bool whether the helper could be loaded or not
* @throws \Cake\View\Error\MissingHelperException When a helper could not be found.
* @throws \Cake\View\Exception\MissingHelperException When a helper could not be found.
* App helpers are searched, and then plugin helpers.
*/
public function __isset($helper) {
@@ -111,10 +111,10 @@ protected function _resolveClassName($class) {
* @param string $class The classname that is missing.
* @param string $plugin The plugin the helper is missing in.
* @return void
* @throws \Cake\View\Error\MissingHelperException
* @throws \Cake\View\Exception\MissingHelperException
*/
protected function _throwMissingClassError($class, $plugin) {
throw new Error\MissingHelperException([
throw new Exception\MissingHelperException([
'class' => $class . 'Helper',
'plugin' => $plugin
]);
@@ -18,7 +18,6 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Core\Exception\Exception;
use Cake\Event\Event;
use Cake\Event\EventManager;
use Cake\Event\EventManagerTrait;
@@ -30,6 +29,8 @@
use Cake\Utility\Inflector;
use Cake\View\CellTrait;
use Cake\View\ViewVarsTrait;
use InvalidArgumentException;
use LogicException;
/**
* View, the V in the MVC triad. View interacts with Helpers and view variables passed
@@ -344,7 +345,7 @@ public function __construct(Request $request = null, Response $response = null,
* Defaults to false.
* - `ignoreMissing` - Used to allow missing elements. Set to true to not throw exceptions.
* @return string Rendered Element
* @throws \Cake\View\Error\MissingElementException When an element is missing and `ignoreMissing`
* @throws \Cake\View\Exception\MissingElementException When an element is missing and `ignoreMissing`
* is false.
*/
public function element($name, array $data = array(), array $options = array()) {
@@ -370,7 +371,7 @@ public function element($name, array $data = array(), array $options = array())
list ($plugin, $name) = pluginSplit($name, true);
$name = str_replace('/', DS, $name);
$file = $plugin . 'Element' . DS . $name . $this->_ext;
throw new Error\MissingElementException($file);
throw new Exception\MissingElementException($file);
}
}
@@ -683,9 +684,10 @@ public function loadHelpers() {
* array of data. Handles parent/extended views.
*
* @param string $viewFile Filename of the view
* @param array $data Data to include in rendered view. If empty the current View::$viewVars will be used.
* @param array $data Data to include in rendered view. If empty the current
* View::$viewVars will be used.
* @return string Rendered output
* @throws \Cake\Core\Exception\Exception when a block is left open.
* @throws \LogicException When a block is left open.
*/
protected function _render($viewFile, $data = array()) {
if (empty($data)) {
@@ -717,7 +719,7 @@ protected function _render($viewFile, $data = array()) {
$remainingBlocks = count($this->Blocks->unclosed());
if ($initialBlocks !== $remainingBlocks) {
throw new Exception(sprintf(
throw new LogicException(sprintf(
'The "%s" block was left open. Blocks are not allowed to cross files.',
$this->Blocks->active()
));
@@ -774,7 +776,7 @@ public function addHelper($helperName, array $config = []) {
*
* @param string $name Controller action to find template filename for
* @return string Template filename
* @throws \Cake\View\Error\MissingViewException when a view file could not be found.
* @throws \Cake\View\Exception\MissingViewException when a view file could not be found.
*/
protected function _getViewFileName($name = null) {
$subDir = null;
@@ -809,7 +811,7 @@ protected function _getViewFileName($name = null) {
return $this->_checkFilePath($path . $name . $this->_ext, $path);
}
}
throw new Error\MissingViewException(array('file' => $name . $this->_ext));
throw new Exception\MissingViewException(array('file' => $name . $this->_ext));
}
/**
@@ -821,16 +823,18 @@ protected function _getViewFileName($name = null) {
* @param string $file The path to the template file.
* @param string $path Base path that $file should be inside of.
* @return string The file path
* @throws \Cake\Core\Exception\Exception
* @throws \InvalidArgumentException
*/
protected function _checkFilePath($file, $path) {
if (strpos($file, '..') === false) {
return $file;
}
$absolute = realpath($file);
if (strpos($absolute, $path) !== 0) {
$msg = sprintf('Cannot use "%s" as a template, it is not within any view template path.', $file);
throw new Exception($msg);
throw new InvalidArgumentException(sprintf(
'Cannot use "%s" as a template, it is not within any view template path.',
$file
));
}
return $absolute;
}
@@ -862,7 +866,7 @@ public function pluginSplit($name, $fallback = true) {
*
* @param string $name The name of the layout to find.
* @return string Filename for layout file (.ctp).
* @throws \Cake\View\Error\MissingLayoutException when a layout cannot be located
* @throws \Cake\View\Exception\MissingLayoutException when a layout cannot be located
*/
protected function _getLayoutFileName($name = null) {
if ($name === null) {
@@ -891,7 +895,7 @@ protected function _getLayoutFileName($name = null) {
}
}
}
throw new Error\MissingLayoutException(array(
throw new Exception\MissingLayoutException(array(
'file' => $layoutPaths[0] . $name . $this->_ext
));
}
@@ -21,7 +21,7 @@
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\TestSuite\TestCase;
use Cake\View\Error\MissingViewException;
use Cake\View\Exception\MissingViewException;
use TestApp\Controller\PagesController;
/**
@@ -60,7 +60,7 @@ public function testMissingView() {
/**
* Test that missing view in debug mode renders missing_view error page
*
* @expectedException \Cake\View\Error\MissingViewException
* @expectedException \Cake\View\Exception\MissingViewException
* @expectedExceptionCode 500
* @return void
*/
@@ -37,9 +37,9 @@
use Cake\ORM\Error\MissingBehaviorException;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use Cake\View\Error\MissingHelperException;
use Cake\View\Error\MissingLayoutException;
use Cake\View\Error\MissingViewException;
use Cake\View\Exception\MissingHelperException;
use Cake\View\Exception\MissingLayoutException;
use Cake\View\Exception\MissingViewException;
/**
* BlueberryComponent class
@@ -22,7 +22,7 @@
use Cake\Network\Email\Email;
use Cake\TestSuite\TestCase;
use Cake\Utility\File;
use Cake\View\Error\MissingViewException;
use Cake\View\Exception\MissingViewException;
/**
* Help to test Email
@@ -1631,7 +1631,7 @@ public function testSendRenderPlugin() {
$this->assertContains('Here is your value: 12345', $result['message']);
$this->assertContains('This email was sent using the TestPlugin.', $result['message']);
$this->setExpectedException('Cake\View\Error\MissingViewException');
$this->setExpectedException('Cake\View\Exception\MissingViewException');
$this->CakeEmail->template('test_plugin_tpl', 'plug_default')->send();
}
@@ -136,7 +136,7 @@ public function testCellManualRender() {
/**
* Tests manual render() invocation with error
*
* @expectedException \Cake\View\Error\MissingCellViewException
* @expectedException \Cake\View\Exception\MissingCellViewException
* @return void
*/
public function testCellManualRenderError() {
@@ -193,7 +193,7 @@ public function testPluginCellAlternateTemplateRenderParam() {
/**
* Tests that using an unexisting cell throws an exception.
*
* @expectedException \Cake\View\Error\MissingCellException
* @expectedException \Cake\View\Exception\MissingCellException
* @return void
*/
public function testUnexistingCell() {
@@ -95,7 +95,7 @@ public function testLazyLoad() {
/**
* test lazy loading of helpers
*
* @expectedException \Cake\View\Error\MissingHelperException
* @expectedException \Cake\View\Exception\MissingHelperException
* @return void
*/
public function testLazyLoadException() {
@@ -161,7 +161,7 @@ public function testLoadWithEnabledFalse() {
/**
* test missinghelper exception
*
* @expectedException \Cake\View\Error\MissingHelperException
* @expectedException \Cake\View\Exception\MissingHelperException
* @return void
*/
public function testLoadMissingHelper() {
@@ -662,7 +662,7 @@ public function testGetLayoutFileNameDirectoryTraversal() {
/**
* Test for missing views
*
* @expectedException \Cake\View\Error\MissingViewException
* @expectedException \Cake\View\Exception\MissingViewException
* @return void
*/
public function testMissingView() {
@@ -680,7 +680,7 @@ public function testMissingView() {
/**
* Test for missing layouts
*
* @expectedException \Cake\View\Error\MissingLayoutException
* @expectedException \Cake\View\Exception\MissingLayoutException
* @return void
*/
public function testMissingLayout() {
@@ -762,7 +762,7 @@ public function testElement() {
/**
* Test elementInexistent method
*
* @expectedException Cake\View\Error\MissingElementException
* @expectedException Cake\View\Exception\MissingElementException
* @return void
*/
public function testElementInexistent() {
@@ -772,7 +772,7 @@ public function testElementInexistent() {
/**
* Test elementInexistent3 method
*
* @expectedException Cake\View\Error\MissingElementException
* @expectedException Cake\View\Exception\MissingElementException
* @return void
*/
public function testElementInexistent3() {
@@ -21,7 +21,7 @@
use Cake\Core\Configure;
use Cake\Network\Exception\NotFoundException;
use Cake\Utility\Inflector;
use Cake\View\Error\MissingViewException;
use Cake\View\Exception\MissingViewException;
/**
* Static content controller
@@ -52,7 +52,7 @@ class PagesController extends AppController {
* @param mixed What page to display
* @return void
* @throws Cake\Network\Exception\NotFoundException When the view file could not be found
* or Cake\View\Error\MissingViewException in debug mode.
* or Cake\View\Exception\MissingViewException in debug mode.
*/
public function display() {
$path = func_get_args();

0 comments on commit c1b5187

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