diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index fbc96389472..fad4639d06b 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -441,11 +441,29 @@ protected function _extractValidationMessages() { return; } + $plugins = array(null); + if (empty($this->params['exclude-plugins'])) { + $plugins = array_merge($plugins, App::objects('plugins')); + } + foreach ($plugins as $plugin) { + $this->_extractPluginValidationMessages($plugin); + } + } + +/** + * Extract validation messages from application or plugin models + * + * @param string $plugin Plugin name or `null` to process application models + * @return void + */ + protected function _extractPluginValidationMessages($plugin = null) { App::uses('AppModel', 'Model'); - $plugin = null; - if (!empty($this->params['plugin'])) { - App::uses($this->params['plugin'] . 'AppModel', $this->params['plugin'] . '.Model'); - $plugin = $this->params['plugin'] . '.'; + if (!empty($plugin)) { + if (!CakePlugin::loaded($plugin)) { + return; + } + App::uses($plugin . 'AppModel', $plugin . '.Model'); + $plugin = $plugin . '.'; } $models = App::objects($plugin . 'Model', null, false); diff --git a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php index d4aa46433e5..48526892815 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php @@ -268,7 +268,7 @@ public function testExtractPlugin() { $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); $this->Task = $this->getMock('ExtractTask', - array('_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'), + array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'), array($this->out, $this->out, $this->in) ); @@ -280,6 +280,7 @@ public function testExtractPlugin() { $this->assertNotRegExp('#Pages#', $result); $this->assertContains('translate.ctp:1', $result); $this->assertContains('This is a translatable string', $result); + $this->assertContains('I can haz plugin model validation message', $result); } /** diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php index 5f0480d674f..2708e162223 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php @@ -32,4 +32,13 @@ class TestPluginAuthors extends TestPluginAppModel { public $name = 'TestPluginAuthors'; + public $validate = array( + 'field' => array( + 'notEmpty' => array( + 'rule' => 'notEmpty', + 'message' => 'I can haz plugin model validation message', + ), + ), + ); + }