mirror of
https://github.com/flarum/core.git
synced 2025-06-06 06:35:09 +02:00
parent
c99c83435b
commit
e0790de2e5
@ -1,10 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Require the extension's composer autoload file. This will enable all of our
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
// classes in the src directory to be autoloaded.
|
use {{namespace}}\Listener;
|
||||||
require __DIR__.'/vendor/autoload.php';
|
|
||||||
|
|
||||||
// Return the name of our Extension class. Flarum will register it as a service
|
// Return a function that registers the extension with Flarum. This is
|
||||||
// provider, allowing it to register bindings and execute code when the
|
// the place to listen to events, register bindings with the container
|
||||||
// application boots.
|
// and execute code when the application boots.
|
||||||
return '{{namespace}}\Extension';
|
//
|
||||||
|
// Any typehinted argument of this function is automatically resolved
|
||||||
|
// by the IoC container.
|
||||||
|
return function (Dispatcher $events) {
|
||||||
|
$events->subscribe(Listener\AddClientAssets::class);
|
||||||
|
};
|
||||||
|
@ -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:
|
|
@ -1,12 +0,0 @@
|
|||||||
<?php namespace {{namespace}};
|
|
||||||
|
|
||||||
use Flarum\Support\Extension as BaseExtension;
|
|
||||||
use Illuminate\Events\Dispatcher;
|
|
||||||
|
|
||||||
class Extension extends BaseExtension
|
|
||||||
{
|
|
||||||
public function listen(Dispatcher $events)
|
|
||||||
{
|
|
||||||
$events->subscribe('{{namespace}}\Listeners\AddClientAssets');
|
|
||||||
}
|
|
||||||
}
|
|
31
stubs/extension/src/Listener/AddClientAssets.php
Executable file
31
stubs/extension/src/Listener/AddClientAssets.php
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
<?php namespace {{namespace}}\Listener;
|
||||||
|
|
||||||
|
use Flarum\Event\ConfigureClientView;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
|
class AddClientAssets
|
||||||
|
{
|
||||||
|
public function subscribe(Dispatcher $events)
|
||||||
|
{
|
||||||
|
$events->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
<?php namespace {{namespace}}\Listeners;
|
|
||||||
|
|
||||||
use Flarum\Event\ConfigureLocales;
|
|
||||||
use Flarum\Event\ConfigureClientView;
|
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
class AddClientAssets
|
|
||||||
{
|
|
||||||
public function subscribe(Dispatcher $events)
|
|
||||||
{
|
|
||||||
$events->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'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user