Guest User

Untitled

a guest
Sep 5th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. // Powiedzmy, ze masz takie cos (kopia z twojego kodu)
  4.  
  5.  
  6. if ($this->redirect) {
  7.    $this->response = $this->redirect;
  8. } elseif (is_null($this->response)) {
  9.     $this->response = $this->render('matrix/swot.html.twig', [
  10.         'form' => $this->form->createView(),
  11.         'matrixview' => $this->matrix->getView(),
  12.         'page' => $this->getDoctrine()->getManager()->getRepository(Page::class)->findOneByRoute($request->get('_route')),
  13.     ]);
  14. }
  15.  
  16. return $this->response;
  17.  
  18.  
  19. // Mozesz to zapisac inaczej
  20. // Zero zmian funkcjonalnych, kod bedzie dzialal identycznie.
  21.  
  22. if ($this->redirect) {
  23.     return $this->redirect;
  24. }
  25.  
  26. return $this->render('matrix/swot.html.twig', [
  27.         'form' => $this->form->createView(),
  28.         'matrixview' => $this->matrix->getView(),
  29.         'page' => $this->getDoctrine()->getManager()->getRepository(Page::class)->findOneByRoute($request->get('_route')),
  30.     ]);
  31.  
  32. // Od razu czyta sie przyjemniej imho
  33.  
  34. // Mozna nawet
  35.  
  36. return !$this->redirect ?
  37.     $this->render('matrix/swot.html.twig', [
  38.         'form' => $this->form->createView(),
  39.         'matrixview' => $this->matrix->getView(),
  40.         'page' => $this->getDoctrine()->getManager()->getRepository(Page::class)->findOneByRoute($request->get('_route')),
  41.     ]) : $this->redirect;
Advertisement
Add Comment
Please, Sign In to add comment