Documentation

FilesystemGenerator
in package

Generates filesystem objects basing on a structure provided with an array and using file templates and variables. Variables in template files use the Twig syntax, but processed with October\Rain\Syntax\Bracket.

Example - generate a plugin directory containing the plugin.php file. The file is created from a template, which uses a couple of variables.

$structure = [ 'author', 'author/plugin', 'author/plugin/plugin.php' => 'plugin.php.tpl' ]; $generator = new FilesystemGenerator('$', $structure, '$/Author/Plugin/templates/plugin');

$variables = [ 'namespace' => 'Author/Plugin' ]; $generator->setVariables($variables); $generator->generate();

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

$destinationPath  : mixed
$structure  : mixed
$templatesPath  : mixed
$variables  : mixed
__construct()  : mixed
Initializes the object.
generate()  : mixed
getTemplateContents()  : mixed
setVariable()  : mixed
setVariables()  : mixed
makeDirectory()  : mixed
makeFile()  : mixed

Properties

Methods

__construct()

Initializes the object.

public __construct(string $destinationPath, array<string|int, mixed> $structure[, string $templatesPath = null ]) : mixed
Parameters
$destinationPath : string

Destination path to create the filesystem objects in. The path can contain filesystem symbols.

$structure : array<string|int, mixed>

Specifies the structure as array.

$templatesPath : string = null

Path to the directory that contains file templates. The parameter is required only in case any files should be created. The path can contain filesystem symbols.

Return values
mixed

getTemplateContents()

public getTemplateContents(mixed $templateName) : mixed
Parameters
$templateName : mixed
Return values
mixed

setVariable()

public setVariable(mixed $key, mixed $value) : mixed
Parameters
$key : mixed
$value : mixed
Return values
mixed

setVariables()

public setVariables(mixed $variables) : mixed
Parameters
$variables : mixed
Return values
mixed

makeDirectory()

protected makeDirectory(mixed $dirPath) : mixed
Parameters
$dirPath : mixed
Return values
mixed

makeFile()

protected makeFile(mixed $filePath, mixed $templateName) : mixed
Parameters
$filePath : mixed
$templateName : mixed
Return values
mixed

Search results