mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Some docblock formatting changes, and /libs/bake.php - takes time, but domumenting is very educating :)
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@140 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ea0191d321
commit
ec0abbaac0
9 changed files with 381 additions and 296 deletions
|
@ -14,32 +14,31 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: AppController
|
* This file is application-wide controller file. You can put all
|
||||||
* This file is application-wide controller file. You can put all
|
* application-wide controller-related methods here.
|
||||||
* application-wide controller-related methods here.
|
*
|
||||||
*
|
* @filesource
|
||||||
* @filesource
|
* @author Cake Authors/Developers
|
||||||
* @author Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @package cake
|
||||||
* @package cake
|
* @subpackage cake.app
|
||||||
* @subpackage cake.app
|
* @since Cake v 0.2.9
|
||||||
* @since Cake v 0.2.9
|
* @version $Revision$
|
||||||
* @version $Revision$
|
* @modifiedby $LastChangedBy$
|
||||||
* @modifiedby $LastChangedBy$
|
* @lastmodified $Date$
|
||||||
* @lastmodified $Date$
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add your application-wide methods in the class below, your controllers
|
* Add your application-wide methods in the class below, your controllers
|
||||||
* will be inheriting them.
|
* will be inheriting them.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.app
|
* @subpackage cake.app
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class AppController extends Controller {
|
class AppController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,32 +14,31 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: AppModel
|
* This file is application-wide model file. You can put all
|
||||||
* This file is application-wide model file. You can put all
|
* application-wide model-related methods here.
|
||||||
* application-wide model-related methods here.
|
*
|
||||||
*
|
* @filesource
|
||||||
* @filesource
|
* @author Cake Authors/Developers
|
||||||
* @author Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @package cake
|
||||||
* @package cake
|
* @subpackage cake.app
|
||||||
* @subpackage cake.app
|
* @since Cake v 0.2.9
|
||||||
* @since Cake v 0.2.9
|
* @version $Revision$
|
||||||
* @version $Revision$
|
* @modifiedby $LastChangedBy$
|
||||||
* @modifiedby $LastChangedBy$
|
* @lastmodified $Date$
|
||||||
* @lastmodified $Date$
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add your application-wide methods in the class below, your models
|
* Add your application-wide methods in the class below, your models
|
||||||
* will be inheriting them.
|
* will be inheriting them.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.app
|
* @subpackage cake.app
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class AppModel extends Model {
|
class AppModel extends Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,21 +14,21 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is core configuration file. Use it to configure core behaviour of
|
* This is core configuration file. Use it to configure core behaviour of
|
||||||
* Cake.
|
* Cake.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.config
|
* @subpackage cake.config
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @modifiedby $LastChangedBy$
|
* @modifiedby $LastChangedBy$
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set debug level here:
|
* Set debug level here:
|
||||||
|
|
|
@ -14,26 +14,26 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this file you set up your database connection details.
|
* In this file you set up your database connection details.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.config
|
* @subpackage cake.config
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @modifiedby $LastChangedBy$
|
* @modifiedby $LastChangedBy$
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database configuration array. You can configure multiple connections.
|
* Database configuration array. You can configure multiple connections.
|
||||||
*
|
*
|
||||||
* @var array $DATABASE_CONFIG
|
* @var array $DATABASE_CONFIG
|
||||||
*/
|
*/
|
||||||
$DATABASE_CONFIG = array(
|
$DATABASE_CONFIG = array(
|
||||||
'devel' => array(
|
'devel' => array(
|
||||||
'driver' => 'mysql',
|
'driver' => 'mysql',
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this file you set paths to different directories used by Cake.
|
* In this file you set paths to different directories used by Cake.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.config
|
* @subpackage cake.config
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @modifiedby $LastChangedBy$
|
* @modifiedby $LastChangedBy$
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If index.php file is used instead of an .htaccess file
|
* If index.php file is used instead of an .htaccess file
|
||||||
|
|
|
@ -14,23 +14,23 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this file, you set up routes to your controllers and their actions.
|
* In this file, you set up routes to your controllers and their actions.
|
||||||
* Routes are very important mechanism that allows you to freely connect
|
* Routes are very important mechanism that allows you to freely connect
|
||||||
* different urls to chosen controllers and their actions (functions).
|
* different urls to chosen controllers and their actions (functions).
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.config
|
* @subpackage cake.config
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @modifiedby $LastChangedBy$
|
* @modifiedby $LastChangedBy$
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here, we are connecting '/' (base path) to controller called 'Pages', and
|
* Here, we are connecting '/' (base path) to controller called 'Pages', and
|
||||||
|
|
|
@ -14,23 +14,23 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this file, you set up routes to your controllers and their actions.
|
* In this file, you set up routes to your controllers and their actions.
|
||||||
* Routes are very important mechanism that allows you to freely connect
|
* Routes are very important mechanism that allows you to freely connect
|
||||||
* different urls to chosen controllers and their actions (functions).
|
* different urls to chosen controllers and their actions (functions).
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.config
|
* @subpackage cake.config
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @modifiedby $LastChangedBy$
|
* @modifiedby $LastChangedBy$
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here, we are connecting '/' (base path) to controller called 'Pages', and
|
* Here, we are connecting '/' (base path) to controller called 'Pages', and
|
||||||
|
|
|
@ -14,21 +14,21 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this file, you can set up 'templates' for every tag generated by the tag
|
* In this file, you can set up 'templates' for every tag generated by the tag
|
||||||
* generator.
|
* generator.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Cake Authors/Developers
|
* @author Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.config
|
* @subpackage cake.config
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @modifiedby $LastChangedBy$
|
* @modifiedby $LastChangedBy$
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag template for a link.
|
* Tag template for a link.
|
||||||
|
|
391
libs/bake.php
391
libs/bake.php
|
@ -14,81 +14,84 @@
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose: Bake
|
* Creates controller, model, view files, and the required directories on demand.
|
||||||
* Creates controller, model, view files, and the required directories on demand.
|
* Used by /scripts/add.php.
|
||||||
* Used by scripts/add.php
|
*
|
||||||
*
|
* @filesource
|
||||||
* @filesource
|
* @author Cake Authors/Developers
|
||||||
* @author Cake Authors/Developers
|
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
||||||
* @copyright Copyright (c) 2005, Cake Authors/Developers
|
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
||||||
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
|
* @package cake
|
||||||
* @package cake
|
* @subpackage cake.libs
|
||||||
* @subpackage cake.libs
|
* @since Cake v 0.2.9
|
||||||
* @since Cake v 0.2.9
|
* @version $Revision$
|
||||||
* @version $Revision$
|
* @modifiedby $LastChangedBy$
|
||||||
* @modifiedby $LastChangedBy$
|
* @lastmodified $Date$
|
||||||
* @lastmodified $Date$
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Require needed libraries.
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
uses('object', 'inflector');
|
uses('object', 'inflector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Bake class creates files in configured application directories. This is a
|
||||||
*
|
* base class for /scripts/add.php.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.libs
|
* @subpackage cake.libs
|
||||||
* @since Cake v 0.2.9
|
* @since Cake v 0.2.9
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
class Bake extends Object {
|
class Bake extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Standard input stream (php://stdin).
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var resource
|
||||||
*/
|
* @access private
|
||||||
|
*/
|
||||||
var $stdin = null;
|
var $stdin = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Standard output stream (php://stdout).
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var resource
|
||||||
*/
|
* @access private
|
||||||
|
*/
|
||||||
var $stdout = null;
|
var $stdout = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Standard error stream (php://stderr).
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var resource
|
||||||
*/
|
* @access private
|
||||||
|
*/
|
||||||
var $stderr = null;
|
var $stderr = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Counts taken actions.
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var integer
|
||||||
*/
|
* @access private
|
||||||
|
*/
|
||||||
var $actions = null;
|
var $actions = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Decides wether to overwrite existing files without asking.
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var boolean
|
||||||
*/
|
* @access private
|
||||||
var $dont_ask = false;
|
*/
|
||||||
|
var $dontAsk = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns template for file generator.
|
||||||
*
|
*
|
||||||
* @param unknown_type $type
|
* @param string $type
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
*/
|
||||||
function template ($type) {
|
function template ($type) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'view': return "%s";
|
case 'view': return "%s";
|
||||||
|
@ -128,11 +131,18 @@ class %sTest extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Baker's constructor method. Initialises bakery, and starts production.
|
||||||
*
|
*
|
||||||
* @param unknown_type $type
|
* @param string $type
|
||||||
* @param unknown_type $names
|
* @param array $names
|
||||||
*/
|
* @access public
|
||||||
|
* @uses Bake::stdin Opens stream for reading.
|
||||||
|
* @uses Bake::stdout Opens stream for writing.
|
||||||
|
* @uses Bake::stderr Opens stream for writing.
|
||||||
|
* @uses Bake::newModel() Depending on the case, can create a new model.
|
||||||
|
* @uses Bake::newView() Depending on the case, can create a new view.
|
||||||
|
* @uses Bake::newController() Depending on the case, can create a new controller.
|
||||||
|
*/
|
||||||
function __construct ($type, $names) {
|
function __construct ($type, $names) {
|
||||||
|
|
||||||
$this->stdin = fopen('php://stdin', 'r');
|
$this->stdin = fopen('php://stdin', 'r');
|
||||||
|
@ -177,11 +187,18 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new view in VIEWS/$controller/ directory.
|
||||||
*
|
*
|
||||||
* @param unknown_type $controller
|
* @param string $controller
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Inflector::underscore() Underscores directory' name.
|
||||||
|
* @uses Bake::createDir() Creates new directory in views, depending on the controller's name.
|
||||||
|
* @uses VIEWS
|
||||||
|
* @uses Bake::createFile() Creates view file.
|
||||||
|
* @uses Bake::template() Collects view template.
|
||||||
|
* @uses Bake::actions Adds one action for each run.
|
||||||
|
*/
|
||||||
function newView ($controller, $name) {
|
function newView ($controller, $name) {
|
||||||
$dir = Inflector::underscore($controller);
|
$dir = Inflector::underscore($controller);
|
||||||
$path = "{$dir}/".strtolower($name).".thtml";
|
$path = "{$dir}/".strtolower($name).".thtml";
|
||||||
|
@ -192,11 +209,18 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new controller with defined actions, controller's test and helper
|
||||||
*
|
* with helper's test.
|
||||||
* @param unknown_type $name
|
*
|
||||||
* @param array $actions
|
* @param string $name
|
||||||
*/
|
* @param array $actions
|
||||||
|
* @access private
|
||||||
|
* @uses Bake::makeController()
|
||||||
|
* @uses Bake::makeControllerTest()
|
||||||
|
* @uses Bake::makeHelper()
|
||||||
|
* @uses Bake::makeHelperTest()
|
||||||
|
* @uses Bake::actions Adds one action for each run.
|
||||||
|
*/
|
||||||
function newController ($name, $actions=array()) {
|
function newController ($name, $actions=array()) {
|
||||||
$this->makeController($name, $actions);
|
$this->makeController($name, $actions);
|
||||||
$this->makeControllerTest($name);
|
$this->makeControllerTest($name);
|
||||||
|
@ -206,12 +230,19 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new controller file with defined actions.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @param array $actions
|
* @param array $actions
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::makeControllerName() CamelCase for controller's name.
|
||||||
|
* @uses Bake::makeHelperName() CamelCase for helper's name.
|
||||||
|
* @uses Bake::template() Controller's template.
|
||||||
|
* @uses Bake::getActions() Actions' templates to be included in the controller.
|
||||||
|
* @uses Bake::createFile() Creates controller's file.
|
||||||
|
* @uses Bake::makeControllerFn() Underscored name for controller's filename.
|
||||||
|
*/
|
||||||
function makeController ($name, $actions) {
|
function makeController ($name, $actions) {
|
||||||
$ctrl = $this->makeControllerName($name);
|
$ctrl = $this->makeControllerName($name);
|
||||||
$helper = $this->makeHelperName($name);
|
$helper = $this->makeHelperName($name);
|
||||||
|
@ -220,31 +251,41 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns controller's name in CamelCase.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Inflector::camelize CamelCase for controller name.
|
||||||
|
*/
|
||||||
function makeControllerName ($name) {
|
function makeControllerName ($name) {
|
||||||
return Inflector::camelize($name).'Controller';
|
return Inflector::camelize($name).'Controller';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns a name for controller's file, underscored.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Inflector::underscore() Underscore for controller's file name.
|
||||||
|
*/
|
||||||
function makeControllerFn ($name) {
|
function makeControllerFn ($name) {
|
||||||
return CONTROLLERS.Inflector::underscore($name).'_controller.php';
|
return CONTROLLERS.Inflector::underscore($name).'_controller.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new test for a controller.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses CONTROLLER_TESTS
|
||||||
|
* @uses Inflector::underscore()
|
||||||
|
* @uses Bake::getTestBody()
|
||||||
|
* @uses Bake::makeControllerName()
|
||||||
|
* @uses Bake::createFile()
|
||||||
|
*/
|
||||||
function makeControllerTest ($name) {
|
function makeControllerTest ($name) {
|
||||||
$fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
|
$fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
|
||||||
$body = $this->getTestBody($this->makeControllerName($name));
|
$body = $this->getTestBody($this->makeControllerName($name));
|
||||||
|
@ -252,42 +293,58 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new helper.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::template()
|
||||||
|
* @uses Bake::makeHelperName()
|
||||||
|
* @uses Bake::createFile()
|
||||||
|
* @uses Bake::makeHelperFn()
|
||||||
|
*/
|
||||||
function makeHelper ($name) {
|
function makeHelper ($name) {
|
||||||
$body = sprintf($this->template('helper'), $this->makeHelperName($name));
|
$body = sprintf($this->template('helper'), $this->makeHelperName($name));
|
||||||
return $this->createFile($this->makeHelperFn($name), $body);
|
return $this->createFile($this->makeHelperFn($name), $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns CamelCase name for a helper.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Inflector::camelize()
|
||||||
|
*/
|
||||||
function makeHelperName ($name) {
|
function makeHelperName ($name) {
|
||||||
return Inflector::camelize($name).'Helper';
|
return Inflector::camelize($name).'Helper';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Underscores file name for a helper.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses HELPERS
|
||||||
|
* @uses Inflector::underscore()
|
||||||
|
*/
|
||||||
function makeHelperFn ($name) {
|
function makeHelperFn ($name) {
|
||||||
return HELPERS.Inflector::underscore($name).'_helper.php';
|
return HELPERS.Inflector::underscore($name).'_helper.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new test for a helper.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses HELPER_TESTS
|
||||||
|
* @uses Inflector::underscore()
|
||||||
|
* @uses Bake::getTestBody()
|
||||||
|
* @uses Bake::makeHelperName()
|
||||||
|
* @uses Bake::createFile()
|
||||||
|
*/
|
||||||
function makeHelperTest ($name) {
|
function makeHelperTest ($name) {
|
||||||
$fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
|
$fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
|
||||||
$body = $this->getTestBody($this->makeHelperName($name));
|
$body = $this->getTestBody($this->makeHelperName($name));
|
||||||
|
@ -295,11 +352,13 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns array of actions' templates.
|
||||||
*
|
*
|
||||||
* @param unknown_type $as
|
* @param array $as
|
||||||
* @return unknown
|
* @return array
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::template()
|
||||||
|
*/
|
||||||
function getActions ($as) {
|
function getActions ($as) {
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach ($as as $a)
|
foreach ($as as $a)
|
||||||
|
@ -308,20 +367,29 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns test template for defined class.
|
||||||
*
|
*
|
||||||
* @param unknown_type $class
|
* @param string $class
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::template()
|
||||||
|
*/
|
||||||
function getTestBody ($class) {
|
function getTestBody ($class) {
|
||||||
return sprintf($this->template('test'), $class, $class);
|
return sprintf($this->template('test'), $class, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates new model.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::createFile()
|
||||||
|
* @uses Bake::getModelFn()
|
||||||
|
* @uses Bake::template()
|
||||||
|
* @uses Bake::getModelName()
|
||||||
|
* @uses Bake::makeModelTest()
|
||||||
|
* @uses Bake::actions
|
||||||
|
*/
|
||||||
function newModel ($name) {
|
function newModel ($name) {
|
||||||
$this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
|
$this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
|
||||||
$this->makeModelTest ($name);
|
$this->makeModelTest ($name);
|
||||||
|
@ -329,21 +397,30 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns underscored name for model's file.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses MODELS
|
||||||
|
* @uses Inflector::underscore()
|
||||||
|
*/
|
||||||
function getModelFn ($name) {
|
function getModelFn ($name) {
|
||||||
return MODELS.Inflector::underscore($name).'.php';
|
return MODELS.Inflector::underscore($name).'.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates a test for a given model.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses MODEL_TESTS
|
||||||
|
* @uses Inflector::underscore()
|
||||||
|
* @uses Bake::getTestBody()
|
||||||
|
* @uses Bake::getModelName()
|
||||||
|
* @uses Bake::createFile()
|
||||||
|
*/
|
||||||
function makeModelTest ($name) {
|
function makeModelTest ($name) {
|
||||||
$fn = MODEL_TESTS.Inflector::underscore($name).'_test.php';
|
$fn = MODEL_TESTS.Inflector::underscore($name).'_test.php';
|
||||||
$body = $this->getTestBody($this->getModelName($name));
|
$body = $this->getTestBody($this->getModelName($name));
|
||||||
|
@ -351,25 +428,32 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Returns CamelCased name of a model.
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Inflector::camelize()
|
||||||
|
*/
|
||||||
function getModelName ($name) {
|
function getModelName ($name) {
|
||||||
return Inflector::camelize($name);
|
return Inflector::camelize($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates a file with given path and contents.
|
||||||
*
|
*
|
||||||
* @param unknown_type $path
|
* @param string $path
|
||||||
* @param unknown_type $contents
|
* @param string $contents
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::dontAsk
|
||||||
|
* @uses Bake::stdin
|
||||||
|
* @uses Bake::stdout
|
||||||
|
* @uses Bake::stderr
|
||||||
|
*/
|
||||||
function createFile ($path, $contents) {
|
function createFile ($path, $contents) {
|
||||||
|
|
||||||
if (is_file($path) && !$this->dont_ask) {
|
if (is_file($path) && !$this->dontAsk) {
|
||||||
fwrite($this->stdout, "File {$path} exists, overwrite? (yNaq) ");
|
fwrite($this->stdout, "File {$path} exists, overwrite? (yNaq) ");
|
||||||
$key = fgets($this->stdin);
|
$key = fgets($this->stdin);
|
||||||
|
|
||||||
|
@ -378,7 +462,7 @@ class %sTest extends TestCase {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
elseif (preg_match("/^a$/", $key)) {
|
elseif (preg_match("/^a$/", $key)) {
|
||||||
$this->dont_ask = true;
|
$this->dontAsk = true;
|
||||||
}
|
}
|
||||||
elseif (preg_match("/^y$/", $key)) {
|
elseif (preg_match("/^y$/", $key)) {
|
||||||
}
|
}
|
||||||
|
@ -403,11 +487,14 @@ class %sTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Creates a directory with given path.
|
||||||
*
|
*
|
||||||
* @param unknown_type $path
|
* @param string $path
|
||||||
* @return unknown
|
* @return boolean
|
||||||
*/
|
* @access private
|
||||||
|
* @uses Bake::stdin
|
||||||
|
* @uses Bake::stdout
|
||||||
|
*/
|
||||||
function createDir ($path) {
|
function createDir ($path) {
|
||||||
if (is_dir($path))
|
if (is_dir($path))
|
||||||
return true;
|
return true;
|
||||||
|
@ -426,4 +513,4 @@ class %sTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue