Browse Source

Removing 1.3 Backwards compatible code to load underscored files. Now you can App::build('Locale') instead of 'locales'

Jose Lorenzo Rodriguez 14 years ago
parent
commit
00a0c60733

+ 17 - 51
lib/Cake/Core/App.php

@@ -176,6 +176,7 @@ class App {
 		'libs' => 'Lib',
 		'vendors' => 'Vendor',
 		'plugins' => 'Plugin',
+		'locales' => 'Locale'
 	);
 
 /**
@@ -548,25 +549,6 @@ class App {
 			}
 		}
 
-		// To help apps migrate to 2.0 old style file names are allowed
-		// if the trailing segment is one of the types that changed, alternates will be tried.
-		foreach ($paths as $path) {
-			$underscored = Inflector::underscore($className);
-			$tries = array($path . $underscored . '.php');
-			$parts = explode('_', $underscored);
-			$numParts = count($parts);
-			if ($numParts > 1 && in_array($parts[$numParts - 1], array('behavior', 'helper', 'component'))) {
-				array_pop($parts);
-				$tries[] = $path . implode('_', $parts) . '.php';
-			}
-			foreach ($tries as $file) {
-				if (file_exists($file)) {
-					self::_map($file, $className);
-					return include $file;
-				}
-			}
-		}
-
 		return false;
 	}
 
@@ -826,71 +808,55 @@ class App {
 		if (empty(self::$_packageFormat)) {
 			self::$_packageFormat = array(
 				'Model' => array(
-					'%s' . 'Model' . DS,
-					'%s' . 'models' . DS
+					'%s' . 'Model' . DS
 				),
 				'Model/Behavior' => array(
-					'%s' . 'Model' . DS . 'Behavior' . DS,
-					'%s' . 'models' . DS . 'behaviors' . DS
+					'%s' . 'Model' . DS . 'Behavior' . DS
 				),
 				'Model/Datasource' => array(
-					'%s' . 'Model' . DS . 'Datasource' . DS,
-					'%s' . 'models' . DS . 'datasources' . DS
+					'%s' . 'Model' . DS . 'Datasource' . DS
 				),
 				'Model/Datasource/Database' => array(
-					'%s' . 'Model' . DS . 'Datasource' . DS . 'Database' . DS,
-					'%s' . 'models' . DS . 'datasources' . DS . 'database' . DS
+					'%s' . 'Model' . DS . 'Datasource' . DS . 'Database' . DS
 				),
 				'Model/Datasource/Session' => array(
-					'%s' . 'Model' . DS . 'Datasource' . DS . 'Session' . DS,
-					'%s' . 'models' . DS . 'datasources' . DS . 'session' . DS
+					'%s' . 'Model' . DS . 'Datasource' . DS . 'Session' . DS
 				),
 				'Controller' => array(
-					'%s' . 'Controller' . DS,
-					'%s' . 'controllers' . DS
+					'%s' . 'Controller' . DS
 				),
 				'Controller/Component' => array(
-					'%s' . 'Controller' . DS . 'Component' . DS,
-					'%s' . 'controllers' . DS . 'components' . DS
+					'%s' . 'Controller' . DS . 'Component' . DS
 				),
 				'Controller/Component/Auth' => array(
-					'%s' . 'Controller' . DS . 'Component' . DS . 'Auth' . DS,
-					'%s' . 'controllers' . DS . 'components' . DS . 'auth' . DS
+					'%s' . 'Controller' . DS . 'Component' . DS . 'Auth' . DS
 				),
 				'View' => array(
-					'%s' . 'View' . DS,
-					'%s' . 'views' . DS
+					'%s' . 'View' . DS
 				),
 				'View/Helper' => array(
-					'%s' . 'View' . DS . 'Helper' . DS,
-					'%s' . 'views' . DS . 'helpers' . DS
+					'%s' . 'View' . DS . 'Helper' . DS
 				),
 				'Console' => array(
-					'%s' . 'Console' . DS,
-					'%s' . 'console' . DS
+					'%s' . 'Console' . DS
 				),
 				'Console/Command' => array(
-					'%s' . 'Console' . DS . 'Command' . DS,
-					'%s' . 'console' . DS . 'shells' . DS,
+					'%s' . 'Console' . DS . 'Command' . DS
 				),
 				'Console/Command/Task' => array(
-					'%s' . 'Console' . DS . 'Command' . DS . 'Task' . DS,
-					'%s' . 'console' . DS . 'shells' . DS . 'tasks' . DS
+					'%s' . 'Console' . DS . 'Command' . DS . 'Task' . DS
 				),
 				'Lib' => array(
-					'%s' . 'Lib' . DS,
-					'%s' . 'libs' . DS
+					'%s' . 'Lib' . DS
 				),
-				'locales' => array(
-					'%s' . 'Locale' . DS,
-					'%s' . 'locale' . DS
+				'Locale' => array(
+					'%s' . 'Locale' . DS
 				),
 				'Vendor' => array(
 					'%s' . 'Vendor' . DS, VENDORS
 				),
 				'Plugin' => array(
 					APP . 'Plugin' . DS,
-					APP . 'plugins' . DS,
 					dirname(dirname(CAKE)) . DS . 'plugins' . DS
 				)
 			);

+ 6 - 6
lib/Cake/Test/Case/Controller/ComponentCollectionTest.php

@@ -88,9 +88,9 @@ class ComponentCollectionTest extends CakeTestCase {
 
 		App::build(array('plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)));
 		CakePlugin::load('TestPlugin');
-		$result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.OtherComponent'));
-		$this->assertInstanceOf('OtherComponentComponent', $result);
-		$this->assertInstanceOf('OtherComponentComponent', $this->Components->SomeOther);
+		$result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.Other'));
+		$this->assertInstanceOf('OtherComponent', $result);
+		$this->assertInstanceOf('OtherComponent', $this->Components->SomeOther);
 
 		$result = $this->Components->attached();
 		$this->assertEquals(array('Cookie', 'SomeOther'), $result, 'attached() results are wrong.');
@@ -131,9 +131,9 @@ class ComponentCollectionTest extends CakeTestCase {
 			'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
 		));
 		CakePlugin::load('TestPlugin');
-		$result = $this->Components->load('TestPlugin.OtherComponent');
-		$this->assertInstanceOf('OtherComponentComponent', $result, 'Component class is wrong.');
-		$this->assertInstanceOf('OtherComponentComponent', $this->Components->OtherComponent, 'Class is wrong');
+		$result = $this->Components->load('TestPlugin.Other');
+		$this->assertInstanceOf('OtherComponent', $result, 'Component class is wrong.');
+		$this->assertInstanceOf('OtherComponent', $this->Components->Other, 'Class is wrong');
 		App::build();
 		CakePlugin::unload();
 	}

+ 17 - 33
lib/Cake/Test/Case/Core/AppTest.php

@@ -41,8 +41,7 @@ class AppTest extends CakeTestCase {
 	public function testBuild() {
 		$old = App::path('Model');
 		$expected = array(
-			APP . 'Model' . DS,
-			APP . 'models' . DS
+			APP . 'Model' . DS
 		);
 		$this->assertEquals($expected, $old);
 
@@ -50,8 +49,7 @@ class AppTest extends CakeTestCase {
 		$new = App::path('Model');
 		$expected = array(
 			'/path/to/models/',
-			APP . 'Model' . DS,
-			APP . 'models' . DS
+			APP . 'Model' . DS
 		);
 		$this->assertEquals($expected, $new);
 
@@ -60,8 +58,7 @@ class AppTest extends CakeTestCase {
 		$new = App::path('Model');
 		$expected = array(
 			'/path/to/models/',
-			APP . 'Model' . DS,
-			APP . 'models' . DS
+			APP . 'Model' . DS
 		);
 		$this->assertEquals($expected, $new);
 
@@ -70,7 +67,6 @@ class AppTest extends CakeTestCase {
 		$new = App::path('Model');
 		$expected = array(
 			APP . 'Model' . DS,
-			APP . 'models' . DS,
 			'/path/to/models/'
 		);
 		$this->assertEquals($expected, $new);
@@ -83,14 +79,12 @@ class AppTest extends CakeTestCase {
 		$new = App::path('Model');
 		$expected = array(
 			APP . 'Model' . DS,
-			APP . 'models' . DS,
 			'/path/to/models/'
 		);
 		$this->assertEquals($expected, $new);
 		$new = App::path('Controller');
 		$expected = array(
 			APP . 'Controller' . DS,
-			APP . 'controllers' . DS,
 			'/path/to/controllers/'
 		);
 		$this->assertEquals($expected, $new);
@@ -108,8 +102,7 @@ class AppTest extends CakeTestCase {
 	public function testCompatibleBuild() {
 		$old = App::path('models');
 		$expected = array(
-			APP . 'Model' . DS,
-			APP . 'models' . DS
+			APP . 'Model' . DS
 		);
 		$this->assertEquals($expected, $old);
 
@@ -119,8 +112,7 @@ class AppTest extends CakeTestCase {
 
 		$expected = array(
 			'/path/to/models/',
-			APP . 'Model' . DS,
-			APP . 'models' . DS
+			APP . 'Model' . DS
 		);
 		$this->assertEquals($expected, $new);
 		$this->assertEquals($expected, App::path('Model'));
@@ -128,8 +120,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('datasources' => array('/path/to/datasources/')));
 		$expected = array(
 			'/path/to/datasources/',
-			APP . 'Model' . DS . 'Datasource' . DS,
-			APP . 'models' . DS . 'datasources' . DS
+			APP . 'Model' . DS . 'Datasource' . DS
 		);
 		$result = App::path('datasources');
 		$this->assertEquals($expected, $result);
@@ -138,8 +129,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('behaviors' => array('/path/to/behaviors/')));
 		$expected = array(
 			'/path/to/behaviors/',
-			APP . 'Model' . DS . 'Behavior' . DS,
-			APP . 'models' . DS . 'behaviors' . DS
+			APP . 'Model' . DS . 'Behavior' . DS
 		);
 		$result = App::path('behaviors');
 		$this->assertEquals($expected, $result);
@@ -148,8 +138,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('controllers' => array('/path/to/controllers/')));
 		$expected = array(
 			'/path/to/controllers/',
-			APP . 'Controller' . DS,
-			APP . 'controllers' . DS
+			APP . 'Controller' . DS
 		);
 		$result = App::path('controllers');
 		$this->assertEquals($expected, $result);
@@ -158,8 +147,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('components' => array('/path/to/components/')));
 		$expected = array(
 			'/path/to/components/',
-			APP . 'Controller' . DS . 'Component' . DS,
-			APP . 'controllers' . DS . 'components' . DS
+			APP . 'Controller' . DS . 'Component' . DS
 		);
 		$result = App::path('components');
 		$this->assertEquals($expected, $result);
@@ -168,8 +156,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('views' => array('/path/to/views/')));
 		$expected = array(
 			'/path/to/views/',
-			APP . 'View' . DS,
-			APP . 'views' . DS
+			APP . 'View' . DS
 		);
 		$result = App::path('views');
 		$this->assertEquals($expected, $result);
@@ -178,8 +165,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('helpers' => array('/path/to/helpers/')));
 		$expected = array(
 			'/path/to/helpers/',
-			APP . 'View' . DS . 'Helper' .DS,
-			APP . 'views' . DS . 'helpers' . DS
+			APP . 'View' . DS . 'Helper' .DS
 		);
 		$result = App::path('helpers');
 		$this->assertEquals($expected, $result);
@@ -188,8 +174,7 @@ class AppTest extends CakeTestCase {
 		App::build(array('shells' => array('/path/to/shells/')));
 		$expected = array(
 			'/path/to/shells/',
-			APP . 'Console' . DS . 'Command' . DS,
-			APP . 'console' . DS . 'shells' . DS,
+			APP . 'Console' . DS . 'Command' . DS
 		);
 		$result = App::path('shells');
 		$this->assertEquals($expected, $result);
@@ -249,8 +234,7 @@ class AppTest extends CakeTestCase {
 	public function testBuildWithReset() {
 		$old = App::path('Model');
 		$expected = array(
-			APP . 'Model' . DS,
-			APP . 'models' . DS
+			APP . 'Model' . DS
 		);
 		$this->assertEquals($expected, $old);
 
@@ -394,9 +378,9 @@ class AppTest extends CakeTestCase {
 		$this->assertTrue(in_array('TestPluginPost', $result));
 
 		$result = App::objects('TestPlugin.behavior');
-		$this->assertTrue(in_array('TestPluginPersisterOne', $result));
+		$this->assertTrue(in_array('TestPluginPersisterOneBehavior', $result));
 		$result = App::objects('TestPlugin.Model/Behavior');
-		$this->assertTrue(in_array('TestPluginPersisterOne', $result));
+		$this->assertTrue(in_array('TestPluginPersisterOneBehavior', $result));
 
 		$result = App::objects('TestPlugin.helper');
 		$expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper');
@@ -553,8 +537,8 @@ class AppTest extends CakeTestCase {
  */
 	public function testPluginImporting() {
 		App::build(array(
-			'libs' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS),
-			'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
+			'Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS),
+			'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
 		));
 		CakePlugin::loadAll();
 

