Make BaseModule a real entity
- Add all dependencies, necessary to run the content (baseUrl, Arguments) - Encapsulate all POST/GET/DELETE/PATCH/PUT methods as protected methods inside the BaseModule - Return Module content ONLY per `BaseModule::run()` (including the Hook logic there as well)
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\App\Page;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Widget;
|
||||
@@ -33,6 +34,7 @@ use Friendica\Model;
|
||||
use Friendica\Module\Contact;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
use Friendica\Network\HTTPException\ForbiddenException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
@@ -43,25 +45,22 @@ class Advanced extends BaseModule
|
||||
{
|
||||
/** @var Database */
|
||||
protected $dba;
|
||||
/** @var LoggerInterface */
|
||||
protected $logger;
|
||||
/** @var Page */
|
||||
protected $page;
|
||||
|
||||
public function __construct(Database $dba, LoggerInterface $logger, Page $page, L10n $l10n, array $parameters = [])
|
||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, App\Page $page, LoggerInterface $logger, Profiler $profiler, Database $dba, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $parameters);
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->logger = $logger;
|
||||
$this->page = $page;
|
||||
$this->dba = $dba;
|
||||
$this->page = $page;
|
||||
|
||||
if (!Session::isAuthenticated()) {
|
||||
throw new ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
}
|
||||
|
||||
public function post()
|
||||
protected function post(array $request = [], array $post = [])
|
||||
{
|
||||
$cid = $this->parameters['id'];
|
||||
|
||||
@@ -110,7 +109,7 @@ class Advanced extends BaseModule
|
||||
}
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$cid = $this->parameters['id'];
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use Friendica\Network\HTTPException;
|
||||
|
||||
class Contacts extends BaseModule
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$app = DI::app();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ use Friendica\Util\Strings;
|
||||
*/
|
||||
class Hovercard extends BaseModule
|
||||
{
|
||||
public function rawContent()
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$contact_url = $_REQUEST['url'] ?? '';
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ use Friendica\Network\HTTPException\BadRequestException;
|
||||
*/
|
||||
class Media extends BaseModule
|
||||
{
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$cid = $this->parameters['id'];
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use Friendica\Util\XML;
|
||||
|
||||
class Poke extends BaseModule
|
||||
{
|
||||
public function post()
|
||||
protected function post(array $request = [], array $post = [])
|
||||
{
|
||||
if (!local_user() || empty($this->parameters['id'])) {
|
||||
return self::postReturn(false);
|
||||
@@ -123,7 +123,7 @@ class Poke extends BaseModule
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.'));
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\App\Arguments;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\L10n;
|
||||
@@ -33,6 +32,8 @@ use Friendica\Model;
|
||||
use Friendica\Module\Contact;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Revoke extends BaseModule
|
||||
{
|
||||
@@ -41,18 +42,12 @@ class Revoke extends BaseModule
|
||||
|
||||
/** @var Database */
|
||||
protected $dba;
|
||||
/** @var BaseURL */
|
||||
protected $baseUrl;
|
||||
/** @var Arguments */
|
||||
protected $args;
|
||||
|
||||
public function __construct(Database $dba, BaseURL $baseUrl, Arguments $args, L10n $l10n, array $parameters = [])
|
||||
|
||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Database $dba, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $parameters);
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $server, $parameters);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->args = $args;
|
||||
|
||||
if (!local_user()) {
|
||||
return;
|
||||
@@ -78,7 +73,7 @@ class Revoke extends BaseModule
|
||||
}
|
||||
}
|
||||
|
||||
public function post()
|
||||
protected function post(array $request = [], array $post = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
throw new HTTPException\UnauthorizedException();
|
||||
@@ -98,7 +93,7 @@ class Revoke extends BaseModule
|
||||
$this->baseUrl->redirect('contact/' . $this->parameters['id']);
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
return Login::form($_SERVER['REQUEST_URI']);
|
||||
|
||||
Reference in New Issue
Block a user