MapReferencedToParentKey() final public method

final public MapReferencedToParentKey ( ColumnData $ReferencedKeyData, ColumnData $ParentKeyData )
$ReferencedKeyData Storm\Core\Relational\ColumnData
$ParentKeyData Storm\Core\Relational\ColumnData
コード例 #1
0
 public function Persist(Relational\Transaction $Transaction, Relational\ResultRow $ParentData, array $RelationshipChanges)
 {
     /* @var $RelationshipChanges Relational\RelationshipChange[] */
     $JoinRowsWithoutPrimaryKeys = [];
     foreach ($RelationshipChanges as $RelationshipChange) {
         if ($RelationshipChange->HasPersistedRelationship()) {
             $JoinRow = $this->MapPersistedRelationshipToJoinRow($RelationshipChange->GetPersistedRelationship());
             $Transaction->Persist($JoinRow);
             if (!$JoinRow->HasPrimaryKey()) {
                 $JoinRowsWithoutPrimaryKeys[] = $JoinRow;
             }
         }
         if ($RelationshipChange->HasDiscardedRelationship()) {
             $JoinRow = $this->MapDiscardedRelationshipToJoinRow($RelationshipChange->GetDiscardedRelationship());
             $Transaction->Discard($JoinRow->GetPrimaryKey());
         }
     }
     if (count($JoinRowsWithoutPrimaryKeys) > 0) {
         $ParentRow = $ParentData->GetRow($this->ParentForeignKey->GetReferencedTable());
         $Transaction->SubscribeToPrePersistEvent($this->JoinTable, function () use(&$ParentRow, &$JoinRowsWithoutPrimaryKeys) {
             foreach ($JoinRowsWithoutPrimaryKeys as $JoinRowWithoutPrimaryKey) {
                 $this->ParentForeignKey->MapReferencedToParentKey($ParentRow, $JoinRowWithoutPrimaryKey);
             }
         });
     }
 }
コード例 #2
0
ファイル: KeyedRelation.php プロジェクト: timetoogo/penumbra
 /**
  * @return Relational\ResultRow
  */
 protected function MapParentRowToRelatedKey(ForeignKey $ForeignKey, Relational\ResultRow $ParentRow)
 {
     if ($this->IsInversed) {
         $ParentKey = $ForeignKey->ParentKey();
         $ForeignKey->MapReferencedToParentKey($ParentRow, $ParentKey);
         return $ParentKey;
     } else {
         $ReferencedKey = $ForeignKey->ReferencedKey();
         $ForeignKey->MapParentToReferencedKey($ParentRow, $ReferencedKey);
         return $ReferencedKey;
     }
 }