コード例 #1
0
 /**
  * Get foreign key join annotation. If foreign key is composite
  * JoinColumns returned, otherwise JoinColumn returned.
  *
  * @param \MwbExporter\Model\ForeignKey $fkey  Foreign key
  * @param boolean $owningSide  Is join for owning side or vice versa
  * @return \MwbExporter\Object\Annotation
  */
 protected function getJoins(ForeignKey $fkey, $owningSide = true)
 {
     $joins = array();
     $lcols = $owningSide ? $fkey->getForeigns() : $fkey->getLocals();
     $fcols = $owningSide ? $fkey->getLocals() : $fkey->getForeigns();
     $onDelete = $this->getFormatter()->getDeleteRule($fkey->getParameters()->get('deleteRule'));
     for ($i = 0; $i < count($lcols); $i++) {
         $joins[] = $this->getAnnotation('JoinColumn', array('name' => $this->quoteIdentifier($lcols[$i]->getColumnName()), 'referencedColumnName' => $this->quoteIdentifier($fcols[$i]->getColumnName()), 'nullable' => $lcols[$i]->getNullableValue(), 'onDelete' => $onDelete));
     }
     return count($joins) > 1 ? $this->getAnnotation('JoinColumns', array($joins), array('multiline' => true, 'wrapper' => ' * %s')) : $joins[0];
 }
コード例 #2
0
 /**
  * Get foreign key join descriptor.
  *
  * @param \MwbExporter\Model\ForeignKey $fkey  Foreign key
  * @param string $owningSide  Is join for owning side or vice versa
  * @return array
  */
 protected function getJoins(ForeignKey $fkey, $owningSide = true)
 {
     $joins = array();
     $lcols = $owningSide ? $fkey->getForeigns() : $fkey->getLocals();
     $fcols = $owningSide ? $fkey->getLocals() : $fkey->getForeigns();
     $onDelete = $this->getFormatter()->getDeleteRule($fkey->getParameters()->get('deleteRule'));
     for ($i = 0; $i < count($lcols); $i++) {
         $joins[] = array('name' => $lcols[$i]->getColumnName(), 'referencedColumnName' => $fcols[$i]->getColumnName(), 'nullable' => $lcols[$i]->isNotNull() ? false : null, 'onDelete' => $onDelete);
     }
     return count($joins) > 1 ? array('joinColumns' => $this->convertJoinColumns($joins)) : array('joinColumn' => $joins[0]);
 }