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:
Philipp 2021-11-20 15:38:03 +01:00
parent 238613fd01
commit 8bdd90066f
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
252 changed files with 615 additions and 623 deletions

View file

@ -35,7 +35,7 @@ use Friendica\Network\HTTPException;
class Common extends BaseProfile
{
public function content(): string
protected function content(array $request = []): string
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPException;
class Contacts extends Module\BaseProfile
{
public function content(): string
protected function content(array $request = []): string
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));

View file

@ -35,13 +35,13 @@ use Friendica\Core\L10n;
*/
class Index extends BaseModule
{
public function rawContent()
protected function rawContent(array $request = [])
{
(new Profile($this->l10n, $this->parameters))->rawContent();
(new Profile($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->server, $this->parameters))->rawContent();
}
public function content(): string
protected function content(array $request = []): string
{
return (new Status($this->l10n, $this->parameters))->content();
return (new Status($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->server, $this->parameters))->content();
}
}

View file

@ -29,7 +29,7 @@ use Friendica\Network\HTTPException;
class Media extends BaseProfile
{
public function content(): string
protected function content(array $request = []): string
{
$a = DI::app();

View file

@ -46,7 +46,7 @@ use Friendica\Util\Temporal;
class Profile extends BaseProfile
{
public function rawContent()
protected function rawContent(array $request = [])
{
if (ActivityPub::isRequest()) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname']]);
@ -73,7 +73,7 @@ class Profile extends BaseProfile
}
}
public function content(): string
protected function content(array $request = []): string
{
$a = DI::app();

View file

@ -33,7 +33,7 @@ use Friendica\Util\DateTimeFormat;
class Schedule extends BaseProfile
{
public function post()
protected function post(array $request = [], array $post = [])
{
if (!local_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
@ -50,7 +50,7 @@ class Schedule extends BaseProfile
Post\Delayed::deleteById($_REQUEST['delete']);
}
public function content(): string
protected function content(array $request = []): string
{
if (!local_user()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));

View file

@ -46,7 +46,7 @@ use Friendica\Util\XML;
class Status extends BaseProfile
{
public function content(): string
protected function content(array $request = []): string
{
$args = DI::args();