+ 1 - 1
lib/Cake/Test/Case/Routing/DispatcherTest.php

@@ -1124,7 +1124,7 @@ class DispatcherTest extends CakeTestCase {
 		$result = $Dispatcher->dispatch($url, $response, array('return' => 1));
 		$this->assertTrue(class_exists('TestsController'));
 		$this->assertTrue(class_exists('TestPluginAppController'));
-		$this->assertTrue(class_exists('PluginsComponentComponent'));
+		$this->assertTrue(class_exists('PluginsComponent'));
 
 		$this->assertEquals($result->params['controller'], 'tests');
 		$this->assertEquals($result->params['plugin'], 'test_plugin');

+ 2 - 2
lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php

@@ -215,11 +215,11 @@ class ControllerTestCaseTest extends CakeTestCase {
 				'TestPlugin.TestPluginComment'
 			),
 			'components' => array(
-				'TestPlugin.PluginsComponent'
+				'TestPlugin.Plugins'
 			)
 		));
 		$this->assertEquals($Tests->name, 'Tests');
-		$this->assertInstanceOf('PluginsComponentComponent', $Tests->PluginsComponent);
+		$this->assertInstanceOf('PluginsComponent', $Tests->Plugins);
 
 		$result = ClassRegistry::init('TestPlugin.TestPluginComment');
 		$this->assertInstanceOf('TestPluginComment', $result);

