Thanks to visit codestin.com
Credit goes to github.com

Skip to content

YAML file configuration and Command to generate YML from an entity - #449

Merged
Abhoryo merged 27 commits into
APY:masterfrom
acseo:master
May 10, 2015
Merged

YAML file configuration and Command to generate YML from an entity#449
Abhoryo merged 27 commits into
APY:masterfrom
acseo:master

Conversation

@npotier

@npotier npotier commented Aug 8, 2013

Copy link
Copy Markdown
Collaborator

Hi,

After few talks about it, here is a pull request to add yml file configuration and a command to generate theses file from an entity.

YML file configuration

  • Like doctrine, YML file configuration for an entity must be placed in a special directory and have a special name MyBundle/Resources/config/grid/MyEntity.myGroup.grid.yml
  • The YML file structure is the following:
# Resources/config/grid/MyEntity.myGroup.grid.yml
namespace\of\MyEntity
    Source:
        columns: 
            id: ~
            myColumn1: ~
        groupBy: ~
        filterable: ~
    Columns:
        id:
            filterable: true
            visible: true
            id: id
            title: columnTitle
        myColumn1: ....
    ...
  • Annotation and YML Driver are both loaded in services.xml

YML Generation command

  • The command will allow you to generate a YML config file for an entity and a group:
php app/console apydatagrid:generate:grid --entity="MyBundle:MyEntity" --group="default"
  • The file will be generated and written in src/MyBundle/Resources/config/grid/MyEntity.default.grid.yml.
  • The generation of the file is based on a skeleton template stored in APYDataGrid/Resourses/skeleton/grid/grid.yml.twig.

Feel free to make any comments on this PR !

npotier added 7 commits August 7, 2013 09:43
Possibilité d'utiliser un fichier yml à la place des annotations.
Pour l'instant, le fichier MyEntity.grid.yml est recherché dans le même répertoire que MyEntity.php

Le fichier MyEntity.yml a cette structure :

Namespace\of\MyEntity:
    Source:
        columns:
            id :
                groups : [group1, group2]
            myColumn: ~
    Columns:
        id:
            filterable: true
            visible: true
            id: id
            title: MonId
        myColumn:
            id : idColumn
            title : title
            filterable: true
            visible: true

TODO :
- Trouver une stratégie pour déterminer l'emplacement du fichier yml associé à l'entité
- Valider le format du fichier YML en amont (utilisation de TreeBuilder ?)
- Ecrire des tests
Fait cohabiter les Drivers Annotation et YAML
Comment thread Command/GenerateGridCommand.php Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est une option.

@Abhoryo

Abhoryo commented Aug 8, 2013

Copy link
Copy Markdown
Member

Ça m'a l'air top. Vous êtes bien motivés.
Au final la version xml ne devrait pas être trop longue à faire aussi et on pourrait préciser le format (yml ou xml) dans la ligne de commande.

J'aimais bien les annotations mais maintenant il y a trop d'options.
Sinon j'ai jamais testé mais les annotations et ce nouveau driver mélangent les options, si oui c'est les annotations qui ont le dessus, non ?

@npotier

npotier commented Aug 8, 2013

Copy link
Copy Markdown
Collaborator Author

Merci pour le feedback :)

En effet le XML ne devrait pas être compliqué à mettre en place, et une
option permettant de définir le format ferait l'affaire.

Les deux Drivers peuvent cohabiter. Le driver qui prend le dessus dépend
des priorités configurées dans services.xml

Nicolas

Le 8 août 2013 à 18:54, Petit Yoann [email protected] a écrit :

Ça m'a l'air top. Vous êtes bien motivés.
Au final la version xml ne devrait pas être trop longue à faire aussi et on
pourrait préciser le format (yml ou xml) dans la ligne de commande.

J'aimais bien les annotations mais maintenant il y a trop d'options.
Sinon j'ai jamais testé mais les annotations et ce nouveau driver mélangent
les options, si oui c'est les annotations qui ont le dessus, non ?


Reply to this email directly or view it on
GitHubhttps://github.com//pull/449#issuecomment-22337707
.

@Abhoryo

Abhoryo commented Aug 8, 2013

Copy link
Copy Markdown
Member

Les priorité sont définies dans le bundle et non par l'utilisateur si je ne m'abuse. Il faudra voir comment résoudre ce problème.

@npotier

npotier commented Aug 8, 2013

Copy link
Copy Markdown
Collaborator Author

Tout a fait. C'est le cas... Pour l'instant. Peut être faut il donner la
possibilité de choisir par configuration quels Drivers activer, et dans
quel ordre.

Nicolas.

Le 8 août 2013 à 22:16, Petit Yoann [email protected] a écrit :

Les priorité sont définies dans le bundle et non par l'utilisateur si je ne
m'abuse. Il faudra voir comment résoudre ce problème.


Reply to this email directly or view it on
GitHubhttps://github.com//pull/449#issuecomment-22352103
.

@Abhoryo

Abhoryo commented Aug 8, 2013

Copy link
Copy Markdown
Member

Oui, peut être du style:
drivers: ["annotation","yml","xml"]
par défaut.
Mais pour cela, il faudrait leur affecter un nom.

