From 566c7694b57a0e4f5df44d2ffd8f247647a8e3f4 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 15 Apr 2021 11:42:45 +0000 Subject: [PATCH] [CONFIG][TWIG] Move twig config to php code to add support for placing templates in modules (plugins and components) --- config/packages/twig.yaml | 4 ---- src/Core/Modules/Module.php | 2 +- src/Kernel.php | 7 +++++++ 3 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 config/packages/twig.yaml diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml deleted file mode 100644 index 05ee15f67e..0000000000 --- a/config/packages/twig.yaml +++ /dev/null @@ -1,4 +0,0 @@ -twig: - paths: - '%kernel.project_dir%/templates': default_path - "%kernel.project_dir%/public": public_path \ No newline at end of file diff --git a/src/Core/Modules/Module.php b/src/Core/Modules/Module.php index aac565c4c9..a75a1894d9 100644 --- a/src/Core/Modules/Module.php +++ b/src/Core/Modules/Module.php @@ -62,7 +62,7 @@ abstract class Module if (!$note->isVisibleTo($user)) { // ^ Ensure user isn't trying to trip us up Log::error('Suspicious activity: user ' . $user->getNickname() . - ' tried to repeat note ' . $note->getId() . + ' tried to interact with note ' . $note->getId() . ', but they shouldn\'t have access to it'); throw new NoSuchNoteException(); } else { diff --git a/src/Kernel.php b/src/Kernel.php index b4ebc57e6c..5341933eac 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -112,6 +112,13 @@ class Kernel extends BaseKernel $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); + $module_templates = array_merge(glob(INSTALLDIR . '/components/*/templates'), glob(INSTALLDIR . '/plugins/*/templates')); + $templates = ['%kernel.project_dir%/templates' => 'default_path', '%kernel.project_dir%/public' => 'public_path']; + foreach ($module_templates as $t) { + $templates[$t] = null; + } + $container->loadFromExtension('twig', ['paths' => $templates]); + // Overriding doesn't work as we want, overrides the top-most key, do it manually $local_file = INSTALLDIR . '/social.local.yaml'; if (!file_exists($local_file)) {