2017 © Pedro Peláez
 

library doctrine-metadata-grapher

Helper to format doctrine metadata for UML API

image

onurb/doctrine-metadata-grapher

Helper to format doctrine metadata for UML API

  • Sunday, February 18, 2018
  • by nono1971
  • Repository
  • 2 Watchers
  • 1 Stars
  • 8,715 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 15 Versions
  • 17 % Grown

The README.md

Metagatagrapher for Yuml data preparation v 1.1

Build Status Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads, (*1)

MetadataGrapher formats objects data to prepare data for YUML api to generate visual Entities mapping graphs, (*2)

Installation

  • add to your project as a composer dependency:
    // composer.json
    {
        // ...
        require: {
            // ...
            "onurb/doctrine-metadata-grapher": "~1.1"
        }
    }

Use

Send an array of Doctrine ClassMetadata to the YUMLMetadataGrapher::generateFromMetadata() method
It returns the string to send to YUML to get the mapping graph from the api
If you're a symfony user, you should install onurb/doctrine-yuml-bundle which already uses this library adding a link into the dev toolbar. if you're Zend framework user, it is included into the DoctrineORMModule if you install zend-developer-tools, (*3)

Go to this github repo for concrete examples of use to retrieve the array of ClassMetadata - here, (*4)

Peronalize the display : Add notes, color your classes, hide or display fields description,

hide specific or all entity column, (*5)

Fully optional, you can display fieldds description, add color to your map or wwrite notes linked to a specific class. Colored Map with note, (*6)

To do this, the library provides few Doctrine Annotations, to define color, to add notes, to hide or show attributes properties or display specific methods in the graph All of them are described below, (*7)

Options use

Display fields description

To display an Entity attributes properties, Use the @ShowAttributesProperties annotation on your entity :, (*8)

Yuml Graphs, (*9)

[...]
use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher;
/**
* @Grapher\ShowAttributesProperties
* @ORM\Entity
*/
Class MyEntity
{
    //[...]
}

It il also possible to show properties on all Entities and hide it only on less important Entities, (*10)

    /**
     * @param ClassMetadata[] $metadata
     * @param boolean $showFieldsDescription
     * @param array $colors
     * @param array $notes
     * @return string
     */
    public function generateFromMetadata(
        array $metadata,
        $showFieldsDescription = false,
        $colors = array(),
        $notes = array()
    )

To show fields descriptions just turn the $showFieldsDescription to true, (*11)

    $metadataGrapher = new \Onurb\Doctrine\ORMMetadataGrapher\YumlMetadataGrapher();
    $dsl_text = $metadataGrapher->generateFromMetadata($classMetadata, true);

It is also possible to hide One Entity (or more) using the @HideAttributesProperties annotation (if $showFieldsDescription turned to true : no effect if false), (*12)

/**
* @Grapher\HideAttributesProperties
*/
MyEntity
{
    //[...]
}

Hide Entity columns with annotations : using the @grapher\HideColumns annotation on the class :, (*13)

/**
* @Grapher\Hidecolumns
*/
MyEntity
{
    //[...]
}

Or hide a specific secret column you want to hide, using the @Grapher\HiddenColumn on the Entity attribute : can be usefull to hide you credential logic, or to avoid recurrent fields, like created_at, or updated_at in the graph., (*14)

MyEntity
{
    /**
     * @ORM\Column(/* ... */)
     * @Grapher\HiddenColumn
     */
    private $secret;
}

Use colors

you can use the yuml colors and apply it as you wish , on a class or on an entire namespace. color priority is given by hierarchy in the namespace..., (*15)

Colors usage

The easiest way to define class color is to use annotations in Entities like this :, (*16)

use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher;
/**
* @Grapher\Color("blue")
*/

But doing it on each class can be boring if you want a complete namespace with the same color (to display a zend Module or a Symfony bundle with a specific color for example)., (*17)

So it is also possible to define default color on namespaces, but not with annotations, only applied on entities., (*18)

It is done using the third argument of generateMetadata() method to inject an associated array. Color priority is given to Annotations, user can define a color for the namespace, and specifics colors for classes he want to highlight. It can be passed by parameters options depending of your framework logic to allow final users customization, (*19)

    // [...]
    $defaultColors = array(
        'MyModule\\Project\Namespace\FunctionalityOne => 'green,
        'MyModule\\Project\Namespace\FunctionalityTwo => 'red,
        'AnotherModule\\Namespace' => 'violet',
    );
    $dsl_text = $metadataGrapher->generateFromMetadata($classMetadata, false, $defaultColors);

A complete list of available colors can be found here Color list, (*20)

Display methods

Final user can display any method he wants in the graph, simply adding an annotation
Class With Methods, (*21)

```php use use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher;, (*22)

// [...] /** * @Grapher\IsDisplayedMethod() */ public function myImportantMethod() {} ```, (*23)

Add notes

You can now add a note linked in the mapping to an Entity Note graph, (*24)

Notes usage

Notes are managed by annotations declared directly on classes to note:, (*25)

use Doctrine\ORM\Mapping as ORM;
use Onurb\Doctrine\ORMMetadataGrapher\Mapping as Grapher;
/**
* @Grapher\Note("My first Entity note")
* @ORM\Entity
*/
class MyEntity{}

Note color is yellow by default... Maybe because of post-it color... My choice ;), (*26)

you can customize it like this :, (*27)

/**
* @Grapher\Note(value="An Entity note", color="a_great_yuml_color")
*/

As we did with colors, you can also inject an array of notes in the generateMetadata method, but it is useless with annotations => we don't put notes on namespaces, only Entities., (*28)

The Versions

18/02 2018

dev-master

9999999-dev http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

18/02 2018

1.1.11

1.1.11.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

30/04 2017

1.1.10

1.1.10.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

12/04 2017

1.1.9

1.1.9.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

11/04 2017

1.1.8

1.1.8.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

11/04 2017

1.1.7

1.1.7.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

09/04 2017

1.1.6

1.1.6.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

24/07 2016

1.1.5

1.1.5.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

22/07 2016

1.1.4

1.1.4.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

17/07 2016

1.1.3

1.1.3.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

14/07 2016

1.1.2

1.1.2.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

13/07 2016

1.1.1.1

1.1.1.1 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

13/07 2016

1.1.1

1.1.1.0 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

03/07 2016

1.0.0.1

1.0.0.1 http://www.doctrine-project.org/

Helper to format doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml

03/07 2016

1.0

1.0.0.0 http://www.doctrine-project.org/

Doctrine library that formats doctrine metadata for UML API

  Sources   Download

The Requires

 

The Development Requires

by Bruno Heron

orm doctrine metadata grapher diagram yuml