【问题标题】:Overwrite generator.yml覆盖 generator.yml
【发布时间】:2013-08-15 15:10:11
【问题描述】:

我需要覆盖供应商捆绑包中的 generator.yml 文件。覆盖捆绑包是好的,也覆盖文档(odm)。如何正确覆盖generator.yml?我需要在现有包中添加两个字段。帮帮我……

管理员生成器 - Cedric Lambardot

我有原始的 generator.yml:

generator: admingenerator.generator.doctrine_odm
params:
  model: Acme\ProductBundle\Document\Product
  namespace_prefix: Acme
  bundle_name: ProductBundle
  i18n_catalog: AcmeProductBundle
  object_actions:
        delete: ~
  fields:
    name:
      label: product.name

    model:
      label: model

    #...

builders:
  list:
    params:
      title: product.list
      display: [ name,  model,  ]
      actions:
        new: ~
      object_actions:
        edit: ~
        delete: ~
  filters:
    params:
      display: [ name, model, ...]
  new:
    params:
      title: product.new
      tabs:
        'data':           
          'data': [ name,  model, ... ]
        'images':  
          'images': [ ... ]
        'seo':
          'seo': [ ... ]
        'parameter.plural':
          'parameter.plural': [ ... ]
      actions:
        list: ~
        save: ~
        save-and-list: ~
  edit:
    params:
      title: "\"{{ Product.name }}\""
      tabs:
        'data':           
          'data': [ name,  model, ... ]
        'images':  
          'images': [ ... ]
        'seo':
          'seo': [ ... ]
        'parameter.plural':
          'parameter.plural': [ ... ]
        'suiteCompose':
          'suiteCompose': [ ... ]
      actions:
        list: ~
        save: ~
        save-and-list: ~
  actions:
      params:
        object_actions:
            delete: ~

在覆盖的 Bundle 中创建相同的文件,向他指出一个新文档并添加两个字段。但是所有相同的包都是由旧的 generator.yml 生成的

generator: admingenerator.generator.doctrine_odm
params:
  model: Acme\AnniProductBundle\Document\Product
  namespace_prefix: Acme
  bundle_name: ProductBundle
  i18n_catalog: AcmeProductBundle
  object_actions:
        delete: ~
  fields:
    name:
      label: product.name

    model:
      label: model

    #...

builders:
  list:
    params:
      title: product.list
      display: [ name,  model,  ]
      actions:
        new: ~
      object_actions:
        edit: ~
        delete: ~
  filters:
    params:
      display: [ name, model, ...]
  new:
    params:
      title: product.new
      tabs:
        'data':           
          'data': [ name,  model, ... ]
        'images':  
          'images': [ ... ]
        'seo':
          'seo': [ ... ]
        'parameter.plural':
          'parameter.plural': [ ... ]
      actions:
        list: ~
        save: ~
        save-and-list: ~
  edit:
    params:
      title: "\"{{ Product.name }}\""
      tabs:
        'data':           
          'data': [ name,  model, ... ]
        'images':  
          'images': [ ... ]
        'seo':
          'seo': [ ... ]
        'parameter.plural':
          'parameter.plural': [ ... ]
        'suiteCompose':
          'suiteCompose': [ ... ]
      actions:
        list: ~
        save: ~
        save-and-list: ~
  actions:
      params:
        object_actions:
            delete: ~

【问题讨论】:

  • 你试过什么? (whathaveyoutried.com) 有没有一个小例子可以说明你的问题?就目前而言,这个问题非常模糊。
  • 我需要在我的文档中添加两个字段,并在列表、编辑和新表单中显示他

标签: php symfony admin-generator


【解决方案1】:

我做到了!仅在 app/config/config.yml append 中是必需的:

admingenerator_generator:
    base_admin_template: ...
    use_doctrine_odm: true

->    overwrite_if_exists: true

    stylesheets: []
    templates_dirs: [ ... ]
    twig:
        ...

【讨论】:

    猜你喜欢
    • 2011-06-11
    • 2012-01-28
    • 2011-05-29
    • 1970-01-01
    • 2012-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    相关资源
    最近更新 更多