1 | <?php |
||
13 | class InstitutionRequests extends AbstractTable |
||
14 | { |
||
15 | |||
16 | protected $config = array( |
||
17 | 'name' => 'Institution Requests', |
||
18 | 'showPagination' => true, |
||
19 | 'showQuickSearch' => false, |
||
20 | 'showItemPerPage' => true, |
||
21 | 'itemCountPerPage' => 10, |
||
22 | 'showColumnFilters' => true, |
||
23 | ); |
||
24 | |||
25 | |||
26 | /** |
||
27 | * @var array Definition of headers |
||
28 | */ |
||
29 | protected $headers = array( |
||
30 | 'address' => array('title' => 'Address' , 'filters' => 'text'),// from institution table |
||
31 | 'name' => array('title' => 'Name') ,// from user table |
||
32 | |||
33 | ); |
||
34 | |||
35 | public function init() |
||
39 | |||
40 | protected function initFilters($query) |
||
46 | } |
||
47 |
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: