$routers
$routers : \phpDocumentor\Transformer\Router\Queue
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.
$routers : \phpDocumentor\Transformer\Router\Queue
$translator : \phpDocumentor\Translator\Translator
checkRequirements() : void
This method verifies whether PHP has all requirements needed to run this writer.
If one of the requirements is missing for this Writer then an exception of type RequirementMissing should be thrown; this indicates to the calling process that this writer will not function.
when a requirements is missing stating which one.
transform(\phpDocumentor\Descriptor\ProjectDescriptor $project, \phpDocumentor\Transformer\Transformation $transformation) : void
This method combines the ProjectDescriptor and the given target template and creates a static html page at the artifact location.
\phpDocumentor\Descriptor\ProjectDescriptor | $project | Document containing the structure. |
\phpDocumentor\Transformer\Transformation | $transformation | Transformation to execute. |
setRouters(\phpDocumentor\Transformer\Router\Queue $routers) : void
Sets the routers that can be used to determine the path of links.
\phpDocumentor\Transformer\Router\Queue | $routers |
setTranslator(\phpDocumentor\Translator\Translator $translator)
\phpDocumentor\Translator\Translator | $translator |
initializeEnvironment(\phpDocumentor\Descriptor\ProjectDescriptor $project, \phpDocumentor\Transformer\Transformation $transformation, string $destination) : \Twig_Environment
Initializes the Twig environment with the template, base extension and additionally defined extensions.
\phpDocumentor\Descriptor\ProjectDescriptor | $project | |
\phpDocumentor\Transformer\Transformation | $transformation | |
string | $destination |
addPhpDocumentorExtension(\phpDocumentor\Descriptor\ProjectDescriptor $project, \phpDocumentor\Transformer\Transformation $transformation, string $destination, \Twig_Environment $twigEnvironment) : void
Adds the phpDocumentor base extension to the Twig Environment.
\phpDocumentor\Descriptor\ProjectDescriptor | $project | |
\phpDocumentor\Transformer\Transformation | $transformation | |
string | $destination | |
\Twig_Environment | $twigEnvironment |
addExtensionsFromTemplateConfiguration(\phpDocumentor\Transformer\Transformation $transformation, \phpDocumentor\Descriptor\ProjectDescriptor $project, \Twig_Environment $twigEnvironment) : void
Tries to add any custom extensions that have been defined in the template or the transformation's configuration.
This method will read the twig-extension
parameter of the transformation (which inherits the template's
parameter set) and try to add those extensions to the environment.
\phpDocumentor\Transformer\Transformation | $transformation | |
\phpDocumentor\Descriptor\ProjectDescriptor | $project | |
\Twig_Environment | $twigEnvironment |
if a twig-extension should be loaded but it could not be found.
getDestinationPath(\phpDocumentor\Descriptor\DescriptorAbstract $node, \phpDocumentor\Transformer\Transformation $transformation) : string|false
Uses the currently selected node and transformation to assemble the destination path for the file.
The Twig writer accepts the use of a Query to be able to generate output for multiple objects using the same template.
The given node is the result of such a query, or if no query given the selected element, and the transformation contains the destination file.
Since it is important to be able to generate a unique name per element can the user provide a template variable in the name of the file. Such a template variable always resides between double braces and tries to take the node value of a given query string.
Example:
An artifact stating classes/{{name}}.html
will try to find the
node 'name' as a child of the given $node and use that value instead.
\phpDocumentor\Descriptor\DescriptorAbstract | $node | |
\phpDocumentor\Transformer\Transformation | $transformation |
if no artifact is provided and no routing rule matches.
if the provided node does not contain anything.
returns the destination location or false if generation should be aborted.
getTemplatePath(\phpDocumentor\Transformer\Transformation $transformation) : string
Returns the path belonging to the template.
\phpDocumentor\Transformer\Transformation | $transformation |