Enhancing CLI. New commands and cleaning up.
This commit is contained in:
parent
821cc6e51c
commit
e2a204e0dc
@ -734,20 +734,42 @@ final class Doctrine
|
||||
* @param string $specifiedConnections Array of connections you wish to create the database for
|
||||
* @return void
|
||||
*/
|
||||
public static function createDatabases($specifiedConnections)
|
||||
public static function createDatabases($specifiedConnections = array())
|
||||
{
|
||||
if (!is_array($specifiedConnections)) {
|
||||
$specifiedConnections = (array) $specifiedConnections;
|
||||
}
|
||||
|
||||
$connections = Doctrine_Manager::getInstance()->getConnections();
|
||||
$manager = Doctrine_Manager::getInstance();
|
||||
$connections = $manager->getConnections();
|
||||
|
||||
foreach ($connections as $name => $connection) {
|
||||
if (!empty($specifiedConnections) && !in_array($name, $specifiedConnections)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$connection->export->createDatabase($name);
|
||||
$info = $manager->parsePdoDsn($connection->getOption('dsn'));
|
||||
$username = $connection->getOption('username');
|
||||
$password = $connection->getOption('password');
|
||||
|
||||
// Make connection without database specified so we can create it
|
||||
$connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false);
|
||||
|
||||
try {
|
||||
// Create database
|
||||
$connect->export->createDatabase($name);
|
||||
|
||||
// Close the tmp connection with no database
|
||||
$manager->closeConnection($connect);
|
||||
|
||||
// Close original connection
|
||||
$manager->closeConnection($connection);
|
||||
|
||||
// Reopen original connection with newly created database
|
||||
$manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true);
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -765,14 +787,20 @@ final class Doctrine
|
||||
$specifiedConnections = (array) $specifiedConnections;
|
||||
}
|
||||
|
||||
$connections = Doctrine_Manager::getInstance()->getConnections();
|
||||
$manager = Doctrine_Manager::getInstance();
|
||||
|
||||
$connections = $manager->getConnections();
|
||||
|
||||
foreach ($connections as $name => $connection) {
|
||||
if (!empty($specifiedConnections) && !in_array($name, $specifiedConnections)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$connection->export->dropDatabase($name);
|
||||
try {
|
||||
$connection->export->dropDatabase($name);
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,6 +192,20 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
||||
|
||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onOpen($this);
|
||||
}
|
||||
/**
|
||||
* getOption
|
||||
*
|
||||
* Retrieves option
|
||||
*
|
||||
* @param string $option
|
||||
* @return void
|
||||
*/
|
||||
public function getOption($option)
|
||||
{
|
||||
if (isset($this->options[$option])) {
|
||||
return $this->options[$option];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* getAttribute
|
||||
* retrieves a database connection attribute
|
||||
|
@ -300,6 +300,31 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
|
||||
}
|
||||
return $this->_connections[$name];
|
||||
}
|
||||
|
||||
public function parsePdoDsn($dsn)
|
||||
{
|
||||
$parts = array();
|
||||
|
||||
$names = array('dsn', 'scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment');
|
||||
|
||||
foreach ($names as $name) {
|
||||
if ( ! isset($parts[$name])) {
|
||||
$parts[$name] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$e = explode(':', $dsn);
|
||||
$parts['scheme'] = $e[0];
|
||||
$parts['dsn'] = $dsn;
|
||||
|
||||
$e = explode(';', $e[1]);
|
||||
foreach ($e as $string) {
|
||||
list($key, $value) = explode('=', $string);
|
||||
$parts[$key] = $value;
|
||||
}
|
||||
|
||||
return $parts;
|
||||
}
|
||||
/**
|
||||
* parseDsn
|
||||
*
|
||||
|
65
lib/Doctrine/Task/BuildAll.php
Normal file
65
lib/Doctrine/Task/BuildAll.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: BuildAll.php 2761 2007-10-07 23:42:29Z zYne $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.phpdoctrine.com>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Task_BuildAll
|
||||
*
|
||||
* @package Doctrine
|
||||
* @subpackage Task
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
* @version $Revision: 2761 $
|
||||
* @author Jonathan H. Wage <jwage@mac.com>
|
||||
*/
|
||||
class Doctrine_Task_BuildAll extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Calls generate-models-from-yaml, create-db, and create-tables',
|
||||
$requiredArguments = array(),
|
||||
$optionalArguments = array();
|
||||
|
||||
protected $models,
|
||||
$tables;
|
||||
|
||||
public function __construct($dispatcher = null)
|
||||
{
|
||||
parent::__construct($dispatcher);
|
||||
|
||||
$this->models = new Doctrine_Task_GenerateModelsFromYaml($this->dispatcher);
|
||||
$this->createDb = new Doctrine_Task_CreateDb($this->dispatcher);
|
||||
$this->tables = new Doctrine_Task_CreateTables($this->dispatcher);
|
||||
|
||||
$this->requiredArguments = array_merge($this->requiredArguments, $this->models->requiredArguments, $this->createDb->requiredArguments, $this->tables->requiredArguments);
|
||||
$this->optionalArguments = array_merge($this->optionalArguments, $this->models->optionalArguments, $this->createDb->optionalArguments, $this->tables->optionalArguments);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->models->setArguments($this->getArguments());
|
||||
$this->models->execute();
|
||||
|
||||
$this->createDb->setArguments($this->getArguments());
|
||||
$this->createDb->execute();
|
||||
|
||||
$this->tables->setArguments($this->getArguments());
|
||||
$this->tables->execute();
|
||||
}
|
||||
}
|
58
lib/Doctrine/Task/BuildAllLoad.php
Normal file
58
lib/Doctrine/Task/BuildAllLoad.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: BuildAllLoad.php 2761 2007-10-07 23:42:29Z zYne $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.phpdoctrine.com>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Task_BuildAllLoad
|
||||
*
|
||||
* @package Doctrine
|
||||
* @subpackage Task
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
* @version $Revision: 2761 $
|
||||
* @author Jonathan H. Wage <jwage@mac.com>
|
||||
*/
|
||||
class Doctrine_Task_BuildAllLoad extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Calls build-all, and load-data',
|
||||
$requiredArguments = array(),
|
||||
$optionalArguments = array();
|
||||
|
||||
public function __construct($dispatcher = null)
|
||||
{
|
||||
parent::__construct($dispatcher);
|
||||
|
||||
$this->buildAll = new Doctrine_Task_BuildAll($this->dispatcher);
|
||||
$this->loadData = new Doctrine_Task_LoadData($this->dispatcher);
|
||||
|
||||
$this->requiredArguments = array_merge($this->requiredArguments, $this->buildAll->requiredArguments, $this->loadData->requiredArguments);
|
||||
$this->optionalArguments = array_merge($this->optionalArguments, $this->buildAll->optionalArguments, $this->loadData->optionalArguments);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->buildAll->setArguments($this->getArguments());
|
||||
$this->buildAll->execute();
|
||||
|
||||
$this->loadData->setArguments($this->getArguments());
|
||||
$this->loadData->execute();
|
||||
}
|
||||
}
|
58
lib/Doctrine/Task/BuildAllReload.php
Normal file
58
lib/Doctrine/Task/BuildAllReload.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: BuildAllReload.php 2761 2007-10-07 23:42:29Z zYne $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.phpdoctrine.com>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Task_BuildAllReload
|
||||
*
|
||||
* @package Doctrine
|
||||
* @subpackage Task
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
* @version $Revision: 2761 $
|
||||
* @author Jonathan H. Wage <jwage@mac.com>
|
||||
*/
|
||||
class Doctrine_Task_BuildAllReload extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Calls rebuild-db and load-data',
|
||||
$requiredArguments = array(),
|
||||
$optionalArguments = array();
|
||||
|
||||
public function __construct($dispatcher = null)
|
||||
{
|
||||
parent::__construct($dispatcher);
|
||||
|
||||
$this->rebuildDb = new Doctrine_Task_RebuildDb($this->dispatcher);
|
||||
$this->loadData = new Doctrine_Task_LoadData($this->dispatcher);
|
||||
|
||||
$this->requiredArguments = array_merge($this->requiredArguments, $this->rebuildDb->requiredArguments, $this->loadData->requiredArguments);
|
||||
$this->optionalArguments = array_merge($this->optionalArguments, $this->rebuildDb->optionalArguments, $this->loadData->optionalArguments);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->rebuildDb->setArguments($this->getArguments());
|
||||
$this->rebuildDb->execute();
|
||||
|
||||
$this->loadData->setArguments($this->getArguments());
|
||||
$this->loadData->execute();
|
||||
}
|
||||
}
|
@ -40,5 +40,7 @@ class Doctrine_Task_Compile extends Doctrine_Task
|
||||
public function execute()
|
||||
{
|
||||
Doctrine::compile($this->getArgument('compiled_path'), $this->getArgument('drivers', array()));
|
||||
|
||||
$this->notify('Compiled Doctrine successfully to: ' . $this->getArgument('compiled_path'));
|
||||
}
|
||||
}
|
@ -32,11 +32,13 @@
|
||||
*/
|
||||
class Doctrine_Task_CreateDb extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Create database for each of your connections',
|
||||
$optionalArguments = array('connection' => 'Optionally specify a single connection to create the database for.');
|
||||
public $description = 'Create all databases for your connections. If the database already exists, nothing happens.',
|
||||
$optionalArguments = array();
|
||||
|
||||
public function execute()
|
||||
{
|
||||
Doctrine::createDatabases($this->getArgument('connection'));
|
||||
Doctrine::createDatabases();
|
||||
|
||||
$this->notify('Created databases successfully');
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
class Doctrine_Task_CreateTables extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Create tables for all existing database connections',
|
||||
public $description = 'Create tables for all existing database connections. If table exists nothing happens.',
|
||||
$requiredArguments = array('models_path' => 'Specify path to your models directory.'),
|
||||
$optionalArguments = array();
|
||||
|
||||
@ -40,6 +40,6 @@ class Doctrine_Task_CreateTables extends Doctrine_Task
|
||||
{
|
||||
Doctrine::createTablesFromModels($this->getArgument('models_path'));
|
||||
|
||||
$this->dispatcher->notify('successfully created tables');
|
||||
$this->dispatcher->notify('Created tables successfully');
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ class Doctrine_Task_DropDb extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Drop database for all existing connections',
|
||||
$requiredArguments = array(),
|
||||
$optionalArguments = array('connection' => 'Optionally specify a single connection to drop the database for.');
|
||||
$optionalArguments = array();
|
||||
|
||||
public function execute()
|
||||
{
|
||||
@ -46,8 +46,8 @@ class Doctrine_Task_DropDb extends Doctrine_Task
|
||||
return;
|
||||
}
|
||||
|
||||
Doctrine::dropDatabases($this->getArgument('connection'));
|
||||
Doctrine::dropDatabases();
|
||||
|
||||
$this->notify('Successfully dropped all databases');
|
||||
$this->notify('Dropped databases successfully');
|
||||
}
|
||||
}
|
@ -55,6 +55,6 @@ class Doctrine_Task_DumpData extends Doctrine_Task
|
||||
|
||||
Doctrine::dumpData($path, $individualFiles);
|
||||
|
||||
$this->dispatcher->notify(sprintf('successfully dumped data to %s', $path));
|
||||
$this->dispatcher->notify(sprintf('Dumped data successfully to: %s', $path));
|
||||
}
|
||||
}
|
@ -41,6 +41,6 @@ class Doctrine_Task_GenerateMigration extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateMigrationClass($this->getArgument('class_name'), $this->getArgument('migrations_path'));
|
||||
|
||||
$this->dispatcher->notify(sprintf('successfully generated migration class: %s to %s', $this->getArgument('class_name'), $this->getArgument('migrations_path')));
|
||||
$this->dispatcher->notify(sprintf('Generated migration class: %s successfully to %s', $this->getArgument('class_name'), $this->getArgument('migrations_path')));
|
||||
}
|
||||
}
|
@ -40,6 +40,6 @@ class Doctrine_Task_GenerateMigrationsFromDb extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateMigrationsFromDb($this->getArgument('migrations_path'));
|
||||
|
||||
$this->dispatcher->notify('successfully generated migration classes from databases');
|
||||
$this->dispatcher->notify('Generated migration classes successfully from database');
|
||||
}
|
||||
}
|
@ -41,6 +41,6 @@ class Doctrine_Task_GenerateMigrationsFromModels extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateMigrationsFromModels($this->getArgument('migrations_path'), $this->getArgument('models_path'));
|
||||
|
||||
$this->dispatcher->notify('successfully generated migrations from models');
|
||||
$this->dispatcher->notify('Generated migration classes successfully from models');
|
||||
}
|
||||
}
|
@ -40,6 +40,6 @@ class Doctrine_Task_GenerateModelsFromDb extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateModelsFromDb($this->getArgument('models_path'), (array) $this->getArgument('connection'));
|
||||
|
||||
$this->dispatcher->notify('successfully generated models from databases');
|
||||
$this->dispatcher->notify('Generated models successfully from databases');
|
||||
}
|
||||
}
|
@ -41,6 +41,6 @@ class Doctrine_Task_GenerateModelsFromYaml extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateModelsFromYaml($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'));
|
||||
|
||||
$this->dispatcher->notify('successfully generated models from yaml');
|
||||
$this->notify('Generated models successfully from YAML schema');
|
||||
}
|
||||
}
|
@ -51,6 +51,6 @@ class Doctrine_Task_GenerateSql extends Doctrine_Task
|
||||
|
||||
file_put_contents($path, $sql);
|
||||
|
||||
$this->dispatcher->notify('successfully generated sql for models');
|
||||
$this->dispatcher->notify('Generated SQL successfully for models');
|
||||
}
|
||||
}
|
@ -40,6 +40,6 @@ class Doctrine_Task_GenerateYamlFromDb extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateYamlFromDb($this->getArgument('yaml_schema_path'));
|
||||
|
||||
$this->dispatcher->notify('successfully generated yaml schema from databases');
|
||||
$this->dispatcher->notify('Generate YAML schema successfully from database');
|
||||
}
|
||||
}
|
@ -41,6 +41,6 @@ class Doctrine_Task_GenerateYamlFromModels extends Doctrine_Task
|
||||
{
|
||||
Doctrine::generateYamlFromModels($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'));
|
||||
|
||||
$this->dispatcher->notify('successfully generated yaml schema from models');
|
||||
$this->dispatcher->notify('Generated YAML schema successfully from models');
|
||||
}
|
||||
}
|
@ -42,6 +42,6 @@ class Doctrine_Task_LoadData extends Doctrine_Task
|
||||
Doctrine::loadModels($this->getArgument('models_path'));
|
||||
Doctrine::loadData($this->getArgument('data_fixtures_path'));
|
||||
|
||||
$this->dispatcher->notify('data was successfully loaded');
|
||||
$this->dispatcher->notify('Data was successfully loaded');
|
||||
}
|
||||
}
|
@ -42,6 +42,6 @@ class Doctrine_Task_LoadDummyData extends Doctrine_Task
|
||||
Doctrine::loadModels($this->getArgument('models_path'));
|
||||
Doctrine::loadDummyData($this->getArgument('append') ? true:false, $this->getArgument('num') ? $this->getArgument('num'):5);
|
||||
|
||||
$this->dispatcher->notify('dummy data successfully loaded');
|
||||
$this->dispatcher->notify('Dummy data was successfully loaded');
|
||||
}
|
||||
}
|
@ -40,6 +40,6 @@ class Doctrine_Task_Migrate extends Doctrine_Task
|
||||
{
|
||||
$version = Doctrine::migrate($this->getArgument('migrations_path'), $this->getArgument('version'));
|
||||
|
||||
$this->dispatcher->notify('migrated to version # ' . $version);
|
||||
$this->dispatcher->notify('migrated successfully to version #' . $version);
|
||||
}
|
||||
}
|
58
lib/Doctrine/Task/RebuildDb.php
Normal file
58
lib/Doctrine/Task/RebuildDb.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: RebuildDb.php 2761 2007-10-07 23:42:29Z zYne $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.phpdoctrine.com>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Task_RebuildDb
|
||||
*
|
||||
* @package Doctrine
|
||||
* @subpackage Task
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
* @version $Revision: 2761 $
|
||||
* @author Jonathan H. Wage <jwage@mac.com>
|
||||
*/
|
||||
class Doctrine_Task_RebuildDb extends Doctrine_Task
|
||||
{
|
||||
public $description = 'Drops and re-creates databases',
|
||||
$requiredArguments = array(),
|
||||
$optionalArguments = array();
|
||||
|
||||
public function __construct($dispatcher = null)
|
||||
{
|
||||
parent::__construct($dispatcher);
|
||||
|
||||
$this->dropDb = new Doctrine_Task_DropDb($this->dispatcher);
|
||||
$this->buildAll = new Doctrine_Task_BuildAll($this->dispatcher);
|
||||
|
||||
$this->requiredArguments = array_merge($this->requiredArguments, $this->dropDb->requiredArguments, $this->buildAll->requiredArguments);
|
||||
$this->optionalArguments = array_merge($this->optionalArguments, $this->dropDb->optionalArguments, $this->buildAll->optionalArguments);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->dropDb->setArguments($this->getArguments());
|
||||
$this->dropDb->execute();
|
||||
|
||||
$this->buildAll->setArguments($this->getArguments());
|
||||
$this->buildAll->execute();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user