Skip to content

Commit

Permalink
Replacing App::import in favor of App::uses where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 3, 2010
1 parent 1d12984 commit b1ec304
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 50 deletions.
2 changes: 1 addition & 1 deletion cake/console/templates/skel/app_helper.php
Expand Up @@ -20,7 +20,7 @@
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Helper', 'Helper', false);
App::uses('Helper', 'Helper');

/**
* This is a placeholder class.
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/cake_socket.php
Expand Up @@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Validation');
App::uses('Validation', 'Core');

/**
* Cake network socket connection class.
Expand Down
5 changes: 2 additions & 3 deletions cake/libs/model/behaviors/translate.php
Expand Up @@ -18,6 +18,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('I18n', 'Core');

/**
* Translate behavior
*
Expand Down Expand Up @@ -346,9 +348,6 @@ public function afterDelete(&$model) {
*/
protected function _getLocale(&$model) {
if (!isset($model->locale) || is_null($model->locale)) {
if (!class_exists('I18n')) {
App::import('Core', 'i18n');
}
$I18n =& I18n::getInstance();
$I18n->l10n->get(Configure::read('Config.language'));
$model->locale = $I18n->l10n->locale;
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo_source.php
Expand Up @@ -17,7 +17,7 @@
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'String');
App::uses('String', 'Core');

/**
* DboSource
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/db_acl.php
Expand Up @@ -23,7 +23,7 @@
/**
* Load Model and AppModel
*/
App::import('Model', 'App');
App::uses('AppModel', 'Model');

/**
* ACL Node
Expand Down
14 changes: 7 additions & 7 deletions cake/libs/model/model.php
Expand Up @@ -23,12 +23,13 @@
/**
* Included libs
*/
App::import('Core', 'ClassRegistry', false);
App::import('Core', 'Validation', false);
App::import('Core', 'String', false);
App::import('Model', 'BehaviorCollection', false);
App::import('Model', 'ModelBehavior', false);
App::import('Model', 'ConnectionManager', false);
App::uses('ClassRegistry', 'Core');
App::uses('Validation', 'Core');
App::uses('String', 'Core');
App::uses('BehaviorCollection', 'Model');
App::uses('ModelBehavior', 'Model');
App::uses('ConnectionManager', 'Model');
App::uses('Xml', 'Core');

/**
* Object-relational mapper.
Expand Down Expand Up @@ -822,7 +823,6 @@ function set($one, $two = null) {
}
if (is_object($one)) {
if ($one instanceof SimpleXMLElement || $one instanceof DOMNode) {
App::import('Core', 'Xml');
$one = $this->_normalizeXmlData(Xml::toArray($one));
} else {
$one = Set::reverse($one);
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/route/plugin_short_route.php
@@ -1,5 +1,5 @@
<?php
App::import('Core', 'route/CakeRoute');
App::uses('CakeRoute', 'Core');
/**
* Plugin short route, that copies the plugin param to the controller parameters
* It is used for supporting /:plugin routes.
Expand Down
5 changes: 3 additions & 2 deletions cake/libs/route/redirect_route.php
@@ -1,6 +1,7 @@
<?php
App::import('Core', 'CakeResponse');
App::import('Core', 'route/CakeRoute');
App::uses('CakeResponse', 'Core');
App::uses('CakeRoute', 'Core');

/**
* Redirect route will perform an immediate redirect
*
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/router.php
Expand Up @@ -286,7 +286,7 @@ public static function connect($route, $defaults = array(), $options = array())
* @return array Array of routes
*/
public static function redirect($route, $url, $options) {
App::import('Core', 'route/RedirectRoute');
App::uses('RedirectRoute', 'Core');
$options['routeClass'] = 'RedirectRoute';
return self::connect($route, $url, $options);
}
Expand Down Expand Up @@ -565,7 +565,7 @@ private static function __parseExtension($url) {
*/
private static function __connectDefaultRoutes() {
if ($plugins = App::objects('plugin')) {
App::import('Core', 'route/PluginShortRoute');
App::uses('PluginShortRoute', 'Core');
foreach ($plugins as $key => $value) {
$plugins[$key] = Inflector::underscore($value);
}
Expand Down
5 changes: 2 additions & 3 deletions cake/libs/security.php
Expand Up @@ -18,6 +18,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('String', 'Core');

/**
* Security Library contains utility methods related to security
*
Expand Down Expand Up @@ -59,9 +61,6 @@ public static function inactiveMins() {
* @return string Hash
*/
public static function generateAuthKey() {
if (!class_exists('String')) {
App::import('Core', 'String');
}
return Security::hash(String::uuid());
}

Expand Down
5 changes: 2 additions & 3 deletions cake/libs/set.php
Expand Up @@ -18,6 +18,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('String', 'Core');

/**
* Class used for manipulation of arrays.
*
Expand Down Expand Up @@ -582,9 +584,6 @@ public static function classicExtract($data, $path = null) {
}

if (!is_array($path)) {
if (!class_exists('String')) {
App::import('Core', 'String');
}
$path = String::tokenize($path, '.', '{', '}');
}
$tmp = array();
Expand Down
5 changes: 2 additions & 3 deletions cake/libs/validation.php
Expand Up @@ -17,9 +17,8 @@
* @since CakePHP(tm) v 1.2.0.3830
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!class_exists('Multibyte')) {
App::import('Core', 'Multibyte', false);
}

App::uses('Multibyte', 'Core');

/**
* Offers different validation methods.
Expand Down
4 changes: 1 addition & 3 deletions cake/libs/view/helper.php
Expand Up @@ -20,9 +20,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

if (!class_exists('Router')) {
App::import('Core', 'Router');
}
App::uses('Router', 'Core');

/**
* Abstract base class for all other Helpers in CakePHP.
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helper_collection.php
Expand Up @@ -16,7 +16,7 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'ObjectCollection');
App::uses('ObjectCollection', 'Core');

class HelperCollection extends ObjectCollection {

Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/app_helper.php
Expand Up @@ -20,7 +20,7 @@
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('View', 'Helper', false);
App::uses('Helper', 'View');

/**
* This is a placeholder class.
Expand Down
3 changes: 2 additions & 1 deletion cake/libs/view/helpers/jquery_engine.php
Expand Up @@ -22,7 +22,8 @@
* @subpackage cake.view.helpers
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Helper', 'Js');

App::uses('JsHelper', 'Helper');

class JqueryEngineHelper extends JsBaseEngineHelper {
/**
Expand Down
3 changes: 2 additions & 1 deletion cake/libs/view/helpers/js.php
Expand Up @@ -18,6 +18,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('Multibyte', 'Core');

/**
* Javascript Generator helper class for easy use of JavaScript.
*
Expand Down Expand Up @@ -665,7 +667,6 @@ public function value($val, $quoteString = true) {
* @return string Escaped string.
*/
public function escape($string) {
App::import('Core', 'Multibyte');
return $this->_utf8ToHex($string);
}

Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/mootools_engine.php
Expand Up @@ -25,7 +25,7 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Helper', 'Js');
App::uses('JsHelper', 'Helper');

class MootoolsEngineHelper extends JsBaseEngineHelper {
/**
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/prototype_engine.php
Expand Up @@ -20,7 +20,7 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Helper', 'Js');
App::uses('JsHelper', 'Helper');

class PrototypeEngineHelper extends JsBaseEngineHelper {
/**
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/rss.php
Expand Up @@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Xml');
App::uses('Xml', 'Core');

/**
* RSS Helper class for easy output RSS structures.
Expand Down
8 changes: 2 additions & 6 deletions cake/libs/view/helpers/text.php
Expand Up @@ -24,12 +24,8 @@
* Included libraries.
*
*/
if (!class_exists('HtmlHelper')) {
App::import('Helper', 'Html');
}
if (!class_exists('Multibyte')) {
App::import('Core', 'Multibyte');
}
App::uses('HtmlHelper', 'Helper');
App::uses('Multibyte', 'Core');

/**
* Text helper library.
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/view/media.php
Expand Up @@ -17,7 +17,8 @@
* @since CakePHP(tm) v 1.2.0.5714
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('View', 'View', false);
App::uses('View', 'View');
App::uses('CakeRequest', 'Core');

class MediaView extends View {
/**
Expand Down Expand Up @@ -45,7 +46,6 @@ function __construct($controller = null) {
if (is_object($controller) && isset($controller->response)) {
$this->response = $controller->response;
} else {
App::import('Core', 'CakeRequest');
$this->response = new CakeResponse;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/scaffold.php
Expand Up @@ -19,7 +19,7 @@
* @since Cake v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('View', 'Theme');
App::uses('ThemeView', 'View');

/**
* ScaffoldView provides specific view file loading features for scaffolded views.
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/theme.php
Expand Up @@ -17,7 +17,7 @@
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('View', 'View');
App::uses('View', 'View');

/**
* Theme view class
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/view/view.php
Expand Up @@ -21,8 +21,8 @@
/**
* Included libraries.
*/
App::import('View', 'HelperCollection', false);
App::import('View', 'Helper', false);
App::uses('HelperCollection', 'View');
App::uses('Helper', 'View');

/**
* View, the V in the MVC triad.
Expand Down

0 comments on commit b1ec304

Please sign in to comment.