/** * * @param SimpleXMLElement $data * @param type $parent */ public function __construct($data, $parent) { parent::__construct($data, $parent); $referencedColumn = $this->data->xpath("value[@key='referencedColumns']"); $local = \MwbExporter\Core\Registry::get((string) $referencedColumn[0]->link); $ownerColumn = $this->data->xpath("value[@key='columns']"); $foreign = \MwbExporter\Core\Registry::get((string) $ownerColumn[0]->link); $this->local = $local; // local column object $this->foreign = $foreign; // foreign column object // for doctrine2 annotations switch the local and the foreign // reference for a proper output $local->markAsForeignReference($this); $foreign->markAsLocalReference($this); // many to many if($fk = $this->getOwningTable()->getForeignKeys()){ // only two or more foreign keys implicate an m2m relation // of the current table if(count($fk) > 1){ foreach($fk as $foreignKey1){ foreach($fk as $foreignKey2){ if($foreignKey1->getReferencedTable()->getId() != $foreignKey2->getReferencedTable()->getId()){ $foreignKey1->getReferencedTable()->setManyToManyRelation( array( 'reference' => $this, 'refTable' => $foreignKey2->getReferencedTable() ) ); } } } } } }
public function __construct($data, $parent) { parent::__construct($data, $parent); }