Problem/Motivation
#2459819: Remove CacheableInterface (and no longer let block plugins implement it) introduced RendererInterface::addDependency(array $build, CacheableDependencyInterface $object
). That's great.
But many objects can optionally implement CacheableDependencyInterface
. Which means that in many cases, before calling ::addDependency()
, we need to check that the depended object actually does implement that interface. Which makes the DX atrocious. We absolutely need this DX to be super simple.
This is the case for field definition objects for example: some are config entities (and thus implement CacheableDependencyInterface
), others aren't (and thus don't). But the best example are access results: AccessResultInterface
is the only required interface, but most (though not all!) access result objects actually also implement CacheableDependencyInterface
. For the code to be correct, again, we currently need to do an if-test before calling ::addDependency()
. That's terrible.
Proposed resolution
Remove addDependency()
's typehint and do an instanceof CacheableDependencyInterface
instead.
Remaining tasks
None.
User interface changes
None.
API changes
API relaxation, no breaking API change.