A few tweaks.
This commit is contained in:
parent
17636810d5
commit
3df29f7d01
@ -98,14 +98,14 @@ class Doctrine_Data_Export extends Doctrine_Data
|
||||
}
|
||||
|
||||
foreach ($data as $className => $classData) {
|
||||
Doctrine_Parser::dump($classData->toArray(), $directory.DIRECTORY_SEPARATOR.$className.'.'.$format, $format);
|
||||
Doctrine_Parser::dump($classData->toArray(), $format, $directory.DIRECTORY_SEPARATOR.$className.'.'.$format);
|
||||
}
|
||||
} else {
|
||||
if (is_dir($directory)) {
|
||||
throw new Doctrine_Data_Exception('You must specify the path to a '.$format.' file to export. You specified a directory.');
|
||||
}
|
||||
|
||||
return Doctrine_Parser::dump($data, $directory, $format);
|
||||
return Doctrine_Parser::dump($data, $format, $directory);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -41,6 +41,6 @@ class Doctrine_Export_Schema_Xml extends Doctrine_Export_Schema
|
||||
*/
|
||||
public function build($array)
|
||||
{
|
||||
return Doctrine_Parser::dumpXml($array, null);
|
||||
return Doctrine_Parser::dump($array, 'yml');
|
||||
}
|
||||
}
|
@ -41,6 +41,6 @@ class Doctrine_Export_Schema_Yml extends Doctrine_Export_Schema
|
||||
*/
|
||||
public function build($array)
|
||||
{
|
||||
return Doctrine_Parser::dumpYml($array, null);
|
||||
return Doctrine_Parser::dump($array, 'yml');
|
||||
}
|
||||
}
|
@ -94,7 +94,7 @@ abstract class Doctrine_Parser
|
||||
* @return void
|
||||
* @author Jonathan H. Wage
|
||||
*/
|
||||
static public function dump($array, $path = null, $type = 'xml')
|
||||
static public function dump($array, $type = 'xml', $path = null)
|
||||
{
|
||||
$parser = self::getParser($type);
|
||||
|
||||
|
@ -8,7 +8,7 @@ Dumping array to yml variable
|
||||
$array = array('test' => array('key' => 'value'), 'test2' => 'test');
|
||||
|
||||
// Dump the array to yml and return, set to $yml(does not write to file). Replace null with a path to a yml file if you wish to write to disk
|
||||
$yml = Doctrine_Parser::dump($array, null, 'yml');
|
||||
$yml = Doctrine_Parser::dump($array, 'yml');
|
||||
</code>
|
||||
|
||||
$yml would contain the following
|
||||
@ -26,7 +26,7 @@ Dumping array to yml file
|
||||
$array = array('test' => array('key' => 'value'), 'test2' => 'test');
|
||||
|
||||
// Dump the above array to test.yml using yml parser
|
||||
Doctrine_Parser::dump($array, 'test.yml', 'yml');
|
||||
Doctrine_Parser::dump($array, 'yml', 'test.yml');
|
||||
</code>
|
||||
|
||||
A file named test.yml would be created and would contain the following
|
||||
@ -45,7 +45,7 @@ Loading and parsing data from a yml file to a php array
|
||||
$array = array('test' => array('key' => 'value'), 'test2' => 'test');
|
||||
|
||||
// We dump the above array to test.yml using the yml parser dumper
|
||||
Doctrine_Parser::dump($array, 'test.yml', 'yml');
|
||||
Doctrine_Parser::dump($array, 'yml', 'test.yml');
|
||||
|
||||
// Now we reload that dumped yaml file back to the original array format using the yml parser loder
|
||||
$array = Doctrine_Parser::load('test.yml', 'yml');
|
||||
|
@ -5,7 +5,7 @@ The Doctrine Migration tools allow you to migrate databases and it issues alter
|
||||
Migration classes consist of a simple class that extends from Doctrine_Migration. You can define a public up() and down() method that is meant for doing and undoing changes to a database for that migration step.
|
||||
|
||||
<code type="php">
|
||||
class MigrationTestTable extends Doctrine_Record
|
||||
class MigrationTest extends Doctrine_Record
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
@ -17,12 +17,12 @@ class Migration2 extends Doctrine_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->createTable('migration_test_table', array('field1' => array('type' => 'string')));
|
||||
$this->createTable('migration_test', array('field1' => array('type' => 'string')));
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropTable('migration_test_table');
|
||||
$this->dropTable('migration_test');
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,12 +30,12 @@ class Migration3 extends Doctrine_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn('migration_test_table', 'field1', 'string');
|
||||
$this->addColumn('migration_test', 'field1', 'string');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->renameColumn('migration_test_table', 'field1', 'field2');
|
||||
$this->renameColumn('migration_test', 'field1', 'field2');
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,12 +43,12 @@ class Migration4 extends Doctrine_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->changeColumn('migration_test_table', 'field1', 'integer');
|
||||
$this->changeColumn('migration_test', 'field1', 'integer');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->changeColumn('migration_test_table', 'field1', 'string');
|
||||
$this->changeColumn('migration_test', 'field1', 'string');
|
||||
}
|
||||
}
|
||||
</code>
|
||||
|
@ -47,7 +47,7 @@ class Doctrine_Migration_TestCase extends Doctrine_UnitTestCase
|
||||
}
|
||||
}
|
||||
|
||||
class MigrationTestTable extends Doctrine_Record
|
||||
class MigrationTest extends Doctrine_Record
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
@ -59,12 +59,12 @@ class Migration2 extends Doctrine_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->createTable('migration_test_table', array('field1' => array('type' => 'string')));
|
||||
$this->createTable('migration_test', array('field1' => array('type' => 'string')));
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropTable('migration_test_table');
|
||||
$this->dropTable('migration_test');
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,12 +72,12 @@ class Migration3 extends Doctrine_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn('migration_test_table', 'field1', 'string');
|
||||
$this->addColumn('migration_test', 'field1', 'string');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->renameColumn('migration_test_table', 'field1', 'field2');
|
||||
$this->renameColumn('migration_test', 'field1', 'field2');
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,11 +85,11 @@ class Migration4 extends Doctrine_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->changeColumn('migration_test_table', 'field1', 'integer');
|
||||
$this->changeColumn('migration_test', 'field1', 'integer');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->changeColumn('migration_test_table', 'field1', 'string');
|
||||
$this->changeColumn('migration_test', 'field1', 'string');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user