From c9bf15abd2e02dd6dd5469170dedb396a48b1786 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 20 Jan 2016 22:13:55 +0100 Subject: [PATCH] Update extension skeleton Closes #743. --- framework/core/stubs/extension/bootstrap.php | 18 +++++--- framework/core/stubs/extension/locale/en.yml | 28 ------------ .../core/stubs/extension/src/Extension.php | 12 ----- .../src/Listener/AddClientAssets.php | 31 +++++++++++++ .../src/Listeners/AddClientAssets.php | 44 ------------------- 5 files changed, 42 insertions(+), 91 deletions(-) delete mode 100644 framework/core/stubs/extension/locale/en.yml delete mode 100644 framework/core/stubs/extension/src/Extension.php create mode 100755 framework/core/stubs/extension/src/Listener/AddClientAssets.php delete mode 100755 framework/core/stubs/extension/src/Listeners/AddClientAssets.php diff --git a/framework/core/stubs/extension/bootstrap.php b/framework/core/stubs/extension/bootstrap.php index 891396609..b0c515f41 100644 --- a/framework/core/stubs/extension/bootstrap.php +++ b/framework/core/stubs/extension/bootstrap.php @@ -1,10 +1,14 @@ subscribe(Listener\AddClientAssets::class); +}; diff --git a/framework/core/stubs/extension/locale/en.yml b/framework/core/stubs/extension/locale/en.yml deleted file mode 100644 index 5365c6ce2..000000000 --- a/framework/core/stubs/extension/locale/en.yml +++ /dev/null @@ -1,28 +0,0 @@ -{{name}}: - - ## - # UNIQUE KEYS - The following keys are used in only one location each. - ## - - # Translations in this namespace are used by the admin interface. - admin: - - # These keys are provided as examples. Delete them before using this template! - sample_location: - sample_text: "Hello, world!" - - - # Translations in this namespace are used by the forum user interface. - forum: - - - # Translations in this namespace are used by the forum and admin interfaces. - lib: - - - ## - # REUSED TRANSLATIONS - These keys should not be used directly in code! - ## - - # Translations in this namespace are referenced by two or more unique keys. - ref: diff --git a/framework/core/stubs/extension/src/Extension.php b/framework/core/stubs/extension/src/Extension.php deleted file mode 100644 index 83f95a156..000000000 --- a/framework/core/stubs/extension/src/Extension.php +++ /dev/null @@ -1,12 +0,0 @@ -subscribe('{{namespace}}\Listeners\AddClientAssets'); - } -} diff --git a/framework/core/stubs/extension/src/Listener/AddClientAssets.php b/framework/core/stubs/extension/src/Listener/AddClientAssets.php new file mode 100755 index 000000000..ef50f559f --- /dev/null +++ b/framework/core/stubs/extension/src/Listener/AddClientAssets.php @@ -0,0 +1,31 @@ +listen(ConfigureClientView::class, [$this, 'addAssets']); + } + + public function addAssets(ConfigureClientView $event) + { + if ($event->isForum()) { + $event->addAssets([ + __DIR__.'/../../js/forum/dist/extension.js', + __DIR__.'/../../less/forum/extension.less', + ]); + $event->addBootstrapper('{{name}}/main'); + } + + if ($event->isAdmin()) { + $event->addAssets([ + __DIR__.'/../../js/admin/dist/extension.js', + __DIR__.'/../../less/admin/extension.less', + ]); + $event->addBootstrapper('{{name}}/main'); + } + } +} diff --git a/framework/core/stubs/extension/src/Listeners/AddClientAssets.php b/framework/core/stubs/extension/src/Listeners/AddClientAssets.php deleted file mode 100755 index 30afb7e9a..000000000 --- a/framework/core/stubs/extension/src/Listeners/AddClientAssets.php +++ /dev/null @@ -1,44 +0,0 @@ -listen(ConfigureLocales::class, [$this, 'addLocale']); - $events->listen(ConfigureClientView::class, [$this, 'addAssets']); - } - - public function addLocale(ConfigureLocales $event) - { - $event->addTranslations('en', __DIR__.'/../../locale/en.yml'); - } - - public function addAssets(ConfigureClientView $event) - { - $event->forumAssets([ - __DIR__.'/../../js/forum/dist/extension.js', - __DIR__.'/../../less/forum/extension.less' - ]); - - $event->forumBootstrapper('{{name}}/main'); - - $event->forumTranslations([ - // '{{name}}.hello_world' - ]); - - $event->adminAssets([ - __DIR__.'/../../js/admin/dist/extension.js', - __DIR__.'/../../less/admin/extension.less' - ]); - - $event->adminBootstrapper('{{name}}/main'); - - $event->adminTranslations([ - // '{{name}}.hello_world' - ]); - } -}