Skip to content

Commit

Permalink
Merge pull request #118 from Kunstmaan/fix-HasPageTemplateInterface
Browse files Browse the repository at this point in the history
Add container to repo to avoid method on non object error
  • Loading branch information
jockri committed May 12, 2014
2 parents dda587c + 7c92d19 commit 0f8a905
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion EventListener/CloneListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public function postDeepCloneAndSave(DeepCloneAndSaveEvent $event)
}
if ($originalEntity instanceof HasPageTemplateInterface) {
$clonedEntity = $event->getClonedEntity();
$newPageTemplateConfiguration = clone $this->em->getRepository('KunstmaanPagePartBundle:PageTemplateConfiguration')->findOrCreateFor($originalEntity);
$PageTemplateConfigurationRepo = $this->em->getRepository('KunstmaanPagePartBundle:PageTemplateConfiguration');
$PageTemplateConfigurationRepo->setContainer($this->kernel->getContainer());
$newPageTemplateConfiguration = clone $PageTemplateConfigurationRepo->findOrCreateFor($originalEntity);
$newPageTemplateConfiguration->setId(null);
$newPageTemplateConfiguration->setPageId($clonedEntity->getId());
$this->em->persist($newPageTemplateConfiguration);
Expand Down
2 changes: 1 addition & 1 deletion Tests/EventListener/CloneListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function setUp()
->getMock();

$this->repo = $this->getMockBuilder('Doctrine\ORM\EntityRepository')
->setMethods(array('findOrCreateFor', 'copyPageParts'))
->setMethods(array('findOrCreateFor', 'copyPageParts', 'setContainer'))
->disableOriginalConstructor()
->getMock();

Expand Down

0 comments on commit 0f8a905

Please sign in to comment.