Skip to content

Commit b8344ec

Browse files
committed
Replacing some of the App::import by App::uses
1 parent 848461f commit b8344ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+131
-151
lines changed

lib/Cake/Console/Command/AclShell.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* @since CakePHP(tm) v 1.2.0.5012
1818
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1919
*/
20-
App::import('Component', 'Acl');
21-
App::import('Model', 'DbAcl');
20+
App::uses('AclComponent', 'Controller/Component');
21+
App::uses('DbAcl', 'Model');
2222

2323
/**
2424
* Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode

lib/Cake/Console/Command/ApiShell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @since CakePHP(tm) v 1.2.0.5012
2020
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
2121
*/
22-
App::import('Core', 'File');
22+
App::uses('File', 'Utility');
2323

2424
/**
2525
* API shell to show method signatures of CakePHP core classes.

lib/Cake/Console/Command/BakeShell.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
2323
*/
2424

25+
App::uses('Model', 'Model');
26+
2527
/**
2628
* Bake is a command-line code generation utility for automating programmer chores.
2729
*
@@ -151,11 +153,11 @@ public function all() {
151153

152154
$modelExists = false;
153155
$model = $this->_modelName($name);
154-
if (App::import('Model', $model)) {
156+
App::uses($model, 'Model');
157+
if (class_exists($model)) {
155158
$object = new $model();
156159
$modelExists = true;
157160
} else {
158-
App::import('Model', 'Model', false);
159161
$object = new Model(array('name' => $name, 'ds' => $this->connection));
160162
}
161163

@@ -176,7 +178,8 @@ public function all() {
176178
$this->Controller->bakeTest($controller);
177179
}
178180
}
179-
if (App::import('Controller', $controller)) {
181+
App::uses($controller . 'Controller', 'Controller')
182+
if (class_exists($controller . 'Controller')) {
180183
$this->View->args = array($controller);
181184
$this->View->execute();
182185
}

lib/Cake/Console/Command/ConsoleShell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public function initialize() {
5656
App::uses('Dispatcher', 'Routing');
5757
$this->Dispatcher = new Dispatcher();
5858
$this->models = App::objects('model');
59-
App::import('Model', $this->models);
6059

6160
foreach ($this->models as $model) {
6261
$class = Inflector::camelize(str_replace('.php', '', $model));
6362
$this->models[$model] = $class;
63+
App::uses($class, 'Model');
6464
$this->{$class} = new $class();
6565
}
6666
$this->out('Model classes:');

lib/Cake/Console/Command/Task/ControllerTask.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public function all() {
108108
foreach ($this->__tables as $table) {
109109
$model = $this->_modelName($table);
110110
$controller = $this->_controllerName($model);
111-
if (App::import('Model', $model)) {
111+
App::uses($model, 'Model');
112+
if (!class_exists($model)) {
112113
$actions = $this->bakeActions($controller);
113114
if ($this->bake($controller, $actions) && $unitTestExists) {
114115
$this->bakeTest($controller);
@@ -273,7 +274,8 @@ public function bakeActions($controllerName, $admin = null, $wannaUseSession = t
273274
if ($plugin) {
274275
$modelImport = $plugin . '.' . $modelImport;
275276
}
276-
if (!App::import('Model', $modelImport)) {
277+
App::uses($modelImport, 'Model');
278+
if (!class_exists($modelImport)) {
277279
$this->err(__('You must have a model for this class to build basic methods. Please try again.'));
278280
$this->_stop();
279281
}

lib/Cake/Console/Command/Task/DbConfigTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public function bake($configs) {
353353
* @return void
354354
*/
355355
public function getConfig() {
356-
App::import('Model', 'ConnectionManager', false);
356+
App::uses('ConnectionManager', 'Model');
357357

358358
$useDbConfig = 'default';
359359
$configs = get_class_vars($this->databaseClassName);

lib/Cake/Console/Command/Task/FixtureTask.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
App::uses('BakeTask', 'Console/Command/Task');
22+
App::uses('Model', 'Model');
2223

2324
/**
2425
* Task class for creating and updating fixtures files.
@@ -186,9 +187,7 @@ public function importOptions($modelName) {
186187
* @return string Baked fixture content
187188
*/
188189
public function bake($model, $useTable = false, $importOptions = array()) {
189-
if (!class_exists('CakeSchema')) {
190-
App::import('Model', 'CakeSchema', false);
191-
}
190+
App::uses('CakeSchema', 'Model');
192191
$table = $schema = $records = $import = $modelImport = $recordImport = null;
193192
if (!$useTable) {
194193
$useTable = Inflector::tableize($model);
@@ -394,7 +393,6 @@ protected function _getRecordsFromTable($modelName, $useTable = null) {
394393
} else {
395394
$condition = 'WHERE 1=1 LIMIT ' . (isset($this->params['count']) ? $this->params['count'] : 10);
396395
}
397-
App::import('Model', 'Model', false);
398396
$modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
399397
$records = $modelObject->find('all', array(
400398
'conditions' => $condition,

lib/Cake/Console/Command/Task/ModelTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
App::uses('BakeTask', 'Console/Command/Task');
2222
App::uses('ConnectionManager', 'Model');
23+
App::uses('Model', 'Model');
2324

2425
/**
2526
* Task class for creating and updating model files.
@@ -74,7 +75,6 @@ class ModelTask extends BakeTask {
7475
*
7576
*/
7677
public function execute() {
77-
App::import('Model', 'Model', false);
7878
parent::execute();
7979

8080
if (empty($this->args)) {

lib/Cake/Console/Command/Task/PluginTask.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
* @since CakePHP(tm) v 1.2
1818
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1919
*/
20-
App::import('Core', 'File');
20+
21+
App::uses('File', 'Utility');
2122

2223
/**
2324
* Task class for creating a plugin

lib/Cake/Console/Command/Task/ViewTask.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ public function all() {
191191
$model = $this->_modelName($table);
192192
$this->controllerName = $this->_controllerName($model);
193193
$this->controllerPath = Inflector::underscore($this->controllerName);
194-
if (App::import('Model', $model)) {
194+
App::uses($model, 'Model');
195+
if (class_exists($model)) {
195196
$vars = $this->__loadController();
196197
if (!$actions) {
197198
$actions = $this->_methodsToBake();
@@ -272,17 +273,18 @@ private function __loadController() {
272273
$this->err(__('Controller not found'));
273274
}
274275

275-
$import = $this->controllerName;
276+
$plugin = null;
276277
if ($this->plugin) {
277-
$import = $this->plugin . '.' . $this->controllerName;
278+
$plugin = $this->plugin . '.';
278279
}
279280

280-
if (!App::import('Controller', $import)) {
281-
$file = $this->controllerPath . '_controller.php';
281+
$controllerClassName = $this->controllerName . 'Controller';
282+
App::uses($controllerName, $plugin . 'Controller');
283+
if (!class_exists($controllerClassName)) {
284+
$file = $controllerClassName . '.php';
282285
$this->err(__("The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
283286
$this->_stop();
284287
}
285-
$controllerClassName = $this->controllerName . 'Controller';
286288
$controllerObj = new $controllerClassName();
287289
$controllerObj->plugin = $this->plugin;
288290
$controllerObj->constructClasses();

lib/Cake/Console/ConsoleErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
App::uses('ErrorHandler', 'Error');
2121
App::uses('ConsoleOutput', 'Console');
22+
App::uses('CakeLog', 'Log');
2223

2324
/**
2425
* Error Handler for Cake console. Does simple printing of the
@@ -79,7 +80,6 @@ public static function handleError($code, $description, $file = null, $line = nu
7980
$stderr->write(__("<error>%s Error:</error> %s\n", $name, $message));
8081

8182
if (Configure::read('debug') == 0) {
82-
App::import('Core', 'CakeLog');
8383
CakeLog::write($log, $message);
8484
}
8585
}

lib/Cake/Controller/Component/AclComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ public function check($aro, $aco, $aco_action = null) {
662662
* @return array INI section structure
663663
*/
664664
public function readConfigFile($filename) {
665-
App::import('Core', 'config/IniReader');
665+
App::uses('IniReader', 'Configure');
666666
$iniFile = new IniReader(dirname($filename) . DS);
667667
return $iniFile->read(basename($filename));
668668
}

lib/Cake/Controller/Component/EmailComponent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ function _render($content) {
433433
$viewClass = $this->Controller->view;
434434

435435
if ($viewClass != 'View') {
436-
list($plugin, $viewClass) = pluginSplit($viewClass);
436+
list($plugin, $viewClass) = pluginSplit($viewClass, true);
437437
$viewClass = $viewClass . 'View';
438-
App::import('View', $this->Controller->view);
438+
App::uses($viewClass, $plugin . 'View');
439439
}
440440

441441
$View = new $viewClass($this->Controller, false);
@@ -810,7 +810,7 @@ function _mail() {
810810
* @access private
811811
*/
812812
function _smtp() {
813-
App::import('Core', 'CakeSocket');
813+
App::uses('CakeSocket', 'Network');
814814

815815
$defaults = array(
816816
'host' => 'localhost',

lib/Cake/Controller/Component/RequestHandlerComponent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ public function renderAs(&$controller, $type, $options = array()) {
542542
);
543543

544544
if (!$isAdded) {
545-
if (App::import('Helper', $helper)) {
545+
App::uses($helper . 'Helper', 'Helper');
546+
if (class_exists($helper . 'Helper')) {
546547
$controller->helpers[] = $helper;
547548
}
548549
}

lib/Cake/Controller/Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,9 @@ public function render($action = null, $layout = null, $file = null) {
789789

790790
$viewClass = $this->view;
791791
if ($this->view != 'View') {
792-
list($plugin, $viewClass) = pluginSplit($viewClass);
792+
list($plugin, $viewClass) = pluginSplit($viewClass, true);
793793
$viewClass = $viewClass . 'View';
794-
App::import('View', $this->view);
794+
App::uses($viewClass, $plugin . 'View');
795795
}
796796

797797
$this->request->params['models'] = $this->modelNames;

lib/Cake/Core/App.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* ### Adding paths
2424
*
2525
* You can add paths to the search indexes App uses to find classes using `App::build()`. Adding
26-
* additional controller paths for example would alter where CakePHP looks for controllers when you
27-
* call App::import('Controller', 'Posts'); This allows you to split your application up across the filesystem.
26+
* additional controller paths for example would alter where CakePHP looks for controllers.
27+
* This allows you to split your application up across the filesystem.
2828
*
2929
* ### Inspecting loaded paths
3030
*
@@ -261,7 +261,7 @@ public static function build($paths = array(), $reset = false) {
261261
'View' => array(VIEWS),
262262
'View/Helper' => array(HELPERS),
263263
'locales' => array(APP . 'locale' . DS),
264-
'shells' => array(
264+
'Console' => array(
265265
APP . 'console' . DS . 'shells' . DS,
266266
APP . 'vendors' . DS . 'shells' . DS,
267267
VENDORS . 'shells' . DS

lib/Cake/Error/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function handleException(Exception $exception) {
113113
CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage());
114114
}
115115
if ($config['renderer'] !== 'ExceptionRenderer') {
116-
App::import('Lib', $config['renderer']);
116+
App::uses($config['renderer'], 'Error');
117117
}
118118
$error = new $config['renderer']($exception);
119119
$error->render();

lib/Cake/Error/ExceptionRenderer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
* @since CakePHP(tm) v 2.0
2121
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
2222
*/
23+
24+
App::import('Sanitize', 'Utility');
25+
2326
/**
2427
* Exception Renderer.
2528
*
@@ -88,8 +91,6 @@ class ExceptionRenderer {
8891
* @param array $messages Error messages
8992
*/
9093
function __construct(Exception $exception) {
91-
App::import('Core', 'Sanitize');
92-
9394
$this->controller = $this->_getController($exception);
9495

9596
if (method_exists($this->controller, 'apperror')) {

lib/Cake/I18n/I18n.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static function &getInstance() {
101101

102102
/**
103103
* Used by the translation functions in basics.php
104-
* Can also be used like I18n::translate(); but only if the App::import('I18n'); has been used to load the class.
104+
* Returns a translated string based on current language and translation files stored in locale folder
105105
*
106106
* @param string $singular String to translate
107107
* @param string $plural Plural string (if any)

lib/Cake/I18n/Multibyte.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ private static function __find($char, $type = 'lower') {
10781078
return null;
10791079
}
10801080
if (!Configure::configured('_cake_core_')) {
1081-
App::import('Core', 'config/PhpReader');
1081+
App::uses('PhpReader', 'Configure');
10821082
Configure::config('_cake_core_', new PhpReader(CAKE . 'config' . DS));
10831083
}
10841084
Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');

lib/Cake/Model/BehaviorCollection.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,7 @@ public function load($behavior, $config = array()) {
9494
list($plugin, $name) = pluginSplit($behavior);
9595
$class = $name . 'Behavior';
9696

97-
if (!App::import('Behavior', $behavior)) {
98-
throw new MissingBehaviorFileException(array(
99-
'file' => Inflector::underscore($behavior) . '.php',
100-
'class' => $class
101-
));
102-
}
97+
App::uses($class, 'Model/Behavior');
10398
if (!class_exists($class)) {
10499
throw new MissingBehaviorClassException(array(
105100
'file' => Inflector::underscore($behavior) . '.php',

lib/Cake/Model/CakeSchema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ public function read($options = array()) {
207207
));
208208
$db = ConnectionManager::getDataSource($connection);
209209

210-
App::import('Model', 'AppModel');
211210
if (isset($this->plugin)) {
212-
App::import('Model', Inflector::camelize($this->plugin) . 'AppModel');
211+
App::uses(Inflector::camelize($this->plugin) . 'AppModel', $this->plugin . '.Model');
213212
}
214213

215214
$tables = array();
@@ -234,7 +233,8 @@ public function read($options = array()) {
234233
if (isset($this->plugin)) {
235234
$importModel = $this->plugin . '.' . $model;
236235
}
237-
if (!App::import('Model', $importModel)) {
236+
App::uses($importModel, 'Model');
237+
if (!class_exists($importModel)) {
238238
continue;
239239
}
240240
$vars = get_class_vars($model);

lib/Cake/Model/Datasource/DboSource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
* @since CakePHP(tm) v 0.10.0.1076
1818
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1919
*/
20+
2021
App::uses('String', 'Utility');
22+
App::uses('View', 'View');
2123

2224
/**
2325
* DboSource
@@ -763,7 +765,6 @@ public function showLog($sorted = false) {
763765
return;
764766
}
765767
if (PHP_SAPI != 'cli') {
766-
App::import('Core', 'View');
767768
$controller = null;
768769
$View = new View($controller, false);
769770
$View->set('logs', array($this->configKeyName => $log));

lib/Cake/Utility/Set.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ public static function classicExtract($data, $path = null) {
585585

586586
if (is_string($path) && strpos($path, '{') !== false) {
587587
$path = String::tokenize($path, '.', '{', '}');
588-
} else {
588+
} elseif (is_string($path)) {
589589
$path = explode('.', $path);
590590
}
591591
$tmp = array();

lib/Cake/View/pages/home.ctp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endif;
2424
<a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a>
2525
<?php
2626
if (Configure::read('debug') > 0):
27-
Debugger::checkSecurityKeys();
27+
//Debugger::checkSecurityKeys();
2828
endif;
2929
?>
3030
<p>

lib/Cake/basics.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,7 @@ function __c($msg, $category, $args = null) {
670670
* @param string $message Message to write to log
671671
*/
672672
function LogError($message) {
673-
if (!class_exists('CakeLog')) {
674-
App::import('Core', 'CakeLog');
675-
}
673+
App::uses('CakeLog', 'Log');
676674
$bad = array("\n", "\r", "\t");
677675
$good = ' ';
678676
CakeLog::write('error', str_replace($bad, $good, $message));

0 commit comments

Comments
 (0)