1. <small id='TRR5h'></small><noframes id='TRR5h'>

      <i id='TRR5h'><tr id='TRR5h'><dt id='TRR5h'><q id='TRR5h'><span id='TRR5h'><b id='TRR5h'><form id='TRR5h'><ins id='TRR5h'></ins><ul id='TRR5h'></ul><sub id='TRR5h'></sub></form><legend id='TRR5h'></legend><bdo id='TRR5h'><pre id='TRR5h'><center id='TRR5h'></center></pre></bdo></b><th id='TRR5h'></th></span></q></dt></tr></i><div id='TRR5h'><tfoot id='TRR5h'></tfoot><dl id='TRR5h'><fieldset id='TRR5h'></fieldset></dl></div>
    1. <legend id='TRR5h'><style id='TRR5h'><dir id='TRR5h'><q id='TRR5h'></q></dir></style></legend>
        <bdo id='TRR5h'></bdo><ul id='TRR5h'></ul>
    2. <tfoot id='TRR5h'></tfoot>

    3. 如何在 yml 映射的实体中配置 VichUploader?

      时间:2024-08-15
    4. <i id='2itBV'><tr id='2itBV'><dt id='2itBV'><q id='2itBV'><span id='2itBV'><b id='2itBV'><form id='2itBV'><ins id='2itBV'></ins><ul id='2itBV'></ul><sub id='2itBV'></sub></form><legend id='2itBV'></legend><bdo id='2itBV'><pre id='2itBV'><center id='2itBV'></center></pre></bdo></b><th id='2itBV'></th></span></q></dt></tr></i><div id='2itBV'><tfoot id='2itBV'></tfoot><dl id='2itBV'><fieldset id='2itBV'></fieldset></dl></div>

        <small id='2itBV'></small><noframes id='2itBV'>

        • <bdo id='2itBV'></bdo><ul id='2itBV'></ul>

          <tfoot id='2itBV'></tfoot><legend id='2itBV'><style id='2itBV'><dir id='2itBV'><q id='2itBV'></q></dir></style></legend>

                  <tbody id='2itBV'></tbody>

                本文介绍了如何在 yml 映射的实体中配置 VichUploader?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个名为杂志"的实体,从 yml 文件映射:

                I have a entity called 'Magazine', mapped from yml file:

                AcmeDemoBundleEntityMagazine:
                  type: entity
                  table: magazine
                  id:
                    id:
                      type: integer
                      generator: { strategy: AUTO }
                
                  fields:
                    edition:
                        type: string
                        length: 255
                        nullable: false
                    title:
                        type: text
                        nullable: false
                    cover:
                        type: string
                        length: 255
                        nullable: false
                    file:
                        mapping: magazine_cover
                        filename_property: cover
                

                我在 app/config/config.yml 中做了必要的配置:

                I made the configuration necessary in the app/config/config.yml:

                knp_gaufrette:
                  stream_wrapper: ~
                
                vich_uploader:
                  db_driver: orm
                  mappings:
                    magazine_cover:
                      uri_prefix:         /upload/magazine/cover
                      upload_destination: %kernel.root_dir%/../web/upload/magazine/cover
                      delete_on_remove:   true
                

                实体文件:

                use DoctrineORMMapping as ORM;
                
                use SymfonyComponentHttpFoundationFileFile;
                use SymfonyComponentValidatorConstraints as Assert;
                use VichUploaderBundleMappingPropertyMapping as Vich;
                

                我没有以这种方式工作,在杂志"表中创建了一个字段文件",这不应该发生.我发现一些文章解释了如何使用注释进行配置,但 yml 我什么也没找到.

                I'm not getting work this way, a field 'file' is created in the 'magazine' table, which doesnt should happens. I've found some articles explaining how configure using annotation but yml I don't found nothing.

                推荐答案

                如果您阅读 文档仔细,你会注意到上传相关的配置并没有与学说的实体声明混合.

                If you read the documentation carefully, you'll notice that the upload-related configuration isn't mixed with doctrine's entity declaration.

                您需要创建一个 src/Acme/DemoBundle/Resource/config/vich_uploader/Magazine.yml 文件,内容如下:

                You need to create a src/Acme/DemoBundle/Resource/config/vich_uploader/Magazine.yml file with the following content:

                AcmeDemoBundleEntityMagazine:
                    file:
                        mapping: magazine_cover
                        filename_property: cover
                

                您将在我的 沙盒应用程序中找到工作代码示例.

                这篇关于如何在 yml 映射的实体中配置 VichUploader?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:symfony 2.3 中与学说的多重联系 下一篇:如何在 Doctrine 中设置默认水合器?

                相关文章

                  • <bdo id='w6JH2'></bdo><ul id='w6JH2'></ul>

                1. <legend id='w6JH2'><style id='w6JH2'><dir id='w6JH2'><q id='w6JH2'></q></dir></style></legend>
                2. <small id='w6JH2'></small><noframes id='w6JH2'>

                  <tfoot id='w6JH2'></tfoot>

                  1. <i id='w6JH2'><tr id='w6JH2'><dt id='w6JH2'><q id='w6JH2'><span id='w6JH2'><b id='w6JH2'><form id='w6JH2'><ins id='w6JH2'></ins><ul id='w6JH2'></ul><sub id='w6JH2'></sub></form><legend id='w6JH2'></legend><bdo id='w6JH2'><pre id='w6JH2'><center id='w6JH2'></center></pre></bdo></b><th id='w6JH2'></th></span></q></dt></tr></i><div id='w6JH2'><tfoot id='w6JH2'></tfoot><dl id='w6JH2'><fieldset id='w6JH2'></fieldset></dl></div>