Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor] Fix "twig" case (-> "Twig") in make:twig-component & various places #1633

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/help/MakeAuth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ by asking questions.

It can provide an empty authenticator, or a full login form authentication process.
In both cases it also updates your <info>security.yaml</info>.
For the login form, it also generates a controller and the twig template.
For the login form, it also generates a controller and the Twig template.

<info>php %command.full_name%</info>
2 changes: 1 addition & 1 deletion config/help/MakeTwigExtension.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The <info>%command.name%</info> command generates a new twig extension with its runtime class.
The <info>%command.name%</info> command generates a new Twig extension with its runtime class.

<info>php %command.full_name% AppExtension</info>

Expand Down
2 changes: 1 addition & 1 deletion config/help/security/MakeFormLogin.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The <info>%command.name%</info> command generates a controller and twig template
The <info>%command.name%</info> command generates a controller and Twig template
to allow users to login using the form_login authenticator.

The controller name, and logout ability can be customized by answering the
Expand Down
2 changes: 1 addition & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function generateClass(string $className, string $templateName, array $va
* @param array $variables Array of variables to pass to the template
* @param bool $isController Set to true if generating a Controller that needs
* access to the TemplateComponentGenerator ("generator") in
* the twig template. e.g. to create route attributes for a route method
* the Twig template. e.g. to create route attributes for a route method
*
* @return string The path where the file will be created
*
Expand Down
4 changes: 2 additions & 2 deletions src/Maker/MakeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class: $controllerClassName,
]
);

// Again if the class name is absolute, lets not make assumptions about where the twig template
// Again if the class name is absolute, lets not make assumptions about where the Twig template
// should live. E.g. templates/custom/location/for/my_controller.html.twig instead of
// templates/my/controller.html.twig. We do however remove the root_namespace prefix in either case
// so we don't end up with templates/app/my/controller.html.twig
Expand All @@ -109,7 +109,7 @@ class: $controllerClassName,
$this->controllerClassData->getClassName(relative: true, withoutSuffix: true)
;

// Convert the twig template name into a file path where it will be generated.
// Convert the Twig template name into a file path where it will be generated.
$this->twigTemplatePath = \sprintf('%s%s', Str::asFilePath($templateName), $this->isInvokable ? '.html.twig' : '/index.html.twig');

$this->interactSetGenerateTests($input, $io);
Expand Down
14 changes: 7 additions & 7 deletions src/Maker/MakeTwigComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public static function getCommandName(): string

public static function getCommandDescription(): string
{
return 'Create a twig (or live) component';
return 'Create a Twig (or Live) component';
}

public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setDescription(self::getCommandDescription())
->addArgument('name', InputArgument::OPTIONAL, 'The name of your twig component (ie <fg=yellow>Notification</>)')
->addOption('live', null, InputOption::VALUE_NONE, 'Whether to create a live twig component (requires <fg=yellow>symfony/ux-live-component</>)')
->addArgument('name', InputArgument::OPTIONAL, 'The name of your Twig component (ie <fg=yellow>Notification</>)')
->addOption('live', null, InputOption::VALUE_NONE, 'Whether to create a Live component (requires <fg=yellow>symfony/ux-live-component</>)')
;
}

Expand All @@ -66,7 +66,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$live = $input->getOption('live');

if ($live && !class_exists(AsLiveComponent::class)) {
throw new \RuntimeException('You must install symfony/ux-live-component to create a live component (composer require symfony/ux-live-component)');
throw new \RuntimeException('You must install symfony/ux-live-component to create a Live component (composer require symfony/ux-live-component)');
}

$factory = $generator->createClassNameDetails(
Expand Down Expand Up @@ -100,20 +100,20 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
{
if (!$input->getOption('live')) {
$input->setOption('live', $io->confirm('Make this a live component?', false));
$input->setOption('live', $io->confirm('Make this a Live component?', false));
}

$path = 'config/packages/twig_component.yaml';

if (!$this->fileManager->fileExists($path)) {
throw new RuntimeCommandException(message: 'Unable to find twig_component.yaml');
throw new RuntimeCommandException(message: 'Unable to find config/packages/twig_component.yaml');
}

try {
$value = Yaml::parse($this->fileManager->getFileContents($path));
$this->namespace = substr(array_key_first($value['twig_component']['defaults']), 4);
} catch (\Throwable $throwable) {
throw new RuntimeCommandException(message: 'Unable to parse twig_component.yaml', previous: $throwable);
throw new RuntimeCommandException(message: 'Unable to parse config/packages/twig_component.yaml', previous: $throwable);
}
}
}
2 changes: 1 addition & 1 deletion templates/twig/component_template.tpl.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div{{ attributes }}>
<!-- component html -->
<!-- component HTML -->
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public function testController()
$this->assertStringContainsString('<div data-controller="live"', $output);
$this->assertStringContainsString('data-live-name-value="', $output);
$this->assertStringContainsString('data-live-url-value=', $output);
$this->assertStringContainsString('<!-- component html -->', $output);
$this->assertStringContainsString('<!-- component HTML -->', $output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public function testController()
{
$output = self::getContainer()->get('twig')->createTemplate("<twig:{name} />")->render();

$this->assertSame("<div>\n <!-- component html -->\n</div>\n", $output);
$this->assertSame("<div>\n <!-- component HTML -->\n</div>\n", $output);
}
}
Loading