SonataMediaBundle和PHPCR,Document未正确保存?

时间:2017-03-09 20:44:28

标签: php symfony sonata-admin sonata-media-bundle doctrine-phpcr

尝试上传图片后,收到以下错误消息:

An exception has been thrown during the rendering of a template ("Unable to retrieve the download security : ").

在“create”之后,在以下URI处发生此错误:

/web/app_dev.php/en/admin/sonata/media/media/cms/media/58c1be25e1d27/edit?context=default&hide_context=0

图片上传,文字等等,但我不认为文档已正确保存到数据库中。

以下是我的配置:

“sonata-project / media-bundle”:“^ 3.5”,

“doctrine / phpcr-odm”:“^ 1.4”,

“sonata-project / doctrine-phpcr-admin-bundle”:“^ @ 2.0@dev”,

config.yml

sonata_media:
    # if you don't use default namespace configuration
    class:
        media: Application\Sonata\MediaBundle\PHPCR\Media
        gallery: Application\Sonata\MediaBundle\PHPCR\Gallery
        gallery_has_media: Application\Sonata\MediaBundle\PHPCR\alleryHasMedia
    db_driver: doctrine_phpcr # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
    default_context: default # you need to set a context
    contexts:
        default:  # the default context is mandatory
            providers:
                - sonata.media.provider.dailymotion
                - sonata.media.provider.youtube
                - sonata.media.provider.image
                - sonata.media.provider.file
                - sonata.media.provider.vimeo

            formats:
                small: { width: 100 , quality: 70}
                big:   { width: 500 , quality: 70}

    cdn:
        server:
            path: /uploads/media # http://media.sonata-project.org/

    filesystem:
        local:
            directory:  "%kernel.root_dir%/../web/uploads/media"
            create:     false


doctrine_phpcr:
    # configure the PHPCR session
    session:
        backend:   '%phpcr_backend%'
        workspace: '%phpcr_workspace%'
        username:  '%phpcr_user%'
        password:  '%phpcr_pass%'
    odm:
        auto_mapping: true
        auto_generate_proxy_classes: '%kernel.debug%'
        locales:
            en: [de, fr]
            de: [en, fr]
            fr: [en, de]
        mappings:
            #SonataMediaBundle:
            #    prefix: Sonata\MediaBundle\PHPCR
            ApplicationSonataMediaBundle:
                prefix: Application\Sonata\MediaBundle\PHPCR

Initalizer

app.phpcr.initializer:
    class: Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer
    arguments:
        - SonataMediaBundle
        - ["/cms/media"]
    tags:
        - { name: doctrine_phpcr.initializer }

我正在使用默认的自动生成的PHPCR文档&配置。

1 个答案:

答案 0 :(得分:1)

我有同样的问题,但我使用的是Doctrine而不是PHPCR。

在我的情况下,我在管理

中以上传形式选择了错误的媒体上下文

如果您选择了错误的(不存在的)上下文,则该文件似乎不可编辑。

->add('media', 'sonata_type_model_list', array('required' => false), array(
                        'link_parameters' => array(
                            'context'  => 'Context name', // Important: You have to select the context name and not the context code!
                            'filter'   => array('category' => array('value' => 'Dummy category name')),
                            'provider' => 'sonata.media.provider.file',
                        )
                    ))