Error in Symfony2 project cache:clear warmUp without symfony-cmf/media-bundle
wcluijt opened this issue · 3 comments
When attempting to use the symfony-cmf/block-bundle standalone in a Symfony2 project with the following configuration:
cmf_block:
persistence:
phpcr:
enabled: true
use_sonata_admin: false
content_basepath: /
use_imagine: false
When the symfony-cmf/media-bundle package is not included in the Symfony2 project composer.json, the following error is displayed when executing the php app/console cache:clear
command:
[Doctrine\Common\Proxy\Exception\UnexpectedValueException]
The type hint of parameter "image" in method "setImage" in class "Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ImagineBlock" is invalid.
[ReflectionException]
Class Symfony\Cmf\Bundle\MediaBundle\ImageInterface does not exist
The CmfBlockBundle build() method will trigger a compiler pass call to DoctrinePhpcrMappingsPass::createXmlMappingDriver() which will load the XML files in the Resources/config/doctrine-phpcr/ directory, which includes the ImagineBlock.phpcr.xml file.
The cache:clear
will eventually trigger the Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer warmUp() method which wants to generate proxy classes for loaded classes (including the one from ImagineBlock.phpcr.xml), eventually calling Doctrine\Common\Proxy\ProxyGenerator generateMethods() where the error above is thrown.
Of course, when the symfony-cmf/media-bundle package is included in the Symfony2 project composer.json, the error is gone.
Should the symfony-cmf/media-bundle package be required in this bundle's composer.json?