Sinon, je viens de voir, le générateur que tu as fait ne génère que le nom des colonnes, envisages-tu de rajouter automatiquement les types vis à vis des propriétés Doctrine?
D'ailleurs, je pense qu'il faudrait filtrer ces propriétés pour ne faire apparaître que les propriétés qui sont des champs doctrine sinon ça ne va pas marcher.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si je comprends bien, columns sera un tableau de clés correspondants aux noms des colonnes avec des valeurs null, non ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui c'est ça. Cela vient du fait que pour une raison qui m'échape, la génération du code

columns: [id, myColumn1]

entraine une erreur, alors que :

columns : 
    id: ~
    myColumn1: ~

fonctionne

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact you have to write this array like this:
columns: ["id", "myColumn1"]
But I think a simple string is enough like in annotation:
columns: "id, myColumn1"

@Abhoryo

Abhoryo commented Sep 5, 2013

Copy link
Copy Markdown
Member

Bonjour,
On en était où sur ce post ?

@npotier

npotier commented Sep 5, 2013

Copy link
Copy Markdown
Collaborator Author

Salut,

Il reste à rendre configurable au niveau des parsers et de leur ordre, et aussi vérifier que les relations ManyToOne sont bien prises en compte

@Abhoryo

Abhoryo commented Sep 5, 2013

Copy link
Copy Markdown
Member

Ah ok. Par contre elle n'est plus mergeable.

@L0rD59

L0rD59 commented Dec 18, 2013

Copy link
Copy Markdown

ping @npotier @Abhoryo cette feature m’intéresse :)

@Abhoryo

Abhoryo commented Dec 18, 2013

Copy link
Copy Markdown
Member

On ne peut pas encore tout à fait la merger. Mais ca va venir. tu peux toujours utiliser le code de ce PR.

Comment thread Grid/Export/DSVExport.php Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est les caractères BOM non ? Pourquoi les rajouter ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonjour,

Cela n'a en effet rien à voir avec la gestion XML de la configuration.

Les caractères BOM ont été ajoutés de façon à ce que Excel prenne en compte les accents lors de l'ouverture directe des fichiers CSV.

Ca pourrait être enlevé ou rendu paramétrable en effet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui plutôt un paramètre mais sur le coup ce n'est pas vraiment le même PR.
Donc ici faudrait le supprimer, et ouvrir un nouveau PR ou au moins une issue pour s'en rappeler.

@plfort

plfort commented Jul 17, 2014

Copy link
Copy Markdown
Contributor

Des nouvelles concernant cette PR ? Je suis très intéressé !

@Abhoryo

Abhoryo commented Jul 19, 2014

Copy link
Copy Markdown
Member

Il manque la documentation :D

@clubdesarrolladores

Copy link
Copy Markdown
Contributor

Hi, this is ready for merge in master? we need yml support. Thanks.

@Piquinikis

Copy link
Copy Markdown

Hi, I need this pull request is accepted, thanks!

@espinozaguillermo

Copy link
Copy Markdown

Hi, I need yml support. Merge this pull request, thanks!

@npotier

npotier commented Nov 21, 2014

Copy link
Copy Markdown
Collaborator Author

Hi guys,

Thanks for your interest for this PR :)

I'll write some doc in order to make this PR mergeable by @Abhoryo

@clubdesarrolladores

Copy link
Copy Markdown
Contributor

Thanks, this is a great PR!!

@Janest

Janest commented Dec 2, 2014

Copy link
Copy Markdown

Please merge and tag, I'm very interested in this PR too.

@npotier

npotier commented Jan 22, 2015

Copy link
Copy Markdown
Collaborator Author

Hello / Salut @Abhoryo. Avant tout, bonne année ;)

Peux tu me dire ce qu'il manquerait à cette PR pour être mergée ?

Merci.

Nicolas.

@Abhoryo

Abhoryo commented Feb 20, 2015

Copy link
Copy Markdown
Member

Salut, @npotier , Pourrais-tu corriger le fichier summary qui a plein de tabulations.
Je mergerai quand ce sera fait, tant pis pour la régression.

@phpetra

phpetra commented Mar 7, 2015

Copy link
Copy Markdown
Contributor

Hi guys,
Can I ask about the status of this PR?
My french is not so good, what exactly needs to be done?

@Abhoryo

Abhoryo commented Mar 7, 2015

Copy link
Copy Markdown
Member

Wait for a modification from @npotier and this is good for merge.

@npotier

npotier commented Mar 22, 2015

Copy link
Copy Markdown
Collaborator Author

Salut @Abhoryo, c'est fait. A ta dispo pour avancer.

Nicolas.

Abhoryo pushed a commit that referenced this pull request May 10, 2015
YAML file configuration and Command to generate YML from an entity
@Abhoryo
Abhoryo merged commit 08f109c into APY:master May 10, 2015
@npotier

npotier commented May 10, 2015

Copy link
Copy Markdown
Collaborator Author

Hourra :)

Merci.

@phpetra

phpetra commented May 11, 2015

Copy link
Copy Markdown
Contributor

Nice indeed! :)

@qferr

qferr commented May 11, 2015

Copy link
Copy Markdown
Contributor

+1

@Abhoryo

Abhoryo commented May 11, 2015

Copy link
Copy Markdown
Member

@npotier can you do something about exceptions that everyone encounter ?

Abhoryo pushed a commit that referenced this pull request May 11, 2015
This reverts commit 08f109c, reversing
changes made to 7541ae2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.