[COMPONENT][Subscription] Move respective routes to component

This commit is contained in:
Diogo Peralta Cordeiro 2022-01-04 21:52:24 +00:00
parent 5a0bbfc795
commit 754135743e
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
5 changed files with 25 additions and 110 deletions

View File

@ -49,12 +49,12 @@ class Subscribers extends CircleController
return $this->handleActorByNickname( return $this->handleActorByNickname(
$nickname, $nickname,
fn ($actor) => [ fn ($actor) => [
'_template' => 'collection/actors.html.twig', '_template' => 'collection/actors.html.twig',
'title' => _m('Subscribers'), 'title' => _m('Subscribers'),
'empty_message' => _m('No subscribers'), 'empty_message' => _m('No subscribers.'),
'sort_options' => [], 'sort_form_fields' => [],
'page' => $this->int('page') ?? 1, 'page' => $this->int('page') ?? 1,
'actors' => $actor->getSubscribers(), 'actors' => $actor->getSubscribers(),
], ],
); );
} }

View File

@ -49,12 +49,12 @@ class Subscriptions extends CircleController
return $this->handleActorByNickname( return $this->handleActorByNickname(
$nickname, $nickname,
fn ($actor) => [ fn ($actor) => [
'_template' => 'collection/actors.html.twig', '_template' => 'collection/actors.html.twig',
'title' => _m('Subscribers'), 'title' => _m('Subscriptions'),
'empty_message' => _m('No subscribers'), 'empty_message' => _m('Haven\'t subscribed anyone.'),
'sort_options' => [], 'sort_form_fields' => [],
'page' => $this->int('page') ?? 1, 'page' => $this->int('page') ?? 1,
'actors' => $actor->getSubscribers(), 'actors' => $actor->getSubscribers(),
], ],
); );
} }

View File

@ -27,13 +27,26 @@ use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use App\Util\Nickname;
use Component\Subscription\Controller\Subscribers;
use Component\Subscription\Controller\Subscriptions;
class Subscription extends Component class Subscription extends Component
{ {
public function onAddRoute(RouteLoader $r): bool
{
$r->connect(id: 'actor_subscriptions_id', uri_path: '/actor/{id<\d+>}/subscriptions', target: [Subscriptions::class, 'subscriptionsByActorId']);
$r->connect(id: 'actor_subscriptions_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/subscriptions', target: [Subscriptions::class, 'subscriptionsByActorNickname']);
$r->connect(id: 'actor_subscribers_id', uri_path: '/actor/{id<\d+>}/subscribers', target: [Subscribers::class, 'subscribersByActorId']);
$r->connect(id: 'actor_subscribers_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/subscribers', target: [Subscribers::class, 'subscribersByActorNickname']);
return Event::next;
}
/** /**
* Persists a new Subscription Entity from Subscriber to Subject (Actor being subscribed) and Activity * Persists a new Subscription Entity from Subscriber to Subject (Actor being subscribed) and Activity
* *

View File

@ -1,49 +0,0 @@
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
/**
* Define social's Actor's subscribers routes
*
* @package GNUsocial
* @category Router
*
* @author Diogo Cordeiro <mail@diogo.site>
* @copyright 2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Routes;
use App\Core\Router\RouteLoader;
use App\Util\Nickname;
use Component\Subscription\Controller as C;
abstract class Subscribers
{
public const LOAD_ORDER = 31;
public static function load(RouteLoader $r): void
{
$r->connect(id: 'actor_subscribers_id', uri_path: '/actor/{id<\d+>}/subscribers', target: [C\Subscribers::class, 'subscribersByActorId']);
$r->connect(id: 'actor_subscribers_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/subscribers', target: [C\Subscribers::class, 'subscribersByActorNickname']);
}
}

View File

@ -1,49 +0,0 @@
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
/**
* Define social's Actor's subscriptions routes
*
* @package GNUsocial
* @category Router
*
* @author Diogo Cordeiro <mail@diogo.site>
* @copyright 2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Routes;
use App\Core\Router\RouteLoader;
use App\Util\Nickname;
use Component\Subscription\Controller as C;
abstract class Subscriptions
{
public const LOAD_ORDER = 32;
public static function load(RouteLoader $r): void
{
$r->connect(id: 'actor_subscriptions_id', uri_path: '/actor/{id<\d+>}/subscriptions', target: [C\Subscriptions::class, 'subscriptionsByActorId']);
$r->connect(id: 'actor_subscriptions_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/subscriptions', target: [C\Subscriptions::class, 'subscriptionsByActorNickname']);
}
}