These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Controller; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Kunstmaan\AdminBundle\Entity\DashboardConfiguration; |
||
7 | use Kunstmaan\AdminBundle\FlashMessages\FlashTypes; |
||
8 | use Kunstmaan\AdminBundle\Form\DashboardConfigurationType; |
||
9 | use Symfony\Component\Routing\Annotation\Route; |
||
10 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
||
11 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||
12 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
13 | use Symfony\Component\HttpFoundation\Request; |
||
14 | |||
15 | /** |
||
16 | * The default controller is used to render the main screen the users see when they log in to the admin |
||
17 | */ |
||
18 | class DefaultController extends Controller |
||
19 | { |
||
20 | /** |
||
21 | * The index action will render the main screen the users see when they log in in to the admin |
||
22 | * |
||
23 | * @Route("/", name="KunstmaanAdminBundle_homepage") |
||
24 | * @Template("@KunstmaanAdmin/Default/index.html.twig") |
||
25 | * |
||
26 | * @return array |
||
0 ignored issues
–
show
|
|||
27 | */ |
||
28 | public function indexAction() |
||
29 | { |
||
30 | if ($this->container->hasParameter('kunstmaan_admin.dashboard_route')) { |
||
31 | return $this->redirect($this->generateUrl($this->getParameter('kunstmaan_admin.dashboard_route'))); |
||
32 | } |
||
33 | |||
34 | /* @var DashboardConfiguration $dashboardConfiguration */ |
||
35 | $dashboardConfiguration = $this->getDoctrine() |
||
36 | ->getManager() |
||
37 | ->getRepository('KunstmaanAdminBundle:DashboardConfiguration') |
||
38 | ->findOneBy(array()); |
||
39 | |||
40 | return array('dashboardConfiguration' => $dashboardConfiguration); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * The admin of the index page |
||
45 | * |
||
46 | * @Route("/adminindex", name="KunstmaanAdminBundle_homepage_admin") |
||
47 | * @Template("@KunstmaanAdmin/Default/editIndex.html.twig") |
||
48 | * |
||
49 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
50 | * |
||
51 | * @return array |
||
0 ignored issues
–
show
|
|||
52 | */ |
||
53 | public function editIndexAction(Request $request) |
||
54 | { |
||
55 | /* @var $em EntityManager */ |
||
56 | $em = $this->getDoctrine()->getManager(); |
||
57 | |||
58 | /* @var DashboardConfiguration $dashboardConfiguration */ |
||
59 | $dashboardConfiguration = $em |
||
60 | ->getRepository('KunstmaanAdminBundle:DashboardConfiguration') |
||
61 | ->findOneBy(array()); |
||
62 | |||
63 | if (is_null($dashboardConfiguration)) { |
||
64 | $dashboardConfiguration = new DashboardConfiguration(); |
||
65 | } |
||
66 | $form = $this->createForm(DashboardConfigurationType::class, $dashboardConfiguration); |
||
67 | |||
68 | if ($request->isMethod('POST')) { |
||
69 | $form->handleRequest($request); |
||
70 | if ($form->isSubmitted() && $form->isValid()) { |
||
71 | $em->persist($dashboardConfiguration); |
||
72 | $em->flush($dashboardConfiguration); |
||
73 | |||
74 | $this->addFlash( |
||
75 | FlashTypes::SUCCESS, |
||
76 | $this->get('translator')->trans('kuma_admin.edit.flash.success') |
||
77 | ); |
||
78 | |||
79 | return new RedirectResponse($this->generateUrl('KunstmaanAdminBundle_homepage')); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | return array( |
||
84 | 'form' => $form->createView(), |
||
85 | 'dashboardConfiguration' => $dashboardConfiguration, |
||
86 | ); |
||
87 | } |
||
88 | } |
||
89 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.