示例#1
0
 /**
  * Creates a new Page entity.
  *
  * @param  Request $request
  * @return RedirectResponse|Response
  */
 public function createAction(Request $request)
 {
     $entity = new AdminPage();
     $entity->setCurrentLocale($request->getDefaultLocale());
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $entity->setSlug($entity->getTranslationByLocale($request->getDefaultLocale())->getTitle());
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         $this->successFlashBag('successful.create');
         return $this->redirectToRoute('ojs_admin_page_show', ['id' => $entity->getId()]);
     }
     return $this->render('OjsAdminBundle:AdminPage:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
 }
示例#2
0
 public function testDelete()
 {
     $em = $this->em;
     $entity = new AdminPage();
     $entity->setCurrentLocale($this->locale);
     $entity->setTitle('Title Delete - phpunit');
     $entity->setBody('Body');
     $entity->setVisible(true);
     $em->persist($entity);
     $em->flush();
     $id = $entity->getId();
     $this->logIn();
     $client = $this->client;
     $token = $this->generateToken('ojs_admin_page' . $id);
     $client->request('DELETE', '/admin/page/' . $id . '/delete', array('_token' => $token));
     $this->assertStatusCode(302, $client);
 }
示例#3
0
 protected function createDefaultPages()
 {
     $pages = [['about', 'About', 'About page content goes here.'], ['privacy', 'Privacy', 'Privacy page content goes here.'], ['faq', 'FAQ', 'A list of frequently answered questions goes here.'], ['tos', 'Terms of Service', 'TOS page content goes here.']];
     $em = $this->getContainer()->get('doctrine')->getManager();
     foreach ($pages as $page) {
         $entity = $em->getRepository('OjsAdminBundle:AdminPage')->findOneBy(['slug' => $page[0]]);
         if (!$entity) {
             $entity = new AdminPage();
             $entity->setVisible(true);
             $entity->setCurrentLocale($this->getContainer()->getParameter('locale'));
             $entity->setSlug($page[0]);
             $entity->setTitle($page[1]);
             $entity->setBody($page[2]);
             $em->persist($entity);
         }
     }
     $em->flush();
 }
示例#4
0
 /**
  * @return int
  */
 public function loadPage()
 {
     $entity = new AdminPage();
     $entity->setCurrentLocale('tr')->setTitle('Sample Page Title')->setBody('Sample Page Body')->setSlug('Sample Page Slug')->setCurrentLocale('en')->setTitle('Sample Page Title en')->setBody('Sample Page Body en');
     $this->em->persist($entity);
     $this->em->flush();
     return $entity->getId();
 }