Transformer

in package
Implements CompilerPassInterface

Core class responsible for transforming the cache file to a set of artifacts.

Interfaces, Classes & Used Traits

CompilerPassInterface
Represents a single pass / business rule to be executed by the Compiler.

Constants

mixed EVENT_PRE_TRANSFORMATION = 'transformer.transformation.pre'

mixed EVENT_POST_TRANSFORMATION = 'transformer.transformation.post'

mixed EVENT_PRE_INITIALIZATION = 'transformer.writer.initialization.pre'

mixed EVENT_POST_INITIALIZATION = 'transformer.writer.initialization.post'

mixed EVENT_PRE_TRANSFORM = 'transformer.transform.pre'

mixed EVENT_POST_TRANSFORM = 'transformer.transform.post'

Properties

protected$target  : string|null                

protected$templates  : \phpDocumentor\Transformer\Template\Collection                

protected$writers  : \phpDocumentor\Transformer\Writer\Collection                

protected$transformations  : \phpDocumentor\Transformer\Transformation[]                

private$destination  : \League\Flysystem\FilesystemInterface|null                

private$logger  : \Psr\Log\LoggerInterface                

private$flySystemFactory  : \phpDocumentor\Parser\FlySystemFactory                

Methods

Wires the template collection and writer collection to this transformer.

public__construct(Collection $templateCollection, Collection $writerCollection, LoggerInterface $logger, FlySystemFactory $flySystemFactory) : mixed

Parameters

$templateCollection : Collection
$writerCollection : Collection
$logger : LoggerInterface
$flySystemFactory : FlySystemFactory

Returns

mixed

Returns a textual description of what this pass does for output purposes.

publicgetDescription() : string

Please note that the command line will be truncated to 68 characters ( .. 000.000s) so longer descriptions won't have much use.

Returns

string

Sets the target location where to output the artifacts.

publicsetTarget(string $target) : void

Parameters

$target : string

The target location where to output the artifacts.

Returns the location where to store the artifacts.

publicgetTarget() : string|null

Returns

string|null

publicdestination() : FilesystemInterface

Returns

FilesystemInterface

publicgetTemplatesDirectory() : Filesystem

Returns

Filesystem

Returns the list of templates which are going to be adopted.

publicgetTemplates() : Collection

Returns

Collection

Transforms the given project into a series of artifacts as provided by the templates.

publicexecute(ProjectDescriptor $project) : void

This method will execute the business logic associated with a given compiler pass and allow it to manipulate or consumer the Object Graph using the ProjectDescriptor object.

Parameters

$project : ProjectDescriptor

Representation of the Object Graph that can be manipulated.

Dispatches a logging request.

publiclog(string $message[, string $priority = LogLevel::INFO ]) : void

This method can be used by writers to output logs without having to know anything about the logging mechanism of phpDocumentor.

Parameters

$message : string
$priority : string = LogLevel::INFO

Dispatches a logging request to log a debug message.

publicdebug(string $message) : void

This method can be used by writers to output logs without having to know anything about the logging mechanism of phpDocumentor.

Parameters

$message : string

Initializes all writers that are used during this transformation.

privateinitializeWriters(ProjectDescriptor $project, \phpDocumentor\Transformer\Transformation[] $transformations) : void

Parameters

$project : ProjectDescriptor
$transformations : \phpDocumentor\Transformer\Transformation[]

Initializes the given writer using the provided project meta-data.

privateinitializeWriter(WriterAbstract $writer, ProjectDescriptor $project) : void

This method wil call for the initialization of each writer that supports an initialization routine (as defined by the Initializable interface).

In addition to this, the following events emitted for each writer that is present in the collected list of transformations, even those that do not implement the Initializable interface.

Emitted events:

  • transformer.writer.initialization.pre, before the initialization of a single writer.
  • transformer.writer.initialization.post, after the initialization of a single writer.

Parameters

$writer : WriterAbstract
$project : ProjectDescriptor
uses
Dispatcher

to emit the events surrounding an initialization.

Applies all given transformations to the provided project.

privatetransformProject(ProjectDescriptor $project, \phpDocumentor\Transformer\Transformation[] $transformations) : void

Parameters

$project : ProjectDescriptor
$transformations : \phpDocumentor\Transformer\Transformation[]

Applies the given transformation to the provided project.

privateapplyTransformationToProject(Transformation $transformation, ProjectDescriptor $project) : void

This method will attempt to find an appropriate writer for the given transformation and invoke that with the transformation and project so that an artifact can be generated that matches the intended transformation.

In addition this method will emit the following events:

  • transformer.transformation.pre, before the project has been transformed with this transformation.
  • transformer.transformation.post, after the project has been transformed with this transformation

Parameters

$transformation : Transformation
$project : ProjectDescriptor
uses
Dispatcher

to emit the events surrounding a transformation.