Fix validation of required options
wouterj opened this issue · 4 comments
Some configuration settings are required, these get a ->isRequired()
call in the Config tree and the isset
function should be used in the CreateExtension.
Currently, when not configuring anything for the CreateBundle, the result is a PHP notice and a DI exception:
PHP Notice: Undefined index: model_class in Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony-cmf\cre
ate-bundle\Symfony\Cmf\Bundle\CreateBundle\DependencyInjection\CmfCreateExtension.php on line 118
PHP Stack trace:
PHP 1. {main}() Wouter\web\sf-world\cmf\symfony-standard\app\console:0
PHP 2. Symfony\Component\Console\Application->run() Wouter\web\sf-world\cmf\symfony-standard\app\console:27
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
PHP 4. Symfony\Component\HttpKernel\Kernel->boot() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:70
PHP 5. Symfony\Component\HttpKernel\Kernel->initializeContainer() Wouter\web\sf-world\cmf\symfony-standard\app\bootstrap.php.cache:2212
PHP 6. Symfony\Component\DependencyInjection\ContainerBuilder->compile() Wouter\web\sf-world\cmf\symfony-standard\app\bootstrap.php.cache:2433
PHP 7. Symfony\Component\DependencyInjection\Compiler\Compiler->compile() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBuilder.php:623
PHP 8. Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\Compiler.php:118
PHP 9. Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass.php:39
PHP 10. Symfony\Cmf\Bundle\CreateBundle\DependencyInjection\CmfCreateExtension->load() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass.php:50
PHP 11. Symfony\Cmf\Bundle\CreateBundle\DependencyInjection\CmfCreateExtension->loadPhpcr() Wouter\web\sf-world\cmf\symfony-standard\vendor\symfony-cmf\create-bundle\Symfony\Cmf\Bundle\CreateBundle\DependencyInjection\CmfCreateExtension.php:77
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "cmf_create.image.controller" has a dependency on a non-existent service "cmf_media.persistence.phpcr.manager".
hmm .. I cannot reproduce the issue. neither with 1.0.1 nor with master, even when I disable the prepending via the CoreBundle I do not get any such errors when I run app/console clear:cache
@lsmith77 how I can reproduce it:
- Clone https://github.com/symfony-cmf/symfony-standard/tree/start_se (don't forget to checkout the
start_se
branch) - Install the deps
- Run
app/console server:run
.
managed to reproduce the issue .. lets see ..
ok .. the issue is that CmfMediaBundle is missing then the model_class
isn't set. however as CoreBundle is enabled it sets the basepath
which in turn causes the image
setting to be auto-enabled.
so maybe the solution is the following:
diff --git a/DependencyInjection/CmfCoreExtension.php b/DependencyInjection/CmfCoreExtension.php
index 637e379..34ed3ef 100644
--- a/DependencyInjection/CmfCoreExtension.php
+++ b/DependencyInjection/CmfCoreExtension.php
@@ -91,6 +91,7 @@ class CmfCoreExtension extends Extension implements PrependExtensionInterface
// setting.
if (!isset($extensions['cmf_media'])) {
$prependConfig['persistence']['phpcr']['image'] = array(
+ 'enabled' => false,
'basepath' => $persistenceConfig['basepath'].'/media',
);
}
I think this should prevent the unwanted auto-enabling.