Little cleanup in exceptions.

- Removed duplicated or non-used exceptions.
- Making the error messages more descriptive and stardard.
This commit is contained in:
Renan Gonçalves 2011-10-15 20:06:31 +02:00
parent 3ed712e745
commit 1cf67b1e55
22 changed files with 89 additions and 271 deletions

View file

@ -201,12 +201,11 @@ class ShellDispatcher {
* *
* @param string $shell Optionally the name of a plugin * @param string $shell Optionally the name of a plugin
* @return mixed An object * @return mixed An object
* @throws MissingShellFileException when errors are encountered. * @throws MissingShellException when errors are encountered.
*/ */
protected function _getShell($shell) { protected function _getShell($shell) {
list($plugin, $shell) = pluginSplit($shell, true); list($plugin, $shell) = pluginSplit($shell, true);
$class = Inflector::camelize($shell) . 'Shell'; $class = Inflector::camelize($shell) . 'Shell';
App::uses('Shell', 'Console'); App::uses('Shell', 'Console');
@ -214,7 +213,9 @@ class ShellDispatcher {
App::uses($class, $plugin . 'Console/Command'); App::uses($class, $plugin . 'Console/Command');
if (!class_exists($class)) { if (!class_exists($class)) {
throw new MissingShellFileException(array('shell' => $shell)); throw new MissingShellException(array(
'class' => $class
));
} }
$Shell = new $class(); $Shell = new $class();
return $Shell; return $Shell;

View file

@ -54,7 +54,7 @@ class TaskCollection extends ObjectCollection {
* @param string $task Task name to load * @param string $task Task name to load
* @param array $settings Settings for the task. * @param array $settings Settings for the task.
* @return Task A task object, Either the existing loaded task or a new one. * @return Task A task object, Either the existing loaded task or a new one.
* @throws MissingTaskFileException, MissingTaskClassException when the task could not be found * @throws MissingTaskException when the task could not be found
*/ */
public function load($task, $settings = array()) { public function load($task, $settings = array()) {
list($plugin, $name) = pluginSplit($task, true); list($plugin, $name) = pluginSplit($task, true);
@ -66,7 +66,9 @@ class TaskCollection extends ObjectCollection {
App::uses($taskClass, $plugin . 'Console/Command/Task'); App::uses($taskClass, $plugin . 'Console/Command/Task');
if (!class_exists($taskClass)) { if (!class_exists($taskClass)) {
if (!class_exists($taskClass)) { if (!class_exists($taskClass)) {
throw new MissingTaskClassException($taskClass); throw new MissingTaskException(array(
'class' => $taskClass
));
} }
} }

View file

@ -73,7 +73,7 @@ class ComponentCollection extends ObjectCollection {
* @param string $component Component name to load * @param string $component Component name to load
* @param array $settings Settings for the component. * @param array $settings Settings for the component.
* @return Component A component object, Either the existing loaded component or a new one. * @return Component A component object, Either the existing loaded component or a new one.
* @throws MissingComponentFileException, MissingComponentClassException when the component could not be found * @throws MissingComponentException when the component could not be found
*/ */
public function load($component, $settings = array()) { public function load($component, $settings = array()) {
if (is_array($settings) && isset($settings['className'])) { if (is_array($settings) && isset($settings['className'])) {
@ -90,8 +90,7 @@ class ComponentCollection extends ObjectCollection {
$componentClass = $name . 'Component'; $componentClass = $name . 'Component';
App::uses($componentClass, $plugin . 'Controller/Component'); App::uses($componentClass, $plugin . 'Controller/Component');
if (!class_exists($componentClass)) { if (!class_exists($componentClass)) {
throw new MissingComponentClassException(array( throw new MissingComponentException(array(
'file' => Inflector::underscore($componentClass) . '.php',
'class' => $componentClass 'class' => $componentClass
)); ));
} }

View file

@ -241,37 +241,23 @@ class PrivateActionException extends CakeException {
} }
/** /**
* Used when a Component file cannot be found. * Used when a component cannot be found.
* *
* @package Cake.Error * @package Cake.Error
*/ */
class MissingComponentFileException extends CakeException { class MissingComponentException extends CakeException {
protected $_messageTemplate = 'Component file "%s" is missing.'; protected $_messageTemplate = 'Component class %s could not be found.';
} }
/** /**
* Used when a Component class cannot be found. * Used when a behavior cannot be found.
* *
* @package Cake.Error * @package Cake.Error
*/ */
class MissingComponentClassException extends CakeException { class MissingBehaviorException extends CakeException {
protected $_messageTemplate = 'Component class "%s" is missing.'; protected $_messageTemplate = 'Behavior class %s could not be found.';
} }
/**
* Used when a Behavior file cannot be found.
*
* @package Cake.Error
*/
class MissingBehaviorFileException extends CakeException { }
/**
* Used when a Behavior class cannot be found.
*
* @package Cake.Error
*/
class MissingBehaviorClassException extends CakeException { }
/** /**
* Used when a view file cannot be found. * Used when a view file cannot be found.
* *
@ -291,24 +277,14 @@ class MissingLayoutException extends CakeException {
} }
/** /**
* Used when a helper file cannot be found. * Used when a helper cannot be found.
* *
* @package Cake.Error * @package Cake.Error
*/ */
class MissingHelperFileException extends CakeException { class MissingHelperException extends CakeException {
protected $_messageTemplate = 'Helper file "%s" is missing.'; protected $_messageTemplate = 'Helper class %s could not be found.';
} }
/**
* Used when a helper class cannot be found.
*
* @package Cake.Error
*/
class MissingHelperClassException extends CakeException {
protected $_messageTemplate = 'Helper class "%s" is missing.';
}
/** /**
* Runtime Exceptions for ConnectionManager * Runtime Exceptions for ConnectionManager
* *
@ -328,21 +304,12 @@ class MissingConnectionException extends CakeException {
} }
/** /**
* Used when a Task file cannot be found. * Used when a Task cannot be found.
* *
* @package Cake.Error * @package Cake.Error
*/ */
class MissingTaskFileException extends CakeException { class MissingTaskException extends CakeException {
protected $_messageTemplate = 'Task file "%s" is missing.'; protected $_messageTemplate = 'Task class %s could not be found.';
}
/**
* Used when a Task class cannot be found.
*
* @package Cake.Error
*/
class MissingTaskClassException extends CakeException {
protected $_messageTemplate = 'Task class "%s" is missing.';
} }
/** /**
@ -355,21 +322,12 @@ class MissingShellMethodException extends CakeException {
} }
/** /**
* Used when a shell class cannot be found. * Used when a shell cannot be found.
* *
* @package Cake.Error * @package Cake.Error
*/ */
class MissingShellClassException extends CakeException { class MissingShellException extends CakeException {
protected $_messageTemplate = "Shell class %s could not be loaded."; protected $_messageTemplate = 'Shell class %s could not be found.';
}
/**
* Used when a shell file cannot be found.
*
* @package Cake.Error
*/
class MissingShellFileException extends CakeException {
protected $_messageTemplate = "Shell file %s could not be loaded.";
} }
/** /**
@ -382,12 +340,12 @@ class MissingDatasourceConfigException extends CakeException {
} }
/** /**
* Exception class to be thrown when a datasource is not found * Used when a datasource cannot be found.
* *
* @package Cake.Error * @package Cake.Error
*/ */
class MissingDatasourceFileException extends CakeException { class MissingDatasourceException extends CakeException {
protected $_messageTemplate = 'Datasource "%s" was not found.'; protected $_messageTemplate = 'Datasource class %s could not be found.';
} }
/** /**

View file

@ -99,7 +99,7 @@ class BehaviorCollection extends ObjectCollection {
* @param string $behavior CamelCased name of the behavior to load * @param string $behavior CamelCased name of the behavior to load
* @param array $config Behavior configuration parameters * @param array $config Behavior configuration parameters
* @return boolean True on success, false on failure * @return boolean True on success, false on failure
* @throws MissingBehaviorClassException when a behavior could not be found. * @throws MissingBehaviorException when a behavior could not be found.
*/ */
public function load($behavior, $config = array()) { public function load($behavior, $config = array()) {
if (is_array($config) && isset($config['className'])) { if (is_array($config) && isset($config['className'])) {
@ -115,8 +115,7 @@ class BehaviorCollection extends ObjectCollection {
App::uses($class, $plugin . 'Model/Behavior'); App::uses($class, $plugin . 'Model/Behavior');
if (!class_exists($class)) { if (!class_exists($class)) {
throw new MissingBehaviorClassException(array( throw new MissingBehaviorException(array(
'file' => Inflector::underscore($behavior) . '.php',
'class' => $class 'class' => $class
)); ));
} }

View file

@ -75,7 +75,7 @@ class ConnectionManager {
* @param string $name The name of the DataSource, as defined in app/Config/database.php * @param string $name The name of the DataSource, as defined in app/Config/database.php
* @return DataSource Instance * @return DataSource Instance
* @throws MissingDatasourceConfigException * @throws MissingDatasourceConfigException
* @throws MissingDatasourceFileException * @throws MissingDatasourceException
*/ */
public static function getDataSource($name) { public static function getDataSource($name) {
if (empty(self::$_init)) { if (empty(self::$_init)) {
@ -141,7 +141,7 @@ class ConnectionManager {
* or an array containing the filename (without extension) and class name of the object, * or an array containing the filename (without extension) and class name of the object,
* to be found in app/Model/Datasource/ or lib/Cake/Model/Datasource/. * to be found in app/Model/Datasource/ or lib/Cake/Model/Datasource/.
* @return boolean True on success, null on failure or false if the class is already loaded * @return boolean True on success, null on failure or false if the class is already loaded
* @throws MissingDatasourceFileException * @throws MissingDatasourceException
*/ */
public static function loadDataSource($connName) { public static function loadDataSource($connName) {
if (empty(self::$_init)) { if (empty(self::$_init)) {
@ -168,7 +168,10 @@ class ConnectionManager {
App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package);
if (!class_exists($conn['classname'])) { if (!class_exists($conn['classname'])) {
throw new MissingDatasourceFileException(array('class' => $conn['classname'], 'plugin' => $plugin)); throw new MissingDatasourceException(array(
'class' => $conn['classname'],
'plugin' => $plugin
));
} }
return true; return true;
} }

View file

@ -70,12 +70,12 @@ class TaskCollectionTest extends CakeTestCase {
$this->assertFalse($this->Tasks->enabled('DbConfig'), 'DbConfigTask should be disabled'); $this->assertFalse($this->Tasks->enabled('DbConfig'), 'DbConfigTask should be disabled');
} }
/** /**
* test missinghelper exception * test missingtask exception
* *
* @expectedException MissingTaskClassException * @expectedException MissingTaskException
* @return void * @return void
*/ */
public function testLoadMissingTaskFile() { public function testLoadMissingTask() {
$result = $this->Tasks->load('ThisTaskShouldAlwaysBeMissing'); $result = $this->Tasks->load('ThisTaskShouldAlwaysBeMissing');
} }

View file

@ -111,10 +111,10 @@ class ComponentCollectionTest extends CakeTestCase {
/** /**
* test missingcomponent exception * test missingcomponent exception
* *
* @expectedException MissingComponentClassException * @expectedException MissingComponentException
* @return void * @return void
*/ */
public function testLoadMissingComponentFile() { public function testLoadMissingComponent() {
$this->Components->load('ThisComponentShouldAlwaysBeMissing'); $this->Components->load('ThisComponentShouldAlwaysBeMissing');
} }

View file

@ -505,62 +505,36 @@ class ExceptionRendererTest extends CakeTestCase {
500 500
), ),
array( array(
new MissingDatasourceFileException(array('class' => 'MyDatasource', 'plugin' => 'MyPlugin')), new MissingDatasourceException(array('class' => 'MyDatasource', 'plugin' => 'MyPlugin')),
array( array(
'/<h2>Missing Datasource Class<\/h2>/', '/<h2>Missing Datasource<\/h2>/',
'/Datasource class <em>MyDatasource<\/em> was not found/' '/Datasource class <em>MyDatasource<\/em> could not be found/'
), ),
500 500
), ),
array( array(
new MissingHelperFileException(array('file' => 'MyCustomHelper.php', 'class' => 'MyCustomHelper')), new MissingHelperException(array('class' => 'MyCustomHelper')),
array( array(
'/<h2>Missing Helper File<\/h2>/', '/<h2>Missing Helper<\/h2>/',
'/Create the class below in file:/', '/Create the class <em>MyCustomHelper<\/em> below in file:/',
'/(\/|\\\)MyCustomHelper.php/' '/(\/|\\\)MyCustomHelper.php/'
), ),
500 500
), ),
array( array(
new MissingHelperClassException(array('file' => 'MyCustomHelper.php', 'class' => 'MyCustomHelper')), new MissingBehaviorException(array('class' => 'MyCustomBehavior')),
array( array(
'/<h2>Missing Helper Class<\/h2>/', '/<h2>Missing Behavior<\/h2>/',
'/The helper class <em>MyCustomHelper<\/em> can not be found or does not exist./', '/Create the class <em>MyCustomBehavior<\/em> below in file:/',
'/(\/|\\\)MyCustomHelper.php/',
),
500
),
array(
new MissingBehaviorFileException(array('file' => 'MyCustomBehavior.php', 'class' => 'MyCustomBehavior')),
array(
'/<h2>Missing Behavior File<\/h2>/',
'/Create the class below in file:/',
'/(\/|\\\)MyCustomBehavior.php/',
),
500
),
array(
new MissingBehaviorClassException(array('file' => 'MyCustomBehavior.php', 'class' => 'MyCustomBehavior')),
array(
'/The behavior class <em>MyCustomBehavior<\/em> can not be found or does not exist./',
'/(\/|\\\)MyCustomBehavior.php/' '/(\/|\\\)MyCustomBehavior.php/'
), ),
500 500
), ),
array( array(
new MissingComponentFileException(array('file' => 'SideboxComponent.php', 'class' => 'SideboxComponent')), new MissingComponentException(array('class' => 'SideboxComponent')),
array( array(
'/<h2>Missing Component File<\/h2>/', '/<h2>Missing Component<\/h2>/',
'/Create the class <em>SideboxComponent<\/em> in file:/', '/Create the class <em>SideboxComponent<\/em> below in file:/',
'/(\/|\\\)SideboxComponent.php/'
),
500
),
array(
new MissingComponentClassException(array('file' => 'SideboxComponent.php', 'class' => 'SideboxComponent')),
array(
'/<h2>Missing Component Class<\/h2>/',
'/Create the class <em>SideboxComponent<\/em> in file:/',
'/(\/|\\\)SideboxComponent.php/' '/(\/|\\\)SideboxComponent.php/'
), ),
500 500
@ -620,7 +594,7 @@ class ExceptionRendererTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testMissingRenderSafe() { public function testMissingRenderSafe() {
$exception = new MissingHelperFileException(array('class' => 'Fail')); $exception = new MissingHelperException(array('class' => 'Fail'));
$ExceptionRenderer = new ExceptionRenderer($exception); $ExceptionRenderer = new ExceptionRenderer($exception);
$ExceptionRenderer->controller = $this->getMock('Controller'); $ExceptionRenderer->controller = $this->getMock('Controller');
@ -628,7 +602,7 @@ class ExceptionRendererTest extends CakeTestCase {
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest'); $ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
$ExceptionRenderer->controller->expects($this->at(2)) $ExceptionRenderer->controller->expects($this->at(2))
->method('render') ->method('render')
->with('missingHelperFile') ->with('missingHelper')
->will($this->throwException($exception)); ->will($this->throwException($exception));
$ExceptionRenderer->controller->expects($this->at(3)) $ExceptionRenderer->controller->expects($this->at(3))

View file

@ -538,7 +538,7 @@ class BehaviorCollectionTest extends CakeTestCase {
/** /**
* test that attaching a non existant Behavior triggers a cake error. * test that attaching a non existant Behavior triggers a cake error.
* *
* @expectedException MissingBehaviorClassException * @expectedException MissingBehaviorException
* @return void * @return void
*/ */
public function testInvalidBehaviorCausingCakeError() { public function testInvalidBehaviorCausingCakeError() {

View file

@ -224,7 +224,7 @@ class ConnectionManagerTest extends CakeTestCase {
* testLoadDataSourceException() method * testLoadDataSourceException() method
* *
* @return void * @return void
* @expectedException MissingDatasourceFileException * @expectedException MissingDatasourceException
*/ */
public function testLoadDataSourceException() { public function testLoadDataSourceException() {
$connection = array('classname' => 'NonExistentDataSource', 'filename' => 'non_existent'); $connection = array('classname' => 'NonExistentDataSource', 'filename' => 'non_existent');

View file

@ -109,10 +109,10 @@ class HelperCollectionTest extends CakeTestCase {
/** /**
* test missinghelper exception * test missinghelper exception
* *
* @expectedException MissingHelperClassException * @expectedException MissingHelperException
* @return void * @return void
*/ */
public function testLoadMissingHelperFile() { public function testLoadMissingHelper() {
$result = $this->Helpers->load('ThisHelperShouldAlwaysBeMissing'); $result = $this->Helpers->load('ThisHelperShouldAlwaysBeMissing');
} }

View file

@ -315,14 +315,14 @@ abstract class ControllerTestCase extends CakeTestCase {
$methods = array(); $methods = array();
} }
list($plugin, $name) = pluginSplit($component, true); list($plugin, $name) = pluginSplit($component, true);
App::uses($name . 'Component', $plugin . 'Controller/Component'); $componentClass = $name . 'Component';
if (!class_exists($name . 'Component')) { App::uses($componentClass, $plugin . 'Controller/Component');
throw new MissingComponentFileException(array( if (!class_exists($componentClass)) {
'file' => $name . 'Component.php', throw new MissingComponentException(array(
'class' => $name.'Component' 'class' => $componentClass
)); ));
} }
$_component = $this->getMock($name.'Component', $methods, array(), '', false); $_component = $this->getMock($componentClass, $methods, array(), '', false);
$_controller->Components->set($name, $_component); $_controller->Components->set($name, $_component);
} }

View file

@ -16,24 +16,24 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Behavior Class'); ?></h2> <h2><?php echo __d('cake_dev', 'Missing Behavior'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The behavior class <em>%s</em> can not be found or does not exist.', $class); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $class . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Create the class below in file: %s', APP_DIR . DS . 'Model' . DS . 'Behavior' . DS . Inflector::camelize($file)); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'Model' . DS . 'Behavior' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
class <?php echo $class;?> extends ModelBehavior { class <?php echo $class; ?> extends ModelBehavior {
} }
</pre> </pre>
<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_behavior_class.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_behavior.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -1,39 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.errors
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php echo __d('cake_dev', 'Missing Behavior File'); ?></h2>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The Behavior file %s can not be found or does not exist.', APP_DIR . DS . 'Model' . DS . 'Behavior' . DS . Inflector::camelize($file)); ?>
</p>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Create the class below in file: %s', APP_DIR . DS . 'Model' . DS . 'Behavior' . DS . Inflector::camelize($file)); ?>
</p>
<pre>
&lt;?php
class <?php echo $class;?> extends ModelBehavior {
}
</pre>
<p class="notice">
<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_behavior_file.ctp'); ?>
</p>
<?php echo $this->element('exception_stack_trace'); ?>

View file

@ -16,24 +16,24 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Component File'); ?></h2> <h2><?php echo __d('cake_dev', 'Missing Component'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The component file was not found.'); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $class . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Create the class %s in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'Controller' . DS . 'Component' . DS . Inflector::camelize($file)); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'Controller' . DS . 'Component' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
class <?php echo $class;?> extends Component {<br /> class <?php echo $class; ?> extends Component {
} }
</pre> </pre>
<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_component_file.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_component.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -1,39 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.errors
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php echo __d('cake_dev', 'Missing Component Class'); ?></h2>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Component class %1$s was not found.', '<em>' . $class . '</em>'); ?>
</p>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Create the class %s in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'Controller' . DS . 'Component' . DS . Inflector::camelize($file)); ?>
</p>
<pre>
&lt;?php
class <?php echo $class;?> extends Component {<br />
}
</pre>
<p class="notice">
<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_component_class.ctp'); ?>
</p>
<?php echo $this->element('exception_stack_trace'); ?>

View file

@ -27,7 +27,7 @@
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
class <?php echo $controller;?> extends AppController { class <?php echo $controller; ?> extends AppController {
} }
</pre> </pre>

View file

@ -16,14 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Datasource Class'); ?></h2> <h2><?php echo __d('cake_dev', 'Missing Datasource'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Datasource class %1$s was not found.', '<em>' . $class . '</em>'); ?> <?php echo __d('cake_dev', 'Datasource class %s could not be found.', '<em>' . $class . '</em>'); ?>
</p> </p>
<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_datasource_file.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_datasource.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -16,24 +16,24 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Helper Class'); ?></h2> <h2><?php echo __d('cake_dev', 'Missing Helper'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The helper class <em>%s</em> can not be found or does not exist.', $class); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $class . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong> <strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Create the class below in file: %s', APP_DIR . DS . 'View' . DS . 'Helper' . DS . Inflector::camelize($file)); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'View' . DS . 'Helper' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
class <?php echo $class;?> extends AppHelper { class <?php echo $class; ?> extends AppHelper {
} }
</pre> </pre>
<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_helper_class.ctp'); ?> <?php echo __d('cake_dev', 'If you want to customize this error message, create %s', APP_DIR . DS . 'View' . DS . 'Errors' . DS . 'missing_helper.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -1,39 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.errors
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php echo __d('cake_dev', 'Missing Helper File'); ?></h2>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'The helper file %s can not be found or does not exist.', APP_DIR . DS . 'View' . DS . 'Helper' . DS . Inflector::camelize($file)); ?>
</p>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Create the class below in file: %s', APP_DIR . DS . 'View' . DS . 'Helper' . DS . Inflector::camelize($file)); ?>
</p>
<pre>
&lt;?php
class <?php echo $class;?> extends AppHelper {
}
</pre>
<p class="notice">
<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_helper_file.ctp'); ?>
</p>
<?php echo $this->element('exception_stack_trace'); ?>

View file

@ -55,7 +55,7 @@ class HelperCollection extends ObjectCollection {
* @param string $helper Helper name to load * @param string $helper Helper name to load
* @param array $settings Settings for the helper. * @param array $settings Settings for the helper.
* @return Helper A helper object, Either the existing loaded helper or a new one. * @return Helper A helper object, Either the existing loaded helper or a new one.
* @throws MissingHelperFileException, MissingHelperClassException when the helper could not be found * @throws MissingHelperException when the helper could not be found
*/ */
public function load($helper, $settings = array()) { public function load($helper, $settings = array()) {
if (is_array($settings) && isset($settings['className'])) { if (is_array($settings) && isset($settings['className'])) {
@ -73,9 +73,8 @@ class HelperCollection extends ObjectCollection {
$helperClass = $name . 'Helper'; $helperClass = $name . 'Helper';
App::uses($helperClass, $plugin . 'View/Helper'); App::uses($helperClass, $plugin . 'View/Helper');
if (!class_exists($helperClass)) { if (!class_exists($helperClass)) {
throw new MissingHelperClassException(array( throw new MissingHelperException(array(
'class' => $helperClass, 'class' => $helperClass
'file' => $helperClass . '.php'
)); ));
} }
$this->_loaded[$alias] = new $helperClass($this->_View, $settings); $this->_loaded[$alias] = new $helperClass($this->_View, $settings);