[Feature request] Entity and field descriptions export to comments too

+4 votes
asked Nov 28, 2012 in Feature Request by fchris82 (390 points)
edited Dec 20, 2012 by ludek.vodicka

Image caption
I wrote a php script to ORM Designer 1 and insert in the "External tools" which read and write descriptions from the ormdesigner xml files to the "Export ORM" yml file.
The Doctrine2 is more complex, many files, many directories. In many cases the descriptions are important to can read these anybody out of Orm Designer.

Forexample:

use Doctrine\ORM\Mapping AS ORM;

/** 
 * This is the group entity
 *
 * @ORM\Entity
 */
class Group
{
  /** 
   * This is the identity number of the group
   * 
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;

  /** 
   * @ORM\Column(type="string", unique=true, length=255, nullable=false)
   */
  private $name;
}

4 Answers

+1 vote
answered Dec 5, 2012 by ludek.vodicka Skipper developer (140,450 points)
selected Jul 30, 2014 by Martin Freki Stradej
 
Best answer

I have to agree it's an interested idea. It shouldn't be a big problem to implement it for all three formats.

Annotations
Right now I'm not sure only about how to mark ORMD texts in the whole comment. ORMD works in way that it removes known annotations and replaces them with updated ones and keeps any other content (another annotations, user comments,....) as it is.

So if we need to export (and continuously update) descriptions, it's necessary to create some marks to distinguish between ORMD descriptions and user's texts. For example to use some special annotations like:

@ORMD\Description("asfsafsafdsafdsafsaffsafsf")

or some marks, for example colon as first char:

/**
* : afsfsafs
* : asfafsdf
...

XML
In xml format there are also some ways how to implement it. One possible way is to use default XML comments. But this should be a limitation if anyone needs to proceed descriptions from exported XML

<!-- description ..... -->

Another way is to define some ORMD namespace and export these texts in own element in this namespace:

<ormd:description> asdfafsaf </ormd:descriptions>

YML

In YML the situation is very similar as in XML. One way is to use default comments, second way is to define the own elements. I'm not sure if there is a way how to use namespaces, so for example some

ormd_description:  asfafdsafdsaf

I will be glad to open a discussion about this topic. Take this as suggestions how we can implement it. But I will be more than happy to hear how you already export these texts in your script, so we don't have to reinvent the wheel ;-)

Regards
Ludek

commented Jan 10, 2013 by jwagner (3,630 points)

In the YAML metadata file as "comment:" property, similar to your "ormd_description". This needs a custom EntityGenerator, though.

I am not sure if a future Doctrine version can already deal with comments or if they never will because it's not platform agnostic, but that's the way we do it to get the comments from ORMD down to MySQL.

What if that could be added to the columnDefinition automatically?

The script to extract the comments from ORMD XML file and patch the YAML files is pretty straightforward, however entity generation needs to be customized in Doctrine.

0 votes
answered Dec 5, 2012 by jwagner (3,630 points)
edited Jan 17, 2013 by jwagner

I have also created a custom script for this, --and, much to my surprise, it still works with ORMD2!-- (Not true, I still had the old ORMD1 XML file for the script to analyze...)
But to have it natively supported would be terrific as it would work for YAML, XML and PHP annotations.

0 votes
answered Jan 14, 2013 by jwagner (3,630 points)

This also applies to "default" value. Although Doctrine2 does not by default honor that field, writing a custom EntityGenerator to include default values in the column definition would be so much easier if they would already be exported to the YAML / XML mapping information.

Right now we use our custom patch script to copy the comments and defaults from ORM Designer XML to YAML mapping files.

commented Nov 15, 2014 by otherjohn (170 points)

Can you share how you do this?

0 votes
answered Apr 7, 2014 by iavansis.miguel (320 points)

Hi! Do you have any scripts working?
There is any place to share custom scripts? I think It will be very useful.

...