Classes, interfaces and traits

ExtensionInterface

An interface shared by all Twig interfaces intended for phpDocumentor.

« More »

Extension

Basic extension adding phpDocumentor specific functionality for Twig templates.

Global variables:

  • ast_node, the current $data element

Functions:

  • path(string) , converts the given relative path to be based of the projects root instead of the current directory

Filters:

  • markdown, converts the associated text from Markdown formatting to HTML.
  • trans, translates the given string
  • route, attempts to generate a URL for a given Descriptor
  • sort_desc, sorts the given objects by their Name property/getter in a descending fashion
  • sort_asc, sorts the given objects by their Name property/getter in a ascending fashion
« More »

ServiceProvider

Provides a series of services that are necessary for Twig to work with phpDocumentor.

This provider uses the translator component to fuel the twig writer and ands the to the twig writer to the writer collection. This enables transformations to mention 'twig' as their writer attribute.

« More »

Classes, interfaces and traits

Twig

A specialized writer which uses the Twig templating engine to convert templates to HTML output.

This writer support the Query attribute of a Transformation to generate multiple templates in one transformation.

The Query attribute supports a simplified version of Twig queries and will use each individual result as the 'node' global variable in the Twig template.

Example:

Suppose a Query indexes.classes is given then this writer will be invoked as many times as there are classes in the project and the 'node' global variable in twig will be filled with each individual class entry.

When using the Query attribute in the transformation it is important to use a variable in the Artifact attribute as well (otherwise the same file would be overwritten several times).

A simple example transformation line could be:

```
<transformation
    writer="twig"
    source="templates/twig/index.twig"
    artifact="index.html"/>
```

This example transformation would use this writer to transform the
index.twig template file in the twig template folder into index.html at
the destination location.
Since no Query is provided the 'node' global variable will contain
the Project Descriptor of the Object Graph.

A complex example transformation line could be:

```
<transformation
    query="indexes.classes"
    writer="twig"
    source="templates/twig/class.twig"
    artifact="{{name}}.html"/>
```

This example transformation would use this writer to transform the
class.twig template file in the twig template folder into a file with
the 'name' property for an individual class inside the Object Graph.
Since a Query *is* provided will the 'node' global variable contain a
specific instance of a class applicable to the current iteration.
« More »