Skip to content
Merged
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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"source": "https://github.com/cakephp/twig-view"
},
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^5.0.0",
"jasny/twig-extensions": "^1.3",
"twig/markdown-extra": "^3.0",
Expand Down Expand Up @@ -50,8 +51,8 @@
}
},
"scripts": {
"cs-check": "phpcs --colors --parallel=16 -p src/ tests/",
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/",
"cs-check": "phpcs --colors --parallel=16 -p",
"cs-fix": "phpcbf --colors --parallel=16 -p",
"phpstan": "tools/phpstan analyse",
"stan": "@phpstan",
"phpstan-baseline": "tools/phpstan --generate-baseline",
Expand Down
31 changes: 31 additions & 0 deletions config/app.example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* CakePHP TwigView Plugin - Example Configuration
*
* Copy the relevant settings to your application's config/app.php or config/app_local.php.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://opensource.org/licenses/mit-license.php MIT License
*/

return [
/**
* TwigView Plugin Configuration
*
* These settings control the behavior of the TwigView plugin.
*/
'TwigView' => [
/**
* Use underscore command names.
*
* When `true`, registers `twig_view compile` (with underscore).
* When `false` or not set, registers `twig-view compile` (deprecated, with hyphen).
*
* Upgrade path:
* 1. Update your scripts/CI to use `twig_view compile`
* 2. Set this to `true`
*/
'useUnderscoreCommands' => true,
],
];
3 changes: 3 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0"?>
<ruleset name="TwigView">
<file>src/</file>
<file>tests/</file>

<rule ref="CakePHP"/>
</ruleset>
8 changes: 7 additions & 1 deletion src/TwigViewPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use Cake\Console\CommandCollection;
use Cake\Core\BasePlugin;
use Cake\Core\Configure;
use Cake\TwigView\Command\CompileCommand;

/**
Expand All @@ -46,7 +47,12 @@ class TwigViewPlugin extends BasePlugin
*/
public function console(CommandCollection $commands): CommandCollection
{
$commands->add('twig-view compile', CompileCommand::class);
if (Configure::read('TwigView.useUnderscoreCommands')) {
$commands->add('twig_view compile', CompileCommand::class);
} else {
// Deprecated: use `'TwigView.useUnderscoreCommands' => true` to switch to `twig_view compile`
$commands->add('twig-view compile', CompileCommand::class);
}

return $commands;
}
Expand Down