Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using @property to autocomplete components and helpers in some IDEs. …

…Also added @property to bake of controller and model. Fixes #103.
  • Loading branch information...
commit d84531d29c8944a81ab00cb82be616814d73cc2d 1 parent 7604763
@jrbasso jrbasso authored
View
11 lib/Cake/Console/Templates/default/classes/controller.ctp
@@ -24,6 +24,17 @@ echo "<?php\n";
/**
* <?php echo $controllerName; ?> Controller
*
+<?php
+if (!$isScaffold) {
+ $defaultModel = Inflector::singularize($controllerName);
+ echo " * @property {$defaultModel} \${$defaultModel}\n";
+ if (!empty($components)) {
+ foreach ($components as $component) {
+ echo " * @property {$component}Component \${$component}\n";
+ }
+ }
+}
+?>
*/
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
View
9 lib/Cake/Console/Templates/default/classes/model.ctp
@@ -23,6 +23,15 @@ echo "<?php\n"; ?>
/**
* <?php echo $name ?> Model
*
+<?php
+foreach (array('hasOne', 'belongsTo', 'hasMany', 'hasAndBelongsToMany') as $assocType) {
+ if (!empty($associations[$assocType])) {
+ foreach ($associations[$assocType] as $relation) {
+ echo " * @property {$relation['className']} \${$relation['alias']}\n";
+ }
+ }
+}
+?>
*/
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
<?php if ($useDbConfig != 'default'): ?>
View
10 lib/Cake/Controller/Controller.php
@@ -47,7 +47,15 @@
* using Router::connect().
*
* @package Cake.Controller
- * @link http://book.cakephp.org/view/956/Introduction
+ * @property AclComponent $Acl
+ * @property AuthComponent $Auth
+ * @property CookieComponent $Cookie
+ * @property EmailComponent $Email
+ * @property PaginatorComponent $Paginator
+ * @property RequestHandlerComponent $RequestHandler
+ * @property SecurityComponent $Security
+ * @property SessionComponent $Session
+ * @link http://book.cakephp.org/view/956/Introduction
*/
class Controller extends Object {
View
5 lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
@@ -270,6 +270,9 @@ public function testBake() {
$this->Task->expects($this->any())->method('createFile')->will($this->returnValue(true));
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components);
+ $this->assertContains(' * @property Article $Article', $result);
+ $this->assertContains(' * @property AclComponent $Acl', $result);
+ $this->assertContains(' * @property AuthComponent $Auth', $result);
$this->assertContains('class ArticlesController extends AppController', $result);
$this->assertContains("\$components = array('Acl', 'Auth')", $result);
$this->assertContains("\$helpers = array('Ajax', 'Time')", $result);
@@ -278,11 +281,13 @@ public function testBake() {
$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);
$this->assertContains("class ArticlesController extends AppController", $result);
$this->assertContains("public \$scaffold", $result);
+ $this->assertNotContains('@property', $result);
$this->assertNotContains('helpers', $result);
$this->assertNotContains('components', $result);
$result = $this->Task->bake('Articles', '--actions--', array(), array());
$this->assertContains('class ArticlesController extends AppController', $result);
+ $this->assertIdentical(substr_count($result, '@property'), 1);
$this->assertNotContains('components', $result);
$this->assertNotContains('helpers', $result);
$this->assertContains('--actions--', $result);
View
4 lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
@@ -726,6 +726,10 @@ public function testBakeRelations() {
)
);
$result = $this->Task->bake('BakeArticle', compact('associations'));
+ $this->assertContains(' * @property BakeUser $BakeUser', $result);
+ $this->assertContains(' * @property OtherModel $OtherModel', $result);
+ $this->assertContains(' * @property BakeComment $BakeComment', $result);
+ $this->assertContains(' * @property BakeTag $BakeTag', $result);
$this->assertPattern('/\$hasAndBelongsToMany \= array\(/', $result);
$this->assertPattern('/\$hasMany \= array\(/', $result);
$this->assertPattern('/\$belongsTo \= array\(/', $result);
View
1  lib/Cake/View/Helper/FormHelper.php
@@ -27,6 +27,7 @@
* Automatic generation of HTML FORMs from given data.
*
* @package Cake.View.Helper
+ * @property HtmlHelper $Html
* @link http://book.cakephp.org/view/1383/Form
*/
class FormHelper extends AppHelper {
View
2  lib/Cake/View/Helper/JsHelper.php
@@ -28,6 +28,8 @@
* given client-side library.
*
* @package Cake.View.Helper
+ * @property HtmlHelper $Html
+ * @property FormHelper $Form
*/
class JsHelper extends AppHelper {
/**
View
1  lib/Cake/View/Helper/PaginatorHelper.php
@@ -25,6 +25,7 @@
* PaginationHelper encloses all methods needed when working with pagination.
*
* @package Cake.View.Helper
+ * @property HtmlHelper $Html
* @link http://book.cakephp.org/view/1458/Paginator
*/
class PaginatorHelper extends AppHelper {
View
1  lib/Cake/View/Helper/RssHelper.php
@@ -24,6 +24,7 @@
* RSS Helper class for easy output RSS structures.
*
* @package Cake.View.Helper
+ * @property TimeHelper $Time
* @link http://book.cakephp.org/view/1460/RSS
*/
class RssHelper extends AppHelper {
View
1  lib/Cake/View/Helper/TextHelper.php
@@ -33,6 +33,7 @@
* Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links...
*
* @package Cake.View.Helper
+ * @property HtmlHelper $Html
* @link http://book.cakephp.org/view/1469/Text
*/
class TextHelper extends AppHelper {
View
10 lib/Cake/View/View.php
@@ -34,6 +34,16 @@
* layout using `$this->set()`
*
* @package Cake.View
+ * @property CacheHelper $Cache
+ * @property FormHelper $Form
+ * @property HtmlHelper $Html
+ * @property JsHelper $Js
+ * @property NumberHelper $Number
+ * @property PaginatorHelper $Paginator
+ * @property RssHelper $Rss
+ * @property SessionHelper $Session
+ * @property TextHelper $Text
+ * @property TimeHelper $Time
*/
class View extends Object {
Please sign in to comment.
Something went wrong with that request. Please try again.