[CORE][Router] Rename \App\Core\Router\Router to \App\Core\Router and merge \App\Core\Router\RouteLoader with \App\Core\Router

This commit is contained in:
Hugo Sales 2022-03-27 16:43:59 +01:00 committed by Diogo Peralta Cordeiro
parent 60af9f5e9b
commit 483983790a
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
79 changed files with 362 additions and 260 deletions

View File

@ -25,7 +25,7 @@ use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Formatting; use App\Util\Formatting;
@ -37,7 +37,7 @@ use Doctrine\ORM\QueryBuilder;
class Attachment extends Component class Attachment extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('note_attachment_show', '/object/note/{note_id<\d+>}/attachment/{attachment_id<\d+>}', [C\Attachment::class, 'attachmentShowWithNote']); $r->connect('note_attachment_show', '/object/note/{note_id<\d+>}/attachment/{attachment_id<\d+>}', [C\Attachment::class, 'attachmentShowWithNote']);
$r->connect('note_attachment_view', '/object/note/{note_id<\d+>}/attachment/{attachment_id<\d+>}/view', [C\Attachment::class, 'attachmentViewWithNote']); $r->connect('note_attachment_view', '/object/note/{note_id<\d+>}/attachment/{attachment_id<\d+>}/view', [C\Attachment::class, 'attachmentViewWithNote']);

View File

@ -30,7 +30,7 @@ use App\Core\Event;
use App\Core\GSFile; use App\Core\GSFile;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -29,7 +29,7 @@ use App\Core\Entity;
use App\Core\Event; use App\Core\Event;
use App\Core\GSFile; use App\Core\GSFile;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -24,7 +24,7 @@ namespace Component\Attachment\tests\Entity;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\GSFile; use App\Core\GSFile;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
use App\Util\TemporaryFile; use App\Util\TemporaryFile;

View File

@ -26,8 +26,7 @@ use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\GSFile; use App\Core\GSFile;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Util\Common; use App\Util\Common;
use Component\Attachment\Entity\Attachment; use Component\Attachment\Entity\Attachment;
use Component\Attachment\Entity\AttachmentThumbnail; use Component\Attachment\Entity\AttachmentThumbnail;
@ -41,7 +40,7 @@ class Avatar extends Component
{ {
} }
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('avatar_actor', '/actor/{actor_id<\d+>}/avatar/{size<full|big|medium|small>?medium}', [Controller\Avatar::class, 'avatar_view']); $r->connect('avatar_actor', '/actor/{actor_id<\d+>}/avatar/{size<full|big|medium|small>?medium}', [Controller\Avatar::class, 'avatar_view']);
$r->connect('avatar_default', '/avatar/default/{size<full|big|medium|small>?medium}', [Controller\Avatar::class, 'default_avatar_view']); $r->connect('avatar_default', '/avatar/default/{size<full|big|medium|small>?medium}', [Controller\Avatar::class, 'default_avatar_view']);

View File

@ -27,7 +27,7 @@ use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Event; use App\Core\Event;
use App\Core\Router\Router; use App\Core\Router;
use App\Util\Common; use App\Util\Common;
use Component\Attachment\Entity\Attachment; use Component\Attachment\Entity\Attachment;
use Component\Attachment\Entity\AttachmentThumbnail; use Component\Attachment\Entity\AttachmentThumbnail;

View File

@ -24,12 +24,12 @@ namespace Component\Blog;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use Component\Blog\Controller as C; use Component\Blog\Controller as C;
class Blog extends Plugin class Blog extends Plugin
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect(id: 'blog_post', uri_path: '/blog/post', target: [C\Post::class, 'makePost']); $r->connect(id: 'blog_post', uri_path: '/blog/post', target: [C\Post::class, 'makePost']);
return Event::next; return Event::next;

View File

@ -28,8 +28,7 @@ use App\Core\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\Core\Router;
use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Feed; use App\Entity\Feed;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -59,7 +58,7 @@ class Circle extends Component
protected const SLUG = 'circle'; protected const SLUG = 'circle';
protected const PLURAL_SLUG = 'circles'; protected const PLURAL_SLUG = 'circles';
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('actor_circle_view_by_circle_id', '/circle/{circle_id<\d+>}', [CircleController\Circle::class, 'circleById']); $r->connect('actor_circle_view_by_circle_id', '/circle/{circle_id<\d+>}', [CircleController\Circle::class, 'circleById']);
// View circle members by (tagger id or nickname) and tag // View circle members by (tagger id or nickname) and tag

View File

@ -25,7 +25,7 @@ namespace Component\Circle\Controller;
use App\Core\Cache; use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use Component\Circle\Entity\ActorCircle; use Component\Circle\Entity\ActorCircle;

View File

