mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-09 01:44:28 +02:00
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:
parent
238613fd01
commit
8bdd90066f
252 changed files with 615 additions and 623 deletions
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
|
@ -31,16 +31,16 @@ use Friendica\Database\Database;
|
|||
use Friendica\Model\Contact as ContactModel;
|
||||
use Friendica\Network\HTTPException\ForbiddenException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Worker\Delivery;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Suggest friends to a known contact
|
||||
*/
|
||||
class FriendSuggest extends BaseModule
|
||||
{
|
||||
/** @var BaseURL */
|
||||
protected $baseUrl;
|
||||
/** @var Database */
|
||||
protected $dba;
|
||||
/** @var \Friendica\Contact\FriendSuggest\Repository\FriendSuggest */
|
||||
|
@ -48,21 +48,20 @@ class FriendSuggest extends BaseModule
|
|||
/** @var \Friendica\Contact\FriendSuggest\Factory\FriendSuggest */
|
||||
protected $friendSuggestFac;
|
||||
|
||||
public function __construct(BaseURL $baseUrl, Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, L10n $l10n, array $parameters = [])
|
||||
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler,Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $parameters);
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $server, $parameters);
|
||||
|
||||
if (!local_user()) {
|
||||
throw new ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->dba = $dba;
|
||||
$this->friendSuggestRepo = $friendSuggestRepo;
|
||||
$this->friendSuggestFac = $friendSuggestFac;
|
||||
}
|
||||
|
||||
public function post()
|
||||
protected function post(array $request = [], array $post = [])
|
||||
{
|
||||
$cid = intval($this->parameters['contact']);
|
||||
|
||||
|
@ -100,7 +99,7 @@ class FriendSuggest extends BaseModule
|
|||
info($this->t('Friend suggestion sent.'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$cid = intval($this->parameters['contact']);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue