diff --git a/lib/Doctrine.php b/lib/Doctrine.php index 3169e5f72..e60f89164 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -477,6 +477,7 @@ final class Doctrine } $parent = new ReflectionClass('Doctrine_Record'); + $loadedModels = array(); // we iterate trhough the diff of previously declared classes diff --git a/lib/Doctrine/Parser.php b/lib/Doctrine/Parser.php index 04324575f..4beb0f163 100644 --- a/lib/Doctrine/Parser.php +++ b/lib/Doctrine/Parser.php @@ -31,47 +31,73 @@ */ abstract class Doctrine_Parser { + /** + * loadData + * + * Override in the parser driver + * + * @param string $array + * @return void + * @author Jonathan H. Wage + */ 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); - + /** + * getParser + * + * Get instance of the specified parser + * + * @param string $type + * @return void + * @author Jonathan H. Wage + */ static public function getParser($type) { $class = 'Doctrine_Parser_'.ucfirst($type); 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') { $parser = self::getParser($type); 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') { $parser = self::getParser($type); 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 diff --git a/lib/Doctrine/Parser/Yml.php b/lib/Doctrine/Parser/Yml.php index bbd5c0088..85cdcf243 100644 --- a/lib/Doctrine/Parser/Yml.php +++ b/lib/Doctrine/Parser/Yml.php @@ -33,6 +33,16 @@ require_once('spyc.php'); */ 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) { $spyc = new Spyc(); @@ -45,7 +55,15 @@ class Doctrine_Parser_Yml extends Doctrine_Parser return $yml; } } - + /** + * loadData + * + * Load and parse data from a yml file + * + * @param string $path + * @return void + * @author Jonathan H. Wage + */ public function loadData($path) { $spyc = new Spyc(); diff --git a/models/GroupUser.php b/models/GroupUser.php index ce5f8b7bd..e7acea16c 100644 --- a/models/GroupUser.php +++ b/models/GroupUser.php @@ -7,4 +7,10 @@ class Groupuser extends Doctrine_Record $this->hasColumn('group_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')); + } } diff --git a/models/Phonenumber.php b/models/Phonenumber.php index 63d27a5a9..23b178dc4 100644 --- a/models/Phonenumber.php +++ b/models/Phonenumber.php @@ -11,5 +11,13 @@ class Phonenumber extends Doctrine_Record $this->hasOne('Entity', array('local' => 'entity_id', 'foreign' => 'id', 'onDelete' => 'CASCADE')); + + $this->hasOne('Group', array('local' => 'entity_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE')); + + $this->hasOne('User', array('local' => 'entity_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE')); } } diff --git a/playground/index.php b/playground/index.php index fc4aec852..ae8650f87 100644 --- a/playground/index.php +++ b/playground/index.php @@ -1,4 +1,11 @@ setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL); -$tables = array('entity', - 'entityReference', - 'email', - 'phonenumber', - 'groupuser', - 'album', - 'song', - 'element', - 'error', - 'description', - 'address', - 'account', - 'task', - 'resource', - 'assignment', - 'resourceType', - 'resourceReference'); +$tables = array('Entity', + 'EntityReference', + 'EntityAddress', + 'Email', + 'Phonenumber', + 'Groupuser', + 'Group', + 'User', + 'Album', + 'Song', + 'Element', + 'Error', + 'Description', + 'Address', + 'Account', + 'Task', + 'Resource', + 'Assignment', + 'ResourceType', + 'ResourceReference'); -$conn->export->exportClasses($tables); - -require_once('data.php'); \ No newline at end of file +$conn->export->exportClasses($tables); \ No newline at end of file