Skip to content

Commit

Permalink
Merge pull request #38 from Brightcookie/development
Browse files Browse the repository at this point in the history
Merge important fix from development
  • Loading branch information
sraka1 committed Sep 11, 2015
2 parents e2ce3ea + eb509f0 commit 393fed7
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions migrations/20150906233033_StatementRefs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,26 @@ public function up()

private function addReferences($statementDocument)
{
if ($statementDocument->isReferencing()) {
$referencedStatement = $statementDocument->getReferencedStatement();
try {
if ($statementDocument->isReferencing()) {

$referencedStatement = $statementDocument->getReferencedStatement();

if ($referencedStatement->isReferencing()) {
$this->addReferences($referencedStatement->getReferencedStatement());
}
if ($referencedStatement->isReferencing()) {
$this->addReferences($referencedStatement);
}

$existingReferences = [];
if (null !== $referencedStatement->getReferences()) {
$existingReferences = $referencedStatement->getReferences();
}
$statementDocument->setReferences(array_push($existingReferences, $referencedStatement->getStatement()));
$statementDocument->save();
}
$existingReferences = [];
if (null !== $referencedStatement->getReferences()) {
$existingReferences = $referencedStatement->getReferences();
}
$existingReferences[] = $referencedStatement->getStatement();
$statementDocument->setReferences($existingReferences);
$statementDocument->save();
}
} catch (\Exception $e) {
return false;
}
}

public function down()
Expand All @@ -51,7 +57,7 @@ private function removeReferences($statementDocument)
$referencedStatement = $statementDocument->getReferencedStatement();

if ($referencedStatement->isReferencing()) {
$this->removeReferences($referencedStatement->getReferencedStatement());
$this->removeReferences($referencedStatement);
}

$noReferences = [];
Expand Down

0 comments on commit 393fed7

Please sign in to comment.