Browse Source

Add method to split plugin and class names up.

Refs #3512
mark_story 12 years ago
parent
commit
7818aa87ec

+ 16 - 6
src/Console/Command/Task/BakeTask.php

@@ -80,12 +80,6 @@ class BakeTask extends Shell {
  * @return void
  */
 	public function main() {
-		foreach ($this->args as $i => $arg) {
-			if (strpos($arg, '.')) {
-				list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
-				break;
-			}
-		}
 		if (isset($this->params['plugin'])) {
 			$this->plugin = $this->params['plugin'];
 		}
@@ -95,6 +89,22 @@ class BakeTask extends Shell {
 	}
 
 /**
+ * Handles splitting up the plugin prefix and classname.
+ *
+ * Sets the plugin parameter and plugin property.
+ *
+ * @param string $name The name to possibly split.
+ * @return string The name without the plugin prefix.
+ */
+	protected function _getName($name) {
+		if (strpos($name, '.')) {
+			list($plugin, $name) = pluginSplit($name);
+			$this->plugin = $this->params['plugin'] = $plugin;
+		}
+		return $name;
+	}
+
+/**
  * Get the option parser for this task.
  *
  * This base class method sets up some commonly used options.

+ 1 - 0
src/Console/Command/Task/ControllerTask.php

@@ -46,6 +46,7 @@ class ControllerTask extends BakeTask {
  */
 	public function main($name = null) {
 		parent::main();
+		$name = $this->_getName($name);
 
 		if (empty($name)) {
 			$this->out(__d('cake_console', 'Possible controllers based on your current database:'));

+ 1 - 0
src/Console/Command/Task/FixtureTask.php

@@ -92,6 +92,7 @@ class FixtureTask extends BakeTask {
  */
 	public function main($name = null) {
 		parent::main();
+		$name = $this->_getName($name);
 
 		if (empty($name)) {
 			$this->out(__d('cake_console', 'Choose a fixture to bake from the following:'));

+ 1 - 0
src/Console/Command/Task/ModelTask.php

@@ -77,6 +77,7 @@ class ModelTask extends BakeTask {
  */
 	public function main($name = null) {
 		parent::main();
+		$name = $this->_getName($name);
 
 		if (empty($name)) {
 			$this->out(__d('cake_console', 'Choose a model to bake from the following:'));

+ 1 - 0
src/Console/Command/Task/SimpleBakeTask.php

@@ -77,6 +77,7 @@ abstract class SimpleBakeTask extends BakeTask {
 		if (empty($name)) {
 			return $this->error('You must provide a name to bake a ' . $this->name());
 		}
+		$name = $this->_getName($name);
 		$name = Inflector::camelize($name);
 		$this->bake($name);
 		$this->bakeTest($name);

+ 1 - 0
src/Console/Command/Task/ViewTask.php

@@ -109,6 +109,7 @@ class ViewTask extends BakeTask {
 			}
 			return true;
 		}
+		$name = $this->_getName($name);
 
 		$controller = null;
 		if (!empty($this->params['controller'])) {