
    /**
{% block phpdoc_method_header %}
     * Creates a new {{ entity }} entity.
{% endblock phpdoc_method_header %}
     *
{% block phpdoc_method_annotations %}
{% if 'annotation' == format %}
     * @Route("/new", name="{{ route_name_prefix }}_new")
     * @Method({"GET", "POST"})
{% endif %}
{% endblock phpdoc_method_annotations %}
     */
{% block method_definition %}
    public function newAction(Request $request)
{% endblock method_definition %}
    {
{% block method_body %}
        ${{ entity_singularized }} = new {{ entity_class }}();
        $form = $this->createForm('{{ namespace }}\Form\{{ entity_class }}Type', ${{ entity_singularized }});
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist(${{ entity_singularized }});
            $em->flush();

            {% if 'show' in actions -%}
                return $this->redirectToRoute('{{ route_name_prefix }}_show', array('id' => ${{ entity_singularized }}->getId()));
            {%- else -%}
                return $this->redirectToRoute('{{ route_name_prefix }}_index'));
            {%- endif %}

        }
{% endblock method_body %}

{% block method_return %}
        return $this->render('{{ entity|lower|replace({'\\': '/'}) }}/new.html.twig', array(
            '{{ entity_singularized }}' => ${{ entity_singularized }},
            'form' => $form->createView(),
        ));
{% endblock method_return %}
    }
