Пример #1
0
 /**
  * View a single content page
  *
  * This Controller action is being routed to from either our custom ContentRouter,
  * or the ExceptionController.
  * @see Opifer\SiteBundle\Router\ContentRouter
  *
  * @param Request          $request
  * @param ContentInterface $content
  * @param int              $statusCode
  *
  * @return Response
  *
  * @throws \Exception
  */
 public function viewAction(Request $request, ContentInterface $content, $statusCode = 200)
 {
     $version = $request->query->get('_version');
     $response = new Response();
     /** @var ContentEnvironment $environment */
     $environment = $this->get('opifer.content.block_content_environment');
     $response->setStatusCode($statusCode);
     if (null !== $version && $this->isGranted('ROLE_ADMIN')) {
         $this->getDoctrine()->getManager()->getFilters()->disable('draftversion');
         $environment->load($content->getId(), $version);
     } else {
         $environment->load($content->getId());
     }
     return $this->render($environment->getView(), $environment->getViewParameters());
 }
Пример #2
0
 public function save(ContentInterface $content)
 {
     if (!$content->getId()) {
         $content->setAuthor($this->tokenStorage->getToken()->getUser());
     }
     return parent::save($content);
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function save(ContentInterface $content)
 {
     if (!$content->getId()) {
         $this->em->persist($content);
     } else {
         $cacheDriver = $this->em->getConfiguration()->getResultCacheImpl();
         $cacheDriver->deleteAll();
     }
     $this->em->flush();
     return $content;
 }
Пример #4
0
 /**
  * {@inheritDoc}
  */
 public function save(ContentInterface $content)
 {
     if (!$content->getId()) {
         $this->em->persist($content);
     }
     $this->em->flush();
     return $content;
 }
Пример #5
0
 /**
  * {@inheritDoc}
  */
 public function save(ContentInterface $content)
 {
     if (!$content->getId()) {
         $content->setAuthor($this->tokenStorage->getToken()->getUser());
         $this->em->persist($content);
     }
     $this->em->flush();
     return $content;
 }