コード例 #1
0
    /**
     *
     * @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()
                                )
                            );
                        }
                    }
                }
            }
        }
    }
コード例 #2
0
 /**
  *
  * @param \MwbExporter\Core\Model\ForeignKey $foreignKey
  */
 public function injectRelation( \MwbExporter\Core\Model\ForeignKey $foreignKey)
 {
     foreach($this->relations as $_relation){
         if($_relation->getId() === $foreignKey->getId()){
             return;
         }
     }
     $this->relations[] = $foreignKey;
 }
コード例 #3
0
 public function __construct($data, $parent)
 {
     parent::__construct($data, $parent);
 }
コード例 #4
0
 public function markAsForeignReference( \MwbExporter\Core\Model\ForeignKey $foreign)
 {
     if($this->foreigns == null) {
         $this->foreigns = array();
     }
     $this->foreigns[($foreign->getId())] = $foreign;
     // $this->foreigns[] = $foreign; // unfortunately this code doubles the references
 }