Skip to content

New API - changes in generator.yml structure #75

Open
@ioleo

Description

@ioleo

Useing Symfony2 Config Component

I plan to implement useing symfony2 config compoment to validate generator YAML files. This is also a great opportunity to improve our API (and for obvious reasons, we can only do that now, before v2.0-stable).

New API - what needs improvement?

I'd like to start a discussion about the pros and cons of current API. Each of us used Admingenerator for diffrent projects and faced diffrent problems. I'd like to hear your thoughts. To ignite the discussion, I'll throw in a bunch of thoughts.

In my projects I had multiple custom object actions. To not repeat myself and share the configuration between builders, I had them defined in the global params section.

However, there was no easy way to overwrite/customize the list per builder. Eg. if I had:

params:
  object_actions:
    custom1: ~
    custom2: ~
    edit: ~
    show: ~
    delete: ~

But on Show builder, I'd like to display all of them... except show (for obvious reasons). By the same argument, on edit builder, I want to remove the edit action. On Action builder I wanted only custom1 and custom2 (without the default actions edit/show/delete).

Also, in some cases I wanted to simply change the order. Eg. in Show builder: custom2, custom1, while in Edit builder custom1, custom2.

Note: later on, we've implemented a very hacky trick, that if you set your field to null, it will read the global config.. and merge it... why hacky? Well, have a look at that code and tell me it's easy to read :)

Another example - to allow translateing messages from generator files, we've introduced the parameter bag feature, which provides a structured syntax that (if detected) will output a call to translator service with the correct parameters.

However, over time I feel like generator files are "pandora boxes" where you do everything:

  • configure basic parameters (like generator used, translation domain, namespace or model)
  • configure fields
  • configure forms
  • add (and translate) labels, help blocks, and other messages
  • configure actions
  • configure filters

This is OK for a VERY SIMPLE project. But as soon as your project grows in size or complexity, you end up with huge generator files, which are almost unreadable.

I'd like to change that. I'd like to move some things out of the generator file. I think the "generator" file should be only for basic configuration (to generate a "stub") and all those details (like form configuration) should live in seperate PHP classes.

So... the "ideal" generator for me, would only contain some basic parameters, and "switches" that turn on/off certain features. Eg. say you want to generate ONLY the show builder.

This could also improve the cache generation time - if a feature was disabled, certaint blocks of code would be skipped.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions