This Transformer can be used to pass an incoming branch unmodified through the environment resolving step and use it as asset environment. The input value passed to transform will be immediately returned without further modification.
{
"transformer": "passthrough"
}
$transformer = new \CPSIT\FrontendAssetHandler\Asset\Environment\Transformer\PassthroughTransformer();
$environment = $transformer->transform('foo');
// $environment = 'foo'
Use this Transformer if you need to slugify the incoming branch. This is especially useful if branches contain characters that need to be URL-encoded.
{
"transformer": "slug",
"options": {
"pattern": "fe-{slug}"
}
}
$transformer = new \CPSIT\FrontendAssetHandler\Asset\Environment\Transformer\SlugTransformer();
$environment = $transformer->transform('feature/some-cool-modifications');
// $environment = 'feature-some-cool-modifications'
$transformer = new \CPSIT\FrontendAssetHandler\Asset\Environment\Transformer\SlugTransformer('fe-{slug}');
$environment = $transformer->transform('feature/some-cool-modifications');
// $environment = 'fe-feature-some-cool-modifications'
Sometimes environments are fixed to a static value, e.g. latest
or stable
. In this case
you can use this Transformer and provide the static value which is always returned when
calling the transform()
method.
{
"transformer": "static",
"options": {
"value": "latest"
}
}
$transformer = new \CPSIT\FrontendAssetHandler\Asset\Environment\Transformer\StaticTransformer('latest');
$environment = $transformer->transform('foo');
// $environment = 'latest'
This Transformer offers a similar behavior as the StaticTransformer
.
It accepts a version and returns it when calling transform()
.
{
"transformer": "version",
"options": {
"version": "1.0.0"
}
}
$transformer = new \CPSIT\FrontendAssetHandler\Asset\Environment\Transformer\VersionTransformer('1.0.0');
$environment = $transformer->transform('foo');
// $environment = '1.0.0'