dty63504 2015-11-06 17:25
浏览 57
已采纳

无法识别Symfony CMF Media Bundle表单类型 - 无法加载“cmf_media_image”类型

I've been following the CMF Media bundle installation, after wading through all the composer conflicts and such I now can't load a simple form with an image widget.

Gives Could not load type "cmf_media_image"

If I run php app/console container:debug --tag=form.type it does not appear in the list of form types.

Relevant code:

Config.yml

[...]
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form:
        resources:
            - 'bootstrap_3_layout.html.twig'
            - 'CmfMediaBundle:Form:fields.html.twig'

cmf_media:
    persistence:
        phpcr:
            enabled:         false

liip_imagine:
    filter_sets:
        # default filter to be used with the image preview
        image_upload_thumbnail:
            data_loader: cmf_media_doctrine_phpcr
            quality: 85
            filters:
                thumbnail: { size: [100, 100], mode: outbound }
doctrine_phpcr:
    session:
        backend:
            type: doctrinedbal
            # connection: default
        workspace: default
        username: admin
        password: admin
    odm:
        auto_mapping: true
        auto_generate_proxy_classes: "%kernel.debug%"

autoload.php

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');

composer.json

"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.7.*",
    "doctrine/dbal": "*",
    "doctrine/doctrine-bundle": "*",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~4.0",
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "components/jquery": "^2.1",
    "components/font-awesome": "^4.4",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "avanzu/admin-theme-bundle": "^1.3",
    "egeloen/ckeditor-bundle": "^3.0",
    "symfony-cmf/media-bundle": "^1.2",
    "doctrine/orm": "^2.5",
    "jackalope/jackalope-doctrine-dbal": "1.2.*",
    "jackalope/jackalope": "1.2.*",
    "liip/imagine-bundle": "^1.3",
    "doctrine/phpcr-bundle": "1.*",
    "doctrine/phpcr-odm": "1.2.*"
},
"require-dev": {
    "sensio/generator-bundle": "~2.3"
},

app/AppKernel.php

public function registerBundles()
    {
        $bundles = array(
            [...]
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
            new Liip\ImagineBundle\LiipImagineBundle(),
            new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
            new Symfony\Cmf\Bundle\MediaBundle\CmfMediaBundle(),
       );
[...]

Output of php app/console container:debug --tag=form.type

container] Public services with tag form.type
 Service ID                               alias                          Class name
 doctrine_phpcr.odm.form.type.path        phpcr_odm_path                 Doctrine\Bundle\PHPCRBundle\Form\Type\PathType
 form.type.birthday                       birthday                       Symfony\Component\Form\Extension\Core\Type\BirthdayType
 form.type.button                         button                         Symfony\Component\Form\Extension\Core\Type\ButtonType
 form.type.checkbox                       checkbox                       Symfony\Component\Form\Extension\Core\Type\CheckboxType
 form.type.choice                         choice                         Symfony\Component\Form\Extension\Core\Type\ChoiceType
 form.type.collection                     collection                     Symfony\Component\Form\Extension\Core\Type\CollectionType
 form.type.country                        country                        Symfony\Component\Form\Extension\Core\Type\CountryType
 form.type.currency                       currency                       Symfony\Component\Form\Extension\Core\Type\CurrencyType
 form.type.date                           date                           Symfony\Component\Form\Extension\Core\Type\DateType
 form.type.datetime                       datetime                       Symfony\Component\Form\Extension\Core\Type\DateTimeType
 form.type.email                          email                          Symfony\Component\Form\Extension\Core\Type\EmailType
 form.type.entity                         entity                         Symfony\Bridge\Doctrine\Form\Type\EntityType
 form.type.file                           file                           Symfony\Component\Form\Extension\Core\Type\FileType
 form.type.form                           form                           Symfony\Component\Form\Extension\Core\Type\FormType
 form.type.hidden                         hidden                         Symfony\Component\Form\Extension\Core\Type\HiddenType
 form.type.integer                        integer                        Symfony\Component\Form\Extension\Core\Type\IntegerType
 form.type.language                       language                       Symfony\Component\Form\Extension\Core\Type\LanguageType
 form.type.locale                         locale                         Symfony\Component\Form\Extension\Core\Type\LocaleType
 form.type.money                          money                          Symfony\Component\Form\Extension\Core\Type\MoneyType
 form.type.number                         number                         Symfony\Component\Form\Extension\Core\Type\NumberType
 form.type.password                       password                       Symfony\Component\Form\Extension\Core\Type\PasswordType
 form.type.percent                        percent                        Symfony\Component\Form\Extension\Core\Type\PercentType
 form.type.phpcr.document                 phpcr_document                 Doctrine\Bundle\PHPCRBundle\Form\Type\DocumentType
 form.type.phpcr.reference                phpcr_reference                Doctrine\Bundle\PHPCRBundle\Form\Type\PHPCRReferenceType
 form.type.phpcr_odm.reference_collection phpcr_odm_reference_collection Doctrine\Bundle\PHPCRBundle\Form\Type\PHPCRODMReferenceCollectionType
 form.type.radio                          radio                          Symfony\Component\Form\Extension\Core\Type\RadioType
 form.type.repeated                       repeated                       Symfony\Component\Form\Extension\Core\Type\RepeatedType
 form.type.reset                          reset                          Symfony\Component\Form\Extension\Core\Type\ResetType
 form.type.search                         search                         Symfony\Component\Form\Extension\Core\Type\SearchType
 form.type.submit                         submit                         Symfony\Component\Form\Extension\Core\Type\SubmitType
 form.type.text                           text                           Symfony\Component\Form\Extension\Core\Type\TextType
 form.type.textarea                       textarea                       Symfony\Component\Form\Extension\Core\Type\TextareaType
 form.type.time                           time                           Symfony\Component\Form\Extension\Core\Type\TimeType
 form.type.timezone                       timezone                       Symfony\Component\Form\Extension\Core\Type\TimezoneType
 form.type.url                            url                            Symfony\Component\Form\Extension\Core\Type\UrlType
 ivory_ck_editor.form.type                ckeditor                       Ivory\CKEditorBundle\Form\Type\CKEditorType
 liip_imagine.form.type.image             liip_imagine_image             Liip\ImagineBundle\Form\Type\ImageType

I've just double checked that the file is in the bundle, it is vendor/symfony-cmf/media-bundle/Resources/views/Form/fields.html.twig

Any help is seriously appreciated.

  • 写回答

1条回答 默认 最新

  • doutang7414 2015-11-07 22:37
    关注

    Unfortunately, the cmf_media_image (and the other CmfMediaBundle form types) is only available with the phpcr storage. Your configuration has phpcr storage disabled. If you wanted to use phpcr, enable it. Otherwise you could have a look how to make the storage interfaces work with the storage system of your choice and contribute that code to the bundle. It would be highly appreciated.

    The documentation on the form types http://symfony.com/doc/current/cmf/bundles/media/form_types.html unfortunately does not point this out. I will add a note in that regard.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python