覆盖generator.yml

时间:2013-08-15 15:10:11

标签: php symfony admin-generator

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

Admin generator - 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: ~

1 个答案:

答案 0 :(得分:0)

我做到了!只有在app / config / config.yml中才需要附加:

admingenerator_generator:
    base_admin_template: ...
    use_doctrine_odm: true

->    overwrite_if_exists: true

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