1 | <?php |
||
21 | class ThumbnailAspect |
||
22 | { |
||
23 | /** |
||
24 | * @var LoggerInterface |
||
25 | * @Flow\Inject |
||
26 | */ |
||
27 | protected $systemLogger; |
||
28 | |||
29 | /** |
||
30 | * @Flow\Inject |
||
31 | * @var PackageManager |
||
32 | */ |
||
33 | protected $packageManager; |
||
34 | |||
35 | /** |
||
36 | * @Flow\Inject |
||
37 | * @var ResourceManager |
||
38 | */ |
||
39 | protected $resourceManager; |
||
40 | |||
41 | /** |
||
42 | * @Flow\Inject |
||
43 | * @var CompilingEvaluator |
||
44 | */ |
||
45 | protected $eelEvaluator; |
||
46 | |||
47 | /** |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $settings; |
||
51 | |||
52 | /** |
||
53 | * @param array $settings |
||
54 | * @return void |
||
55 | */ |
||
56 | public function injectSettings(array $settings) |
||
60 | |||
61 | /** |
||
62 | * After a thumbnail has been refreshed the resource is optimized, meaning the |
||
63 | * image is only optimized once when created. |
||
64 | * |
||
65 | * A new resource is generated for every thumbnail, meaning the original is |
||
66 | * never touched. |
||
67 | * |
||
68 | * Only local file system target is supported to keep it from being blocking. |
||
69 | * It would however be possible to create a local copy of the resource, |
||
70 | * process it, import it and set that as the thumbnail resource. |
||
71 | * |
||
72 | * @Flow\AfterReturning("method(Neos\Media\Domain\Model\Thumbnail->refresh())") |
||
73 | * @param JoinPointInterface $joinPoint The current join point |
||
74 | * @return void |
||
75 | * @throws Exception |
||
76 | * @throws UnknownPackageException |
||
77 | */ |
||
78 | public function optimizeThumbnail(JoinPointInterface $joinPoint) |
||
124 | } |
||
125 |
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: