\phpDocumentor\Plugin\TwigExtension

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

Summary

Methods
Properties
Constants
__construct()
setRouters()
setTranslator()
setDestination()
getDestination()
getGlobals()
getFunctions()
getFilters()
convertToRootPath()
No public properties found
No constants found
No protected methods found
$data
$translator
$routeRenderer
N/A
No private methods found
No private properties found
N/A

Properties

Methods

__construct()

__construct(\phpDocumentor\Descriptor\ProjectDescriptor  $project, \phpDocumentor\Transformer\Transformation  $transformation) 

Registers the structure and transformation with this extension.

The Structure and Transformation object can be used to get context from and to provide additional information.

Parameters

\phpDocumentor\Descriptor\ProjectDescriptor $project

Represents the complete Abstract Syntax Tree.

\phpDocumentor\Transformer\Transformation $transformation

Represents the transformation meta data used in the current generation cycle.

setRouters()

setRouters(\phpDocumentor\Transformer\Router\Queue  $routers) : void

Sets the router used to render the URL where a Descriptor can be found.

Parameters

\phpDocumentor\Transformer\Router\Queue $routers

setTranslator()

setTranslator(\phpDocumentor\Translator\Translator  $translator) : void

Sets the translation component.

Parameters

\phpDocumentor\Translator\Translator $translator

setDestination()

setDestination(string  $destination) : void

Sets the destination directory relative to the Project's Root.

The destination is the target directory containing the resulting file. This destination is relative to the Project's root and can be used for the calculation of nesting depths, etc.

Parameters

string $destination

getDestination()

getDestination() : string

Returns the target directory relative to the Project's Root.

Returns

string

getGlobals()

getGlobals() : array<mixed,mixed>

Returns an array of global variables to inject into a Twig template.

Returns

array<mixed,mixed>

getFunctions()

getFunctions() : array<mixed,\Twig_FunctionInterface>

Returns a listing of all functions that this extension adds.

This method is automatically used by Twig upon registering this extension (which is done automatically by phpDocumentor) to determine an additional list of functions.

See the Class' DocBlock for a listing of functionality added by this Extension.

Returns

array<mixed,\Twig_FunctionInterface>

getFilters()

getFilters() : array<mixed,\Twig_SimpleFilter>

Returns a list of all filters that are exposed by this extension.

Returns

array<mixed,\Twig_SimpleFilter>

convertToRootPath()

convertToRootPath(string  $relative_path) : string

Converts the given path to be relative to the root of the documentation target directory.

It is not possible to use absolute paths in documentation templates since they may be used locally, or in a subfolder. As such we need to calculate the number of levels to go up from the current document's directory and then append the given path.

For example:

Suppose you are in <root>/classes/my/class.html and you want open
<root>/my/index.html then you provide 'my/index.html' to this method
and it will convert it into ../../my/index.html (<root>/classes/my is
two nesting levels until the root).

This method does not try to normalize or optimize the paths in order to save on development time and performance, and because it adds no real value.

Parameters

string $relative_path

Returns

string