Add routes for current BaseModules

This commit is contained in:
Philipp Holzer 2019-05-01 20:16:21 +02:00
parent a4c2de7a0b
commit b6b9e57488
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
4 changed files with 13 additions and 5 deletions

View file

@ -42,6 +42,14 @@ class Router
{ {
$this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Itemsource::class); $this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Itemsource::class);
$this->routeCollector->addRoute(['GET'], '/amcd', Module\AccountManagementControlDocument::class); $this->routeCollector->addRoute(['GET'], '/amcd', Module\AccountManagementControlDocument::class);
$this->routeCollector->addRoute(['GET'], '/acctlink', Module\Acctlink::class);
$this->routeCollector->addRoute(['GET'], '/apps', Module\Apps::class);
$this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class);
$this->routeCollector->addRoute(['GET'], '/babel', Module\Babel::class);
$this->routeCollector->addGroup('/contact', function (RouteCollector $collector) {
$collector->addRoute(['GET'], '[/]', Module\Contact::class);
$collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]', Module\Contact::class);
});
} }
public function __construct(RouteCollector $routeCollector = null) public function __construct(RouteCollector $routeCollector = null)

View file

@ -8,8 +8,8 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Model\Attach as MAttach; use Friendica\Model\Attach as MAttach;
/** /**
@ -26,8 +26,8 @@ class Attach extends BaseModule
if ($a->argc != 2) { if ($a->argc != 2) {
System::httpExit(400); // Bad Request. System::httpExit(400); // Bad Request.
} }
// @TODO: Replace with parameter from router
$item_id = intval($a->argv[1]); $item_id = intval($a->argv[1]);
// Check for existence // Check for existence

View file

@ -46,6 +46,7 @@ class Contact extends BaseModule
$contact_id = null; $contact_id = null;
$contact = null; $contact = null;
// @TODO: Replace with parameter from router
if ($a->argc == 2 && intval($a->argv[1]) if ($a->argc == 2 && intval($a->argv[1])
|| $a->argc == 3 && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations']) || $a->argc == 3 && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])
) { ) {
@ -64,6 +65,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
if ($contact['self']) { if ($contact['self']) {
// @TODO: Replace with parameter from router
if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) { if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
$a->internalRedirect('profile/' . $contact['nick']); $a->internalRedirect('profile/' . $contact['nick']);
} else { } else {

View file

@ -2,12 +2,9 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\Content\Text\HTML;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Model; use Friendica\Model;
use Friendica\Protocol\ActivityPub\Processor;
use Friendica\Protocol\Diaspora;
/** /**
* @author Hypolite Petovan <mrpetovan@gmail.com> * @author Hypolite Petovan <mrpetovan@gmail.com>
@ -22,6 +19,7 @@ class Itemsource extends \Friendica\BaseModule
$a = self::getApp(); $a = self::getApp();
// @TODO: Replace with parameter from router
if (!empty($a->argv[1])) { if (!empty($a->argv[1])) {
$guid = $a->argv[1]; $guid = $a->argv[1];
} }