Skip to content

Commit

Permalink
fix sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiewebb committed Jul 26, 2020
1 parent 4aeb701 commit 3c78dfc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
4 changes: 2 additions & 2 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Flarum\Extend;
use Webbinaro\AdvCalendar\Api\Controllers as ControllersAlias;
use Illuminate\Events\Dispatcher;
use Webbinaro\AdvCalendar\Integrations\EventResource;
use Webbinaro\AdvCalendar\Integrations\EventResourceRegister;
use Webbinaro\AdvCalendar\Integrations\SitemapsResource;
use Webbinaro\AdvCalendar\Listeners;

Expand Down Expand Up @@ -48,7 +48,7 @@
$events->subscribe(Listeners\AdvEventListener::class);
}),

new \FoF\Sitemap\Extend\RegisterResource(EventResource::class),
new EventResourceRegister(),

];

Expand Down
6 changes: 3 additions & 3 deletions js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions js/src/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import PermissionGrid from 'flarum/components/PermissionGrid';
import BasicsPage from 'flarum/components/BasicsPage';


app.initializers.add('webbinaro/adv-extras', () => {
console.log('[webbinaro/adv-extras] Hello, admin!');
app.initializers.add('webbinaro/flarum-calendar', () => {
console.log('[webbinaro/flarum-calendar] Hello, admin!');
extend(PermissionGrid.prototype, 'moderateItems', items => {
items.add(
'webbinaro-calendar',
Expand All @@ -30,7 +30,7 @@ app.initializers.add('webbinaro/adv-extras', () => {
);
});

app.extensionSettings['webbinaro/adv-extras'] = () =>
app.extensionSettings['flarum-calendar'] = () =>
app.modal.show(
new SettingsModal({
title: app.translator.trans('flarum-calendar.admin.title'),
Expand Down
35 changes: 35 additions & 0 deletions src/Integrations/EventResourceRegister.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php


namespace Webbinaro\AdvCalendar\Integrations;

use Flarum\Extend\ExtenderInterface;
use Flarum\Extension\Extension;
use FoF\Sitemap\Resources\Resource;
use Illuminate\Contracts\Container\Container;
use InvalidArgumentException;

/**
* Class EventResourceRegister
* @package Webbinaro\AdvCalendar\Integrations
* Purely a copy and workaround of the reigster function form fof/sitemaps
* until https://github.com/FriendsOfFlarum/sitemap/pull/15 is fixed
*/
class EventResourceRegister implements ExtenderInterface
{

public function extend(Container $container, Extension $extension = null)
{
$container->extend('fof.sitemap.resources', function (array $resources) use ($container) {
$resource = $container->make(EventResource::class);

if ($resource instanceof Resource) {
$resources[] = $resource;
} else {
throw new InvalidArgumentException("{EventResource::class} has to extend ".Resource::class);
}

return $resources;
});
}
}

0 comments on commit 3c78dfc

Please sign in to comment.