+4 votes

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;
}
in Feature Request by (390 points)
edited by

4 Answers

+1 vote
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

by Skipper developer (136k points)
selected by

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

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.

by (3.6k points)
edited by
0 votes

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.

by (3.6k points)

Can you share how you do this?

0 votes

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

by (320 points)