Commit 8d2aebad authored by Jonathan.Wage's avatar Jonathan.Wage

A little formatting and documentation.

parent 526c4ab1
This diff is collapsed.
<?php <?php
/* /*
* $Id: Task.php 2761 2007-10-07 23:42:29Z zYne $ * $Id: Cli.php 2761 2007-10-07 23:42:29Z zYne $
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
...@@ -35,7 +35,7 @@ class Doctrine_Cli ...@@ -35,7 +35,7 @@ class Doctrine_Cli
protected $tasks = array(); protected $tasks = array();
protected $scriptName = null; protected $scriptName = null;
protected $config = array(); protected $config = array();
/** /**
* __construct * __construct
* *
...@@ -46,12 +46,13 @@ class Doctrine_Cli ...@@ -46,12 +46,13 @@ class Doctrine_Cli
{ {
$this->config = $config; $this->config = $config;
} }
/** /**
* run * run
* *
* @param string $args * @param string $args
* @return void * @return void
* @throws new Doctrine_Cli_Exception
*/ */
public function run($args) public function run($args)
{ {
...@@ -82,13 +83,13 @@ class Doctrine_Cli ...@@ -82,13 +83,13 @@ class Doctrine_Cli
throw new Doctrine_Cli_Exception('Cli task could not be found: '.$taskClass); throw new Doctrine_Cli_Exception('Cli task could not be found: '.$taskClass);
} }
} }
/** /**
* prepareArgs * prepareArgs
* *
* @param string $taskInstance * @param string $taskInstance
* @param string $args * @param string $args
* @return void * @return array $prepared
*/ */
protected function prepareArgs($taskInstance, $args) protected function prepareArgs($taskInstance, $args)
{ {
...@@ -128,10 +129,12 @@ class Doctrine_Cli ...@@ -128,10 +129,12 @@ class Doctrine_Cli
return $prepared; return $prepared;
} }
/** /**
* printTasks * printTasks
* *
* Prints an index of all the available tasks in the CLI instance
*
* @return void * @return void
*/ */
public function printTasks() public function printTasks()
...@@ -184,12 +187,12 @@ class Doctrine_Cli ...@@ -184,12 +187,12 @@ class Doctrine_Cli
echo "\n".str_repeat("-", 40)."\n"; echo "\n".str_repeat("-", 40)."\n";
} }
} }
/** /**
* loadTasks * loadTasks
* *
* @param string $directory * @param string $directory
* @return void * @return array $loadedTasks
*/ */
public function loadTasks($directory = null) public function loadTasks($directory = null)
{ {
......
...@@ -238,7 +238,6 @@ class Doctrine_Data ...@@ -238,7 +238,6 @@ class Doctrine_Data
* @param string $Doctrine_Record * @param string $Doctrine_Record
* @param string $fieldName * @param string $fieldName
* @return void * @return void
* @author Jonathan H. Wage
*/ */
public function isRelation(Doctrine_Record $record, $fieldName) public function isRelation(Doctrine_Record $record, $fieldName)
{ {
...@@ -255,4 +254,24 @@ class Doctrine_Data ...@@ -255,4 +254,24 @@ class Doctrine_Data
return false; return false;
} }
/**
* purge
*
* Purge all data for loaded models or for the passed array of Doctrine_Records
*
* @param string $models
* @return void
*/
public function purge($models = array())
{
$models = Doctrine::getLoadedModels($models);
foreach ($models as $model)
{
$model = new $model();
$model->getTable()->createQuery()->delete($model)->execute();
}
}
} }
\ No newline at end of file
...@@ -37,6 +37,7 @@ Doctrine::autoload('Doctrine_Connection_Module'); ...@@ -37,6 +37,7 @@ Doctrine::autoload('Doctrine_Connection_Module');
class Doctrine_Import extends Doctrine_Connection_Module class Doctrine_Import extends Doctrine_Connection_Module
{ {
protected $sql = array(); protected $sql = array();
/** /**
* lists all databases * lists all databases
* *
...@@ -50,6 +51,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -50,6 +51,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listDatabases']); return $this->conn->fetchColumn($this->sql['listDatabases']);
} }
/** /**
* lists all availible database functions * lists all availible database functions
* *
...@@ -63,6 +65,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -63,6 +65,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listFunctions']); return $this->conn->fetchColumn($this->sql['listFunctions']);
} }
/** /**
* lists all database triggers * lists all database triggers
* *
...@@ -73,6 +76,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -73,6 +76,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists all database sequences * lists all database sequences
* *
...@@ -87,6 +91,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -87,6 +91,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listSequences']); return $this->conn->fetchColumn($this->sql['listSequences']);
} }
/** /**
* lists table constraints * lists table constraints
* *
...@@ -97,6 +102,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -97,6 +102,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table constraints * lists table constraints
* *
...@@ -107,6 +113,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -107,6 +113,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table constraints * lists table constraints
* *
...@@ -117,6 +124,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -117,6 +124,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists tables * lists tables
* *
...@@ -127,6 +135,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -127,6 +135,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table triggers * lists table triggers
* *
...@@ -137,6 +146,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -137,6 +146,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists table views * lists table views
* *
...@@ -147,6 +157,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -147,6 +157,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.'); throw new Doctrine_Import_Exception(__FUNCTION__ . ' not supported by this driver.');
} }
/** /**
* lists database users * lists database users
* *
...@@ -160,6 +171,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -160,6 +171,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listUsers']); return $this->conn->fetchColumn($this->sql['listUsers']);
} }
/** /**
* lists database views * lists database views
* *
...@@ -174,6 +186,7 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -174,6 +186,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return $this->conn->fetchColumn($this->sql['listViews']); return $this->conn->fetchColumn($this->sql['listViews']);
} }
/** /**
* importSchema * importSchema
* *
...@@ -187,7 +200,13 @@ class Doctrine_Import extends Doctrine_Connection_Module ...@@ -187,7 +200,13 @@ class Doctrine_Import extends Doctrine_Connection_Module
{ {
$connections = Doctrine_Manager::getInstance()->getConnections(); $connections = Doctrine_Manager::getInstance()->getConnections();
foreach ($connections as $connection) { foreach ($connections as $name => $connection) {
// Limit the databases to the ones specified by $databases.
// Check only happens if array is not empty
if (!empty($databases) && !in_array($name, $databases)) {
continue;
}
$builder = new Doctrine_Import_Builder(); $builder = new Doctrine_Import_Builder();
$builder->generateBaseClasses(true); $builder->generateBaseClasses(true);
$builder->setTargetPath($directory); $builder->setTargetPath($directory);
......
...@@ -342,6 +342,8 @@ class Doctrine_Migration ...@@ -342,6 +342,8 @@ class Doctrine_Migration
} }
$this->setCurrentVersion($to); $this->setCurrentVersion($to);
return true;
} }
/** /**
......
...@@ -41,7 +41,7 @@ class Doctrine_Migration_Builder ...@@ -41,7 +41,7 @@ class Doctrine_Migration_Builder
* @var string * @var string
*/ */
private $migrationsPath = ''; private $migrationsPath = '';
/** /**
* suffix * suffix
* *
...@@ -50,7 +50,7 @@ class Doctrine_Migration_Builder ...@@ -50,7 +50,7 @@ class Doctrine_Migration_Builder
* @var string $suffix * @var string $suffix
*/ */
private $suffix = '.class.php'; private $suffix = '.class.php';
/** /**
* tpl * tpl
* *
...@@ -73,7 +73,7 @@ class Doctrine_Migration_Builder ...@@ -73,7 +73,7 @@ class Doctrine_Migration_Builder
$this->loadTemplate(); $this->loadTemplate();
} }
/** /**
* setMigrationsPath * setMigrationsPath
* *
...@@ -130,7 +130,7 @@ class %s extends %s ...@@ -130,7 +130,7 @@ class %s extends %s
} }
END; END;
} }
/** /**
* generateMigrationsFromDb * generateMigrationsFromDb
* *
...@@ -148,7 +148,7 @@ END; ...@@ -148,7 +148,7 @@ END;
return $result; return $result;
} }
/** /**
* generateMigrationsFromModels * generateMigrationsFromModels
* *
...@@ -194,6 +194,8 @@ END; ...@@ -194,6 +194,8 @@ END;
} }
$this->generateMigrationClass($className, array(), $up, $down); $this->generateMigrationClass($className, array(), $up, $down);
return true;
} }
/** /**
...@@ -243,7 +245,7 @@ END; ...@@ -243,7 +245,7 @@ END;
* buildDropTable * buildDropTable
* *
* @param string $tableData * @param string $tableData
* @return void * @return string
*/ */
public function buildDropTable($tableData) public function buildDropTable($tableData)
{ {
...@@ -254,7 +256,7 @@ END; ...@@ -254,7 +256,7 @@ END;
* dataToPhpCode * dataToPhpCode
* *
* @param string $data * @param string $data
* @return void * @return string
*/ */
public function dataToPhpCode($data) public function dataToPhpCode($data)
{ {
...@@ -269,7 +271,7 @@ END; ...@@ -269,7 +271,7 @@ END;
/** /**
* generateMigrationClass * generateMigrationClass
* *
* @package default * @return void
*/ */
public function generateMigrationClass($className, $options = array(), $up = null, $down = null, $return = false) public function generateMigrationClass($className, $options = array(), $up = null, $down = null, $return = false)
{ {
...@@ -296,7 +298,7 @@ END; ...@@ -296,7 +298,7 @@ END;
/** /**
* buildMigrationClass * buildMigrationClass
* *
* @package default * @return string
*/ */
public function buildMigrationClass($className, $fileName = null, $options = array(), $up = null, $down = null) public function buildMigrationClass($className, $fileName = null, $options = array(), $up = null, $down = null)
{ {
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
*/ */
/** /**
* Doctrine_Cli_Task * Doctrine_Task
*
* Abstract class used for writing Doctrine Tasks
* *
* @package Doctrine * @package Doctrine
* @subpackage Task * @subpackage Task
...@@ -41,6 +43,9 @@ abstract class Doctrine_Task ...@@ -41,6 +43,9 @@ abstract class Doctrine_Task
/** /**
* __construct * __construct
* *
* Since this is an abstract classes that extend this must follow a patter of Doctrine_Task_{TASK_NAME}
* This is what determines the task name for executing it.
*
* @return void * @return void
*/ */
public function __construct() public function __construct()
...@@ -54,7 +59,7 @@ abstract class Doctrine_Task ...@@ -54,7 +59,7 @@ abstract class Doctrine_Task
* Override with each task class * Override with each task class
* *
* @return void * @return void
* @author Jonathan H. Wage * @abstract
*/ */
abstract function execute(); abstract function execute();
...@@ -63,7 +68,7 @@ abstract class Doctrine_Task ...@@ -63,7 +68,7 @@ abstract class Doctrine_Task
* *
* Validates that all required fields are present * Validates that all required fields are present
* *
* @return void * @return bool true
*/ */
public function validate() public function validate()
{ {
...@@ -95,7 +100,7 @@ abstract class Doctrine_Task ...@@ -95,7 +100,7 @@ abstract class Doctrine_Task
* *
* @param string $name * @param string $name
* @param string $default * @param string $default
* @return void * @return mixed
*/ */
public function getArgument($name, $default = null) public function getArgument($name, $default = null)
{ {
...@@ -109,7 +114,7 @@ abstract class Doctrine_Task ...@@ -109,7 +114,7 @@ abstract class Doctrine_Task
/** /**
* getArguments * getArguments
* *
* @return void * @return array $this->arguments
*/ */
public function getArguments() public function getArguments()
{ {
...@@ -119,10 +124,10 @@ abstract class Doctrine_Task ...@@ -119,10 +124,10 @@ abstract class Doctrine_Task
/** /**
* setArguments * setArguments
* *
* @param string $args * @param array $args
* @return void * @return void
*/ */
public function setArguments($args) public function setArguments(array $args)
{ {
$this->arguments = $args; $this->arguments = $args;
} }
...@@ -130,7 +135,7 @@ abstract class Doctrine_Task ...@@ -130,7 +135,7 @@ abstract class Doctrine_Task
/** /**
* getTaskName * getTaskName
* *
* @return void * @return string $taskName
*/ */
public function getTaskName() public function getTaskName()
{ {
...@@ -140,7 +145,7 @@ abstract class Doctrine_Task ...@@ -140,7 +145,7 @@ abstract class Doctrine_Task
/** /**
* getDescription * getDescription
* *
* @return void * @return string $description
*/ */
public function getDescription() public function getDescription()
{ {
...@@ -150,7 +155,7 @@ abstract class Doctrine_Task ...@@ -150,7 +155,7 @@ abstract class Doctrine_Task
/** /**
* getRequiredArguments * getRequiredArguments
* *
* @return void * @return array $requiredArguments
*/ */
public function getRequiredArguments() public function getRequiredArguments()
{ {
...@@ -160,7 +165,7 @@ abstract class Doctrine_Task ...@@ -160,7 +165,7 @@ abstract class Doctrine_Task
/** /**
* getOptionalArguments * getOptionalArguments
* *
* @return void * @return array $optionalArguments
*/ */
public function getOptionalArguments() public function getOptionalArguments()
{ {
...@@ -170,7 +175,7 @@ abstract class Doctrine_Task ...@@ -170,7 +175,7 @@ abstract class Doctrine_Task
/** /**
* getRequiredArgumentsDescriptions * getRequiredArgumentsDescriptions
* *
* @return void * @return array $requiredArgumentsDescriptions
*/ */
public function getRequiredArgumentsDescriptions() public function getRequiredArgumentsDescriptions()
{ {
...@@ -180,8 +185,7 @@ abstract class Doctrine_Task ...@@ -180,8 +185,7 @@ abstract class Doctrine_Task
/** /**
* getOptionalArgumentsDescriptions * getOptionalArgumentsDescriptions
* *
* @return void * @return array $optionalArgumentsDescriptions
* @author Jonathan H. Wage
*/ */
public function getOptionalArgumentsDescriptions() public function getOptionalArgumentsDescriptions()
{ {
......
--- ---
Contact: Contact:
Contact_1: Contact_1:
name: Jonathan H. Wage name: Jonathan H. Wage
Contact_3:
name: Daniel Adams
Contact_4:
name: Robert Adams
\ No newline at end of file
--- ---
User: User:
User_1: User_1:
username: jwage username: jonwage
hair_color: light brown hair_color: brown
Contact: Contact_1 Contact: Contact_1
User_2:
username: dadams
hair_color: dark brown
Contact: Contact_3
User_3:
username: radams
hair_color: light brown
Contact: Contact_4
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment