1 | <?php |
||
26 | final class TenantAwareArticleSerializationSubscriber implements EventSubscriberInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var TenantContextInterface |
||
30 | */ |
||
31 | private $tenantContext; |
||
32 | |||
33 | /** |
||
34 | * @var TenantRepositoryInterface |
||
35 | */ |
||
36 | private $tenantRepository; |
||
37 | |||
38 | /** |
||
39 | * @var TenantInterface |
||
40 | */ |
||
41 | private $originalTenant; |
||
42 | |||
43 | /** |
||
44 | * TenantAwareArticleSerializationSubscriber constructor. |
||
45 | * |
||
46 | * @param TenantContextInterface $tenantContext |
||
47 | */ |
||
48 | public function __construct(TenantContextInterface $tenantContext, TenantRepositoryInterface $tenantRepository) |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public static function getSubscribedEvents() |
||
72 | |||
73 | /** |
||
74 | * @param ObjectEvent $event |
||
75 | */ |
||
76 | public function onPreSerialize(ObjectEvent $event) |
||
85 | |||
86 | /** |
||
87 | * @param ObjectEvent $event |
||
88 | */ |
||
89 | public function onPostSerialize(ObjectEvent $event) |
||
95 | } |
||
96 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: