original_string: public function newAction(Request $request)
      {
          $series = $this->get('oktolab_media')->createSeries();
          $form = $this->createForm(SeriesType::class, $series);
          $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.new_series_button', 'attr' => ['class' => 'btn btn-primary']]);
  
          if ($request->getMethod() == "POST") { //sends form
              $form->handleRequest($request);
              $em = $this->getDoctrine()->getManager();
              if ($form->isValid()) { //form is valid, save or preview
                  if ($form->get('submit')->isClicked()) { //save me
                      $em->persist($series);
                      $em->flush();
                      $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_create_series');
                      return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqId()]));
                  } else { //???
                      $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series');
                      return $this->redirect($this->generateUrl('oktolab_series'));
                  }
              }
              $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_create_series');
          }
  
          return ['form' => $form->createView()];
      }
code: public function newAction(Request $request)
      {
          $series = $this->get('oktolab_media')->createSeries();
          $form = $this->createForm(SeriesType::class, $series);
          $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.new_series_button', 'attr' => ['class' => 'btn btn-primary']]);
  
          if ($request->getMethod() == "POST") { //sends form
              $form->handleRequest($request);
              $em = $this->getDoctrine()->getManager();
              if ($form->isValid()) { //form is valid, save or preview
                  if ($form->get('submit')->isClicked()) { //save me
                      $em->persist($series);
                      $em->flush();
                      $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_create_series');
                      return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqId()]));
                  } else { //???
                      $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series');
                      return $this->redirect($this->generateUrl('oktolab_series'));
                  }
              }
              $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_create_series');
          }
  
          return ['form' => $form->createView()];
      }
code_tokens: public function newAction ( Request $ request ) { $ series = $ this -> get ( 'oktolab_media' ) -> createSeries ( ) ; $ form = $ this -> createForm ( SeriesType :: class , $ series ) ; $ form -> add ( 'submit' , SubmitType :: class , [ 'label' => 'oktolab_media.new_series_button' , 'attr' => [ 'class' => 'btn btn-primary' ] ] ) ; if ( $ request -> getMethod ( ) == "POST" ) { //sends form $ form -> handleRequest ( $ request ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( $ form -> isValid ( ) ) { //form is valid, save or preview if ( $ form -> get ( 'submit' ) -> isClicked ( ) ) { //save me $ em -> persist ( $ series ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'oktolab_media.success_create_series' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'oktolab_series_show' , [ 'series' => $ series -> getUniqId ( ) ] ) ) ; } else { //??? $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'oktolab_media.unknown_action_series' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'oktolab_series' ) ) ; } } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , 'oktolab_media.error_create_series' ) ; } return [ 'form' => $ form -> createView ( ) ] ; }
docstring: Displays a form to create a new Series entity.
  
  @Route("/new", name="oktolab_series_new")
  @Method({"GET", "POST"})
  @Template()
docstring_tokens: Displays a form to create a new Series entity .