Пример #1
0
 public function testSetFields()
 {
     $now = new DateTime();
     $this->assertEquals('sslkdnn', $this->data->setContent('sslkdnn')->getContent());
     $this->assertEquals('fr', $this->data->setLocale('fr')->getLocale());
     $this->assertEquals($now, $this->data->setModified($now)->getModified());
 }
Пример #2
0
 /**
  * Displays a form to edit an existing I18n entity.
  *
  * @Route("/{id}/edit", name="i18n_edit")
  * @Method({"GET", "POST"})
  */
 public function editAction(Request $request, I18n $i18n)
 {
     //         $deleteForm = $this->createDeleteForm($i18n);
     if (empty($i18n->getContent())) {
         $i18n->setContent([['locale' => '', 'text' => '']]);
     }
     $editForm = $this->createForm(I18nType::class, $i18n);
     $editForm->handleRequest($request);
     if ($editForm->isSubmitted() && $editForm->isValid()) {
         $em = $this->getDoctrine()->getManager();
         //renumber array elements
         $i18n->setContent(array_values($i18n->getContent()));
         $em->persist($i18n);
         $em->flush();
         return $this->redirectToRoute('i18n_index');
     }
     return $this->render('i18n/edit.html.twig', array('i18n' => $i18n, 'edit_form' => $editForm->createView()));
 }