Skip to content

Commit

Permalink
Removing uses of App::uses
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Sep 9, 2012
1 parent 74b6f1e commit 463cec7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
4 changes: 3 additions & 1 deletion App/Console/Command/AppShell.php
Expand Up @@ -16,7 +16,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('Shell', 'Console');
namespace App\Console\Command;

use Cake\Console\Shell;

/**
* Application Shell
Expand Down
4 changes: 3 additions & 1 deletion App/View/Helper/AppHelper.php
Expand Up @@ -20,7 +20,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('Helper', 'View');
namespace App\View\Helper;

use Cake\View\Helper;

/**
* Application helper
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Console/Command/ConsoleShell.php
Expand Up @@ -57,7 +57,6 @@ public function startup() {
foreach ($this->models as $model) {
$class = $model;
$this->models[$model] = $class;
App::uses($class, 'Model');
$this->{$class} = new $class();
}
$this->out(__d('cake_console', 'Model classes:'));
Expand Down
14 changes: 4 additions & 10 deletions lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -59,7 +59,7 @@ class TestTask extends BakeTask {

/**
* Mapping between packages, and their baseclass + package.
* This is used to generate App::uses() call to autoload base
* This is used to generate App::classname() call to autoload base
* classes if a developer has forgotten to do so.
*
* @var array
Expand Down Expand Up @@ -258,14 +258,8 @@ public function typeCanDetectFixtures($type) {
* @return boolean
*/
public function isLoadableClass($package, $class) {
App::uses($class, $package);
list($plugin, $ns) = pluginSplit($package);
if ($plugin) {
App::uses("{$plugin}AppController", $package);
App::uses("{$plugin}AppModel", $package);
App::uses("{$plugin}AppHelper", $package);
}
return class_exists($class);
$classname = App::classname($class, $package);
return !empty($classname);
}

/**
Expand Down Expand Up @@ -309,7 +303,7 @@ public function getRealClassName($type, $class) {
}

/**
* Map the types that TestTask uses to concrete types that App::uses can use.
* Map the types that TestTask uses to concrete types that App::classname can use.
*
* @param string $type The type of thing having a test generated.
* @param string $plugin The plugin name.
Expand Down
5 changes: 1 addition & 4 deletions lib/Cake/Core/App.php
Expand Up @@ -472,10 +472,7 @@ public static function objects($type, $path = null, $cache = true) {
}

/**
* Method to handle the automatic class loading. It will look for each class' package
* defined using App::uses() and with this information it will resolve the package name to a full path
* to load the class from. File name for each class should follow the class name. For instance,
* if a class is name `MyCustomClass` the file name should be `MyCustomClass.php`
* Method to handle the class loading manually, ie. Vendor classes.
*
* @param string $className the name of the class to load
* @return boolean
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Network/Email/Email.php
Expand Up @@ -1529,10 +1529,10 @@ protected function _renderTemplates($content) {
return $rendered;
}
$viewClass = $this->_viewRender;
if ($viewClass !== 'View') {
list($plugin, $viewClass) = pluginSplit($viewClass, true);
$viewClass .= 'View';
App::uses($viewClass, $plugin . 'View');
if ($viewClass === 'View') {
$viewClass = App::classname('View', 'View');
} else {
$viewClass = App::classname($viewClass, 'View', 'View');
}

$View = new $viewClass(null);
Expand Down

0 comments on commit 463cec7

Please sign in to comment.