Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change case of Controller::$plugin, fixing missing plugin exceptions,…

… tests updated. Also removing no longer needed camelize() calls
  • Loading branch information...
commit 5f9729264849ea54c2dec73ffaf5a6097e5cecf7 1 parent 3f72c92
@ceeram ceeram authored
View
2  lib/Cake/Console/Command/Task/ControllerTask.php
@@ -311,7 +311,7 @@ public function bake($controllerName, $actions = '', $helpers = null, $component
$isScaffold = ($actions === 'scaffold') ? true : false;
- $this->Template->set('plugin', Inflector::camelize($this->plugin));
+ $this->Template->set('plugin', $this->plugin);
$this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'isScaffold'));
$contents = $this->Template->generate('classes', 'controller');
View
2  lib/Cake/Console/Command/Task/ModelTask.php
@@ -741,7 +741,7 @@ public function bake($name, $data = array()) {
$data = array_merge($defaults, $data);
$this->Template->set($data);
- $this->Template->set('plugin', Inflector::camelize($this->plugin));
+ $this->Template->set('plugin', $this->plugin);
$out = $this->Template->generate('classes', 'model');
$path = $this->getPath();
View
15 lib/Cake/Console/Command/Task/PluginTask.php
@@ -76,7 +76,7 @@ protected function _interactive($plugin = null) {
}
if (!$this->bake($plugin)) {
- $this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::camelize($plugin)));
+ $this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . $plugin));
}
}
@@ -88,20 +88,19 @@ protected function _interactive($plugin = null) {
* @return bool
*/
public function bake($plugin) {
- $pluginPath = Inflector::camelize($plugin);
$pathOptions = App::path('plugins');
if (count($pathOptions) > 1) {
$this->findPath($pathOptions);
}
$this->hr();
$this->out(__d('cake_console', "<info>Plugin Name:</info> %s", $plugin));
- $this->out(__d('cake_console', "<info>Plugin Directory:</info> %s", $this->path . $pluginPath));
+ $this->out(__d('cake_console', "<info>Plugin Directory:</info> %s", $this->path . $plugin));
$this->hr();
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y');
if (strtolower($looksGood) == 'y') {
- $Folder = new Folder($this->path . $pluginPath);
+ $Folder = new Folder($this->path . $plugin);
$directories = array(
'Config' . DS . 'schema',
'Model' . DS . 'Behavior',
@@ -119,7 +118,7 @@ public function bake($plugin) {
);
foreach ($directories as $directory) {
- $dirPath = $this->path . $pluginPath . DS . $directory;
+ $dirPath = $this->path . $plugin . DS . $directory;
$Folder->create($dirPath);
$File = new File($dirPath . DS . 'empty', true);
}
@@ -139,7 +138,7 @@ public function bake($plugin) {
$out .= "class {$plugin}AppController extends AppController {\n\n";
$out .= "}\n\n";
$out .= "?>";
- $this->createFile($this->path . $pluginPath. DS . 'Controller' . DS . $controllerFileName, $out);
+ $this->createFile($this->path . $plugin. DS . 'Controller' . DS . $controllerFileName, $out);
$modelFileName = $plugin . 'AppModel.php';
@@ -147,10 +146,10 @@ public function bake($plugin) {
$out .= "class {$plugin}AppModel extends AppModel {\n\n";
$out .= "}\n\n";
$out .= "?>";
- $this->createFile($this->path . $pluginPath . DS . 'Model' . DS . $modelFileName, $out);
+ $this->createFile($this->path . $plugin . DS . 'Model' . DS . $modelFileName, $out);
$this->hr();
- $this->out(__d('cake_console', '<success>Created:</success> %s in %s', $plugin, $this->path . $pluginPath), 2);
+ $this->out(__d('cake_console', '<success>Created:</success> %s in %s', $plugin, $this->path . $plugin), 2);
}
return true;
View
21 lib/Cake/Controller/Controller.php
@@ -440,7 +440,7 @@ public function __set($name, $value) {
*/
public function setRequest(CakeRequest $request) {
$this->request = $request;
- $this->plugin = isset($request->params['plugin']) ? $request->params['plugin'] : null;
+ $this->plugin = isset($request->params['plugin']) ? Inflector::camelize($request->params['plugin']) : null;
$this->view = isset($request->params['action']) ? $request->params['action'] : null;
if (isset($request->params['pass']) && isset($request->params['named'])) {
$this->passedArgs = array_merge($request->params['pass'], $request->params['named']);
@@ -460,15 +460,14 @@ public function setRequest(CakeRequest $request) {
* @return void
*/
protected function __mergeVars() {
- $pluginName = $pluginController = $plugin = null;
+ $pluginController = $pluginDot = null;
if (!empty($this->plugin)) {
- $pluginName = Inflector::camelize($this->plugin);
- $pluginController = $pluginName . 'AppController';
+ $pluginController = $this->plugin . 'AppController';
if (!is_subclass_of($this, $pluginController)) {
$pluginController = null;
}
- $plugin = $pluginName . '.';
+ $pluginDot = $this->plugin . '.';
}
if (is_subclass_of($this, $this->_mergeParent) || !empty($pluginController)) {
@@ -477,13 +476,13 @@ protected function __mergeVars() {
$merge = array('components', 'helpers');
if ($uses == $this->uses && !empty($this->uses)) {
- if (!in_array($plugin . $this->modelClass, $this->uses)) {
- array_unshift($this->uses, $plugin . $this->modelClass);
- } elseif ($this->uses[0] !== $plugin . $this->modelClass) {
+ if (!in_array($pluginDot . $this->modelClass, $this->uses)) {
+ array_unshift($this->uses, $pluginDot . $this->modelClass);
+ } elseif ($this->uses[0] !== $pluginDot . $this->modelClass) {
$this->uses = array_flip($this->uses);
- unset($this->uses[$plugin . $this->modelClass]);
+ unset($this->uses[$pluginDot . $this->modelClass]);
$this->uses = array_flip($this->uses);
- array_unshift($this->uses, $plugin . $this->modelClass);
+ array_unshift($this->uses, $pluginDot . $this->modelClass);
}
} elseif (
($this->uses !== null || $this->uses !== false) &&
@@ -494,7 +493,7 @@ protected function __mergeVars() {
$this->_mergeVars($merge, $this->_mergeParent, true);
}
- if ($pluginController && $pluginName != null) {
+ if ($pluginController && $this->plugin != null) {
$merge = array('components', 'helpers');
$appVars = get_class_vars($pluginController);
if (
View
1  lib/Cake/Core/App.php
@@ -630,7 +630,6 @@ public static function import($type = null, $name = null, $parent = true, $searc
}
list($plugin, $name) = pluginSplit($name);
if (!empty($plugin)) {
- $plugin = Inflector::camelize($plugin);
if (!CakePlugin::loaded($plugin)) {
return false;
}
View
2  lib/Cake/Model/CakeSchema.php
@@ -206,7 +206,7 @@ public function read($options = array()) {
$db = ConnectionManager::getDataSource($connection);
if (isset($this->plugin)) {
- App::uses(Inflector::camelize($this->plugin) . 'AppModel', $this->plugin . '.Model');
+ App::uses($this->plugin . 'AppModel', $this->plugin . '.Model');
}
$tables = array();
View
4 lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
@@ -555,7 +555,7 @@ public function testDoAssociationsNonInteractive() {
* @return void
*/
public function testBakeFixture() {
- $this->Task->plugin = 'test_plugin';
+ $this->Task->plugin = 'TestPlugin';
$this->Task->interactive = true;
$this->Task->Fixture->expects($this->at(0))->method('bake')->with('BakeArticle', 'bake_articles');
$this->Task->bakeFixture('BakeArticle', 'bake_articles');
@@ -571,7 +571,7 @@ public function testBakeFixture() {
* @return void
*/
public function testBakeTest() {
- $this->Task->plugin = 'test_plugin';
+ $this->Task->plugin = 'TestPlugin';
$this->Task->interactive = true;
$this->Task->Test->expects($this->at(0))->method('bake')->with('Model', 'BakeArticle');
$this->Task->bakeTest('BakeArticle');
View
14 lib/Cake/Test/Case/Routing/DispatcherTest.php
@@ -874,7 +874,7 @@ public function testPluginDispatch() {
$this->assertEqual($result[$key], $value, 'Value mismatch ' . $key . ' %');
}
- $this->assertIdentical($controller->plugin, 'my_plugin');
+ $this->assertIdentical($controller->plugin, 'MyPlugin');
$this->assertIdentical($controller->name, 'SomePages');
$this->assertIdentical($controller->params['controller'], 'some_pages');
$this->assertIdentical($controller->passedArgs, array('0' => 'home', 'param'=>'value', 'param2'=>'value2'));
@@ -901,7 +901,7 @@ public function testAutomaticPluginDispatch() {
$url = new CakeRequest('my_plugin/other_pages/index/param:value/param2:value2');
$controller = $Dispatcher->dispatch($url, array('return' => 1));
- $this->assertIdentical($controller->plugin, 'my_plugin');
+ $this->assertIdentical($controller->plugin, 'MyPlugin');
$this->assertIdentical($controller->name, 'OtherPages');
$this->assertIdentical($controller->action, 'index');
$this->assertIdentical($controller->passedArgs, array('param' => 'value', 'param2' => 'value2'));
@@ -936,7 +936,7 @@ public function testAutomaticPluginControllerDispatch() {
$controller = $Dispatcher->dispatch($url, array('return' => 1));
- $this->assertIdentical($controller->plugin, 'my_plugin');
+ $this->assertIdentical($controller->plugin, 'MyPlugin');
$this->assertIdentical($controller->name, 'MyPlugin');
$this->assertIdentical($controller->action, 'add');
$this->assertEqual($controller->params['named'], array('param' => 'value', 'param2' => 'value2'));
@@ -954,7 +954,7 @@ public function testAutomaticPluginControllerDispatch() {
$url = new CakeRequest($pluginUrl);
$controller = $Dispatcher->dispatch($url, array('return' => 1));
- $this->assertIdentical($controller->plugin, 'my_plugin');
+ $this->assertIdentical($controller->plugin, 'MyPlugin');
$this->assertIdentical($controller->name, 'MyPlugin');
$this->assertIdentical($controller->action, 'index');
@@ -975,7 +975,7 @@ public function testAutomaticPluginControllerDispatch() {
$this->assertEqual($controller->params['action'], 'admin_add');
$this->assertEqual($controller->params['pass'], array(5));
$this->assertEqual($controller->params['named'], array('param' => 'value', 'param2' => 'value2'));
- $this->assertIdentical($controller->plugin, 'my_plugin');
+ $this->assertIdentical($controller->plugin, 'MyPlugin');
$this->assertIdentical($controller->name, 'MyPlugin');
$this->assertIdentical($controller->action, 'admin_add');
@@ -983,13 +983,13 @@ public function testAutomaticPluginControllerDispatch() {
$this->assertEqual($controller->passedArgs, $expected);
Configure::write('Routing.prefixes', array('admin'));
- CakePLugin::load('ArticlesTest', array('path' => '/fake/path'));
+ CakePlugin::load('ArticlesTest', array('path' => '/fake/path'));
Router::reload();
$Dispatcher = new TestDispatcher();
$controller = $Dispatcher->dispatch(new CakeRequest('admin/articles_test'), array('return' => 1));
- $this->assertIdentical($controller->plugin, 'articles_test');
+ $this->assertIdentical($controller->plugin, 'ArticlesTest');
$this->assertIdentical($controller->name, 'ArticlesTest');
$this->assertIdentical($controller->action, 'admin_index');
View
6 lib/Cake/View/Helper/FormHelper.php
@@ -261,8 +261,12 @@ function create($model = null, $options = array()) {
$options['action'] = $this->request->params['action'];
}
+ $plugin = null;
+ if ($this->plugin) {
+ $plugin = Inflector::underscore($this->plugin);
+ }
$actionDefaults = array(
- 'plugin' => $this->plugin,
+ 'plugin' => $plugin,
'controller' => $this->_View->viewPath,
'action' => $options['action'],
);
View
7 lib/Cake/View/View.php
@@ -316,7 +316,11 @@ public function element($name, $data = array(), $options = array()) {
}
if (isset($options['cache'])) {
- $keys = array_merge(array($plugin, $name), array_keys($options), array_keys($data));
+ $underscored = null;
+ if ($plugin) {
+ $underscored = Inflector::underscore($plugin);
+ }
+ $keys = array_merge(array($underscored, $name), array_keys($options), array_keys($data));
$caching = array(
'config' => $this->elementCache,
'key' => implode('_', $keys)
@@ -803,7 +807,6 @@ protected function _paths($plugin = null, $cached = true) {
$viewPaths = App::path('View');
$corePaths = array_flip(App::core('View'));
if (!empty($plugin)) {
- $plugin = Inflector::camelize($plugin);
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
if (!isset($corePaths[$viewPaths[$i]])) {
Please sign in to comment.
Something went wrong with that request. Please try again.