+ 0 - 1
lib/Cake/Test/Case/View/ViewTest.php

@@ -257,7 +257,6 @@ class ViewTest extends CakeTestCase {
 		$expected = array(
 			CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Plugin' . DS . 'TestPlugin' . DS,
 			$pluginPath . 'View' . DS,
-			$pluginPath . 'views' . DS,
 			$pluginPath . 'Lib' . DS . 'View' . DS,
 			CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS,
 			CAKE . 'View' . DS

+ 1 - 1
lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/other_component.php

@@ -16,5 +16,5 @@
  * @since         CakePHP(tm) v 1.2.0.4206
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-class OtherComponentComponent extends Object {
+class OtherComponent extends Object {
 }

+ 2 - 2
lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/plugins_component.php

@@ -16,6 +16,6 @@
  * @since         CakePHP(tm) v 1.2.0.4206
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-class PluginsComponentComponent extends Component {
-	public $components = array('TestPlugin.OtherComponent');
+class PluginsComponent extends Component {
+	public $components = array('TestPlugin.Other');
 }

lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/test_plugin_component.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/TestPluginComponent.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/test_plugin_other_component.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/TestPluginOtherComponent.php


+ 1 - 1
lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/TestsController.php

@@ -20,7 +20,7 @@ class TestsController extends TestPluginAppController {
 	public $name = 'Tests';
 	public $uses = array();
 	public $helpers = array('TestPlugin.OtherHelper', 'Html');
-	public $components = array('TestPlugin.PluginsComponent');
+	public $components = array('TestPlugin.Plugins');
 
 	public function index() {
 		$this->set('test_value', 'It is a variable');

lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/test_plugin_library.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/TestPluginLibrary.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/test_plugin_persister_one.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/test_plugin_persister_two.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/test_other_source.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/TestOtherSource.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/test_plugin_app_model.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAppModel.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/test_plugin_auth_user.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthUser.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/test_plugin_authors.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php


lib/Cake/Test/test_app/Plugin/TestPlugin/Model/test_plugin_comment.php → lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php