Skip to content

Commit db51ee4

Browse files
authored
Merge pull request #108 from cakephp/command-name
Add configurable underscore command naming
2 parents 303811a + 9c35f31 commit db51ee4

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"source": "https://github.com/cakephp/twig-view"
2323
},
2424
"require": {
25+
"php": ">=8.1",
2526
"cakephp/cakephp": "^5.0.0",
2627
"jasny/twig-extensions": "^1.3",
2728
"twig/markdown-extra": "^3.0",
@@ -50,8 +51,8 @@
5051
}
5152
},
5253
"scripts": {
53-
"cs-check": "phpcs --colors --parallel=16 -p src/ tests/",
54-
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/",
54+
"cs-check": "phpcs --colors --parallel=16 -p",
55+
"cs-fix": "phpcbf --colors --parallel=16 -p",
5556
"phpstan": "tools/phpstan analyse",
5657
"stan": "@phpstan",
5758
"phpstan-baseline": "tools/phpstan --generate-baseline",

config/app.example.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* CakePHP TwigView Plugin - Example Configuration
4+
*
5+
* Copy the relevant settings to your application's config/app.php or config/app_local.php.
6+
*
7+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
8+
* @link https://cakephp.org CakePHP(tm) Project
9+
* @license https://opensource.org/licenses/mit-license.php MIT License
10+
*/
11+
12+
return [
13+
/**
14+
* TwigView Plugin Configuration
15+
*
16+
* These settings control the behavior of the TwigView plugin.
17+
*/
18+
'TwigView' => [
19+
/**
20+
* Use underscore command names.
21+
*
22+
* When `true`, registers `twig_view compile` (with underscore).
23+
* When `false` or not set, registers `twig-view compile` (deprecated, with hyphen).
24+
*
25+
* Upgrade path:
26+
* 1. Update your scripts/CI to use `twig_view compile`
27+
* 2. Set this to `true`
28+
*/
29+
'useUnderscoreCommands' => true,
30+
],
31+
];

phpcs.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?xml version="1.0"?>
22
<ruleset name="TwigView">
3+
<file>src/</file>
4+
<file>tests/</file>
5+
36
<rule ref="CakePHP"/>
47
</ruleset>

src/TwigViewPlugin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
use Cake\Console\CommandCollection;
2222
use Cake\Core\BasePlugin;
23+
use Cake\Core\Configure;
2324
use Cake\TwigView\Command\CompileCommand;
2425

2526
/**
@@ -46,7 +47,12 @@ class TwigViewPlugin extends BasePlugin
4647
*/
4748
public function console(CommandCollection $commands): CommandCollection
4849
{
49-
$commands->add('twig-view compile', CompileCommand::class);
50+
if (Configure::read('TwigView.useUnderscoreCommands')) {
51+
$commands->add('twig_view compile', CompileCommand::class);
52+
} else {
53+
// Deprecated: use `'TwigView.useUnderscoreCommands' => true` to switch to `twig_view compile`
54+
$commands->add('twig-view compile', CompileCommand::class);
55+
}
5056

5157
return $commands;
5258
}

0 commit comments

Comments
 (0)