1 | <?php |
||
35 | class EventController extends CRUDController |
||
36 | { |
||
37 | protected $entityName = 'KyelaBundle:Event'; |
||
38 | protected $cancelRoute = 'poll_show'; |
||
39 | protected $successRoute = 'poll_show'; |
||
40 | protected $deleteRoute = 'event_delete'; |
||
41 | protected $deleteSuccessRoute = 'poll_show'; |
||
42 | |||
43 | /** |
||
44 | * Displays poll events |
||
45 | * |
||
46 | * @Route("", methods="GET") |
||
47 | * @Template() |
||
48 | */ |
||
49 | public function showAction($isFuture) |
||
58 | |||
59 | /** |
||
60 | * Displays a form to create a new Event entity. |
||
61 | * |
||
62 | * @Route("/new", name="event_new", methods={"GET", "POST"}) |
||
63 | * @Template() |
||
64 | */ |
||
65 | public function newAction(Request $request) |
||
69 | |||
70 | /** |
||
71 | * Displays a form to edit an existing Event entity. |
||
72 | * |
||
73 | * @Route("/{id}/edit", name="event_edit", methods={"GET", "PUT"}) |
||
74 | * @Template() |
||
75 | */ |
||
76 | public function editAction(Request $request, $id) |
||
80 | |||
81 | /** |
||
82 | * Deletes a Event entity. |
||
83 | * |
||
84 | * @Route("/{id}", name="event_delete", methods="DELETE") |
||
85 | */ |
||
86 | public function deleteAction(Request $request, $id) |
||
90 | } |
||
91 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: