Transformer
in package
implements
CompilerPassInterface
Core class responsible for transforming the cache file to a set of artifacts.
Interfaces, Classes and Traits
- CompilerPassInterface
- Represents a single pass / business rule to be executed by the Compiler.
Table of Contents
- COMPILER_PRIORITY = 5000
- EVENT_POST_INITIALIZATION = 'transformer.writer.initialization.post'
- EVENT_POST_TRANSFORM = 'transformer.transform.post'
- EVENT_POST_TRANSFORMATION = 'transformer.transformation.post'
- EVENT_PRE_INITIALIZATION = 'transformer.writer.initialization.pre'
- EVENT_PRE_TRANSFORM = 'transformer.transform.pre'
- EVENT_PRE_TRANSFORMATION = 'transformer.transformation.pre'
- $target : string|null
- $templates : Collection
- $transformations : array<string|int, Transformation>
- $writers : Collection
- $destination : FilesystemInterface|null
- $flySystemFactory : FlySystemFactory
- $logger : LoggerInterface
- __construct() : mixed
- Wires the template collection and writer collection to this transformer.
- destination() : FilesystemInterface
- execute() : void
- Transforms the given project into a series of artifacts as provided by the templates.
- getDescription() : string
- Returns a textual description of what this pass does for output purposes.
- getTarget() : string|null
- Returns the location where to store the artifacts.
- getTemplates() : Collection
- Returns the list of templates which are going to be adopted.
- getTemplatesDirectory() : Filesystem
- setTarget() : void
- Sets the target location where to output the artifacts.
- applyTransformationToProject() : void
- Applies the given transformation to the provided project.
- initializeWriter() : void
- Initializes the given writer using the provided project meta-data.
- initializeWriters() : void
- Initializes all writers that are used during this transformation.
- transformProject() : void
- Applies all given transformations to the provided project.
Constants
COMPILER_PRIORITY
public
int
COMPILER_PRIORITY
= 5000
EVENT_POST_INITIALIZATION
public
mixed
EVENT_POST_INITIALIZATION
= 'transformer.writer.initialization.post'
EVENT_POST_TRANSFORM
public
mixed
EVENT_POST_TRANSFORM
= 'transformer.transform.post'
EVENT_POST_TRANSFORMATION
public
mixed
EVENT_POST_TRANSFORMATION
= 'transformer.transformation.post'
EVENT_PRE_INITIALIZATION
public
mixed
EVENT_PRE_INITIALIZATION
= 'transformer.writer.initialization.pre'
EVENT_PRE_TRANSFORM
public
mixed
EVENT_PRE_TRANSFORM
= 'transformer.transform.pre'
EVENT_PRE_TRANSFORMATION
public
mixed
EVENT_PRE_TRANSFORMATION
= 'transformer.transformation.pre'
Properties
$target
protected
string|null
$target
= null
$templates
protected
Collection
$templates
$transformations
protected
array<string|int, Transformation>
$transformations
= []
$writers
protected
Collection
$writers
$destination
private
FilesystemInterface|null
$destination
= null
$flySystemFactory
private
FlySystemFactory
$flySystemFactory
$logger
private
LoggerInterface
$logger
Methods
__construct()
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
Return values
mixed —destination()
public
destination() : FilesystemInterface
Return values
FilesystemInterface —execute()
Transforms the given project into a series of artifacts as provided by the templates.
public
execute(ProjectDescriptor $project) : void
Parameters
- $project : ProjectDescriptor
-
Representation of the Object Graph that can be manipulated.
Return values
void —getDescription()
Returns a textual description of what this pass does for output purposes.
public
getDescription() : string
Please note that the command line will be truncated to 68 characters (
Return values
string —getTarget()
Returns the location where to store the artifacts.
public
getTarget() : string|null
Return values
string|null —getTemplates()
Returns the list of templates which are going to be adopted.
public
getTemplates() : Collection
Return values
Collection —getTemplatesDirectory()
public
getTemplatesDirectory() : Filesystem
Return values
Filesystem —setTarget()
Sets the target location where to output the artifacts.
public
setTarget(string $target) : void
Parameters
- $target : string
-
The target location where to output the artifacts.
Return values
void —applyTransformationToProject()
Applies the given transformation to the provided project.
private
applyTransformationToProject(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
Tags
Return values
void —initializeWriter()
Initializes the given writer using the provided project meta-data.
private
initializeWriter(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
Tags
Return values
void —initializeWriters()
Initializes all writers that are used during this transformation.
private
initializeWriters(ProjectDescriptor $project, array<string|int, Transformation> $transformations) : void
Parameters
- $project : ProjectDescriptor
- $transformations : array<string|int, Transformation>
Return values
void —transformProject()
Applies all given transformations to the provided project.
private
transformProject(ProjectDescriptor $project, array<string|int, Transformation> $transformations) : void
Parameters
- $project : ProjectDescriptor
- $transformations : array<string|int, Transformation>