Browse Source

Starting to migrate AuthComponent to the new class loader

Jose Lorenzo Rodriguez 15 years ago
parent
commit
f1e2f5e949

+ 2 - 1
lib/Cake/Controller/Component/Auth/ActionsAuthorize.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Component', 'auth/base_authorize');
+ 
+App::uses('BaseAuthorize', 'Controller/Component/Auth');
 
 /**
  * An authorization adapter for AuthComponent.  Provides the ability to authorize using the AclComponent,

+ 2 - 1
lib/Cake/Controller/Component/Auth/BaseAuthenticate.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Core', 'Security');
+
+App::uses('Security', 'Utility');
 
 /**
  * Base Authentication class with common methods and properties.

+ 2 - 1
lib/Cake/Controller/Component/Auth/BasicAuthenticate.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Component', 'auth/base_authenticate');
+
+App::uses('BaseAuthorize', 'Controller/Component/Auth');
 
 /**
  * Basic Authentication adapter for AuthComponent.

+ 2 - 1
lib/Cake/Controller/Component/Auth/ControllerAuthorize.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Component', 'auth/base_authorize');
+
+App::uses('BaseAuthorize', 'Controller/Component/Auth');
 
 /**
  * An authorization adapter for AuthComponent.  Provides the ability to authorize using a controller callback.

+ 2 - 1
lib/Cake/Controller/Component/Auth/CrudAuthorize.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Component', 'auth/base_authorize');
+
+App::uses('BaseAuthorize', 'Controller/Component/Auth');
 
 /**
  * An authorization adapter for AuthComponent.  Provides the ability to authorize using CRUD mappings.

+ 2 - 1
lib/Cake/Controller/Component/Auth/DigestAuthenticate.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Component', 'auth/base_authenticate');
+
+App::uses('BaseAuthenticate', 'Controller/Component/Auth');
 
 /**
  * Digest Authentication adapter for AuthComponent.

+ 2 - 1
lib/Cake/Controller/Component/Auth/FormAuthenticate.php

@@ -12,7 +12,8 @@
  * @link          http://cakephp.org CakePHP(tm) Project
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::import('Component', 'auth/base_authenticate');
+
+App::uses('BaseAuthenticate', 'Controller/Component/Auth');
 
 /**
  * An authentication adapter for AuthComponent.  Provides the ability to authenticate using POST

+ 6 - 2
lib/Cake/Controller/Component/AuthComponent.php

@@ -407,8 +407,10 @@ class AuthComponent extends Component {
 			unset($config[AuthComponent::ALL]);
 		}
 		foreach ($config as $class => $settings) {
+			list($plugin, $class) = pluginSplit($class, true);
 			$className = $class . 'Authorize';
-			if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) {
+			App::uses($className, $plugin . 'Controller/Component/Auth');
+			if (!class_exists($className)) {
 				throw new CakeException(__('Authorization adapter "%s" was not found.', $class));
 			}
 			if (!method_exists($className, 'authorize')) {
@@ -645,8 +647,10 @@ class AuthComponent extends Component {
 			unset($config[AuthComponent::ALL]);
 		}
 		foreach ($config as $class => $settings) {
+			list($plugin, $class) = pluginSplit($class, true);
 			$className = $class . 'Authenticate';
-			if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authenticate')) {
+			App::uses($className, $plugin . 'Controller/Component/Auth');
+			if (!class_exists($className)) {
 				throw new CakeException(__('Authentication adapter "%s" was not found.', $class));
 			}
 			if (!method_exists($className, 'authenticate')) {

+ 1 - 1
lib/Cake/Core/App.php

@@ -425,7 +425,7 @@ class App {
 	public static function objects($type, $path = null, $cache = true) {
 		$objects = array();
 		$extension = '/\.php$/';
-		$directories = false;
+		$includeDirectories = false;
 		$name = $type;
 
 		if (isset(self::$legacy[$type . 's'])) {

+ 4 - 3
lib/Cake/tests/cases/libs/controller/components/acl.test.php

@@ -16,9 +16,10 @@
  * @since         CakePHP(tm) v 1.2.0.5435
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-App::uses('AclComponent', 'Component');
-App::uses('DbAcl', 'Model');
-
+ 
+App::uses('AclComponent', 'Controller/Component');
+App::uses('AclNode', 'Model');
+class_exists('AclComponent');
 
 /**
  * AclNodeTwoTestBase class

+ 2 - 9
lib/Cake/tests/cases/libs/controller/components/auth.test.php

@@ -332,15 +332,11 @@ class AuthTest extends CakeTestCase {
 
 		$this->Controller = new AuthTestController($request);
 
-<<<<<<< HEAD
-		ClassRegistry::addObject('view', new View($this->Controller));
-=======
 		$collection = new ComponentCollection();
 		$collection->init($this->Controller);
 		$this->Auth = new TestAuthComponent($collection);
 		$this->Auth->request = $request;
 		$this->Auth->response = $this->getMock('CakeResponse');
->>>>>>> origin/2.0
 
 		$this->Controller->Components->init($this->Controller);
 
@@ -935,7 +931,6 @@ class AuthTest extends CakeTestCase {
 	}
 
 /**
-<<<<<<< HEAD
  * testPluginModel method
  *
  * @access public
@@ -946,7 +941,7 @@ class AuthTest extends CakeTestCase {
 		Cache::delete('object_map', '_cake_core_');
 		App::build(array(
 			'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
-			'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
+			'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
 		), true);
 		App::objects('plugin', null, false);
 
@@ -996,8 +991,6 @@ class AuthTest extends CakeTestCase {
 	}
 
 /**
-=======
->>>>>>> origin/2.0
  * testAjaxLogin method
  *
  * @access public
@@ -1005,7 +998,7 @@ class AuthTest extends CakeTestCase {
  */
 	function testAjaxLogin() {
 		App::build(array(
-			'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+			'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
 		));
 		$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";