Skip to content

Commit 42708a2

Browse files
committed
Merge branch '3.x' into 3.next
2 parents 3b10d47 + 367e18b commit 42708a2

16 files changed

+142
-25
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ indent_size = 2
1919

2020
[*.twig]
2121
insert_final_newline = false
22+
23+
[tests/comparisons/Template/*.php]
24+
insert_final_newline = false

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require": {
2323
"php": ">=8.1",
24-
"brick/varexporter": "^0.5.0",
24+
"brick/varexporter": "^0.6.0",
2525
"cakephp/cakephp": "^5.1",
2626
"cakephp/twig-view": "^2.0.0",
2727
"nikic/php-parser": "^5.0.0"

src/Command/CommandCommand.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
namespace Bake\Command;
1818

19+
use Cake\Console\Arguments;
20+
use Cake\Utility\Inflector;
21+
1922
/**
2023
* Console Command generator.
2124
*/
@@ -51,4 +54,24 @@ public function template(): string
5154
{
5255
return 'Bake.Command/command';
5356
}
57+
58+
/**
59+
* Get template data.
60+
*
61+
* @param \Cake\Console\Arguments $arguments Arguments object.
62+
* @return array
63+
* @phpstan-return array<string, mixed>
64+
*/
65+
public function templateData(Arguments $arguments): array
66+
{
67+
$data = parent::templateData($arguments);
68+
69+
$data['command_name'] = Inflector::underscore(str_replace(
70+
'.',
71+
' ',
72+
$arguments->getArgument('name')
73+
));
74+
75+
return $data;
76+
}
5477
}

src/Command/PluginCommand.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@ class PluginCommand extends BakeCommand
4545

4646
protected bool $isVendor = false;
4747

48-
/**
49-
* initialize
50-
*
51-
* @return void
52-
*/
53-
public function initialize(): void
54-
{
55-
parent::initialize();
56-
$this->path = current(App::path('plugins'));
57-
}
58-
5948
/**
6049
* Execute the command.
6150
*
@@ -114,10 +103,15 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
114103
*/
115104
public function bake(string $plugin, Arguments $args, ConsoleIo $io): ?bool
116105
{
117-
$pathOptions = App::path('plugins');
118-
if (count($pathOptions) > 1) {
119-
$this->findPath($pathOptions, $io);
106+
if (!$this->isVendor) {
107+
$pathOptions = App::path('plugins');
108+
$this->path = current($pathOptions);
109+
110+
if (count($pathOptions) > 1) {
111+
$this->findPath($pathOptions, $io);
112+
}
120113
}
114+
121115
$io->out(sprintf('<info>Plugin Name:</info> %s', $plugin));
122116
$io->out(sprintf('<info>Plugin Directory:</info> %s', $this->path . $plugin));
123117
$io->hr();

src/Utility/Model/EnumParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use InvalidArgumentException;
77

8-
enum EnumParser
8+
class EnumParser
99
{
1010
/**
1111
* @param string|null $casesString

templates/bake/Command/command.twig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@
2828
*/
2929
class {{ name }}Command extends Command
3030
{
31+
/**
32+
* The name of this command.
33+
*
34+
* @var string
35+
*/
36+
protected string $name = '{{ command_name }}';
37+
38+
/**
39+
* Get the default command name.
40+
*
41+
* @return string
42+
*/
43+
public static function defaultName(): string
44+
{
45+
return '{{ command_name }}';
46+
}
47+
3148
/**
3249
* Get the command description.
3350
*

templates/bake/Template/index.twig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@
6565
<td class="actions">
6666
<?= $this->Html->link(__('View'), ['action' => 'view', {{ pk|raw }}]) ?>
6767
<?= $this->Html->link(__('Edit'), ['action' => 'edit', {{ pk|raw }}]) ?>
68-
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', {{ pk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }})]) ?>
68+
<?= $this->Form->postLink(
69+
__('Delete'),
70+
['action' => 'delete', {{ pk|raw }}],
71+
[
72+
'method' => 'delete',
73+
'confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }}),
74+
]
75+
) ?>
6976
</td>
7077
</tr>
7178
<?php endforeach; ?>

templates/bake/Template/view.twig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,14 @@
141141
<td class="actions">
142142
<?= $this->Html->link(__('View'), ['controller' => '{{ details.controller }}', 'action' => 'view', {{ otherPk|raw }}]) ?>
143143
<?= $this->Html->link(__('Edit'), ['controller' => '{{ details.controller }}', 'action' => 'edit', {{ otherPk|raw }}]) ?>
144-
<?= $this->Form->postLink(__('Delete'), ['controller' => '{{ details.controller }}', 'action' => 'delete', {{ otherPk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ otherPk|raw }})]) ?>
144+
<?= $this->Form->postLink(
145+
__('Delete'),
146+
['controller' => '{{ details.controller }}', 'action' => 'delete', {{ otherPk|raw }}],
147+
[
148+
'method' => 'delete',
149+
'confirm' => __('Are you sure you want to delete # {0}?', {{ otherPk|raw }}),
150+
]
151+
) ?>
145152
</td>
146153
</tr>
147154
<?php endforeach; ?>

tests/comparisons/Command/testBakePlugin.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@
1313
*/
1414
class ExampleCommand extends Command
1515
{
16+
/**
17+
* The name of this command.
18+
*
19+
* @var string
20+
*/
21+
protected string $name = 'test_bake example';
22+
23+
/**
24+
* Get the default command name.
25+
*
26+
* @return string
27+
*/
28+
public static function defaultName(): string
29+
{
30+
return 'test_bake example';
31+
}
32+
1633
/**
1734
* Get the command description.
1835
*

tests/comparisons/Template/testBakeIndex.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@
3232
<td class="actions">
3333
<?= $this->Html->link(__('View'), ['action' => 'view', $templateTaskComment->id]) ?>
3434
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $templateTaskComment->id]) ?>
35-
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $templateTaskComment->id], ['confirm' => __('Are you sure you want to delete # {0}?', $templateTaskComment->id)]) ?>
35+
<?= $this->Form->postLink(
36+
__('Delete'),
37+
['action' => 'delete', $templateTaskComment->id],
38+
[
39+
'method' => 'delete',
40+
'confirm' => __('Are you sure you want to delete # {0}?', $templateTaskComment->id),
41+
]
42+
) ?>
3643
</td>
3744
</tr>
3845
<?php endforeach; ?>

0 commit comments

Comments
 (0)