Skip to content

Commit 24ef0cc

Browse files
authored
Merge pull request #303 from burzum/bug/getTableObject
Fixing a bug that appears when trying to bake plugin models
2 parents 28d9a67 + 9ac53c0 commit 24ef0cc

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/Shell/Task/ModelTask.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ public function all()
175175
*/
176176
public function getTableObject($className, $table)
177177
{
178+
$plugin = $this->param('plugin');
179+
if (!empty($plugin)) {
180+
$className = $plugin . '.' . $className;
181+
}
182+
178183
if (TableRegistry::exists($className)) {
179184
return TableRegistry::get($className);
180185
}

tests/TestCase/Shell/Task/ModelTaskTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ public function testGetTableObject()
181181
$this->assertInstanceOf('Cake\ORM\Table', $result);
182182
$this->assertEquals('bake_articles', $result->table());
183183
$this->assertEquals('Article', $result->alias());
184+
185+
$this->Task->params['plugin'] = 'BakeTest';
186+
$result = $this->Task->getTableObject('Authors', 'bake_articles');
187+
$this->assertInstanceOf('BakeTest\Model\Table\AuthorsTable', $result);
184188
}
185189

186190
/**

0 commit comments

Comments
 (0)