Skip to content

Commit

Permalink
Back to the future and bring some FQN
Browse files Browse the repository at this point in the history
  • Loading branch information
ndm2 committed Nov 30, 2014
1 parent 23b79e4 commit 9e4595e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Template/Bake/Controller/controller.ctp
Expand Up @@ -33,7 +33,7 @@ use <%= $namespace %>\Controller\AppController;
foreach ($components as $component):
$classInfo = $this->Bake->classInfo($component, 'Controller/Component', 'Component');
%>
* @property \<%= $classInfo['namespace'] %>\<%= $classInfo['class'] %> $<%= $classInfo['name'] %>
* @property <%= $classInfo['fqn'] %> $<%= $classInfo['name'] %>
<% endforeach; %>
*/
class <%= $name %>Controller extends AppController {
Expand Down
5 changes: 4 additions & 1 deletion src/View/Helper/BakeHelper.php
Expand Up @@ -98,6 +98,7 @@ public function aliasExtractor($table, $assoc) {
*
* The returned array holds the following keys:
*
* - `fqn` (the fully qualified name)
* - `namespace` (the full namespace without leading separator)
* - `class` (the class name)
* - `plugin` (either the name of the plugin, or `null`)
Expand All @@ -118,12 +119,14 @@ public function classInfo($class, $type, $suffix) {
}
$base = str_replace('/', '\\', trim($base, '\\'));
$sub = '\\' . str_replace('/', '\\', trim($type, '\\'));
$qn = $sub . '\\' . $name . $suffix;

if (class_exists('\Cake' . $sub . '\\' . $name . $suffix)) {
if (class_exists('\Cake' . $qn)) {
$base = 'Cake';
}

return [
'fqn' => '\\' . $base . $qn,
'namespace' => $base . $sub,
'plugin' => $plugin,
'class' => $name . $suffix,
Expand Down
Expand Up @@ -9,7 +9,7 @@
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @since 1.2.0
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

Expand Down

0 comments on commit 9e4595e

Please sign in to comment.