This is my first Symfony 3 application.Please someone review my code. I do not want to make same mistakes, errors etc. in next project.I used fosuserbundle to handle login/register. User can add, edit and delete task. User can also set task as done and view list with all created tasks. Everybody can change language between pl and en.TodoController:<?phpnamespace AppBundle\Controller;use AppBundle\Entity\Todo;use AppBundle\Form\TodoType;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Bundle\FrameworkBundle\Controller\Controller;use Symfony\Component\HttpFoundation\RedirectResponse;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;class TodoController extends Controller{    /**     * @Route(/todo, name=todo_all)     *     * Method shows user's all created to-do tasks     *     * @param Request $request A Request instance     *     * @return Response A Response instance     */    public function allAction(Request $request): Response    {        $locale = $request->getLocale();        $userId = $this->getUser()->getId();        $em = $this->getDoctrine()->getManager();        $todos = $em->getRepository('AppBundle:Todo')                    ->findAllByUserIdWithLocalePriority($userId, $locale);        return $this->render('all.html.twig',[            'todos' => $todos        ]);    }    /**     * @Route(/todo/add, name=todo_add)     *     * @param Request $request A Request instance     *     * @return RedirectResponse|Response Redirect when task is succesfully added to database,     * rendering template when task is not subbmitted or not valid     */    public function addAction(Request $request)    {        $task = new Todo();        $task->setUserId($this->getUser()->getId());        $task->setDone(0);        $form = $this->createForm(TodoType::class, $task, ['locale' => $request->getLocale()]);        $form->handleRequest($request);        if ($form->isSubmitted() && $form->isValid()) {            $em = $this->getDoctrine()->getManager();            $priority = $em->getRepository('AppBundle:Priority')                        ->findOneByPriorityId($task->getPriority());            $task->setPriorityDatabase($priority);            $em->getRepository('AppBundle:Todo');            $em->persist($task);            $em->flush();            $this->addFlash('success', 'add.success');            return $this->redirectToRoute('todo_details', [                'id' => $task->getId()            ]);        }        return $this->render('add.html.twig', [            'title' => 'add.title.header',            'form' => $form->createView(),        ]);    }    /**     * @Route(/todo/details/{id}, name=todo_details)     *     * Method shows details about task     *     * @param int $id Task's Id     * @param Request $request A Request instance     *     * @throws NotFoundHttpException When task is not found in database     *     * @return Response A Response instance     */    public function detailsAction(int $id, Request $request): Response    {        $locale = $request->getLocale();        $userId = $this->getUser()->getId();        $em = $this->getDoctrine()->getManager();        $todo = $em->getRepository('AppBundle:Todo')                ->findByTodoIdAndUserId($id, $userId);        if (!$todo) {            throw $this->createNotFoundException('Task not Found');        }        $priority = $todo->getPriorityDatabase()->{'getPriority'.$locale}();        return $this->render('details.html.twig', [            'todo' => $todo,            'priority' => $priority        ]);    }    /**     * @Route(/todo/edit/{id}, name=todo_edit)     *     * Method to edit task if task exists and was created by current user     *     * @param int $id Task's Id     * @param Request $request A Request instance     *     * @return mixed Response instance or RedirectResponse instance     */    public function editAction(int $id, Request $request)    {        $userId = $this->getUser()->getId();        $em = $this->getDoctrine()->getManager();        $todo = $em->getRepository('AppBundle:Todo')                ->findByTodoIdAndUserId($id, $userId);        if (!$todo) {            $this->addFlash('success','all.notfound');            return $this->redirectToRoute('todo_all');        }        $form = $this->createForm(TodoType::class, $todo, ['locale' => $request->getLocale()]);        $form->handleRequest($request);        if ($form->isSubmitted() && $form->isValid()) {            $em->persist($todo);            $em->flush();            $this->addFlash('success', 'edit.success');            return $this->redirectToRoute('todo_details', [                'id' => $id            ]);        }        return $this->render('add.html.twig', [            'title' => 'add.title.edit',            'form' => $form->createView()        ]);    }    /**     * @Route(/todo/delete/{id}, name=todo_delete)     *     * Method delete task from database if task exists and was created by current user     *     * @param int $id Task's Id     *     * @return Response A Response instance     */    public function deleteAction(int $id): Response    {        $userId = $this->getUser()->getId();        $em = $this->getDoctrine()->getManager();        $toDelete = $em->getRepository('AppBundle:Todo')                   ->findByTodoIdAndUserId($id, $userId);        if ($toDelete) {            $em->remove($toDelete);            $em->flush();            $this->addFlash('success', 'delete.success');        } else {            $this->addFlash('warning', 'delete.warning');        }        return $this->render('delete.html.twig');    }    /**     * @Route(/todo/done/{id}, name=todo_done)     *     * Method sets task as done if task exists and was created by current user     *     * @param int $id Task's Id     *     * @return Response A Response instance     */    public function doneAction(int $id): Response    {        $userId = $this->getUser()->getId();        $em = $this->getDoctrine()->getManager();        $toDone = $em->getRepository('AppBundle:Todo')            ->findByTodoIdAndUserId($id, $userId);        if ($toDone) {            $toDone->setDone(1);            $em->persist($toDone);            $em->flush();            $this->addFlash('success', 'done.success');        } else {            $this->addFlash('warning', 'done.warning');        }        return $this->render('done.html.twig', [            'id' => $id        ]);    }}?>TodoRepository:    <?phpnamespace AppBundle\Repository;/** * TodoRepository * */class TodoRepository extends \Doctrine\ORM\EntityRepository{    /**     * Method to find every task created by user     *     * @param int $userId User's Id     * @param string $locale User's _locale     *     * @return array     */    public function findAllByUserIdWithLocalePriority(int $userId, string $locale): array    {        $tables = $this->findBy([ 'userId' => $userId ], [            'priority' => DESC,            'dueDate' => DESC        ]);        return $this->addPriorityToTodoTable($tables, $locale);    }    /**     * Method to find one task created by user     *     * @param int $id Task's Id     * @param int $userId User's Id     *     * @return null|object Return task if found it in database     */    public function findByTodoIdAndUserId(int $id, int $userId)    {        return $this->findOneBy([            'userId' => $userId,            'id' => $id,        ]);    }    /**     * Method to set priority name in user's _locale instead of priority id     *     * @param array $todos all user's tasks     * @param string $locale User's _locale     *     * @return array Array with all user's tasks with priority's name     */    private function addPriorityToTodoTable(array $todos, string $locale): array    {        foreach ($todos as $todo) {            $todo->setPriority($todo->getPriorityDatabase()->{'getPriority'.$locale}());        }        return $todos;    }}?>PriorityRepository:<?phpnamespace AppBundle\Repository;/** * PriorityRepository * */class PriorityRepository extends \Doctrine\ORM\EntityRepository{    /**     * Method returns array to form with all priority's in user's _locale     *     * @param string $locale user's _locale     *     * @return array Formatted array to ChoiceType     */    public function getPrioritysInUserLocaleToForm(string $locale): array    {        $priority = $this->findBy([], [                'priorityId' => 'ASC'        ]);        $return = [];        foreach ($priority as $value) {            $return[$value->{'getPriority'.$locale}()] = $value->getPriorityId();        }        return $return;    }    /**     * Method to find one object from priority table in database by id     *     * @param int $id Priority's Id in database     *     * @return null|object Return Priority object if find in database     */    public function findOneByPriorityId(int $id)    {        return $this->findOneBy([            'priorityId' => $id        ]);    }}?>TodoType:<?phpnamespace AppBundle\Form;use Doctrine\ORM\EntityManagerInterface;use Symfony\Component\Form\AbstractType;use Symfony\Component\Form\Extension\Core\Type as Type;use Symfony\Component\Form\FormBuilderInterface;use Symfony\Component\OptionsResolver\OptionsResolver;class TodoType extends AbstractType{    /**     * @var EntityManagerInterface     */    private $em;    /**     * TodoType constructor.     *     * @param EntityManagerInterface $em     */    public function __construct(EntityManagerInterface $em)    {        $this->em = $em;    }    /**     * @param FormBuilderInterface $builder     * @param array $options     */    public function buildForm(FormBuilderInterface $builder, array $options)    {        $builder            ->add('title', Type\TextType::class)            ->add('content', Type\TextareaType::class)            ->add('priority', Type\ChoiceType::class, [ 'choices' => $this->addChoicesInUserLocale($options['locale']) ])            ->add('dueDate', Type\DateTimeType::class, [                'widget' => 'single_text',                'attr' => ['class' => 'js-datepicker'],                'html5' => false,            ]);    }    /**     * Configure defaults options     *     * @param OptionsResolver $resolver     */    public function configureOptions( OptionsResolver $resolver )    {        $resolver->setDefaults( [            'locale' => 'en',        ] );    }    /**     * Method adds array with choices to ChoiceType in builder     *     * @param string $locale User's locale     *     * @return array All priority in user _locale formatted as array e.g. ['1' => 'low', ...]     */    private function addChoicesInUserLocale(string $locale): array    {        return $this->em->getRepository('AppBundle:Priority')                ->getPrioritysInUserLocaleToForm($locale);    }}?>
My first Symfony App - todo list
php;to do list;symfony3