@ -24,7 +24,7 @@ namespace Component\Circle\Entity;
use App\Core\Cache; use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Router\Router; use App\Core\Router;
use DateTimeInterface; use DateTimeInterface;
/** /**

View File

@ -23,7 +23,7 @@ namespace Component\Circle\Entity;
use App\Core\DB; use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use Component\Tag\Tag; use Component\Tag\Tag;
use DateTimeInterface; use DateTimeInterface;

View File

@ -32,7 +32,7 @@ use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -32,8 +32,7 @@ use App\Core\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\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
@ -46,7 +45,7 @@ use Symfony\Component\HttpFoundation\Request;
class Conversation extends Component class Conversation extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('conversation', '/conversation/{conversation_id<\d+>}', [Controller\Conversation::class, 'showConversation']); $r->connect('conversation', '/conversation/{conversation_id<\d+>}', [Controller\Conversation::class, 'showConversation']);
$r->connect('conversation_mute', '/conversation/{conversation_id<\d+>}/mute', [Controller\Conversation::class, 'muteConversation']); $r->connect('conversation_mute', '/conversation/{conversation_id<\d+>}/mute', [Controller\Conversation::class, 'muteConversation']);

View File

@ -25,7 +25,7 @@ namespace Component\Conversation\Entity;
use App\Core\DB; use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Router\Router; use App\Core\Router;
/** /**
* Entity class for Conversations * Entity class for Conversations

View File

@ -25,12 +25,12 @@ namespace Component\Feed;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router;
use Component\Feed\Controller as C; use Component\Feed\Controller as C;
class Feed extends Component class Feed extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('feed_public', '/feed/public', [C\Feeds::class, 'public']); $r->connect('feed_public', '/feed/public', [C\Feeds::class, 'public']);
$r->connect('feed_home', '/feed/home', [C\Feeds::class, 'home']); $r->connect('feed_home', '/feed/home', [C\Feeds::class, 'home']);

View File

@ -23,7 +23,7 @@ declare(strict_types = 1);
namespace Component\Feed\tests\Controller; namespace Component\Feed\tests\Controller;
use App\Core\Router\Router; use App\Core\Router;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
use Component\Feed\Controller\Feeds; use Component\Feed\Controller\Feeds;
use Jchook\AssertThrows\AssertThrows; use Jchook\AssertThrows\AssertThrows;

View File

@ -28,8 +28,7 @@ use App\Core\HTTPClient;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -86,7 +85,7 @@ class FreeNetwork extends Component
return Event::next; return Event::next;
} }
public function onAddRoute(RouteLoader $m): bool public function onAddRoute(Router $m): bool
{ {
// Feeds // Feeds
$m->connect('feed_network', '/feed/network', [Feeds::class, 'network']); $m->connect('feed_network', '/feed/network', [Feeds::class, 'network']);

View File

@ -6,7 +6,7 @@ namespace Component\FreeNetwork\Util\WebfingerResource;
use App\Core\Event; use App\Core\Event;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Common; use App\Util\Common;
use Component\FreeNetwork\Exception\WebfingerReconstructionException; use Component\FreeNetwork\Exception\WebfingerReconstructionException;

View File

@ -27,7 +27,7 @@ use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity as E; use App\Entity as E;
use App\Util\Common; use App\Util\Common;

View File

@ -24,8 +24,7 @@ namespace Component\Group;
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\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Common; use App\Util\Common;
@ -38,7 +37,7 @@ use Symfony\Component\HttpFoundation\Request;
class Group extends Component class Group extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect(id: 'group_actor_view_id', uri_path: '/group/{id<\d+>}', target: [C\GroupFeed::class, 'groupViewId']); $r->connect(id: 'group_actor_view_id', uri_path: '/group/{id<\d+>}', target: [C\GroupFeed::class, 'groupViewId']);
$r->connect(id: 'group_actor_view_nickname', uri_path: '/!{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\GroupFeed::class, 'groupViewNickname']); $r->connect(id: 'group_actor_view_nickname', uri_path: '/!{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\GroupFeed::class, 'groupViewNickname']);

View File

@ -23,7 +23,7 @@ namespace Component\Language;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Formatting; use App\Util\Formatting;
@ -38,7 +38,7 @@ use Symfony\Component\HttpFoundation\Request;
class Language extends Component class Language extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('settings_sort_languages', '/settings/sort_languages', [C\Language::class, 'sortLanguages']); $r->connect('settings_sort_languages', '/settings/sort_languages', [C\Language::class, 'sortLanguages']);
return Event::next; return Event::next;

View File

@ -28,7 +28,7 @@ use App\Core\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Feed; use App\Entity\Feed;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -26,8 +26,7 @@ use App\Core\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\Core\Router;
use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Feed; use App\Entity\Feed;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
@ -36,7 +35,7 @@ use Component\LeftPanel\Controller as C;
class LeftPanel extends Component class LeftPanel extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('edit_feeds', '/edit-feeds', C\EditFeeds::class); $r->connect('edit_feeds', '/edit-feeds', C\EditFeeds::class);
return Event::next; return Event::next;

View File

@ -27,8 +27,7 @@ use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Queue; use App\Core\Queue;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -40,7 +39,7 @@ use Throwable;
class Notification extends Component class Notification extends Component
{ {
public function onAddRoute(RouteLoader $m): bool public function onAddRoute(Router $m): bool
{ {
$m->connect('feed_notifications', '/feed/notifications', [Feed::class, 'notifications']); $m->connect('feed_notifications', '/feed/notifications', [Feed::class, 'notifications']);
return Event::next; return Event::next;

View File

@ -24,7 +24,7 @@ declare(strict_types = 1);
namespace Component\Person\Controller; namespace Component\Person\Controller;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity as E; use App\Entity as E;
use App\Entity\LocalUser; use App\Entity\LocalUser;

View File

@ -23,13 +23,13 @@ namespace Component\Person;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Util\Nickname; use App\Util\Nickname;
use Component\Person\Controller as C; use Component\Person\Controller as C;
class Person extends Component class Person extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect(id: 'person_actor_view_id', uri_path: '/person/{id<\d+>}', target: [C\PersonFeed::class, 'personViewId']); $r->connect(id: 'person_actor_view_id', uri_path: '/person/{id<\d+>}', target: [C\PersonFeed::class, 'personViewId']);
$r->connect(id: 'person_actor_view_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\PersonFeed::class, 'personViewNickname'], options: ['is_system_path' => false]); $r->connect(id: 'person_actor_view_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\PersonFeed::class, 'personViewNickname'], options: ['is_system_path' => false]);

View File

@ -24,7 +24,7 @@ declare(strict_types = 1);
namespace Component\Person\tests\Controller; namespace Component\Person\tests\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
use Jchook\AssertThrows\AssertThrows; use Jchook\AssertThrows\AssertThrows;

View File

@ -8,7 +8,7 @@ use App\Core\ActorLocalRoles;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Common; use App\Util\Common;

View File

@ -29,8 +29,7 @@ use App\Core\Event;
use App\Core\GSFile; use App\Core\GSFile;
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\Core\Router;
use App\Core\Router\Router;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
@ -55,7 +54,7 @@ class Posting extends Component
{ {
public const route = 'posting_form_action'; public const route = 'posting_form_action';
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect(self::route, '/form/posting', Controller\Posting::class); $r->connect(self::route, '/form/posting', Controller\Posting::class);
return Event::next; return Event::next;

View File

@ -27,7 +27,7 @@ use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -28,8 +28,7 @@ use App\Core\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\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -44,7 +43,7 @@ use Symfony\Component\HttpFoundation\Request;
class Subscription extends Component class Subscription extends Component
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect(id: 'actor_subscribe_add', uri_path: '/actor/subscribe/{object_id<\d+>}', target: [SubscribersController::class, 'subscribersAdd']); $r->connect(id: 'actor_subscribe_add', uri_path: '/actor/subscribe/{object_id<\d+>}', target: [SubscribersController::class, 'subscribersAdd']);
$r->connect(id: 'actor_subscribe_remove', uri_path: '/actor/unsubscribe/{object_id<\d+>}', target: [SubscribersController::class, 'subscribersRemove']); $r->connect(id: 'actor_subscribe_remove', uri_path: '/actor/unsubscribe/{object_id<\d+>}', target: [SubscribersController::class, 'subscribersRemove']);

View File

@ -24,7 +24,7 @@ namespace Component\Tag\Entity;
use App\Core\Cache; use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use Component\Language\Entity\Language; use Component\Language\Entity\Language;

View File

@ -28,7 +28,7 @@ use App\Core\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\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;

View File

@ -24,7 +24,7 @@ services:
resource: '../src/Controller' resource: '../src/Controller'
tags: ['controller.service_arguments'] tags: ['controller.service_arguments']
App\Core\Router\RouteLoader: App\Core\Router:
tags: ['routing.loader'] tags: ['routing.loader']
# Wrapper around Doctrine's StaticPHP metadata driver # Wrapper around Doctrine's StaticPHP metadata driver

View File

@ -41,8 +41,7 @@ use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Queue; use App\Core\Queue;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
@ -156,9 +155,9 @@ class ActivityPub extends Plugin
* This code executes when GNU social creates the page routing, and we hook * This code executes when GNU social creates the page routing, and we hook
* on this event to add our Inbox and Outbox handler for ActivityPub. * on this event to add our Inbox and Outbox handler for ActivityPub.
* *
* @param RouteLoader $r the router that was initialized * @param Router $r the router that was initialized
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect( $r->connect(
'activitypub_inbox', 'activitypub_inbox',

View File

@ -37,7 +37,7 @@ use App\Core\DB;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Queue; use App\Core\Queue;
use App\Core\Router\Router; use App\Core\Router;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use Exception; use Exception;

View File

@ -34,7 +34,7 @@ namespace Plugin\ActivityPub\Controller;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -37,7 +37,7 @@ use ActivityPhp\Type\AbstractObject;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Activity as GSActivity; use App\Entity\Activity as GSActivity;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -39,7 +39,7 @@ use App\Core\Event;
use App\Core\GSFile; use App\Core\GSFile;
use App\Core\HTTPClient; use App\Core\HTTPClient;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor as GSActor; use App\Entity\Actor as GSActor;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use App\Util\TemporaryFile; use App\Util\TemporaryFile;

View File

@ -41,7 +41,7 @@ use App\Core\GSFile;
use App\Core\HTTPClient; use App\Core\HTTPClient;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Entity\Note as GSNote; use App\Entity\Note as GSNote;
use App\Util\Common; use App\Util\Common;

View File

@ -34,7 +34,7 @@ namespace Plugin\ActivityPub\Util;
use ActivityPhp\Type\Core\OrderedCollection; use ActivityPhp\Type\Core\OrderedCollection;
use ActivityPhp\Type\Core\OrderedCollectionPage; use ActivityPhp\Type\Core\OrderedCollectionPage;
use App\Core\Router\Router; use App\Core\Router;
use Component\Collection\Util\Controller\CircleController; use Component\Collection\Util\Controller\CircleController;
use Component\Collection\Util\Controller\FeedController; use Component\Collection\Util\Controller\FeedController;
use Component\Collection\Util\Controller\OrderedCollection as GSOrderedCollection; use Component\Collection\Util\Controller\OrderedCollection as GSOrderedCollection;

View File

@ -35,8 +35,7 @@ use App\Core\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\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Feed; use App\Entity\Feed;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -123,7 +122,7 @@ class AttachmentCollections extends Plugin
return array_map(fn ($x) => $x['attachment_collection_id'], $res); return array_map(fn ($x) => $x['attachment_collection_id'], $res);
} }
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
// View all collections by actor id and nickname // View all collections by actor id and nickname
$r->connect( $r->connect(

View File

@ -24,7 +24,7 @@ declare(strict_types = 1);
namespace Plugin\AttachmentCollections\Controller; namespace Plugin\AttachmentCollections\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Router\Router; use App\Core\Router;
use Component\Collection\Util\Controller\MetaCollectionController; use Component\Collection\Util\Controller\MetaCollectionController;
use Plugin\AttachmentCollections\Entity\AttachmentCollection; use Plugin\AttachmentCollections\Entity\AttachmentCollection;

View File

@ -24,7 +24,7 @@ declare(strict_types = 1);
namespace Plugin\Bundles\Controller; namespace Plugin\Bundles\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Router\Router; use App\Core\Router;
use Component\Collection\Util\Controller\MetaCollectionController; use Component\Collection\Util\Controller\MetaCollectionController;
use Plugin\Bundles\Entity\BundleCollection; use Plugin\Bundles\Entity\BundleCollection;

View File

@ -25,7 +25,7 @@ namespace Plugin\Cover;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Util\Common; use App\Util\Common;
use Plugin\Cover\Controller as C; use Plugin\Cover\Controller as C;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -47,7 +47,7 @@ class Cover extends Plugin
* *
* @return bool hook value; true means continue processing, false means stop * @return bool hook value; true means continue processing, false means stop
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('settings_profile_cover', 'settings/cover', [Controller\Cover::class, 'coversettings']); $r->connect('settings_profile_cover', 'settings/cover', [Controller\Cover::class, 'coversettings']);
$r->connect('cover', '/cover', [Controller\Cover::class, 'cover']); $r->connect('cover', '/cover', [Controller\Cover::class, 'cover']);

View File

@ -28,7 +28,7 @@ use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;

View File

@ -27,8 +27,7 @@ use App\Core\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\NoteHandlerPlugin; use App\Core\Modules\NoteHandlerPlugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
@ -47,7 +46,7 @@ use Symfony\Component\HttpFoundation\Request;
* @category DeleteNote * @category DeleteNote
* *
* @author Eliseu Amaro <mail@eliseuama.ro> * @author Eliseu Amaro <mail@eliseuama.ro>
* @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2021-2022 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class DeleteNote extends NoteHandlerPlugin class DeleteNote extends NoteHandlerPlugin
@ -136,7 +135,7 @@ class DeleteNote extends NoteHandlerPlugin
* *
* @return bool Event hook * @return bool Event hook
*/ */
public function onAddRoute(RouteLoader $r) public function onAddRoute(Router $r)
{ {
$r->connect(id: 'delete_note_action', uri_path: '/object/note/{note_id<\d+>}/delete', target: Controller\DeleteNote::class); $r->connect(id: 'delete_note_action', uri_path: '/object/note/{note_id<\d+>}/delete', target: Controller\DeleteNote::class);

View File

@ -25,8 +25,7 @@ namespace Plugin\Directory;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
@ -41,7 +40,7 @@ class Directory extends Plugin
* *
* @return bool * @return bool
*/ */
public function onAddRoute(RouteLoader $r) public function onAddRoute(Router $r)
{ {
$r->connect('directory_people', '/directory/people', [Controller\Directory::class, 'people']); $r->connect('directory_people', '/directory/people', [Controller\Directory::class, 'people']);
$r->connect('directory_groups', '/directory/groups', [Controller\Directory::class, 'groups']); $r->connect('directory_groups', '/directory/groups', [Controller\Directory::class, 'groups']);

View File

@ -31,7 +31,7 @@ declare(strict_types = 1);
* @author Miguel Dantas * @author Miguel Dantas
* @author Hugo Sales <hugo@hsal.es> * @author Hugo Sales <hugo@hsal.es>
* @author Diogo Peralta Cordeiro <mail@diogo.site> * @author Diogo Peralta Cordeiro <mail@diogo.site>
* @copyright 2014-2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2014-2022 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
@ -45,8 +45,7 @@ use App\Core\HTTPClient;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
@ -108,11 +107,11 @@ class Embed extends Plugin
* This code executes when GNU social creates the page routing, and we hook * This code executes when GNU social creates the page routing, and we hook
* on this event to add our action handler for Embed. * on this event to add our action handler for Embed.
* *
* @param RouteLoader $m the router that was initialized * @param Router $m the router that was initialized
* *
* @throws Exception * @throws Exception
*/ */
public function onAddRoute(RouteLoader $m): bool public function onAddRoute(Router $m): bool
{ {
$m->connect('oembed', 'main/oembed', Controller\OEmbed::class); $m->connect('oembed', 'main/oembed', Controller\OEmbed::class);
return Event::next; return Event::next;

View File

@ -26,9 +26,8 @@ namespace Plugin\Favourite\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -42,6 +41,7 @@ use App\Util\Exception\RedirectException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use Component\Collection\Util\Controller\FeedController; use Component\Collection\Util\Controller\FeedController;
use Component\Notification\Entity\Attention; use Component\Notification\Entity\Attention;
use function App\Core\I18n\_m;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;

View File

@ -35,8 +35,7 @@ use App\Core\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\NoteHandlerPlugin; use App\Core\Modules\NoteHandlerPlugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Feed; use App\Entity\Feed;
@ -211,7 +210,7 @@ class Favourite extends NoteHandlerPlugin
/** /**
* Maps Routes to their respective Controllers * Maps Routes to their respective Controllers
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
// Add/remove note to/from favourites // Add/remove note to/from favourites
$r->connect(id: 'favourite_add', uri_path: '/object/note/{id<\d+>}/favour', target: [Controller\Favourite::class, 'favouriteAddNote']); $r->connect(id: 'favourite_add', uri_path: '/object/note/{id<\d+>}/favour', target: [Controller\Favourite::class, 'favouriteAddNote']);

View File

@ -35,8 +35,7 @@ namespace Plugin\OAuth2;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Util\Common; use App\Util\Common;
use DateInterval; use DateInterval;
use Exception; use Exception;
@ -93,9 +92,9 @@ class OAuth2 extends Plugin
* This code executes when GNU social creates the page routing, and we hook * This code executes when GNU social creates the page routing, and we hook
* on this event to add our Inbox and Outbox handler for ActivityPub. * on this event to add our Inbox and Outbox handler for ActivityPub.
* *
* @param RouteLoader $r the router that was initialized * @param Router $r the router that was initialized
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('oauth2_mastodon_api_apps', '/api/v1/apps', C\Client::class, ['http-methods' => ['POST']]); $r->connect('oauth2_mastodon_api_apps', '/api/v1/apps', C\Client::class, ['http-methods' => ['POST']]);
$r->connect('oauth2_client', '/oauth/client', C\Client::class, ['http-methods' => ['POST']]); $r->connect('oauth2_client', '/oauth/client', C\Client::class, ['http-methods' => ['POST']]);

View File

@ -26,8 +26,7 @@ use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\NotFoundException; use App\Util\Exception\NotFoundException;
@ -51,7 +50,7 @@ class Oomox extends Plugin
/** /**
* Maps Routes to their respective Controllers * Maps Routes to their respective Controllers
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('oomox_settings', 'settings/oomox', [Controller\Oomox::class, 'oomoxSettings']); $r->connect('oomox_settings', 'settings/oomox', [Controller\Oomox::class, 'oomoxSettings']);
$r->connect('oomox_css', 'plugins/oomox/colours', [Controller\Oomox::class, 'oomoxCSS']); $r->connect('oomox_css', 'plugins/oomox/colours', [Controller\Oomox::class, 'oomoxCSS']);

View File

@ -26,7 +26,7 @@ namespace Plugin\PinnedNotes\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Common; use App\Util\Common;

View File

@ -34,8 +34,7 @@ namespace Plugin\PinnedNotes;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Entity\Note; use App\Entity\Note;
@ -54,7 +53,7 @@ use Symfony\Component\HttpFoundation\Request;
class PinnedNotes extends Plugin class PinnedNotes extends Plugin
{ {
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
// Pin and unpin notes // Pin and unpin notes
$r->connect(id: 'toggle_note_pin', uri_path: '/object/note/{id<\d+>}/pin', target: [C\PinnedNotes::class, 'togglePin']); $r->connect(id: 'toggle_note_pin', uri_path: '/object/note/{id<\d+>}/pin', target: [C\PinnedNotes::class, 'togglePin']);

View File

@ -27,7 +27,7 @@ use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Modules\NoteHandlerPlugin; use App\Core\Modules\NoteHandlerPlugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\InvalidFormException; use App\Util\Exception\InvalidFormException;
@ -57,7 +57,7 @@ class Poll extends NoteHandlerPlugin
* *
* @return bool hook value; true means continue processing, false means stop * @return bool hook value; true means continue processing, false means stop
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('newpoll', 'main/poll/new/{num<\\d+>?3}', [Controller\NewPoll::class, 'newpoll']); $r->connect('newpoll', 'main/poll/new/{num<\\d+>?3}', [Controller\NewPoll::class, 'newpoll']);

View File

@ -26,7 +26,7 @@ use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use App\Util\Formatting; use App\Util\Formatting;
@ -51,7 +51,7 @@ class ProfileColor extends Plugin
* *
* @return bool hook value; true means continue processing, false means stop * @return bool hook value; true means continue processing, false means stop
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
$r->connect('settings_profile_color', 'settings/color', [Controller\ProfileColor::class, 'profileColorSettings']); $r->connect('settings_profile_color', 'settings/color', [Controller\ProfileColor::class, 'profileColorSettings']);
return Event::next; return Event::next;

View File

@ -27,9 +27,8 @@ use App\Core\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
@ -39,6 +38,7 @@ use App\Util\Exception\NoLoggedInUser;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use Component\Notification\Entity\Attention; use Component\Notification\Entity\Attention;
use function App\Core\I18n\_m;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;

View File

@ -33,8 +33,7 @@ use App\Core\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\NoteHandlerPlugin; use App\Core\Modules\NoteHandlerPlugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
@ -341,7 +340,7 @@ class RepeatNote extends NoteHandlerPlugin
* *
* @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers * @return bool Event hook, Event::next (true) is returned to allow Event to be handled by other handlers
*/ */
public function onAddRoute(RouteLoader $r): bool public function onAddRoute(Router $r): bool
{ {
// Add/remove note to/from repeats // Add/remove note to/from repeats
$r->connect(id: 'repeat_add', uri_path: '/object/note/{note_id<\d+>}/repeat', target: [Controller\Repeat::class, 'repeatAddNote']); $r->connect(id: 'repeat_add', uri_path: '/object/note/{note_id<\d+>}/repeat', target: [Controller\Repeat::class, 'repeatAddNote']);

View File

@ -28,8 +28,7 @@ use App\Core\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\Plugin; use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Entity\Note; use App\Entity\Note;
@ -52,7 +51,7 @@ class TagBasedFiltering extends Plugin
return ['note' => "blocked-note-tags-{$actor_id}", 'actor' => "blocked-actor-tags-{$actor_id}"]; return ['note' => "blocked-note-tags-{$actor_id}", 'actor' => "blocked-actor-tags-{$actor_id}"];
} }
public function onAddRoute(RouteLoader $r) public function onAddRoute(Router $r)
{ {
$r->connect(id: self::NOTE_TAG_FILTER_ROUTE, uri_path: '/filter/edit-blocked-note-tags/{note_id<\d+>}', target: [Controller\AddBlocked::class, 'addBlockedNoteTags']); $r->connect(id: self::NOTE_TAG_FILTER_ROUTE, uri_path: '/filter/edit-blocked-note-tags/{note_id<\d+>}', target: [Controller\AddBlocked::class, 'addBlockedNoteTags']);
$r->connect(id: self::ACTOR_TAG_FILTER_ROUTE, uri_path: '/filter/edit-blocked-actor-tags/{actor_id<\d+>}', target: [Controller\AddBlocked::class, 'addBlockedActorTags']); $r->connect(id: self::ACTOR_TAG_FILTER_ROUTE, uri_path: '/filter/edit-blocked-actor-tags/{actor_id<\d+>}', target: [Controller\AddBlocked::class, 'addBlockedActorTags']);

View File

@ -27,7 +27,7 @@ use App\Core\Controller;
use App\Core\DB; use App\Core\DB;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use Functional as F; use Functional as F;

View File

@ -27,7 +27,7 @@ use App\Core\HTTPClient;
use App\Core\Log; use App\Core\Log;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
use App\Core\Queue; use App\Core\Queue;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Entity\Activity; use App\Entity\Activity;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
@ -43,7 +43,7 @@ class WebHooks extends Plugin
{ {
public const controller_route = 'webhook'; public const controller_route = 'webhook';
public function onAddRoute(RouteLoader $r) public function onAddRoute(Router $r)
{ {
$r->connect(self::controller_route, '/webhook-settings', C\WebHooks::class); $r->connect(self::controller_route, '/webhook-settings', C\WebHooks::class);
} }

View File

@ -24,7 +24,7 @@ declare(strict_types = 1);
namespace App\Controller; namespace App\Controller;
use App\Core\Controller; use App\Core\Controller;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use InvalidArgumentException; use InvalidArgumentException;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;

View File

@ -11,7 +11,7 @@ use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Feed; use App\Entity\Feed;
use App\Entity\LocalUser; use App\Entity\LocalUser;

View File

@ -34,7 +34,7 @@ namespace App\Core;
use App\Core\DB; use App\Core\DB;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;

View File

@ -47,7 +47,7 @@ namespace App\Core;
use App\Core\DB; use App\Core\DB;
use App\Core\I18n\I18n; use App\Core\I18n\I18n;
use App\Core\Queue; use App\Core\Queue;
use App\Core\Router\Router; use App\Core\Router;
use App\Kernel; use App\Kernel;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ConfigurationException; use App\Util\Exception\ConfigurationException;

244
src/Core/Router.php Normal file
View File

@ -0,0 +1,244 @@
<?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/>.
// }}}
/**
* Static wrapper for Symfony's router
*
* @package GNUsocial
* @category URL
*
* @author Hugo Sales <hugo@hsal.es>
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Core;
use App\Core\Event;
use App\Core\Log;
use App\Util\Common;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Router as SymfonyRouter;
/**
* @mixin SymfonyRouter
*/
class Router extends Loader
{
/**
* Generates an absolute URL, e.g. "http://example.com/dir/file".
*/
public const ABSOLUTE_URL = UrlGeneratorInterface::ABSOLUTE_URL;
/**
* Generates an absolute path, e.g. "/dir/file".
*/
public const ABSOLUTE_PATH = UrlGeneratorInterface::ABSOLUTE_PATH;
/**
* Generates a relative path based on the current request path, e.g. "../parent-file".
*
* @see UrlGenerator::getRelativePath()
*/
public const RELATIVE_PATH = UrlGeneratorInterface::RELATIVE_PATH;
/**
* Generates a network path, e.g. "//example.com/dir/file".
* Such reference reuses the current scheme but specifies the host.
*/
public const NETWORK_PATH = UrlGeneratorInterface::NETWORK_PATH;
public static ?SymfonyRouter $router = null;
public static function setRouter($rtr): void
{
self::$router = $rtr;
}
public static function isAbsolute(string $url)
{
return isset(parse_url($url)['host']);
}
/**
* Generate a URL for route $id with $args replacing the
* placeholder route values. Extra params are added as query
* string to the URL
*/
public static function url(string $id, array $args = [], int $type = self::ABSOLUTE_PATH): string
{
if ($type === self::RELATIVE_PATH) {
Log::debug('Requested relative path which is not an absolute path... just saying...');
}
return self::$router->generate($id, $args, $type);
}
public static function sanitizeLocalURL(string $url, array $unset_query_args = []): ?string
{
try {
$parts = parse_url($url);
if ($parts === false || (isset($parts['host']) && $parts['host'] !== Common::config('site', 'server'))) {
return null;
}
self::match($parts['path']);
if ($unset_query_args !== [] && isset($parts['query'])) {
$args = [];
parse_str($parts['query'], $args);
$args = array_diff_key($args, $unset_query_args);
$parts['query'] = http_build_query($args);
}
return $parts['path'] . (empty($parts['query']) ? '' : ('?' . $parts['query'])) . (empty($parts['fragment']) ? '' : ('#' . $parts['fragment']));
} catch (ResourceNotFoundException) {
return null;
}
}
private RouteCollection $rc;
/**
* Route loading entry point, called from `config/routes.php`
*
* Must conform to symfony's interface, but the $resource is unused
* and $type must not be null
*/
public function load($resource, ?string $type = null): RouteCollection
{
$this->rc = new RouteCollection();
$route_files = glob(INSTALLDIR . '/src/Routes/*.php');
$to_load = [];
foreach ($route_files as $file) {
require_once $file;
$ns = '\\App\\Routes\\' . basename($file, '.php');
if (\defined("{$ns}::LOAD_ORDER")) {
$to_load[$ns::LOAD_ORDER] = $ns;
} else {
$to_load[] = $ns;
}
}
ksort($to_load);
foreach ($to_load as $ns) {
$ns::load($this);
}
Event::handle('AddRoute', [&$this]);
// Sort routes so that whichever route has the smallest accept option matches first, as it's more specific
// This requires a copy, sadly, as it doesn't seem to be possible to modify the collection in-place
// However, this is fine since this gets cached
$it = $this->rc->getIterator();
$it->uasort(fn (Route $left, Route $right) => \count($left->getDefaults()['accept']) <=> \count($right->getDefaults()['accept']));
$this->rc = new RouteCollection();
foreach ($it as $id => $route) {
$this->rc->add($id, $route);
}
return $this->rc;
}
/**
* Connect a route to a controller
*
* @param string $id Route unique id, used to generate urls, for instance
* @param string $uri_path Path, possibly with {param}s
* @param mixed $target Some kind of callable, typically class with `__invoke` or [object, method]
* @param null|array $param_reqs Array of {param} => regex
* @param null|array $options Possible keys are ['condition', 'defaults', 'format',
* 'fragment', 'http-methods', 'locale', 'methods', 'schemes', 'accept', 'is_system_path']
* 'http-methods' and 'methods' are aliases
*/
public function connect(string $id, string $uri_path, $target, ?array $options = [], ?array $param_reqs = [])
{
// XXX: This hack can definitely be optimised by actually intersecting the arrays,
// maybe this helps: https://backbeat.tech/blog/symfony-routing-tricks-part-1
// see: https://symfony.com/index.php/doc/3.1/components/http_foundation.html#accessing-accept-headers-data
$accept_header_condition = '';
if (isset($options['accept'])) {
foreach ($options['accept'] as $accept) {
$accept_header_condition .= "('{$accept}' in request.getAcceptableContentTypes()) ||";
}
$accept_header_condition = mb_substr($accept_header_condition, 0, -3);
}
$this->rc->add(
$id,
new Route(
// path -- URI path
path: $uri_path,
// defaults = [] -- param default values,
// and special configuration options
defaults: array_merge(
[
'_controller' => \is_array($target) ? $target : [$target, '__invoke'],
'_format' => $options['format'] ?? 'html',
'_fragment' => $options['fragment'] ?? '',
'_locale' => $options['locale'] ?? 'en',
'template' => $options['template'] ?? '',
'accept' => $options['accept'] ?? [],
'is_system_path' => $options['is_system_path'] ?? true,
],
$options['defaults'] ?? [],
),
// requirements = [] -- param => regex
requirements: $param_reqs,
// options = [] -- possible keys: compiler_class:, utf8
// No need for a special compiler class for now,
// Enforce UTF8
options: ['utf8' => true],
// host = '' -- hostname (subdomain, for instance) to match,
// we don't want this
host: '',
// schemes = [] -- URI schemes (https, ftp and such)
schemes: $options['schemes'] ?? [],
// methods = [] -- HTTP methods
methods: $options['http-methods'] ?? $options['methods'] ?? [],
// condition = '' -- Symfony condition expression,
// see https://symfony.com/doc/current/routing.html#matching-expressions
condition: isset($options['accept']) ? $accept_header_condition : ($options['condition'] ?? ''),
),
);
}
/**
* Whether this loader supports loading this route type
* Passed the arguments from the `RoutingConfigurator::import` call from
* `config/routes.php`
*
* @codeCoverageIgnore
*/
public function supports($resource, ?string $type = null): bool
{
return 'GNUsocial' === $type;
}
/**
* function match($url) throws Symfony\Component\Routing\Exception\ResourceNotFoundException
*/
public static function __callStatic(string $name, array $args)
{
return self::$router->{$name}(...$args);
}
}

View File

@ -1,121 +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/>.
// }}}
/**
* Static wrapper for Symfony's router
*
* @package GNUsocial
* @category URL
*
* @author Hugo Sales <hugo@hsal.es>
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Core\Router;
use App\Core\Log;
use App\Util\Common;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Router as SymfonyRouter;
/**
* @mixin SymfonyRouter
*/
abstract class Router
{
/**
* Generates an absolute URL, e.g. "http://example.com/dir/file".
*/
public const ABSOLUTE_URL = UrlGeneratorInterface::ABSOLUTE_URL;
/**
* Generates an absolute path, e.g. "/dir/file".
*/
public const ABSOLUTE_PATH = UrlGeneratorInterface::ABSOLUTE_PATH;
/**
* Generates a relative path based on the current request path, e.g. "../parent-file".
*
* @see UrlGenerator::getRelativePath()
*/
public const RELATIVE_PATH = UrlGeneratorInterface::RELATIVE_PATH;
/**
* Generates a network path, e.g. "//example.com/dir/file".
* Such reference reuses the current scheme but specifies the host.
*/
public const NETWORK_PATH = UrlGeneratorInterface::NETWORK_PATH;
public static ?SymfonyRouter $router = null;
public static function setRouter($rtr): void
{
self::$router = $rtr;
}
public static function isAbsolute(string $url)
{
return isset(parse_url($url)['host']);
}
/**
* Generate a URL for route $id with $args replacing the
* placeholder route values. Extra params are added as query
* string to the URL
*/
public static function url(string $id, array $args = [], int $type = self::ABSOLUTE_PATH): string
{
if ($type === self::RELATIVE_PATH) {
Log::debug('Requested relative path which is not an absolute path... just saying...');
}
return self::$router->generate($id, $args, $type);
}
public static function sanitizeLocalURL(string $url, array $unset_query_args = []): ?string
{
try {
$parts = parse_url($url);
if ($parts === false || (isset($parts['host']) && $parts['host'] !== Common::config('site', 'server'))) {
return null;
}
self::match($parts['path']);
if ($unset_query_args !== [] && isset($parts['query'])) {
$args = [];
parse_str($parts['query'], $args);
$args = array_diff_key($args, $unset_query_args);
$parts['query'] = http_build_query($args);
}
return $parts['path'] . (empty($parts['query']) ? '' : ('?' . $parts['query'])) . (empty($parts['fragment']) ? '' : ('#' . $parts['fragment']));
} catch (ResourceNotFoundException) {
return null;
}
}
/**
* function match($url) throws Symfony\Component\Routing\Exception\ResourceNotFoundException
*/
public static function __callStatic(string $name, array $args)
{
return self::$router->{$name}(...$args);
}
}

View File

@ -28,7 +28,7 @@ use App\Core\Cache;
use App\Core\DB; use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Event; use App\Core\Event;
use App\Core\Router\Router; use App\Core\Router;
use App\Util\Exception\BugFoundException; use App\Util\Exception\BugFoundException;
use App\Util\Exception\NicknameException; use App\Util\Exception\NicknameException;
use App\Util\Exception\NotFoundException; use App\Util\Exception\NotFoundException;

View File

@ -26,7 +26,7 @@ use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Event; use App\Core\Event;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Router\Router; use App\Core\Router;
use DateTimeInterface; use DateTimeInterface;
/** /**

View File

@ -29,7 +29,7 @@ use App\Core\DB;
use App\Core\Entity; use App\Core\Entity;
use App\Core\Event; use App\Core\Event;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\BugFoundException; use App\Util\Exception\BugFoundException;

View File

@ -35,12 +35,12 @@ declare(strict_types = 1);
namespace App\Routes; namespace App\Routes;
use App\Controller as C; use App\Controller as C;
use App\Core\Router\RouteLoader; use App\Core\Router;
abstract class Activity abstract class Activity
{ {
public const LOAD_ORDER = 11; public const LOAD_ORDER = 11;
public static function load(RouteLoader $r): void public static function load(Router $r): void
{ {
$r->connect('activity_view', '/activity/{id<\d+>}', [C\Activity::class, 'ActivityShow']); $r->connect('activity_view', '/activity/{id<\d+>}', [C\Activity::class, 'ActivityShow']);
} }

View File

@ -36,13 +36,13 @@ declare(strict_types = 1);
namespace App\Routes; namespace App\Routes;
use App\Controller as C; use App\Controller as C;
use App\Core\Router\RouteLoader; use App\Core\Router;
abstract class Actor abstract class Actor
{ {
public const LOAD_ORDER = 30; public const LOAD_ORDER = 30;
public static function load(RouteLoader $r): void public static function load(Router $r): void
{ {
$r->connect(id: 'actor_view_id', uri_path: '/actor/{id<\d+>}', target: [C\ActorProfile::class, 'actorViewId']); $r->connect(id: 'actor_view_id', uri_path: '/actor/{id<\d+>}', target: [C\ActorProfile::class, 'actorViewId']);
} }

View File

@ -37,14 +37,14 @@ declare(strict_types = 1);
namespace App\Routes; namespace App\Routes;
use App\Controller as C; use App\Controller as C;
use App\Core\Router\RouteLoader; use App\Core\Router;
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController; use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
abstract class Main abstract class Main
{ {
public const LOAD_ORDER = 10; public const LOAD_ORDER = 10;
public static function load(RouteLoader $r): void public static function load(Router $r): void
{ {
$r->connect('security_login', '/main/login', [C\Security::class, 'login']); $r->connect('security_login', '/main/login', [C\Security::class, 'login']);
$r->connect('security_logout', '/main/logout', [C\Security::class, 'logout']); $r->connect('security_logout', '/main/logout', [C\Security::class, 'logout']);

View File

@ -36,12 +36,12 @@ declare(strict_types = 1);
namespace App\Routes; namespace App\Routes;
use App\Controller as C; use App\Controller as C;
use App\Core\Router\RouteLoader; use App\Core\Router;
abstract class Note abstract class Note
{ {
public const LOAD_ORDER = 40; public const LOAD_ORDER = 40;
public static function load(RouteLoader $r): void public static function load(Router $r): void
{ {
$r->connect('note_view', '/object/note/{id<\d+>}', [C\Note::class, 'NoteShow']); $r->connect('note_view', '/object/note/{id<\d+>}', [C\Note::class, 'NoteShow']);
} }

View File

@ -33,7 +33,7 @@ declare(strict_types = 1);
namespace App\Twig; namespace App\Twig;
use App\Core\Event; use App\Core\Event;
use App\Core\Router\Router; use App\Core\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Feed; use App\Entity\Feed;
use App\Entity\Note; use App\Entity\Note;

View File

@ -35,7 +35,7 @@ declare(strict_types = 1);
namespace App\Util; namespace App\Util;
use App\Core\I18n\I18n; use App\Core\I18n\I18n;
use App\Core\Router\Router; use App\Core\Router;
use App\Core\Security; use App\Core\Security;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;

View File

@ -23,7 +23,7 @@ namespace App\Util\Exception;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router;
use Exception; use Exception;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;

View File

@ -23,8 +23,7 @@ declare(strict_types = 1);
namespace App\Test\Core; namespace App\Test\Core;
use App\Core\Router\RouteLoader; use App\Core\Router;
use App\Core\Router\Router;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
use ReflectionClass; use ReflectionClass;
use Symfony\Component\Routing\Route as SRoute; use Symfony\Component\Routing\Route as SRoute;
@ -34,7 +33,7 @@ class RouterTest extends GNUsocialTestCase
public function testRouter() public function testRouter()
{ {
parent::bootKernel(); parent::bootKernel();
$rl = new RouteLoader(); $rl = new Router();
$rl->load('', null); // parameters ignored $rl->load('', null); // parameters ignored
$rl->connect(id: 'test_route', uri_path: '/test/{id<\d+>}', target: []); $rl->connect(id: 'test_route', uri_path: '/test/{id<\d+>}', target: []);