Example #1
0
 public function getReferencingKeyNames(Table $otherTable, $otherColumnName = null)
 {
     $otherInflectedColumnName = $this->inflectInputColumnName($otherColumnName);
     $refCols = $otherTable->getReferenceColumns();
     foreach ($refCols as $refColName => $refCol) {
         $ref = $refCol->getReference();
         if ($ref->belongsTo($this) && (!$otherColumnName || $otherInflectedColumnName === $refColName)) {
             $thisKey = $this->inflectOutputColumnName($ref->getName());
             $otherKey = $this->inflectOutputColumnName($refColName);
             return [$thisKey, $otherKey];
         }
     }
     throw new \Exception("Failed to get referencing column names: No reference from {$otherTable} to {$this} found");
 }