diff --git a/extensions/approval/.gitignore b/extensions/approval/.gitignore index a4f3b125e..43eeee7fe 100644 --- a/extensions/approval/.gitignore +++ b/extensions/approval/.gitignore @@ -2,3 +2,5 @@ composer.phar .DS_Store Thumbs.db +bower_components +node_modules \ No newline at end of file diff --git a/extensions/approval/bootstrap.php b/extensions/approval/bootstrap.php index 6c3da11ab..7bee97308 100644 --- a/extensions/approval/bootstrap.php +++ b/extensions/approval/bootstrap.php @@ -1,5 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -return 'Flarum\Approval\Extension'; +use Flarum\Approval\Listener; +use Illuminate\Contracts\Events\Dispatcher; + +return function (Dispatcher $events) { + $events->subscribe(Listener\AddClientAssets::class); + $events->subscribe(Listener\AddPostApprovalAttributes::class); + $events->subscribe(Listener\ApproveContent::class); + $events->subscribe(Listener\HideUnapprovedContent::class); + $events->subscribe(Listener\UnapproveNewContent::class); +}; \ No newline at end of file diff --git a/extensions/approval/build.sh b/extensions/approval/build.sh deleted file mode 100644 index 4008b5c46..000000000 --- a/extensions/approval/build.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -base=${PWD} - -if [ ! -f flarum.json ]; then -echo "Could not find flarum.json file!" -exit 1 -fi - - -extension=$(php < ${release}/release.zip - -cd ${release} -unzip release.zip -d ./ -rm release.zip - -# Delete files -rm -rf ${release}/build.sh - -# Install all Composer dependencies -composer install --prefer-dist --optimize-autoloader --ignore-platform-reqs --no-dev - -cd "${release}/js" -if [ -f bower.json ]; then -bower install -fi - -for app in forum admin; do - cd "${release}/js" - - if [ -d $app ]; then - cd $app - - if [ -f bower.json ]; then - bower install - fi - - npm install - gulp --production - rm -rf node_modules bower_components - fi -done - -rm -rf "${release}/extensions/${extension}/js/bower_components" -wait - -# Finally, create the release archive -cd ${release} -find . -type d -exec chmod 0750 {} + -find . -type f -exec chmod 0644 {} + -chmod 0775 . -zip -r ${extension}.zip ./ -mv ${extension}.zip ${base}/${extension}.zip diff --git a/extensions/approval/composer.json b/extensions/approval/composer.json index c663295f7..4dff14668 100644 --- a/extensions/approval/composer.json +++ b/extensions/approval/composer.json @@ -1,7 +1,35 @@ { + "name": "flarum/approval", + "description": "Make discussions and posts require moderator approval.", + "type": "flarum-extension", + "license": "MIT", + "authors": [ + { + "name": "Toby Zerner", + "email": "toby.zerner@gmail.com" + } + ], + "support": { + "issues": "https://github.com/flarum/core/issues", + "source": "https://github.com/flarum/approval" + }, + "require": { + "flarum/core": "^0.1.0-beta.3", + "flarum/flags": "^0.1.0-beta.3" + }, "autoload": { "psr-4": { "Flarum\\Approval\\": "src/" } + }, + "extra": { + "flarum-extension": { + "title": "Approval", + "icon": { + "name": "check", + "backgroundColor": "green", + "color": "#fff" + } + } } } diff --git a/extensions/approval/flarum.json b/extensions/approval/flarum.json deleted file mode 100644 index 8bde180d1..000000000 --- a/extensions/approval/flarum.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "approval", - "title": "Approval", - "description": "Make discussions and posts require moderator approval.", - "keywords": [], - "version": "0.1.0-beta.2", - "author": { - "name": "Toby Zerner", - "email": "toby@flarum.org", - "homepage": "http://tobyzerner.com" - }, - "license": "MIT", - "require": { - "flarum": ">=0.1.0-beta.2", - "reports": ">=0.1.0-beta.2" - }, - "icon": { - "name": "check", - "backgroundColor": "green", - "color": "#fff" - } -} diff --git a/extensions/approval/js/.gitignore b/extensions/approval/js/.gitignore deleted file mode 100644 index 372e20a51..000000000 --- a/extensions/approval/js/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -bower_components -node_modules -dist diff --git a/extensions/approval/js/admin/Gulpfile.js b/extensions/approval/js/admin/Gulpfile.js index 2b986bd70..3e096c0be 100644 --- a/extensions/approval/js/admin/Gulpfile.js +++ b/extensions/approval/js/admin/Gulpfile.js @@ -2,6 +2,6 @@ var gulp = require('flarum-gulp'); gulp({ modules: { - 'approval': 'src/**/*.js' + 'flarum/approval': 'src/**/*.js' } }); diff --git a/extensions/approval/js/admin/dist/extension.js b/extensions/approval/js/admin/dist/extension.js new file mode 100644 index 000000000..07f3d6c8e --- /dev/null +++ b/extensions/approval/js/admin/dist/extension.js @@ -0,0 +1,34 @@ +System.register('flarum/approval/main', ['flarum/extend', 'flarum/app', 'flarum/components/PermissionGrid'], function (_export) { + 'use strict'; + + var extend, app, PermissionGrid; + return { + setters: [function (_flarumExtend) { + extend = _flarumExtend.extend; + }, function (_flarumApp) { + app = _flarumApp['default']; + }, function (_flarumComponentsPermissionGrid) { + PermissionGrid = _flarumComponentsPermissionGrid['default']; + }], + execute: function () { + + app.initializers.add('approval', function () { + extend(PermissionGrid.prototype, 'replyItems', function (items) { + items.add('replyWithoutApproval', { + icon: 'check', + label: 'Reply without approval', + permission: 'discussion.replyWithoutApproval' + }, 95); + }); + + extend(PermissionGrid.prototype, 'moderateItems', function (items) { + items.add('approvePosts', { + icon: 'check', + label: 'Approve posts', + permission: 'discussion.approvePosts' + }, 65); + }); + }); + } + }; +}); \ No newline at end of file diff --git a/extensions/approval/js/forum/Gulpfile.js b/extensions/approval/js/forum/Gulpfile.js index 2b986bd70..3e096c0be 100644 --- a/extensions/approval/js/forum/Gulpfile.js +++ b/extensions/approval/js/forum/Gulpfile.js @@ -2,6 +2,6 @@ var gulp = require('flarum-gulp'); gulp({ modules: { - 'approval': 'src/**/*.js' + 'flarum/approval': 'src/**/*.js' } }); diff --git a/extensions/approval/js/forum/dist/extension.js b/extensions/approval/js/forum/dist/extension.js new file mode 100644 index 000000000..206435ac0 --- /dev/null +++ b/extensions/approval/js/forum/dist/extension.js @@ -0,0 +1,74 @@ +System.register('flarum/approval/main', ['flarum/extend', 'flarum/app', 'flarum/models/Discussion', 'flarum/models/Post', 'flarum/components/DiscussionListItem', 'flarum/components/CommentPost', 'flarum/components/Button', 'flarum/utils/PostControls'], function (_export) { + 'use strict'; + + var extend, override, app, Discussion, Post, DiscussionListItem, CommentPost, Button, PostControls; + return { + setters: [function (_flarumExtend) { + extend = _flarumExtend.extend; + override = _flarumExtend.override; + }, function (_flarumApp) { + app = _flarumApp['default']; + }, function (_flarumModelsDiscussion) { + Discussion = _flarumModelsDiscussion['default']; + }, function (_flarumModelsPost) { + Post = _flarumModelsPost['default']; + }, function (_flarumComponentsDiscussionListItem) { + DiscussionListItem = _flarumComponentsDiscussionListItem['default']; + }, function (_flarumComponentsCommentPost) { + CommentPost = _flarumComponentsCommentPost['default']; + }, function (_flarumComponentsButton) { + Button = _flarumComponentsButton['default']; + }, function (_flarumUtilsPostControls) { + PostControls = _flarumUtilsPostControls['default']; + }], + execute: function () { + + app.initializers.add('flarum-approval', function () { + Discussion.prototype.isApproved = Discussion.attribute('isApproved'); + + Post.prototype.isApproved = Post.attribute('isApproved'); + Post.prototype.canApprove = Post.attribute('canApprove'); + + extend(DiscussionListItem.prototype, 'attrs', function (attrs) { + if (!this.props.discussion.isApproved()) { + attrs.className += ' DiscussionListItem--unapproved'; + } + }); + + extend(CommentPost.prototype, 'attrs', function (attrs) { + if (!this.props.post.isApproved() && !this.props.post.isHidden()) { + attrs.className += ' CommentPost--unapproved'; + } + }); + + extend(CommentPost.prototype, 'headerItems', function (items) { + if (!this.props.post.isApproved() && !this.props.post.isHidden()) { + items.add('unapproved', 'Awaiting Approval'); + } + }); + + override(CommentPost.prototype, 'flagReason', function (original, flag) { + if (flag.type() === 'approval') { + return 'Awaiting approval'; + } + + return original(flag); + }); + + extend(PostControls, 'destructiveControls', function (items, post) { + if (!post.isApproved() && post.canApprove()) { + items.add('approve', m( + Button, + { icon: 'check', onclick: PostControls.approveAction.bind(post) }, + 'Approve' + ), 10); + } + }); + + PostControls.approveAction = function () { + this.save({ isApproved: true }); + }; + }, -10); // set initializer priority to run after reports + } + }; +}); \ No newline at end of file diff --git a/extensions/approval/js/forum/src/main.js b/extensions/approval/js/forum/src/main.js index 23cb23551..95411e1f0 100644 --- a/extensions/approval/js/forum/src/main.js +++ b/extensions/approval/js/forum/src/main.js @@ -7,7 +7,7 @@ import CommentPost from 'flarum/components/CommentPost'; import Button from 'flarum/components/Button'; import PostControls from 'flarum/utils/PostControls'; -app.initializers.add('approval', () => { +app.initializers.add('flarum-approval', () => { Discussion.prototype.isApproved = Discussion.attribute('isApproved'); Post.prototype.isApproved = Post.attribute('isApproved'); diff --git a/extensions/approval/less/admin/extension.less b/extensions/approval/less/admin/extension.less deleted file mode 100644 index e69de29bb..000000000 diff --git a/extensions/approval/locale/en.yml b/extensions/approval/locale/en.yml deleted file mode 100644 index f9584dd98..000000000 --- a/extensions/approval/locale/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -approval: - # hello_world: "Hello, world!" diff --git a/extensions/approval/migrations/2015_09_21_011527_add_is_approved_to_discussions.php b/extensions/approval/migrations/2015_09_21_011527_add_is_approved_to_discussions.php index 9ad21fdf2..349d4a980 100644 --- a/extensions/approval/migrations/2015_09_21_011527_add_is_approved_to_discussions.php +++ b/extensions/approval/migrations/2015_09_21_011527_add_is_approved_to_discussions.php @@ -1,17 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -namespace Flarum\Migrations\Approval; +namespace Flarum\Approval\Migration; +use Flarum\Database\AbstractMigration; use Illuminate\Database\Schema\Blueprint; -use Flarum\Migrations\Migration; -class AddIsApprovedToDiscussions extends Migration +class AddIsApprovedToDiscussions extends AbstractMigration { - /** - * Run the migrations. - * - * @return void - */ public function up() { $this->schema->table('discussions', function (Blueprint $table) { @@ -19,11 +22,6 @@ class AddIsApprovedToDiscussions extends Migration }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down() { $this->schema->table('discussions', function (Blueprint $table) { diff --git a/extensions/approval/migrations/2015_09_21_011706_add_is_approved_to_posts.php b/extensions/approval/migrations/2015_09_21_011706_add_is_approved_to_posts.php index cf44672eb..8098ca3a2 100644 --- a/extensions/approval/migrations/2015_09_21_011706_add_is_approved_to_posts.php +++ b/extensions/approval/migrations/2015_09_21_011706_add_is_approved_to_posts.php @@ -1,17 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -namespace Flarum\Migrations\Approval; +namespace Flarum\Approval\Migration; +use Flarum\Database\AbstractMigration; use Illuminate\Database\Schema\Blueprint; -use Flarum\Migrations\Migration; -class AddIsApprovedToPosts extends Migration +class AddIsApprovedToPosts extends AbstractMigration { - /** - * Run the migrations. - * - * @return void - */ public function up() { $this->schema->table('posts', function (Blueprint $table) { @@ -19,11 +22,6 @@ class AddIsApprovedToPosts extends Migration }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down() { $this->schema->table('posts', function (Blueprint $table) { diff --git a/extensions/approval/scripts/compile.sh b/extensions/approval/scripts/compile.sh new file mode 100755 index 000000000..ce574c9bd --- /dev/null +++ b/extensions/approval/scripts/compile.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# This script compiles the extension so that it can be used in a Flarum +# installation. It should be run from the root directory of the extension. + +base=$PWD + +composer install --prefer-dist --optimize-autoloader --ignore-platform-reqs --no-dev + +cd "${base}/js" + +if [ -f bower.json ]; then + bower install +fi + +for app in forum admin; do + cd "${base}/js" + + if [ -d $app ]; then + cd $app + + if [ -f bower.json ]; then + bower install + fi + + npm install + gulp --production + fi +done diff --git a/extensions/approval/src/Events/PostWasApproved.php b/extensions/approval/src/Event/PostWasApproved.php similarity index 88% rename from extensions/approval/src/Events/PostWasApproved.php rename to extensions/approval/src/Event/PostWasApproved.php index 165d716a6..3dcb49b36 100644 --- a/extensions/approval/src/Events/PostWasApproved.php +++ b/extensions/approval/src/Event/PostWasApproved.php @@ -8,9 +8,9 @@ * file that was distributed with this source code. */ -namespace Flarum\Approval\Events; +namespace Flarum\Approval\Event; -use Flarum\Core\Posts\Post; +use Flarum\Core\Post; class PostWasApproved { diff --git a/extensions/approval/src/Extension.php b/extensions/approval/src/Extension.php deleted file mode 100644 index abb61f68b..000000000 --- a/extensions/approval/src/Extension.php +++ /dev/null @@ -1,16 +0,0 @@ -subscribe('Flarum\Approval\Listeners\AddClientAssets'); - $events->subscribe('Flarum\Approval\Listeners\AddApiAttributes'); - $events->subscribe('Flarum\Approval\Listeners\HideUnapprovedContent'); - $events->subscribe('Flarum\Approval\Listeners\UnapproveNewContent'); - $events->subscribe('Flarum\Approval\Listeners\ApproveContent'); - } -} diff --git a/extensions/approval/src/Listener/AddClientAssets.php b/extensions/approval/src/Listener/AddClientAssets.php new file mode 100644 index 000000000..8d8fc28c8 --- /dev/null +++ b/extensions/approval/src/Listener/AddClientAssets.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Approval\Listener; + +use Flarum\Event\ConfigureClientView; +use Illuminate\Contracts\Events\Dispatcher; + +class AddClientAssets +{ + /** + * @param Dispatcher $events + */ + public function subscribe(Dispatcher $events) + { + $events->listen(ConfigureClientView::class, [$this, 'addAssets']); + } + + /** + * @param ConfigureClientView $event + */ + public function addAssets(ConfigureClientView $event) + { + if ($event->isForum()) { + $event->addAssets([ + __DIR__.'/../../js/forum/dist/extension.js', + __DIR__.'/../../less/forum/extension.less' + ]); + $event->addBootstrapper('flarum/approval/main'); + $event->addTranslations('flarum-approval.forum'); + } + + if ($event->isAdmin()) { + $event->addAssets([ + __DIR__ . '/../../js/admin/dist/extension.js' + ]); + $event->addBootstrapper('flarum/approval/main'); + $event->addTranslations('flarum-approval.admin'); + } + } +} diff --git a/extensions/approval/src/Listener/AddPostApprovalAttributes.php b/extensions/approval/src/Listener/AddPostApprovalAttributes.php new file mode 100644 index 000000000..0d4873e09 --- /dev/null +++ b/extensions/approval/src/Listener/AddPostApprovalAttributes.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Approval\Listener; + +use Flarum\Event\PrepareApiAttributes; +use Flarum\Api\Serializer\DiscussionSerializer; +use Flarum\Api\Serializer\PostSerializer; +use Illuminate\Contracts\Events\Dispatcher; + +class AddPostApprovalAttributes +{ + /** + * @param Dispatcher $events + */ + public function subscribe(Dispatcher $events) + { + $events->listen(PrepareApiAttributes::class, [$this, 'addApiAttributes']); + } + + /** + * @param PrepareApiAttributes $event + */ + public function addApiAttributes(PrepareApiAttributes $event) + { + if ($event->isSerializer(DiscussionSerializer::class) + || $event->isSerializer(PostSerializer::class)) { + $event->attributes['isApproved'] = (bool) $event->model->is_approved; + } + + if ($event->isSerializer(PostSerializer::class)) { + $event->attributes['canApprove'] = (bool) $event->actor->can('approvePosts', $event->model->discussion); + } + } +} diff --git a/extensions/approval/src/Listeners/ApproveContent.php b/extensions/approval/src/Listener/ApproveContent.php similarity index 59% rename from extensions/approval/src/Listeners/ApproveContent.php rename to extensions/approval/src/Listener/ApproveContent.php index a3cca9637..327322085 100644 --- a/extensions/approval/src/Listeners/ApproveContent.php +++ b/extensions/approval/src/Listener/ApproveContent.php @@ -1,27 +1,46 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -use Flarum\Events\PostWillBeSaved; -use Flarum\Approval\Events\PostWasApproved; +namespace Flarum\Approval\Listener; + +use Flarum\Approval\Event\PostWasApproved; +use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\Event\PostWillBeSaved; use Illuminate\Contracts\Events\Dispatcher; class ApproveContent { + use AssertPermissionTrait; + + /** + * @param Dispatcher $events + */ public function subscribe(Dispatcher $events) { $events->listen(PostWillBeSaved::class, [$this, 'approvePost']); $events->listen(PostWasApproved::class, [$this, 'approveDiscussion']); } + /** + * @param PostWillBeSaved $event + */ public function approvePost(PostWillBeSaved $event) { $attributes = $event->data['attributes']; $post = $event->post; if (isset($attributes['isApproved'])) { - $post->assertCan($event->actor, 'approve'); + $this->assertCan($event->actor, 'approve', $post); $isApproved = (bool) $attributes['isApproved']; - } elseif (! empty($attributes['isHidden']) && $post->can($event->actor, 'approve')) { + } elseif (! empty($attributes['isHidden']) && $event->actor->can('approve', $post)) { $isApproved = true; } @@ -32,6 +51,9 @@ class ApproveContent } } + /** + * @param PostWasApproved $event + */ public function approveDiscussion(PostWasApproved $event) { $post = $event->post; diff --git a/extensions/approval/src/Listeners/HideUnapprovedContent.php b/extensions/approval/src/Listener/HideUnapprovedContent.php similarity index 51% rename from extensions/approval/src/Listeners/HideUnapprovedContent.php rename to extensions/approval/src/Listener/HideUnapprovedContent.php index ee975cb71..042f93f5b 100644 --- a/extensions/approval/src/Listeners/HideUnapprovedContent.php +++ b/extensions/approval/src/Listener/HideUnapprovedContent.php @@ -1,19 +1,48 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -use Flarum\Events\ScopeModelVisibility; -use Flarum\Events\ScopePostVisibility; -use Flarum\Events\ScopeHiddenDiscussionVisibility; -use Flarum\Core\Discussions\Discussion; +namespace Flarum\Approval\Listener; + +use Flarum\Event\ScopeModelVisibility; +use Flarum\Event\ScopePostVisibility; +use Flarum\Event\ScopeHiddenDiscussionVisibility; +use Flarum\Core\Discussion; use Illuminate\Contracts\Events\Dispatcher; class HideUnapprovedContent { + /** + * @var Dispatcher + */ + protected $events; + + /** + * @param Dispatcher $events + */ + public function __construct(Dispatcher $events) + { + $this->events = $events; + } + + /** + * @param Dispatcher $events + */ public function subscribe(Dispatcher $events) { $events->listen(ScopeModelVisibility::class, [$this, 'hideUnapprovedDiscussions']); $events->listen(ScopePostVisibility::class, [$this, 'hideUnapprovedPosts']); } + /** + * @param ScopeModelVisibility $event + */ public function hideUnapprovedDiscussions(ScopeModelVisibility $event) { if ($event->model instanceof Discussion) { @@ -24,15 +53,20 @@ class HideUnapprovedContent $query->where('discussions.is_approved', 1) ->orWhere('start_user_id', $user->id); - event(new ScopeHiddenDiscussionVisibility($query, $user, 'discussion.editPosts')); + $this->events->fire( + new ScopeHiddenDiscussionVisibility($query, $user, 'discussion.editPosts') + ); }); } } } + /** + * @param ScopePostVisibility $event + */ public function hideUnapprovedPosts(ScopePostVisibility $event) { - if ($event->discussion->can($event->actor, 'editPosts')) { + if ($event->actor->can('editPosts', $event->discussion)) { return; } diff --git a/extensions/approval/src/Listeners/UnapproveNewContent.php b/extensions/approval/src/Listener/UnapproveNewContent.php similarity index 68% rename from extensions/approval/src/Listeners/UnapproveNewContent.php rename to extensions/approval/src/Listener/UnapproveNewContent.php index d0d9c49ba..2b7f41b44 100644 --- a/extensions/approval/src/Listeners/UnapproveNewContent.php +++ b/extensions/approval/src/Listener/UnapproveNewContent.php @@ -1,24 +1,38 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -use Flarum\Events\PostWillBeSaved; +namespace Flarum\Approval\Listener; + +use Flarum\Event\PostWillBeSaved; use Flarum\Flags\Flag; use Illuminate\Contracts\Events\Dispatcher; class UnapproveNewContent { - private $savingPost; - + /** + * @param Dispatcher $events + */ public function subscribe(Dispatcher $events) { $events->listen(PostWillBeSaved::class, [$this, 'unapproveNewPosts']); } + /** + * @param PostWillBeSaved $event + */ public function unapproveNewPosts(PostWillBeSaved $event) { $post = $event->post; if (! $post->exists) { - if ($post->discussion->can($event->actor, 'replyWithoutApproval')) { + if ($event->actor->can('replyWithoutApproval', $post->discussion)) { if ($post->is_approved === null) { $post->is_approved = true; } diff --git a/extensions/approval/src/Listeners/AddApiAttributes.php b/extensions/approval/src/Listeners/AddApiAttributes.php deleted file mode 100644 index 684af8c07..000000000 --- a/extensions/approval/src/Listeners/AddApiAttributes.php +++ /dev/null @@ -1,26 +0,0 @@ -listen(ApiAttributes::class, [$this, 'addApiAttributes']); - } - - public function addApiAttributes(ApiAttributes $event) - { - if ($event->serializer instanceof DiscussionSerializer || - $event->serializer instanceof PostSerializer) { - $event->attributes['isApproved'] = (bool) $event->model->is_approved; - } - - if ($event->serializer instanceof PostSerializer) { - $event->attributes['canApprove'] = (bool) $event->model->discussion->can($event->actor, 'approvePosts'); - } - } -} diff --git a/extensions/approval/src/Listeners/AddClientAssets.php b/extensions/approval/src/Listeners/AddClientAssets.php deleted file mode 100644 index 18bae640b..000000000 --- a/extensions/approval/src/Listeners/AddClientAssets.php +++ /dev/null @@ -1,44 +0,0 @@ -listen(RegisterLocales::class, [$this, 'addLocale']); - $events->listen(BuildClientView::class, [$this, 'addAssets']); - } - - public function addLocale(RegisterLocales $event) - { - $event->addTranslations('en', __DIR__.'/../../locale/en.yml'); - } - - public function addAssets(BuildClientView $event) - { - $event->forumAssets([ - __DIR__.'/../../js/forum/dist/extension.js', - __DIR__.'/../../less/forum/extension.less' - ]); - - $event->forumBootstrapper('approval/main'); - - $event->forumTranslations([ - // 'approval.hello_world' - ]); - - $event->adminAssets([ - __DIR__.'/../../js/admin/dist/extension.js', - __DIR__.'/../../less/admin/extension.less' - ]); - - $event->adminBootstrapper('approval/main'); - - $event->adminTranslations([ - // 'approval.hello_world' - ]); - } -}