controller.ctp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Controller bake template file
  4. *
  5. * Allows templating of Controllers generated from bake.
  6. *
  7. * PHP 5
  8. *
  9. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. *
  12. * Licensed under The MIT License
  13. * Redistributions of files must retain the above copyright notice.
  14. *
  15. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link http://cakephp.org CakePHP(tm) Project
  17. * @package Cake.Console.Templates.default.classes
  18. * @since CakePHP(tm) v 1.3
  19. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  20. */
  21. echo "<?php\n";
  22. echo "App::uses('{$plugin}AppController', '{$pluginPath}Controller');\n";
  23. ?>
  24. /**
  25. * <?php echo $controllerName; ?> Controller
  26. *
  27. <?php
  28. if (!$isScaffold) {
  29. $defaultModel = Inflector::singularize($controllerName);
  30. echo " * @property {$defaultModel} \${$defaultModel}\n";
  31. if (!empty($components)) {
  32. foreach ($components as $component) {
  33. echo " * @property {$component}Component \${$component}\n";
  34. }
  35. }
  36. }
  37. ?>
  38. */
  39. class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
  40. <?php if ($isScaffold): ?>
  41. /**
  42. * Scaffold
  43. *
  44. * @var mixed
  45. */
  46. public $scaffold;
  47. <?php else:
  48. if (count($helpers)):
  49. echo "/**\n * Helpers\n *\n * @var array\n */\n";
  50. echo "\tpublic \$helpers = array(";
  51. for ($i = 0, $len = count($helpers); $i < $len; $i++):
  52. if ($i != $len - 1):
  53. echo "'" . Inflector::camelize($helpers[$i]) . "', ";
  54. else:
  55. echo "'" . Inflector::camelize($helpers[$i]) . "'";
  56. endif;
  57. endfor;
  58. echo ");\n\n";
  59. endif;
  60. if (count($components)):
  61. echo "/**\n * Components\n *\n * @var array\n */\n";
  62. echo "\tpublic \$components = array(";
  63. for ($i = 0, $len = count($components); $i < $len; $i++):
  64. if ($i != $len - 1):
  65. echo "'" . Inflector::camelize($components[$i]) . "', ";
  66. else:
  67. echo "'" . Inflector::camelize($components[$i]) . "'";
  68. endif;
  69. endfor;
  70. echo ");\n\n";
  71. endif;
  72. echo trim($actions) . "\n";
  73. endif; ?>
  74. }