Permalink
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...
jrbasso committed Aug 1, 2011
1 parent 7604763 commit d84531d29c8944a81ab00cb82be616814d73cc2d
@@ -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 {
@@ -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'): ?>
@@ -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 {
@@ -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);
@@ -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);
@@ -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 {
@@ -28,6 +28,8 @@
* given client-side library.
*
* @package Cake.View.Helper
* @property HtmlHelper $Html
* @property FormHelper $Form
*/
class JsHelper extends AppHelper {
/**
@@ -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 {
@@ -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 {
@@ -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
@@ -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 {

0 comments on commit d84531d

Please sign in to comment.