symfony-cmf/block-bundle

missing function

featureless opened this issue · 3 comments

The 'exists' function is missing in the PhpcrBlockLoader class to use sonata_block_exists in twig template

dbu commented

then that function is not defined by the Sonata\BlockBundle\Block\BlockLoaderInterface interface? is there an additional interface to implement? or does sonata check with a method_exists? or just hope a method happens to be there even though the interface does not require it?

either way, if you want to do a pull request to do the necessary changes, i am happy to review and merge that.

When I use 'sonata_block_exists' in twig template I have this error:

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedMethodException: "Attempted to call an undefined method named "exists" of class "Symfony\Cmf\Bundle\BlockBundle\Block\PhpcrBlockLoader"." at C:\projets\vendor\sonata-project\block-bundle\Block\BlockLoaderChain.php line 41 {"exception":"[object] (Symfony\Component\Debug\Exception\UndefinedMethodException(code: 0): Attempted to call an undefined method named "exists" of class "Symfony\Cmf\Bundle\BlockBundle\Block\PhpcrBlockLoader". at C:\projets\vendor\sonata-project\block-bundle\Block\BlockLoaderChain.php:41)"} []

dbu commented

seems like sonata_block_exists does not check the interfaces well, it should check if that method exists. as said, i am happy to review a pull request if you want to add the exists method and figure out how that method is supposed to be defined, if we should implement an interface.