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

EZP-30673: Fixed path to global template directory #20

Merged
merged 2 commits into from
Jul 1, 2019
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
4 changes: 2 additions & 2 deletions bundle/DependencyInjection/Compiler/TwigThemePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container)
return;
}

$globalViewsDir = $container->getParameter('kernel.root_dir') . '/Resources/views';
$globalViewsDir = $container->getParameter('twig.default_path');
if (!is_dir($globalViewsDir)) {
(new Filesystem())->mkdir($globalViewsDir);
}
Expand All @@ -54,7 +54,7 @@ public function process(ContainerBuilder $container)
}

$twigLoaderDef = $container->findDefinition('ezdesign.twig_theme_loader');
// Now look for themes at application level (app/Resources/views/themes)
// Now look for themes at application level
$appLevelThemesDir = $globalViewsDir . '/themes';
if (is_dir($appLevelThemesDir)) {
foreach ((new Finder())->directories()->in($appLevelThemesDir)->depth('== 0') as $directoryInfo) {
Expand Down
2 changes: 1 addition & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For assets, the system uses the Symfony Asset component with asset packages.

- **Theme**: Labeled collection of templates and assets.

Typically a directory containing templates. For example, templates located under `app/Resources/views/themes/my_theme`
Typically a directory containing templates. For example, templates located under `templates/themes/my_theme`
or `src/AppBundle/Resources/views/themes/my_theme` are part of `my_theme` theme.
- **Design**: Collection of themes.

Expand Down
12 changes: 6 additions & 6 deletions doc/templates.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Design usage with templates

By convention, a theme directory must be located under `<bundle_directory>/Resources/views/themes/` or global
`app/Resources/views/themes/` directories.
`templates/themes/` directories.

Typical paths can be for example:
- `app/Resources/views/themes/foo/` => Templates will be part of the `foo` theme.
- `app/Resources/views/themes/bar/` => Templates will be part of the `bar` theme.
- `templates/themes/foo/` => Templates will be part of the `foo` theme.
- `templates/themes/bar/` => Templates will be part of the `bar` theme.
- `src/AppBundle/Resources/views/themes/foo/` => Templates will be part of the `foo`theme.
- `src/Acme/TestBundle/Resources/views/themes/the_best/` => Templates will be part of `the_best` theme.

Expand Down Expand Up @@ -36,17 +36,17 @@ ezpublish:
## Fallback order

The default fallback order is:
- Application theme directory: `app/Resources/views/themes/<theme_name>/`
- Application theme directory: `templates/themes/<theme_name>/`
- Bundle theme directory: `src/<bundle_directory>/Resources/views/themes/<theme_name>/`

Prior to version 2.0 of this package, `app/Resources/views` was the top-level global override directory.
Prior to version 2.0 of this package, `templates` was the top-level global override directory.
This behavior is not recommended as it could affect both core features and third party bundles
which already use `@ezdesign`. However, if still needed, it can be achieved by the following configuration:

```yaml
ezdesign:
templates_override_paths:
- '%kernel.root_dir%/app/Resources/views'
- '%kernel.project_dir%/templates'
```

> Bundle fallback order is the instantiation order in `AppKernel`.
Expand Down