Browse Source

Move MissingHelperException, MissingLayoutException to View/Error

ADmad 12 years ago
parent
commit
60f3eb9660

+ 3 - 1
src/Error/MissingHelperException.php

@@ -15,7 +15,9 @@
  * @since         3.0.0
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-namespace Cake\Error;
+namespace Cake\View\Error;
+
+use Cake\Error\Exception;
 
 /**
  * Used when a helper cannot be found.

+ 3 - 1
src/Error/MissingLayoutException.php

@@ -15,7 +15,9 @@
  * @since         3.0.0
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-namespace Cake\Error;
+namespace Cake\View\Error;
+
+use Cake\Error\Exception;
 
 /**
  * Used when a layout file cannot be found.

+ 2 - 3
src/View/HelperRegistry.php

@@ -15,7 +15,6 @@
 namespace Cake\View;
 
 use Cake\Core\App;
-use Cake\Error;
 use Cake\Event\EventManager;
 use Cake\Utility\ObjectRegistry;
 use Cake\View\View;
@@ -59,7 +58,7 @@ class HelperRegistry extends ObjectRegistry {
  *
  * @param string $helper The helper name to be loaded
  * @return boolean whether the helper could be loaded or not
- * @throws \Cake\Error\MissingHelperException When a helper could not be found.
+ * @throws \Cake\View\Error\MissingHelperException When a helper could not be found.
  *    App helpers are searched, and then plugin helpers.
  */
 	public function __isset($helper) {
@@ -118,7 +117,7 @@ class HelperRegistry extends ObjectRegistry {
  *
  * @param string $class The classname that is missing.
  * @param string $plugin The plugin the helper is missing in.
- * @throws \Cake\Error\MissingHelperException
+ * @throws \Cake\View\Error\MissingHelperException
  */
 	protected function _throwMissingClassError($class, $plugin) {
 		throw new Error\MissingHelperException([

+ 5 - 5
src/View/View.php

@@ -20,7 +20,7 @@ use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Object;
 use Cake\Core\Plugin;
-use Cake\Error;
+use Cake\Error\Exception;
 use Cake\Event\Event;
 use Cake\Event\EventManager;
 use Cake\Network\Request;
@@ -29,7 +29,7 @@ use Cake\Routing\RequestActionTrait;
 use Cake\Routing\Router;
 use Cake\Utility\Inflector;
 use Cake\Utility\ViewVarsTrait;
-use Cake\View\Error\MissingViewException;
+use Cake\View\Error;
 
 /**
  * View, the V in the MVC triad. View interacts with Helpers and view variables passed
@@ -881,7 +881,7 @@ class View extends Object {
 		$remainingBlocks = count($this->Blocks->unclosed());
 
 		if ($initialBlocks !== $remainingBlocks) {
-			throw new Error\Exception(sprintf(
+			throw new Exception(sprintf(
 				'The "%s" block was left open. Blocks are not allowed to cross files.',
 				$this->Blocks->active()
 			));
@@ -987,7 +987,7 @@ class View extends Object {
 				}
 			}
 		}
-		throw new MissingViewException(array('file' => $defaultPath . $name . $this->_ext));
+		throw new Error\MissingViewException(array('file' => $defaultPath . $name . $this->_ext));
 	}
 
 /**
@@ -1017,7 +1017,7 @@ class View extends Object {
  *
  * @param string $name The name of the layout to find.
  * @return string Filename for layout file (.ctp).
- * @throws \Cake\Error\MissingLayoutException when a layout cannot be located
+ * @throws \Cake\View\Error\MissingLayoutException when a layout cannot be located
  */
 	protected function _getLayoutFileName($name = null) {
 		if ($name === null) {

+ 5 - 3
tests/TestCase/Error/ExceptionRendererTest.php

@@ -26,6 +26,8 @@ use Cake\Event\Event;
 use Cake\Network\Request;
 use Cake\Routing\Router;
 use Cake\TestSuite\TestCase;
+use Cake\View\Error\MissingHelperException;
+use Cake\View\Error\MissingLayoutException;
 use Cake\View\Error\MissingViewException;
 
 /**
@@ -518,7 +520,7 @@ class ExceptionRendererTest extends TestCase {
 				500
 			),
 			array(
-				new Error\MissingLayoutException(array('file' => 'layouts/my_layout.ctp')),
+				new MissingLayoutException(array('file' => 'layouts/my_layout.ctp')),
 				array(
 					"/Missing Layout/",
 					"/layouts\/my_layout.ctp/"
@@ -526,7 +528,7 @@ class ExceptionRendererTest extends TestCase {
 				500
 			),
 			array(
-				new Error\MissingHelperException(array('class' => 'MyCustomHelper')),
+				new MissingHelperException(array('class' => 'MyCustomHelper')),
 				array(
 					'/<h2>Missing Helper<\/h2>/',
 					'/<em>MyCustomHelper<\/em> could not be found./',
@@ -608,7 +610,7 @@ class ExceptionRendererTest extends TestCase {
  * @return void
  */
 	public function testMissingRenderSafe() {
-		$exception = new Error\MissingHelperException(array('class' => 'Fail'));
+		$exception = new MissingHelperException(array('class' => 'Fail'));
 		$ExceptionRenderer = new ExceptionRenderer($exception);
 
 		$ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', array('render'));

+ 2 - 2
tests/TestCase/View/HelperRegistryTest.php

@@ -95,7 +95,7 @@ class HelperRegistryTest extends TestCase {
 /**
  * test lazy loading of helpers
  *
- * @expectedException \Cake\Error\MissingHelperException
+ * @expectedException \Cake\View\Error\MissingHelperException
  * @return void
  */
 	public function testLazyLoadException() {
@@ -161,7 +161,7 @@ class HelperRegistryTest extends TestCase {
 /**
  * test missinghelper exception
  *
- * @expectedException \Cake\Error\MissingHelperException
+ * @expectedException \Cake\View\Error\MissingHelperException
  * @return void
  */
 	public function testLoadMissingHelper() {

+ 1 - 2
tests/TestCase/View/ViewTest.php

@@ -22,7 +22,6 @@ use Cake\Core\Plugin;
 use Cake\Network\Request;
 use Cake\Routing\Router;
 use Cake\TestSuite\TestCase;
-use Cake\View\Error\MissingViewException;
 use Cake\View\Helper;
 use Cake\View\View;
 
@@ -557,7 +556,7 @@ class ViewTest extends TestCase {
 /**
  * Test for missing layouts
  *
- * @expectedException \Cake\Error\MissingLayoutException
+ * @expectedException \Cake\View\Error\MissingLayoutException
  * @return void
  */
 	public function testMissingLayout() {