/**
  * TODO : function must be inspected before remove. Now we are not using this method.
  * manager current journal setup step 6
  * @param  Request      $request
  * @return JsonResponse
  */
 public function managerUpdateAction(Request $request)
 {
     /** @var EntityManager $em */
     $em = $this->getDoctrine()->getManager();
     $currentJournal = $this->get("ojs.journal_service")->getSelectedJournal();
     $step6Form = $this->createForm(new Step6(), $currentJournal);
     $step6Form->handleRequest($request);
     $router = $this->get('router');
     if ($step6Form->isValid()) {
         //add blocks
         $twig = $this->get('okulbilisimcmsbundle.twig.post_extension');
         $journalKey = $twig->encode($currentJournal);
         $pages = $em->getRepository("OkulbilisimCmsBundle:Post")->findBy(['object' => $journalKey, 'objectId' => $currentJournal->getId()]);
         if ($pages) {
             $blockRepo = $em->getRepository("OjsSiteBundle:Block");
             $checkPagesBlock = $blockRepo->findOneBy(['type' => 'link', 'objectType' => 'journal', 'objectId' => $currentJournal->getId(), 'title' => 'Pages']);
             if (!$checkPagesBlock) {
                 $block = new Block();
                 $block->setType('link')->setObjectType('journal')->setObjectId($currentJournal->getId())->setColor('primary')->setTitle("Pages");
                 $em->persist($block);
                 $i = 1;
                 foreach ($pages as $page) {
                     $blockLink = new BlockLink();
                     $blockLink->setBlock($block)->setPost($page)->setText($page->getTitle())->setUrl($router->generate('ojs_journal_index_page_detail', ['journal_slug' => $currentJournal->getSlug(), 'slug' => $page->getSlug(), 'institution' => $currentJournal->getInstitution()->getSlug()]))->setLinkOrder($i);
                     $i++;
                     $em->persist($blockLink);
                 }
             }
         }
         $journalSections = $currentJournal->getSections();
         if (count($journalSections) == 0) {
             $journalSection = new JournalSection();
             $journalSection->setTitle($this->get('translator')->trans("Articles"))->setAllowIndex(true)->setJournal($currentJournal)->setJournalId($currentJournal->getId());
             $em->persist($journalSection);
             $currentJournal->addSection($journalSection);
         }
         $currentJournal->setSetupStatus(true);
         $em->flush();
         $journalLink = $this->get('ojs.journal_service')->generateUrl($currentJournal);
         return new JsonResponse(['success' => '1', 'journalLink' => $journalLink]);
     } else {
         return new JsonResponse(array('success' => '0'));
     }
 }
Ejemplo n.º 2
0
 /**
  * @param  Block $block
  * @param $order
  * @return Response
  */
 public function orderAction(Block $block, $order)
 {
     $em = $this->getDoctrine()->getManager();
     $block->setBlockOrder($order);
     $em->persist($block);
     $em->flush();
     return JsonResponse::create(['status' => true]);
 }