Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

skipTables for ControllerTask and ViewTask #347

Closed
wants to merge 4 commits into from

3 participants

@petteyg

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

@petteyg petteyg referenced this pull request
Closed

skipTables #346

@markstory
Owner

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

@petteyg

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.

@markstory
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.

@petteyg

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.

@jippi
Collaborator

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 :)

@jippi jippi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 2, 2011
  1. @petteyg

    skipTables

    petteyg authored
  2. @petteyg

    skipTables for ViewTask

    petteyg authored
Commits on Dec 7, 2011
  1. @petteyg
  2. @petteyg

    typo

    petteyg authored
This page is out of date. Refresh to see the latest.
View
10 lib/Cake/Console/Command/Task/ControllerTask.php
@@ -42,6 +42,13 @@ class ControllerTask extends BakeTask {
public $path = null;
/**
+ * Tables to skip when running all()
+ *
+ * @var array
+ */
+ public $skipTables = array('cake_sessions', 'i18n');
+
+/**
* Override initialize
*
* @return void
@@ -106,6 +113,9 @@ public function all() {
ClassRegistry::config('Model', array('ds' => $this->connection));
$unitTestExists = $this->_checkUnitTest();
foreach ($this->__tables as $table) {
+ if (in_array($table, $this->skipTables)) {
+ continue;
+ }
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
App::uses($model, 'Model');
View
2  lib/Cake/Console/Command/Task/ModelTask.php
@@ -48,7 +48,7 @@ class ModelTask extends BakeTask {
*
* @var array
*/
- public $skipTables = array('i18n');
+ public $skipTables = array('cake_sessions', 'i18n');
/**
* Holds tables found on connection.
View
10 lib/Cake/Console/Command/Task/ViewTask.php
@@ -71,6 +71,13 @@ class ViewTask extends BakeTask {
public $noTemplateActions = array('delete');
/**
+ * Tables to skip when running all()
+ *
+ * @var array
+ */
+ public $skipTables = array('cake_sessions', 'i18n');
+
+/**
* Override initialize
*
* @return void
@@ -174,6 +181,9 @@ public function all() {
}
$this->interactive = false;
foreach ($tables as $table) {
+ if (in_array($table, $this->skipTables)) {
+ continue;
+ }
$model = $this->_modelName($table);
$this->controllerName = $this->_controllerName($model);
App::uses($model, 'Model');
Something went wrong with that request. Please try again.