EC-CUBE Controller Twig Navigator
EC-CUBE Controller Twig Navigator is a Visual Studio Code extension that helps you move between PHP controller actions and Twig templates without leaving the editor.
Features
- Open the Twig template referenced by the current EC-CUBE controller action from the editor context menu.
- Open the controller action that renders the current Twig file from the editor context menu.
- Check
/app/Customize/Controller/ first when moving from Twig to a controller, then fall back to /src/Eccube/Controller/.
- Check
/app/template/<your-directory-name>/ first when moving from a controller to Twig, then fall back to /app/template/default/.
- Handles common
render(), renderView(), @Template(...), and #[Template(...)] patterns.
- Opens a Quick Pick list when multiple matches are found or when an automatic match cannot be resolved.
Workspace setting
If .vscode/settings.json does not exist, the extension creates it automatically and shows a VS Code notification.
Set the preferred EC-CUBE template directory in your workspace .vscode/settings.json.
{
"ecCubeNavigator.templateDirectoryName": "custom_theme"
}
The sample file created by the extension looks like this:
{
"ecCubeNavigator.templateDirectoryName": "custom_theme"
}
The extension uses these template search rules:
/app/template/<ecCubeNavigator.templateDirectoryName>/ when that directory exists
/app/template/default/ when that directory exists
/src/Eccube/Resource/template/default/ only when neither app template directory exists
How it works
From a controller action to Twig
Open a PHP controller file, place the cursor inside an action, right-click, and choose EC-CUBE: Open Related Twig Template.
The extension scans the current action, looks for Twig references such as the examples below, and searches in this order:
/app/template/<ecCubeNavigator.templateDirectoryName>/ when it exists
/app/template/default/ when it exists
/src/Eccube/Resource/template/default/ only when both app template directories do not exist
Supported controller patterns include:
$this->render('Product/detail.twig', ...)
$this->renderView('Product/detail.twig', ...)
@Template("Product/detail.twig")
#[Template('Product/detail.twig')]
You can also right-click directly on the @Template("Section/action.twig") reference inside a controller file and jump from that template string.
From Twig to a controller action
Open a Twig template, right-click, and choose EC-CUBE: Open Related Controller Action.
The extension searches controller actions in this order:
/app/Customize/Controller/ when it exists
/src/Eccube/Controller/
If a match is found in the customize controller directory, the core controller directory is not searched. If the customize controller directory does not exist, the extension searches only the core controller directory.
If the extension finds multiple matches, or if it cannot resolve a direct match automatically, it opens a VS Code Quick Pick list so you can choose the target manually.
Quick Pick results are sorted by relevance. For example, an action named guide prefers Twig files whose names include guide, privacy.twig prefers controller actions related to privacy, and @Template("Forgot/index.twig") gives priority to Forgot before the generic index filename.
Notes
- The extension matches templates by normalized Twig path suffix inside the EC-CUBE directories listed above.
- If your project uses a custom rendering flow that does not include a Twig path string in the controller source, the extension may not find a match.
Repository