Generator
in package
Tags
Table of Contents
- $fileManager : mixed
- $namespacePrefix : mixed
- $pendingOperations : mixed
- $phpCompatUtil : mixed
- $templateComponentGenerator : mixed
- $twigHelper : mixed
- __construct() : mixed
- createClassNameDetails() : ClassNameDetails
- Creates a helper object to get data about a class name.
- dumpFile() : mixed
- generateClass() : string
- Generate a new file for a class from a template.
- generateController() : string
- generateFile() : mixed
- Generate a normal file from a template.
- generateTemplate() : mixed
- Generate a template file.
- getControllerBaseClass() : ClassNameDetails
- getFileContentsForPendingOperation() : string
- getRootDirectory() : string
- getRootNamespace() : string
- hasPendingOperations() : bool
- writeChanges() : mixed
- Actually writes and file changes that are pending.
- addOperation() : mixed
Properties
$fileManager
private
mixed
$fileManager
$namespacePrefix
private
mixed
$namespacePrefix
$pendingOperations
private
mixed
$pendingOperations
= []
$phpCompatUtil
private
mixed
$phpCompatUtil
$templateComponentGenerator
private
mixed
$templateComponentGenerator
$twigHelper
private
mixed
$twigHelper
Methods
__construct()
public
__construct(FileManager $fileManager, string $namespacePrefix[, PhpCompatUtil $phpCompatUtil = null ][, TemplateComponentGenerator $templateComponentGenerator = null ]) : mixed
Parameters
- $fileManager : FileManager
- $namespacePrefix : string
- $phpCompatUtil : PhpCompatUtil = null
- $templateComponentGenerator : TemplateComponentGenerator = null
Return values
mixed —createClassNameDetails()
Creates a helper object to get data about a class name.
public
createClassNameDetails(string $name, string $namespacePrefix[, string $suffix = '' ][, string $validationErrorMessage = '' ]) : ClassNameDetails
Examples:
// App\Entity\FeaturedProduct $gen->createClassNameDetails('FeaturedProduct', 'Entity'); $gen->createClassNameDetails('featured product', 'Entity');
// App\Controller\FooController $gen->createClassNameDetails('foo', 'Controller', 'Controller');
// App\Controller\Admin\FooController $gen->createClassNameDetails('Foo\Admin', 'Controller', 'Controller');
// App\Controller\Security\Voter\CoolController $gen->createClassNameDetails('Cool', 'Security\Voter', 'Voter');
// Full class names can also be passed. Imagine the user has an autoload // rule where Cool\Stuff lives in a "lib/" directory // Cool\Stuff\BalloonController $gen->createClassNameDetails('Cool\Stuff\Balloon', 'Controller', 'Controller');
Parameters
- $name : string
-
The short "name" that will be turned into the class name
- $namespacePrefix : string
-
Recommended namespace where this class should live, but without the "App\" part
- $suffix : string = ''
-
Optional suffix to guarantee is on the end of the class
- $validationErrorMessage : string = ''
Return values
ClassNameDetails —dumpFile()
public
dumpFile(string $targetPath, string $contents) : mixed
Parameters
- $targetPath : string
- $contents : string
Return values
mixed —generateClass()
Generate a new file for a class from a template.
public
generateClass(string $className, string $templateName[, array<string|int, mixed> $variables = [] ]) : string
Parameters
- $className : string
-
The fully-qualified class name
- $templateName : string
-
Template name in Resources/skeleton to use
- $variables : array<string|int, mixed> = []
-
Array of variables to pass to the template
Tags
Return values
string —The path where the file will be created
generateController()
public
generateController(string $controllerClassName, string $controllerTemplatePath[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
- $controllerClassName : string
- $controllerTemplatePath : string
- $parameters : array<string|int, mixed> = []
Return values
string —generateFile()
Generate a normal file from a template.
public
generateFile(string $targetPath, string $templateName[, array<string|int, mixed> $variables = [] ]) : mixed
Parameters
- $targetPath : string
- $templateName : string
- $variables : array<string|int, mixed> = []
Return values
mixed —generateTemplate()
Generate a template file.
public
generateTemplate(string $targetPath, string $templateName[, array<string|int, mixed> $variables = [] ]) : mixed
Parameters
- $targetPath : string
- $templateName : string
- $variables : array<string|int, mixed> = []
Return values
mixed —getControllerBaseClass()
public
static getControllerBaseClass() : ClassNameDetails
Return values
ClassNameDetails —getFileContentsForPendingOperation()
public
getFileContentsForPendingOperation(string $targetPath) : string
Parameters
- $targetPath : string
Return values
string —getRootDirectory()
public
getRootDirectory() : string
Return values
string —getRootNamespace()
public
getRootNamespace() : string
Return values
string —hasPendingOperations()
public
hasPendingOperations() : bool
Return values
bool —writeChanges()
Actually writes and file changes that are pending.
public
writeChanges() : mixed
Return values
mixed —addOperation()
private
addOperation(string $targetPath, string $templateName, array<string|int, mixed> $variables) : mixed
Parameters
- $targetPath : string
- $templateName : string
- $variables : array<string|int, mixed>