Using plugin name on exception thrown and in templates files.

This commit is contained in:
Renan Gonçalves 2011-10-16 13:40:36 +02:00
parent 229bf8e984
commit 573a349209
11 changed files with 29 additions and 17 deletions

View file

@ -116,7 +116,8 @@ 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 MissingBehaviorException(array( throw new MissingBehaviorException(array(
'class' => $class 'class' => $class,
'plugin' => substr($plugin, 0, -1)
)); ));
} }

View file

@ -170,7 +170,7 @@ class ConnectionManager {
if (!class_exists($conn['classname'])) { if (!class_exists($conn['classname'])) {
throw new MissingDatasourceException(array( throw new MissingDatasourceException(array(
'class' => $conn['classname'], 'class' => $conn['classname'],
'plugin' => $plugin 'plugin' => substr($plugin, 0, -1)
)); ));
} }
return true; return true;

View file

@ -81,7 +81,8 @@ class Dispatcher {
if (!($controller instanceof Controller)) { if (!($controller instanceof Controller)) {
throw new MissingControllerException(array( throw new MissingControllerException(array(
'controller' => Inflector::camelize($request->params['controller']) . 'Controller' 'class' => Inflector::camelize($request->params['controller']) . 'Controller',
'plugin' => empty($request->params['controller']) ? null : Inflector::camelize($request->params['plugin'])
)); ));
} }

View file

@ -423,7 +423,7 @@ class ExceptionRendererTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testMissingController() { public function testMissingController() {
$exception = new MissingControllerException(array('controller' => 'PostsController')); $exception = new MissingControllerException(array('class' => 'PostsController'));
$ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception)); $ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception));
ob_start(); ob_start();
@ -508,7 +508,7 @@ class ExceptionRendererTest extends CakeTestCase {
new MissingDatasourceException(array('class' => 'MyDatasource', 'plugin' => 'MyPlugin')), new MissingDatasourceException(array('class' => 'MyDatasource', 'plugin' => 'MyPlugin')),
array( array(
'/<h2>Missing Datasource<\/h2>/', '/<h2>Missing Datasource<\/h2>/',
'/Datasource class <em>MyDatasource<\/em> could not be found/' '/Datasource class <em>MyPlugin.MyDatasource<\/em> could not be found/'
), ),
500 500
), ),
@ -516,6 +516,7 @@ class ExceptionRendererTest extends CakeTestCase {
new MissingHelperException(array('class' => 'MyCustomHelper')), new MissingHelperException(array('class' => 'MyCustomHelper')),
array( array(
'/<h2>Missing Helper<\/h2>/', '/<h2>Missing Helper<\/h2>/',
'/<em>MyCustomHelper<\/em> could not be found./',
'/Create the class <em>MyCustomHelper<\/em> below in file:/', '/Create the class <em>MyCustomHelper<\/em> below in file:/',
'/(\/|\\\)MyCustomHelper.php/' '/(\/|\\\)MyCustomHelper.php/'
), ),

View file

@ -272,7 +272,10 @@ abstract class ControllerTestCase extends CakeTestCase {
} }
App::uses($controller . 'Controller', $plugin . 'Controller'); App::uses($controller . 'Controller', $plugin . 'Controller');
if (!class_exists($controller.'Controller')) { if (!class_exists($controller.'Controller')) {
throw new MissingControllerException(array('controller' => $controller.'Controller')); throw new MissingControllerException(array(
'class' => $controller . 'Controller',
'plugin' => substr($plugin, 0, -1)
));
} }
ClassRegistry::flush(); ClassRegistry::flush();

View file

@ -15,15 +15,16 @@
* @since CakePHP(tm) v 1.3 * @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
$pluginDot = empty($plugin) ? null : $plugin . '.';
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Behavior'); ?></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', '%s could not be found.', '<em>' . $class . '</em>'); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $pluginDot . $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 below in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'Model' . DS . 'Behavior' . DS . $class . '.php'); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', (empty($plugin) ? APP_DIR . DS : CakePlugin::path($plugin)) . 'Model' . DS . 'Behavior' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php

View file

@ -15,15 +15,16 @@
* @since CakePHP(tm) v 0.10.0.1076 * @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
$pluginDot = empty($plugin) ? null : $plugin . '.';
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Component'); ?></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', '%s could not be found.', '<em>' . $class . '</em>'); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $pluginDot . $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 below in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'Controller' . DS . 'Component' . DS . $class . '.php'); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', (empty($plugin) ? APP_DIR . DS : CakePlugin::path($plugin)) . 'Controller' . DS . 'Component' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php

View file

@ -15,19 +15,20 @@
* @since CakePHP(tm) v 0.10.0.1076 * @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
$pluginDot = empty($plugin) ? null : $plugin . '.';
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Controller'); ?></h2> <h2><?php echo __d('cake_dev', 'Missing Controller'); ?></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', '%s could not be found.', '<em>' . $controller . '</em>'); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $pluginDot . $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 below in file: %s', '<em>' . $controller . '</em>', APP_DIR . DS . 'Controller' . DS . $controller . '.php'); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', (empty($plugin) ? APP_DIR . DS : CakePlugin::path($plugin)) . 'Controller' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
class <?php echo $controller; ?> extends AppController { class <?php echo $class; ?> extends AppController {
} }
</pre> </pre>

View file

@ -15,11 +15,12 @@
* @since CakePHP(tm) v 2.0 * @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
$pluginDot = empty($plugin) ? null : $plugin . '.';
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Datasource'); ?></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 %s could not be found.', '<em>' . $class . '</em>'); ?> <?php echo __d('cake_dev', 'Datasource class %s could not be found.', '<em>' . $pluginDot . $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>

View file

@ -15,15 +15,16 @@
* @since CakePHP(tm) v 0.10.0.1076 * @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
$pluginDot = empty($plugin) ? null : $plugin . '.';
?> ?>
<h2><?php echo __d('cake_dev', 'Missing Helper'); ?></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', '%s could not be found.', '<em>' . $class . '</em>'); ?> <?php echo __d('cake_dev', '%s could not be found.', '<em>' . $pluginDot . $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 below in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'View' . DS . 'Helper' . DS . $class . '.php'); ?> <?php echo __d('cake_dev', 'Create the class %s below in file: %s', '<em>' . $class . '</em>', (empty($plugin) ? APP_DIR . DS : CakePlugin::path($plugin)) . 'View' . DS . 'Helper' . DS . $class . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php

View file

@ -74,7 +74,8 @@ class HelperCollection extends ObjectCollection {
App::uses($helperClass, $plugin . 'View/Helper'); App::uses($helperClass, $plugin . 'View/Helper');
if (!class_exists($helperClass)) { if (!class_exists($helperClass)) {
throw new MissingHelperException(array( throw new MissingHelperException(array(
'class' => $helperClass 'class' => $helperClass,
'plugin' => substr($plugin, 0, -1)
)); ));
} }
$this->_loaded[$alias] = new $helperClass($this->_View, $settings); $this->_loaded[$alias] = new $helperClass($this->_View, $settings);