Skip to content
This repository

skipTables for ControllerTask and ViewTask #347

Closed
wants to merge 4 commits into from

3 participants

Gordon Mark Story Christian Winther
Gordon

Add skipTables from ModelTask to ControllerTask and ViewTask so that cake bake controller all and cake bake view all will not fail when i18n table exists

Gordon petteyg referenced this pull request December 01, 2011
Closed

skipTables #346

Mark Story
Owner

Couldn't this filtering be done in ModelTask? Then it wouldn't need to be in 2 places.

Gordon

It is done in ModelTask, so cake bake model all works, but then subsequent cake bake controller all and/or cake bake view all fail.

Mark Story
Owner

Wouldn't having ModelTask::getAllTables() return the filtered results work as well? Then those tables would never be iterated over. There might need to be another parameter for getAllTables() to enable filtering though.

Gordon

All three tasks had a pretty much identical method for going through the tables, so I just copied the "if i18n" part as the least possible modification. With baked controllers and views being somewhat useless without models, though, I don't see why those tasks need to iterate over tables, rather than just using existing models.

Christian Winther
Collaborator
jippi commented July 15, 2013

Hi

I'm gonna close this PR as it's 2 years old, and against a branch that is no longer actively developed on

Thanks for the contribution though :)

Christian Winther jippi closed this July 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
10  lib/Cake/Console/Command/Task/ControllerTask.php
@@ -42,6 +42,13 @@ class ControllerTask extends BakeTask {
42 42
 	public $path = null;
43 43
 
44 44
 /**
  45
+ * Tables to skip when running all()
  46
+ *
  47
+ * @var array
  48
+ */
  49
+	public $skipTables = array('cake_sessions', 'i18n');
  50
+
  51
+/**
45 52
  * Override initialize
46 53
  *
47 54
  * @return void
@@ -106,6 +113,9 @@ public function all() {
106 113
 		ClassRegistry::config('Model', array('ds' => $this->connection));
107 114
 		$unitTestExists = $this->_checkUnitTest();
108 115
 		foreach ($this->__tables as $table) {
  116
+			if (in_array($table, $this->skipTables)) {
  117
+				continue;
  118
+			}
109 119
 			$model = $this->_modelName($table);
110 120
 			$controller = $this->_controllerName($model);
111 121
 			App::uses($model, 'Model');
2  lib/Cake/Console/Command/Task/ModelTask.php
@@ -48,7 +48,7 @@ class ModelTask extends BakeTask {
48 48
  *
49 49
  * @var array
50 50
  */
51  
-	public $skipTables = array('i18n');
  51
+	public $skipTables = array('cake_sessions', 'i18n');
52 52
 
53 53
 /**
54 54
  * Holds tables found on connection.
10  lib/Cake/Console/Command/Task/ViewTask.php
@@ -71,6 +71,13 @@ class ViewTask extends BakeTask {
71 71
 	public $noTemplateActions = array('delete');
72 72
 
73 73
 /**
  74
+ * Tables to skip when running all()
  75
+ *
  76
+ * @var array
  77
+ */
  78
+	public $skipTables = array('cake_sessions', 'i18n');
  79
+
  80
+/**
74 81
  * Override initialize
75 82
  *
76 83
  * @return void
@@ -174,6 +181,9 @@ public function all() {
174 181
 		}
175 182
 		$this->interactive = false;
176 183
 		foreach ($tables as $table) {
  184
+			if (in_array($table, $this->skipTables)) {
  185
+				continue;
  186
+			}
177 187
 			$model = $this->_modelName($table);
178 188
 			$this->controllerName = $this->_controllerName($model);
179 189
 			App::uses($model, 'Model');
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.