Injected objects into blocks via layout XMLs MUST implement CollectionDataSourceInterface
Question
\Magento\Framework\Data\CollectionDataSourceInterface
, to be more precise.
So imagine having this in - say - cms_index_index.xml
:
<block class="Some\Block" name="block" template="tpl.phtml">
<arguments>
<argument name="someObj" xsi:type="object">Some\Object</argument>
</arguments>
</block>
Block arguments of type object
are resolved via \Magento\Framework\View\Layout\Argument\Interpreter\DataObject, class which does a seemingly useless thing: it's checking if your passed object is of type \Magento\Framework\Data\CollectionDataSourceInterface
, throwing an exception if it's not.
Does anyone have the slightest clue as to why this validation is needed? The interface is - for now, at least - empty (marker interface).
Related post: http://magento-quickies.alanstorm.com/post/148712996610/a-typical-magento-2-programming-experience/embed
Solution
Reply posted here: https://github.com/magento/magento2/issues/1166#issuecomment-90084974:
Originally this type of argument was developed for Admin Widget Grids to allow passing Collections as an argument to Grid constructor and it had being restricted to "Magento\Framework\Data\Collection". After a while instead of that there was created an empty marking interface, so now you may pass some custom types of collections with more soft restriction - they all should implement this very CollectionDataSourceInterface.
It's been moved in forums. It's the same as deleting it. So.. yeah, I guess that's it then.