2016-07-30 101 views
1

我尝试symfony3使用的CKEditor,我安装成功,但是当我试图使我们在我的形式在教程中所描述得到一个错误(https://symfony.com/doc/current/bundles/IvoryCKEditorBundle/index.html):使用的CKEditor在symfony3

$builder->add('content', CKEditorType::class); 

但产生这个错误:

Type error: Argument 1 passed to Ivory\CKEditorBundle\Form\Type\CKEditorType::__construct() must be an instance of Ivory\CKEditorBundle\Model\ConfigManagerInterface, none given

它看起来像,有一个问题,因为在其构造FormType不应要求参数,可以是我错了吗?

+0

这似乎是IvoryCKEditorBundle中的一个错误。 – felipsmartins

+0

@felipsmartins不是。 – mblaettermann

回答

1

我有同样的错误,并通过添加CKEditorBundle到AppKernel解决了这个问题。 这是在CountZero's答案的评论中陈述的。你可以找到IvoryCKEditorBundle安装说明here

class AppKernel extends Kernel 
{ 
    public function registerBundles() 
    { 
     $bundles = array(
      new Ivory\CKEditorBundle\IvoryCKEditorBundle(), 
      // ... 
     ); 

     // ... 
    } 
} 
1

IvoryCKEditorBundle中没有错误。如果你提供你的composer.json,命令bin/console debug:containerbin/console config IvoryCKEditorBundle的结果会帮助我给你更准确的答案。

it looks like, there is a problem because a FormType should not demand params in its constructor, am I wrong?

您错了,CKEditorType可能会在其构造函数中要求params,并且它在当前版本中会这样做。 文件有问题vendor/egeloen/ckeditor-bundle/Resources/config/form.xml 它应该为CKEditorBundle配置(提供)服务依赖关系,但事实并非如此。

我会尝试更新作曲家,清除缓存和调试服务容器配置对于这种捆绑,它应该是这样的:

⇒ composer update 
⇒ bin/console cache:clear 
⇒ bin/console debug:container|grep ivory  
    ivory_ck_editor.config_manager          Ivory\CKEditorBundle\Model\ConfigManager              
    ivory_ck_editor.form.type           Ivory\CKEditorBundle\Form\Type\CKEditorType             
    ivory_ck_editor.plugin_manager          Ivory\CKEditorBundle\Model\PluginManager              
    ivory_ck_editor.renderer            Ivory\CKEditorBundle\Renderer\CKEditorRenderer            
    ivory_ck_editor.styles_set_manager         Ivory\CKEditorBundle\Model\StylesSetManager             
    ivory_ck_editor.template_manager          Ivory\CKEditorBundle\Model\TemplateManager             
    ivory_ck_editor.twig_extension          Ivory\CKEditorBundle\Twig\CKEditorExtension 
+2

是的,对我来说,它看起来像OP已经忘记将CKEditorBundle包含到AppKernel里 – mblaettermann

+0

@mblaettermann你是对的!我再次检查了一遍,我没有忘记,但在另一个项目中改变了appkernel,doh。谢谢。顺便说一句,我喜欢这句话:“IvoryCKEditorBundle没有错误。” :) – Asara

+0

如果你们其中一个人作出回答(检查appkernel),我会将其标记为解决方案 – Asara