protected function init()
 {
     // iterate on foreign key configuration
     foreach ($this->node->value as $key => $node) {
         $attributes = $node->attributes();
         $this->parameters->set((string) $attributes['key'], (string) $node[0]);
     }
     // follow references to tables
     foreach ($this->node->link as $key => $node) {
         $attributes = $node->attributes();
         $key = (string) $attributes['key'];
         if ($key === 'referencedTable') {
             $this->referencedTable = $this->getDocument()->getReference()->get((string) $node);
         }
         if ($key === 'owner') {
             $this->owningTable = $this->getDocument()->getReference()->get((string) $node);
             $this->owningTable->injectRelation($this);
         }
     }
     $referencedColumn = $this->node->xpath("value[@key='referencedColumns']");
     $this->local = $this->getDocument()->getReference()->get((string) $referencedColumn[0]->link);
     $ownerColumn = $this->node->xpath("value[@key='columns']");
     $this->foreign = $this->getDocument()->getReference()->get((string) $ownerColumn[0]->link);
     // for doctrine2 annotations switch the local and the foreign
     // reference for a proper output
     $this->local->markAsForeignReference($this);
     $this->foreign->markAsLocalReference($this);
 }
 protected function init()
 {
     $this->getDocument()->addLog(sprintf('Processing foreign key "%s.%s"', $this->getTable()->getRawTableName(), $this->getName()));
     // follow references to tables
     foreach ($this->node->link as $key => $node) {
         $attributes = $node->attributes();
         $key = (string) $attributes['key'];
         if ($key === 'referencedTable') {
             $this->referencedTable = $this->getReference()->get((string) $node);
         }
         if ($key === 'owner') {
             $this->owningTable = $this->getReference()->get((string) $node);
             $this->owningTable->injectRelation($this);
         }
     }
     $this->locals = array();
     foreach ($this->node->xpath("value[@key='columns']") as $column) {
         foreach ($column->children() as $link) {
             $this->locals[] = $this->getReference()->get((string) $link);
         }
     }
     $this->foreigns = array();
     foreach ($this->node->xpath("value[@key='referencedColumns']") as $column) {
         foreach ($column->children() as $link) {
             $this->foreigns[] = $this->getReference()->get((string) $link);
         }
     }
     // for doctrine2 annotations switch the local and the foreign
     // reference for a proper output
     foreach ($this->locals as $column) {
         $this->getDocument()->addLog(sprintf('Mark column %s.%s as foreign reference for %s', $column->getTable()->getRawTableName(), $column->getColumnName(), $this->getReferencedTable()->getRawTableName()));
         $column->markAsForeignReference($this);
     }
     foreach ($this->foreigns as $column) {
         $this->getDocument()->addLog(sprintf('Mark column %s.%s as local reference for %s', $column->getTable()->getRawTableName(), $column->getColumnName(), $this->getReferencedTable()->getRawTableName()));
         $column->markAsLocalReference($this);
     }
 }