mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-08 13:14:27 +02:00
Inherit ApiResponse
from Response
This commit is contained in:
parent
561aba18e3
commit
537b74f307
46 changed files with 326 additions and 277 deletions
|
@ -21,18 +21,23 @@
|
|||
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Security\BasicAuth;
|
||||
use Friendica\Security\OAuth;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\HTTPInputData;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BaseApi extends BaseModule
|
||||
{
|
||||
|
@ -53,12 +58,23 @@ class BaseApi extends BaseModule
|
|||
*/
|
||||
protected static $request = [];
|
||||
|
||||
/** @var App */
|
||||
protected $app;
|
||||
|
||||
/** @var ApiResponse */
|
||||
protected $response;
|
||||
|
||||
public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
}
|
||||
|
||||
protected function delete()
|
||||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
if (!$this->app->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,8 +82,8 @@ class BaseApi extends BaseModule
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
if (!$this->app->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,8 +91,8 @@ class BaseApi extends BaseModule
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
if (!$this->app->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,8 +100,8 @@ class BaseApi extends BaseModule
|
|||
{
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
if (!$this->app->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue