Changeset 3965
- Timestamp:
- 03/10/08 20:08:13 (16 months ago)
- Location:
- branches/0.10/lib/Doctrine/Import
- Files:
-
- 2 modified
-
Builder.php (modified) (4 diffs)
-
Schema.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Import/Builder.php
r3961 r3965 61 61 */ 62 62 protected $_packagesPath = ''; 63 63 64 /** 65 * _packagesFolderName 66 * 67 * @var string 68 */ 69 protected $_packagesFolderName = 'packages'; 70 64 71 /** 65 72 * _suffix … … 104 111 */ 105 112 protected $_baseClassName = 'Doctrine_Record'; 106 113 107 114 /** 108 115 * _tpl … … 134 141 if ($path) { 135 142 if ( ! $this->_packagesPath) { 136 $this->setPackagesPath($path . DIRECTORY_SEPARATOR . 'packages');143 $this->setPackagesPath($path . DIRECTORY_SEPARATOR . $this->_packagesFolderName); 137 144 } 138 145 … … 252 259 public function setOptions($options) 253 260 { 254 if ( !empty($options)) {261 if ( ! empty($options)) { 255 262 foreach ($options as $key => $value) { 256 263 $this->setOption($key, $value); -
branches/0.10/lib/Doctrine/Import/Schema.php
r3961 r3965 21 21 22 22 /** 23 * classDoctrine_Import_Schema23 * Doctrine_Import_Schema 24 24 * 25 * Different methods to import a XML schema. The logic behind using two different 26 * methods is simple. Some people will like the idea of producing Doctrine_Record 27 * objects directly, which is totally fine. But in fast and growing application, 28 * table definitions tend to be a little bit more volatile. importArr() can be used 29 * to output a table definition in a PHP file. This file can then be stored 30 * independantly from the object itself. 25 * Class for importing Doctrine_Record classes from a yaml schema definition 31 26 * 32 27 * @package Doctrine … … 43 38 protected $_options = array('packagesPrefix' => 'Package', 44 39 'packagesPath' => '', 40 'packagesFolderName' => 'packages', 41 'suffix' => '.php', 45 42 'generateBaseClasses' => true, 43 'baseClassesPrefix' => 'Base', 46 44 'baseClassesDirectory' => 'generated', 47 'baseClassName' => 'Doctrine_Record', 48 'suffix' => '.php'); 45 'baseClassName' => 'Doctrine_Record'); 49 46 50 47 /** … … 93 90 public function setOptions($options) 94 91 { 95 if ( !empty($options)) {92 if ( ! empty($options)) { 96 93 $this->_options = $options; 97 94 } … … 101 98 * buildSchema 102 99 * 103 * Loop throug directories of schema files and par tthem all in to one complete array of schema information100 * Loop throug directories of schema files and parse them all in to one complete array of schema information 104 101 * 105 102 * @param string $schema Array of schema files or single schema file. Array of directories with schema files or single directory … … 141 138 * 142 139 * @param string $schema The file containing the XML schema 140 * @param string $format Format of the schema file 143 141 * @param string $directory The directory where the Doctrine_Record class will be written 144 * @param array $modelsOptional array of models to import142 * @param array $models Optional array of models to import 145 143 * 146 144 * @return void … … 170 168 * 171 169 * @param string $schema Path to the file containing the schema 170 * @param string $type Format type of the schema we are parsing 172 171 * @return array $build Built array of schema information 173 172 */ … … 312 311 * 313 312 * Perform some processing on inheritance. 313 * Sets the default type and sets some default values for certain types 314 314 * 315 315 * @param string $array … … 348 348 349 349 // Array of the array keys to move to the parent, and the value to default the child definition to 350 // after moving it 350 // after moving it. Will also populate the subclasses array for the inheritance parent 351 351 $moves = array('columns' => array(), 'relations' => array()); 352 352 … … 362 362 } 363 363 364 // Populate the parents subclasses 364 365 if ($definition['inheritance']['type'] == 'column_aggregation') { 365 366 $array[$extends]['inheritance']['subclasses'][$definition['className']] = array($definition['inheritance']['keyField'] => $definition['inheritance']['keyValue']); … … 375 376 * 376 377 * Loop through an array of schema information and build all the necessary relationship information 377 * Will attempt to auto complete relationships and simplify the amount of information required for defining a relationship 378 * Will attempt to auto complete relationships and simplify the amount of information required 379 * for defining a relationship 378 380 * 379 381 * @param string $array … … 387 389 if (isset($properties['columns']) && ! empty($properties['columns']) && isset($properties['detect_relations']) && $properties['detect_relations']) { 388 390 foreach ($properties['columns'] as $column) { 391 // Check if the column we are inflecting has a _id on the end of it before trying to inflect it and find 392 // the class name for the column 389 393 if (strpos($column['name'], '_id')) { 390 394 $columnClassName = Doctrine_Inflector::classify(str_replace('_id', '', $column['name'])); … … 445 449 // Make sure we do not have any duplicate relations 446 450 $this->_fixDuplicateRelations(); 447 451 452 // Set the full array of relationships for each class to the final array 448 453 foreach ($this->_relations as $className => $relations) { 449 454 $array[$className]['relations'] = $relations; … … 485 490 } 486 491 } 487 492 493 // Make sure it doesn't already exist 488 494 if ( ! isset($this->_relations[$relation['class']][$newRelation['alias']])) { 489 495 $newRelation['key'] = $this->_buildUniqueRelationKey($newRelation); … … 506 512 } else { 507 513 // check to see if this relationship is not autogenerated, if it's not, then the user must have explicitly declared it 508 if ( !isset($relation['autogenerated']) || $relation['autogenerated'] != true) {514 if ( ! isset($relation['autogenerated']) || $relation['autogenerated'] != true) { 509 515 $uniqueRelations = array_merge($uniqueRelations, array($relation['alias'] => $relation)); 510 516 } … … 519 525 * _buildUniqueRelationKey 520 526 * 527 * Build a unique key to identify a relationship by 528 * Md5 hash of all the relationship parameters 529 * 521 530 * @param string $relation 522 531 * @return void … … 524 533 protected function _buildUniqueRelationKey($relation) 525 534 { 526 return md5($relation['local'].$relation['foreign'].$relation['class'].(isset($relation['refClass']) ? $relation['refClass']:null));535 return md5($relation['local'].$relation['foreign'].$relation['class'].(isset($relation['refClass']) ? $relation['refClass']:null)); 527 536 } 528 537 }