Commit 0e964840 authored by Jonathan.Wage's avatar Jonathan.Wage

Changes to make export schema yml closer to working :)

parent 8402633b
...@@ -477,6 +477,7 @@ final class Doctrine ...@@ -477,6 +477,7 @@ final class Doctrine
} }
$parent = new ReflectionClass('Doctrine_Record'); $parent = new ReflectionClass('Doctrine_Record');
$loadedModels = array(); $loadedModels = array();
// we iterate trhough the diff of previously declared classes // we iterate trhough the diff of previously declared classes
......
...@@ -31,47 +31,73 @@ ...@@ -31,47 +31,73 @@
*/ */
abstract class Doctrine_Parser abstract class Doctrine_Parser
{ {
/**
* loadData
*
* Override in the parser driver
*
* @param string $array
* @return void
* @author Jonathan H. Wage
*/
abstract public function loadData($array); abstract public function loadData($array);
/**
* dumpData
*
* Override in the praser driver
*
* @param string $array
* @param string $path
* @return void
* @author Jonathan H. Wage
*/
abstract public function dumpData($array, $path = null); abstract public function dumpData($array, $path = null);
/**
* getParser
*
* Get instance of the specified parser
*
* @param string $type
* @return void
* @author Jonathan H. Wage
*/
static public function getParser($type) static public function getParser($type)
{ {
$class = 'Doctrine_Parser_'.ucfirst($type); $class = 'Doctrine_Parser_'.ucfirst($type);
return new $class; return new $class;
} }
/**
* load
*
* Interface for loading and parsing data from a file
*
* @param string $path
* @param string $type
* @return void
* @author Jonathan H. Wage
*/
static public function load($path, $type = 'xml') static public function load($path, $type = 'xml')
{ {
$parser = self::getParser($type); $parser = self::getParser($type);
return $parser->loadData($path); return $parser->loadData($path);
} }
/**
* dump
*
* Interface for pulling and dumping data to a file
*
* @param string $array
* @param string $path
* @param string $type
* @return void
* @author Jonathan H. Wage
*/
static public function dump($array, $path = null, $type = 'xml') static public function dump($array, $path = null, $type = 'xml')
{ {
$parser = self::getParser($type); $parser = self::getParser($type);
return $parser->dumpData($array, $path); return $parser->dumpData($array, $path);
} }
static public function loadXml($path)
{
return self::load($path, 'xml');
}
static public function dumpXml($array, $path = null)
{
return self::dump($array, $path, 'xml');
}
static public function loadYml($path)
{
return self::load($path, 'yml');
}
static public function dumpYml($array, $path = null)
{
return self::dump($array, $path, 'yml');
}
} }
\ No newline at end of file
...@@ -33,6 +33,16 @@ require_once('spyc.php'); ...@@ -33,6 +33,16 @@ require_once('spyc.php');
*/ */
class Doctrine_Parser_Yml extends Doctrine_Parser class Doctrine_Parser_Yml extends Doctrine_Parser
{ {
/**
* dumpData
*
* Dump an array of data to a specified path to yml file
*
* @param string $array
* @param string $path
* @return void
* @author Jonathan H. Wage
*/
public function dumpData($array, $path = null) public function dumpData($array, $path = null)
{ {
$spyc = new Spyc(); $spyc = new Spyc();
...@@ -45,7 +55,15 @@ class Doctrine_Parser_Yml extends Doctrine_Parser ...@@ -45,7 +55,15 @@ class Doctrine_Parser_Yml extends Doctrine_Parser
return $yml; return $yml;
} }
} }
/**
* loadData
*
* Load and parse data from a yml file
*
* @param string $path
* @return void
* @author Jonathan H. Wage
*/
public function loadData($path) public function loadData($path)
{ {
$spyc = new Spyc(); $spyc = new Spyc();
......
...@@ -7,4 +7,10 @@ class Groupuser extends Doctrine_Record ...@@ -7,4 +7,10 @@ class Groupuser extends Doctrine_Record
$this->hasColumn('group_id', 'integer'); $this->hasColumn('group_id', 'integer');
$this->hasColumn('user_id', 'integer'); $this->hasColumn('user_id', 'integer');
} }
public function setUp()
{
$this->hasOne('Group', array('local' => 'group_id', 'foreign' => 'id'));
$this->hasOne('User', array('local' => 'user_id', 'foreign' => 'id'));
}
} }
...@@ -11,5 +11,13 @@ class Phonenumber extends Doctrine_Record ...@@ -11,5 +11,13 @@ class Phonenumber extends Doctrine_Record
$this->hasOne('Entity', array('local' => 'entity_id', $this->hasOne('Entity', array('local' => 'entity_id',
'foreign' => 'id', 'foreign' => 'id',
'onDelete' => 'CASCADE')); 'onDelete' => 'CASCADE'));
$this->hasOne('Group', array('local' => 'entity_id',
'foreign' => 'id',
'onDelete' => 'CASCADE'));
$this->hasOne('User', array('local' => 'entity_id',
'foreign' => 'id',
'onDelete' => 'CASCADE'));
} }
} }
...@@ -2,3 +2,10 @@ ...@@ -2,3 +2,10 @@
require_once('playground.php'); require_once('playground.php');
require_once('connection.php'); require_once('connection.php');
require_once('models.php'); require_once('models.php');
require_once('data.php');
Doctrine_Data::exportData('data/data.yml', 'yml', $tables);
//Doctrine_Data::importData('data/data.yml', 'yml', $tables);
//Doctrine_Data::exportData('data/test.yml', 'yml', $tables);
\ No newline at end of file
<?php <?php
Doctrine::loadModels('models'); $models = Doctrine::loadModels('models');
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL); $manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
$tables = array('entity', $tables = array('Entity',
'entityReference', 'EntityReference',
'email', 'EntityAddress',
'phonenumber', 'Email',
'groupuser', 'Phonenumber',
'album', 'Groupuser',
'song', 'Group',
'element', 'User',
'error', 'Album',
'description', 'Song',
'address', 'Element',
'account', 'Error',
'task', 'Description',
'resource', 'Address',
'assignment', 'Account',
'resourceType', 'Task',
'resourceReference'); 'Resource',
'Assignment',
'ResourceType',
'ResourceReference');
$conn->export->exportClasses($tables); $conn->export->exportClasses($tables);
\ No newline at end of file
require_once('data.php');
\ 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