Class representing a single Transformation.

category phpDocumentor
package Transformer
author Mike van Riel
license MIT
link http://phpdoc.org

 Methods

Constructs a new Transformation object and populates the required parameters.

__construct(phpDocumentor_Transformer $transformer, string $query, string $writer, string $source, string $artifact) 

Parameters

$transformer

\phpDocumentor_Transformer

The parent transformer.

$query

string

What information to use as datasource for the writer's source.

$writer

string

What type of transformation to apply (XSLT, PDF, Checkstyle etc).

$source

string

Which template or type of source to use.

$artifact

string

What is the filename of the result (relative to the generated root)

Factory method to create a new transformation based on a array containing transformation parameters.

createFromArray(phpDocumentor_Transformer $transformer, array $transformation) : \phpDocumentor_Transformer_Transformation

The array format is:

array(
  'query'      => 'Query string',
  'writer'     => 'WriterName',
  'source'     => 'source location',
  'artifact'   => 'path',
  'parameters' => array()
)
The parameter array is optional.

Parameters

$transformer

\phpDocumentor_Transformer

Responsible transformer object.

$transformation

\mixed[]

Transformation array, see long description for the format.

Exceptions

\InvalidArgumentException

Returns

Dispatches a logging request to log a debug message.

debug(string $message) : void
Inherited

inherited_from \phpDocumentor_Transformer_Abstract::debug()

Parameters

$message

string

The message to log.

Dispatches an event to the Event Dispatcher.

dispatch(string $name, \string[] $arguments) : mixed | null
Inherited

This method tries to dispatch an event; if no Event Dispatcher has been set than this method will explicitly not fail and return null. By not failing we make the Event Dispatcher optional and is it easier for people to re-use this component in their own application.

inherited_from \phpDocumentor_Transformer_Abstract::dispatch()

Parameters

$name

string

Name of the event to dispatch.

$arguments

\string[]

Arguments for this event.

Exceptions

\phpDocumentor_Parser_Exception if there is a dispatcher but it is not of type sfEventDispatcher

Returns

mixednull

Executes the transformation.

execute(string $structure_file) : void

Parameters

$structure_file

string

The location of the structure file.

Returns the name of the artifact.

getArtifact() : string

Returns

string

Returns a specific parameter, or $default if none exists.

getParameter(string $name, mixed $default) : string

Parameters

$name

string

Name of the parameter to return.

$default

mixed

Default value is parameter does not exist.

Returns

string

Returns all parameters for this transformation.

getParameters() : \string[]

Returns

\string[]

Returns the set query.

getQuery() : string

Returns

string

Returns the name of the source / type used in the transformation process.

getSource() : string

Returns

string

Returns the source as a path instead of a regular value.

getSourceAsPath() : string

This method applies the following rules to the value of $source: 1. if the template_path parameter is set and that combined with the source gives an existing file; return that. 2. if the value exists as a file (either relative to the current working directory or absolute), do a realpath and return it. 3. Otherwise prepend it with the phpDocumentor data folder, if that does not exist: throw an exception

Exceptions

\Exception if no valid file could be found.

Returns

string

Returns the transformer object which is responsible for maintaining this transformation.

getTransformer() : \phpDocumentor_Transformer

Returns an instantiated writer object.

getWriter() : \phpDocumentor_Transformer_Writer_Abstract | null

Imports the parameters from a SimpleXMLElement array.

importParameters(SimpleXMLElement $parameters) : void

Parameters

$parameters

\SimpleXMLElement

Object to import

Dispatches a logging request.

log(string $message, int $priority) : void
Inherited

inherited_from \phpDocumentor_Transformer_Abstract::log()

Parameters

$message

string

The message to log.

$priority

int

The logging priority, the lower, the more important. Ranges from 1 to 7

Filename of the resulting artifact relative to the root.

setArtifact(string $artifact) : void

If the query results in a set of artifacts (multiple nodes / array); then this string must contain an identifying variable as returned by the writer.

Parameters

$artifact

string

Name of artifact to generate; usually a filepath.

Sets an array of parameters (key => value).

setParameters(array $parameters) : void

Parameters

$parameters

\string[]

Associative multidimensional array containing parameters for the Writer.

Sets the query.

setQuery(string $query) : void

Parameters

$query

string

Free-form string with writer-specific values.

Sets the source / type which the writer will use to generate artifacts from.

setSource(string $source) : void

Parameters

$source

string

Free-form string with writer-specific meaning.

Sets the transformer object responsible for maintaining the transformations.

setTransformer(phpDocumentor_Transformer $transformer) : void

Parameters

$transformer

\phpDocumentor_Transformer

Responsible transformer object.

Sets the writer type and instantiates a writer.

setWriter(string $writer) : void

Parameters

$writer

string

Name of writer to instantiate.

Recursive function to convert a SimpleXMLElement to an associative array.

convertSimpleXmlToArray(SimpleXMLElement $sxml) : \(string | \string[])[]

Parameters

$sxml

\SimpleXMLElement

object to convert to a flat array.

Returns

\(string\string[])[]

 Properties

 

The event dispatcher object, may be null to not dispatch events.

$event_dispatcher : \sfEventDispatcher | null
Inherited

inherited_from \phpDocumentor_Transformer_Abstract::$$event_dispatcher
 

$artifact

$artifact : string

 

$parameters

$parameters : \string[]

 

$query

$query : string

 

$source

$source : string

 

$transformer

$transformer : \phpDocumentor_Transformer