| Methods |
public
|
__construct(
FileManager $fileManager,
string $namespacePrefix,
PhpCompatUtil $phpCompatUtil = null,
TemplateComponentGenerator $templateComponentGenerator = null,
)
|
#
|
public
|
generateClass(string $className, string $templateName, array $variables = []): string
Generate a new file for a class from a template.
Generate a new file for a class from a template.
Parameters
| $className |
The fully-qualified class name
|
| $templateName |
Template name in Resources/skeleton to use
|
| $variables |
Array of variables to pass to the template
|
Returns
The path where the file will be created
Throws
|
#
|
public
|
generateFile(string $targetPath, string $templateName, array $variables = []): void
Generate a normal file from a template.
Generate a normal file from a template.
|
#
|
public
|
dumpFile(string $targetPath, string $contents): void
|
#
|
public
|
getFileContentsForPendingOperation(string $targetPath): string
|
#
|
public
|
createClassNameDetails(
string $name,
string $namespacePrefix,
string $suffix = '',
string $validationErrorMessage = '',
): ClassNameDetails
Creates a helper object to get data about a class name.
Creates a helper object to get data about a class name.
Examples:
// App\Entity\FeaturedProduct
$gen->createClassNameDetails('FeaturedProduct', 'Entity');
$gen->createClassNameDetails('featured product', 'Entity');
// App\Controller\FooController
$gen->createClassNameDetails('foo', 'Controller', 'Controller');
// App\Controller\Foo\AdminController
$gen->createClassNameDetails('Foo\Admin', 'Controller', 'Controller');
// App\Security\Voter\CoolVoter
$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 |
The short "name" that will be turned into the class name
|
| $namespacePrefix |
Recommended namespace where this class should live, but without the "App\" part
|
| $suffix |
Optional suffix to guarantee is on the end of the class
|
|
#
|
public
|
getRootDirectory(): string
|
#
|
public
|
hasPendingOperations(): bool
|
#
|
public
|
writeChanges(): void
Actually writes and file changes that are pending.
Actually writes and file changes that are pending.
|
#
|
public
|
getRootNamespace(): string
|
#
|
public
|
generateController(string $controllerClassName, string $controllerTemplatePath, array $parameters = []): string
|
#
|
public
|
generateTemplate(string $targetPath, string $templateName, array $variables = []): void
Generate a template file.
Generate a template file.
|
#
|
public
|
getGeneratedFiles(): array
Get the full path of each file created by the Generator.
Get the full path of each file created by the Generator.
|
#
|
public
static
|
getControllerBaseClass(): ClassNameDetails
Deprecated
MakerBundle only supports AbstractController::class. This method will be removed in the future.
|
#
|
private
|
addOperation(string $targetPath, string $templateName, array $variables): void
|
#
|