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); }
/** * Check relation if it is a many to one relation. * * @return boolean */ public function isManyToOne() { $o2o = $this->foreign->parseComment('o2o'); if (!is_null($o2o)) { $isMany = !(bool) $this->getBooleanOption($o2o); } else { $isMany = (bool) $this->parameters->get('many'); } return $isMany; }
/** * Check relation if it is unidirectional * * @return bool */ public function isUnidirectional() { $o = $this->foreign->parseComment('unidirectional'); $is = (bool) $this->getBooleanOption($o); return $is; }
/** * Get column type mapping. * * @param MwbExporter\Model\Column $column * @return string */ public function getMappedType(Column $column) { return $this->getDataType($column->getColumnType()); }