コード例 #1
0
 /**
  * Transforms an object (page) to a string (number).
  *
  * @param PageInterface $page
  * @return mixed|string
  */
 public function transform($page)
 {
     if (null === $page) {
         return "";
     }
     return $page->getId();
 }
コード例 #2
0
ファイル: PageManager.php プロジェクト: lzdv/init-cms-bundle
 /**
  * @param PageInterface $page
  * @return mixed
  */
 public function save(PageInterface $page)
 {
     if (!$page->getId()) {
         $page->setContentRoute(new ContentRoute());
     }
     $this->_em->persist($page);
 }
コード例 #3
0
 /**
  * create a copy of a given page object in a given locale
  *
  * @param $page
  * @param $locale
  * @return \Networking\InitCmsBundle\Model\Page
  */
 public function makeTranslationCopy(PageInterface $page, $locale)
 {
     if ($this->getParameter('networking_init_cms.db_driver') == 'orm') {
         /** @var \Doctrine\Common\Persistence\ObjectManager $em */
         $em = $this->getService('doctrine')->getManager();
     } else {
         /** @var \Doctrine\Common\Persistence\ObjectManager $em */
         $em = $this->getService('doctrine_mongodb')->getManager();
     }
     /** @var \Networking\InitCmsBundle\Model\PageManagerInterface $pageManger */
     $pageManger = $this->getService('networking_init_cms.page_manager');
     $pageClass = $pageManger->getClassName();
     /** @var PageInterface $pageCopy */
     $pageCopy = new $pageClass();
     $pageCopy->setPageName($page->getPageName());
     $pageCopy->setMetaTitle($page->getMetaTitle());
     $pageCopy->setUrl($page->getUrl());
     $pageCopy->setMetaKeyword($page->getMetaKeyword());
     $pageCopy->setMetaDescription($page->getMetaDescription());
     $pageCopy->setActiveFrom($page->getActiveFrom());
     $pageCopy->setIsHome($page->getIsHome());
     $pageCopy->setLocale($locale);
     $pageCopy->setTemplateName($page->getTemplateName());
     $pageCopy->setOriginal($page);
     $layoutBlocks = $page->getLayoutBlock();
     foreach ($layoutBlocks as $layoutBlock) {
         /** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
         $newLayoutBlock = clone $layoutBlock;
         $content = $em->getRepository($newLayoutBlock->getClassType())->find($newLayoutBlock->getObjectId());
         $newContent = clone $content;
         $em->persist($newContent);
         $em->flush();
         $newLayoutBlock->setObjectId($newContent->getId());
         $newLayoutBlock->setPage($pageCopy);
         $em->persist($newLayoutBlock);
     }
     $em->persist($pageCopy);
     $em->flush();
     return $pageCopy;
 }
コード例 #4
0
 /**
  * Return the json response for the ajax edit action
  *
  * @param Form $form
  * @param PageInterface $page
  * @return Response
  */
 protected function getAjaxEditResponse(Form $form, PageInterface $page)
 {
     $view = $form->createView();
     // set the theme for the current Admin Form
     $this->get('twig')->getExtension('form')->renderer->setTheme($view, $this->admin->getFormTheme());
     $pageSettingsHtml = $this->renderView('NetworkingInitCmsBundle:PageAdmin:ajax_page_settings.html.twig', array('action' => 'edit', 'form' => $view, 'object' => $page, 'admin' => $this->admin, 'admin_pool' => $this->get('sonata.admin.pool')));
     return $this->renderJson(array('result' => 'ok', 'objectId' => $page->getId(), 'title' => $page->__toString(), 'messageStatus' => 'success', 'message' => $this->admin->trans('info.page_settings_updated'), 'pageStatus' => $this->admin->trans($page->getStatus()), 'pageSettings' => $pageSettingsHtml));
 }
コード例 #5
0
 /**
  * @param PageInterface $page
  */
 public function autoPageDraft(PageInterface $page)
 {
     $page->setStatus(PageInterface::STATUS_DRAFT);
     $page->setUpdatedAt(new \DateTime());
     /** @var PageAdmin $pageAdmin */
     $pageAdmin = $this->getContainer()->get('networking_init_cms.admin.page');
     $pageAdmin->update($page);
 }
コード例 #6
0
ファイル: Page.php プロジェクト: networking/init-cms-bundle
 /**
  * @return int
  */
 public function convertAliasToInteger()
 {
     if ($this->alias) {
         return $this->alias->getId();
     }
     return null;
 }
コード例 #7
0
 /**
  * @param PageInterface $page
  * @return mixed
  */
 public function getPageUrl(PageInterface $page)
 {
     $request = $this->getService('request');
     return $request->getBaseUrl() . $page->getFullPath();
 }
コード例 #8
0
 /**
  * Get conversation
  *
  * @return int
  */
 public function getPageId()
 {
     return $this->page->getId();
 }
コード例 #9
0
 /**
  * @param PageInterface $object
  * @return mixed|void
  */
 public function postRemove($object)
 {
     $contentRoute = $object->getContentRoute();
     try {
         $this->getModelManager()->delete($contentRoute);
     } catch (\Exception $e) {
         var_dump($e);
         die;
     }
 }