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:
brego 2005-05-18 10:11:28 +00:00
parent ea0191d321
commit ec0abbaac0
9 changed files with 381 additions and 296 deletions

View file

@ -14,32 +14,31 @@
//////////////////////////////////////////////////////////////////////////
/**
* Purpose: AppController
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Add your application-wide methods in the class below, your controllers
* will be inheriting them.
*
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
*
*/
* Add your application-wide methods in the class below, your controllers
* will be inheriting them.
*
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
*
*/
class AppController extends Controller {
}

View file

@ -14,32 +14,31 @@
//////////////////////////////////////////////////////////////////////////
/**
* Purpose: AppModel
* This file is application-wide model file. You can put all
* application-wide model-related methods here.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* This file is application-wide model file. You can put all
* application-wide model-related methods here.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Add your application-wide methods in the class below, your models
* will be inheriting them.
*
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
*
*/
* Add your application-wide methods in the class below, your models
* will be inheriting them.
*
* @package cake
* @subpackage cake.app
* @since Cake v 0.2.9
*
*/
class AppModel extends Model {
}

View file

@ -14,21 +14,21 @@
//////////////////////////////////////////////////////////////////////////
/**
* This is core configuration file. Use it to configure core behaviour of
* Cake.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* This is core configuration file. Use it to configure core behaviour of
* Cake.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Set debug level here:

View file

@ -14,26 +14,26 @@
//////////////////////////////////////////////////////////////////////////
/**
* In this file you set up your database connection details.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* In this file you set up your database connection details.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Database configuration array. You can configure multiple connections.
*
* @var array $DATABASE_CONFIG
*/
* Database configuration array. You can configure multiple connections.
*
* @var array $DATABASE_CONFIG
*/
$DATABASE_CONFIG = array(
'devel' => array(
'driver' => 'mysql',

View file

@ -14,20 +14,20 @@
//////////////////////////////////////////////////////////////////////////
/**
* In this file you set paths to different directories used by Cake.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* In this file you set paths to different directories used by Cake.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* If index.php file is used instead of an .htaccess file

View file

@ -14,23 +14,23 @@
//////////////////////////////////////////////////////////////////////////
/**
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages', and

View file

@ -14,23 +14,23 @@
//////////////////////////////////////////////////////////////////////////
/**
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages', and

View file

@ -14,21 +14,21 @@
//////////////////////////////////////////////////////////////////////////
/**
* In this file, you can set up 'templates' for every tag generated by the tag
* generator.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* In this file, you can set up 'templates' for every tag generated by the tag
* generator.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.config
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Tag template for a link.

View file

@ -14,81 +14,84 @@
//////////////////////////////////////////////////////////////////////////
/**
* Purpose: Bake
* Creates controller, model, view files, and the required directories on demand.
* Used by scripts/add.php
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.libs
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
* Creates controller, model, view files, and the required directories on demand.
* Used by /scripts/add.php.
*
* @filesource
* @author Cake Authors/Developers
* @copyright Copyright (c) 2005, Cake Authors/Developers
* @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.libs
* @since Cake v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*
*/
* Require needed libraries.
*/
uses('object', 'inflector');
/**
* Enter description here...
*
*
* @package cake
* @subpackage cake.libs
* @since Cake v 0.2.9
*
*/
* Bake class creates files in configured application directories. This is a
* base class for /scripts/add.php.
*
* @package cake
* @subpackage cake.libs
* @since Cake v 0.2.9
*/
class Bake extends Object {
/**
* Enter description here...
*
* @var unknown_type
*/
* Standard input stream (php://stdin).
*
* @var resource
* @access private
*/
var $stdin = null;
/**
* Enter description here...
*
* @var unknown_type
*/
* Standard output stream (php://stdout).
*
* @var resource
* @access private
*/
var $stdout = null;
/**
* Enter description here...
*
* @var unknown_type
*/
* Standard error stream (php://stderr).
*
* @var resource
* @access private
*/
var $stderr = null;
/**
* Enter description here...
*
* @var unknown_type
*/
* Counts taken actions.
*
* @var integer
* @access private
*/
var $actions = null;
/**
* Enter description here...
*
* @var unknown_type
*/
var $dont_ask = false;
* Decides wether to overwrite existing files without asking.
*
* @var boolean
* @access private
*/
var $dontAsk = false;
/**
* Enter description here...
*
* @param unknown_type $type
* @return unknown
*/
* Returns template for file generator.
*
* @param string $type
* @return string
* @access private
*/
function template ($type) {
switch ($type) {
case 'view': return "%s";
@ -128,11 +131,18 @@ class %sTest extends TestCase {
/**
* Enter description here...
*
* @param unknown_type $type
* @param unknown_type $names
*/
* Baker's constructor method. Initialises bakery, and starts production.
*
* @param string $type
* @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) {
$this->stdin = fopen('php://stdin', 'r');
@ -177,11 +187,18 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $controller
* @param unknown_type $name
*/
* Creates new view in VIEWS/$controller/ directory.
*
* @param string $controller
* @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) {
$dir = Inflector::underscore($controller);
$path = "{$dir}/".strtolower($name).".thtml";
@ -192,11 +209,18 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $name
* @param array $actions
*/
* Creates new controller with defined actions, controller's test and helper
* with helper's test.
*
* @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()) {
$this->makeController($name, $actions);
$this->makeControllerTest($name);
@ -206,12 +230,19 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $name
* @param array $actions
* @return unknown
*/
* Creates new controller file with defined actions.
*
* @param string $name
* @param array $actions
* @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) {
$ctrl = $this->makeControllerName($name);
$helper = $this->makeHelperName($name);
@ -220,31 +251,41 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Returns controller's name in CamelCase.
*
* @param string $name
* @return string
* @access private
* @uses Inflector::camelize CamelCase for controller name.
*/
function makeControllerName ($name) {
return Inflector::camelize($name).'Controller';
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Returns a name for controller's file, underscored.
*
* @param string $name
* @return string
* @access private
* @uses Inflector::underscore() Underscore for controller's file name.
*/
function makeControllerFn ($name) {
return CONTROLLERS.Inflector::underscore($name).'_controller.php';
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Creates new test for a controller.
*
* @param string $name
* @return boolean
* @access private
* @uses CONTROLLER_TESTS
* @uses Inflector::underscore()
* @uses Bake::getTestBody()
* @uses Bake::makeControllerName()
* @uses Bake::createFile()
*/
function makeControllerTest ($name) {
$fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
$body = $this->getTestBody($this->makeControllerName($name));
@ -252,42 +293,58 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Creates new helper.
*
* @param string $name
* @return boolean
* @access private
* @uses Bake::template()
* @uses Bake::makeHelperName()
* @uses Bake::createFile()
* @uses Bake::makeHelperFn()
*/
function makeHelper ($name) {
$body = sprintf($this->template('helper'), $this->makeHelperName($name));
return $this->createFile($this->makeHelperFn($name), $body);
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Returns CamelCase name for a helper.
*
* @param string $name
* @return string
* @access private
* @uses Inflector::camelize()
*/
function makeHelperName ($name) {
return Inflector::camelize($name).'Helper';
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Underscores file name for a helper.
*
* @param string $name
* @return string
* @access private
* @uses HELPERS
* @uses Inflector::underscore()
*/
function makeHelperFn ($name) {
return HELPERS.Inflector::underscore($name).'_helper.php';
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Creates new test for a helper.
*
* @param string $name
* @return boolean
* @access private
* @uses HELPER_TESTS
* @uses Inflector::underscore()
* @uses Bake::getTestBody()
* @uses Bake::makeHelperName()
* @uses Bake::createFile()
*/
function makeHelperTest ($name) {
$fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
$body = $this->getTestBody($this->makeHelperName($name));
@ -295,11 +352,13 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $as
* @return unknown
*/
* Returns array of actions' templates.
*
* @param array $as
* @return array
* @access private
* @uses Bake::template()
*/
function getActions ($as) {
$out = array();
foreach ($as as $a)
@ -308,20 +367,29 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $class
* @return unknown
*/
* Returns test template for defined class.
*
* @param string $class
* @return string
* @access private
* @uses Bake::template()
*/
function getTestBody ($class) {
return sprintf($this->template('test'), $class, $class);
}
/**
* Enter description here...
*
* @param unknown_type $name
*/
* Creates new model.
*
* @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) {
$this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
$this->makeModelTest ($name);
@ -329,21 +397,30 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Returns underscored name for model's file.
*
* @param string $name
* @return string
* @access private
* @uses MODELS
* @uses Inflector::underscore()
*/
function getModelFn ($name) {
return MODELS.Inflector::underscore($name).'.php';
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Creates a test for a given model.
*
* @param string $name
* @return boolean
* @access private
* @uses MODEL_TESTS
* @uses Inflector::underscore()
* @uses Bake::getTestBody()
* @uses Bake::getModelName()
* @uses Bake::createFile()
*/
function makeModelTest ($name) {
$fn = MODEL_TESTS.Inflector::underscore($name).'_test.php';
$body = $this->getTestBody($this->getModelName($name));
@ -351,25 +428,32 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $name
* @return unknown
*/
* Returns CamelCased name of a model.
*
* @param string $name
* @return string
* @access private
* @uses Inflector::camelize()
*/
function getModelName ($name) {
return Inflector::camelize($name);
}
/**
* Enter description here...
*
* @param unknown_type $path
* @param unknown_type $contents
* @return unknown
*/
* Creates a file with given path and contents.
*
* @param string $path
* @param string $contents
* @return boolean
* @access private
* @uses Bake::dontAsk
* @uses Bake::stdin
* @uses Bake::stdout
* @uses Bake::stderr
*/
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) ");
$key = fgets($this->stdin);
@ -378,7 +462,7 @@ class %sTest extends TestCase {
exit;
}
elseif (preg_match("/^a$/", $key)) {
$this->dont_ask = true;
$this->dontAsk = true;
}
elseif (preg_match("/^y$/", $key)) {
}
@ -403,11 +487,14 @@ class %sTest extends TestCase {
}
/**
* Enter description here...
*
* @param unknown_type $path
* @return unknown
*/
* Creates a directory with given path.
*
* @param string $path
* @return boolean
* @access private
* @uses Bake::stdin
* @uses Bake::stdout
*/
function createDir ($path) {
if (is_dir($path))
return true;
@ -426,4 +513,4 @@ class %sTest extends TestCase {
}
?>
?>