protected function deepCopyPageWithoutChildren(Page $page, Page $parentPage = null) { $copy = new Page(); $copy->setId($page->getId()); $copy->setRouteName($page->getRouteName()); $copy->setPageAlias($page->getPageAlias()); $copy->setType($page->getType()); $copy->setEnabled($page->getEnabled()); $copy->setName($page->getName()); $copy->setSlug($page->getSlug()); $copy->setUrl($page->getUrl()); $copy->setCustomUrl($page->getCustomUrl()); $copy->setMetaKeyword($page->getMetaKeyword()); $copy->setMetaDescription($page->getMetaDescription()); $copy->setJavascript($page->getJavascript()); $copy->setStylesheet($page->getStylesheet()); $copy->setCreatedAt($page->getCreatedAt()); $copy->setUpdatedAt($page->getUpdatedAt()); $copy->setTarget($page->getTarget()); $copy->setTemplateCode($page->getTemplateCode()); $copy->setDecorate($page->getDecorate()); $copy->setPosition($page->getPosition()); $copy->setRequestMethod($page->getRequestMethod()); $copy->setHeaders($page->getHeaders()); $copy->setSite($page->getSite()); $copy->setRawHeaders($page->getRawHeaders()); $copy->setEdited($page->getEdited()); $copy->setTitle($page->getTitle()); $copy->setParent($parentPage ? $parentPage : $page->getParent()); foreach ($page->getTranslations() as $translation) { $translationCopy = $this->deepCopyPageTranslation($translation, $copy); $copy->addTranslation($translationCopy); } foreach ($page->getBlocks() as $block) { if (!$block->getParent()) { $blockCopy = $this->deepCopyBlock($block, $copy); $this->entityManager->persist($blockCopy); } } $this->entityManager->persist($copy); return $copy; }
/** * @param Page $page * @return mixed */ public function findSnapshotLinksTo($page) { return $this->getEntityManager()->createQuery(sprintf("SELECT p FROM %s p JOIN p.snapshots s WHERE s.content LIKE '%%{{ url(%d) }}%%'", $this->class, $page->getId()))->execute(); }