Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PagePartBundle] Fixed error when moving page parts into a different region (#173) #238

Merged
merged 2 commits into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Kunstmaan/PagePartBundle/PagePartAdmin/PagePartAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,12 @@ public function preBindRequest(Request $request)
foreach ($sequences as $sequence) {
if (array_key_exists($sequence, $this->newPageParts)) {
$this->pageParts[$sequence] = $this->newPageParts[$sequence];
} else {
} elseif (array_key_exists($sequence, $tempPageparts)) {
$this->pageParts[$sequence] = $tempPageparts[$sequence];
}
} else
$this->pageParts[$sequence] = $this->getPagePart($sequence, array_search($sequence, $sequences)+1);
}

unset($tempPageparts);
}
}
Expand Down Expand Up @@ -358,6 +360,18 @@ public function getType(AbstractPagePart $pagepart)
return "no name";
}

/**
* @param bigint $id
* @param int $sequenceNumber
*
* @return PagePart
*/
public function getPagePart($id, $sequenceNumber)
{
$ppRefRepo = $this->em->getRepository('KunstmaanPagePartBundle:PagePartRef');
return $ppRefRepo->getPagePart($id, $this->context, $sequenceNumber);
}

/**
* @param object $pagepart
*
Expand Down
19 changes: 19 additions & 0 deletions src/Kunstmaan/PagePartBundle/Repository/PagePartRefRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,23 @@ public function hasPageParts(HasPagePartsInterface $page, $context = 'main')
->setParameter('pageId', $page->getId())
->setParameter('context', $context)->getSingleScalarResult() != 0;
}

/**
* @param bigint $id The id
* @param string $context The context
* @param int $sequenceNumber The sequence number
*
* @return PagePart
*/
public function getPagePart($id, $context = 'main', $sequenceNumber)
{
$ppRef = $this->find($id);
$ppRef->setContext($context);
$ppRef->setSequenceNumber($sequenceNumber);
$this->getEntityManager()->persist($ppRef);
$this->getEntityManager()->flush();

return $this->getEntityManager()->getRepository($ppRef->getPagePartEntityName())->find($ppRef->getPagePartId());

}
}