]> git.mxchange.org Git - friendica.git/commitdiff
Refactor deprecated App::isAjax() to DI::mode()->isAjax()
authornupplaPhil <admin@philipp.info>
Sun, 15 Dec 2019 23:30:39 +0000 (00:30 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 29 Dec 2019 19:17:44 +0000 (20:17 +0100)
mod/item.php
src/App.php
src/App/Authentication.php
src/Module/Admin/Themes/Details.php
src/Module/Admin/Themes/Embed.php
src/Module/Debug/ItemBody.php
src/Module/Group.php

index 9326bf60d90ae478cee8c96ae2579d46219fb950..55e4896e755b1fea7a381460d33634dba62d5c5b 100644 (file)
@@ -878,7 +878,7 @@ function item_content(App $a)
        $o = '';
 
        if (($a->argc >= 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
-               if ($a->isAjax()) {
+               if (DI::mode()->isAjax()) {
                        $o = Item::deleteForUser(['id' => $a->argv[2]], local_user());
                } else {
                        if (!empty($a->argv[3])) {
@@ -889,7 +889,7 @@ function item_content(App $a)
                        }
                }
 
-               if ($a->isAjax()) {
+               if (DI::mode()->isAjax()) {
                        // ajax return: [<item id>, 0 (no perm) | <owner id>]
                        echo json_encode([intval($a->argv[2]), intval($o)]);
                        exit();
index 65ab3be53d4d7efe6c6267c232b235a01551baa9..05d592367d709b3a6472e8e6f151f91da9deedfa 100644 (file)
@@ -543,15 +543,6 @@ class App
                return Core\Theme::getStylesheetPath($this->getCurrentTheme());
        }
 
-       /**
-        * @deprecated 2019.09 - use App\Mode->isAjax() instead
-        * @see        App\Mode::isAjax()
-        */
-       public function isAjax()
-       {
-               return $this->mode->isAjax();
-       }
-
        /**
         * @deprecated use Arguments->get() instead
         *
index f9d14171e9de02f33e8c67a042f18bae42744e7b..b8073698f2e2bb2d669594735039ac9845c6ded9 100644 (file)
@@ -31,6 +31,8 @@ class Authentication
 {
        /** @var Configuration */
        private $config;
+       /** @var App\Mode */
+       private $mode;
        /** @var App\BaseURL */
        private $baseUrl;
        /** @var L10n */
@@ -48,6 +50,7 @@ class Authentication
         * Authentication constructor.
         *
         * @param Configuration   $config
+        * @param App\Mode        $mode
         * @param App\BaseURL     $baseUrl
         * @param L10n            $l10n
         * @param Database        $dba
@@ -55,9 +58,10 @@ class Authentication
         * @param User\Cookie     $cookie
         * @param Session\ISession $session
         */
-       public function __construct(Configuration $config, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
+       public function __construct(Configuration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
        {
                $this->config  = $config;
+               $this->mode = $mode;
                $this->baseUrl = $baseUrl;
                $this->l10n    = $l10n;
                $this->dba     = $dba;
@@ -404,7 +408,7 @@ class Authentication
                }
 
                // Case 2: No valid 2FA session: redirect to code verification page
-               if ($a->isAjax()) {
+               if ($this->mode->isAjax()) {
                        throw new HTTPException\ForbiddenException();
                } else {
                        $this->baseUrl->redirect('2fa');
index c45204e98a278c98b232fc84f5035abf98e748d7..f6a3c61b731db6c43af65c5537ce4a4323165a17 100644 (file)
@@ -32,7 +32,7 @@ class Details extends BaseAdminModule
 
                        info(L10n::t('Theme settings updated.'));
 
-                       if ($a->isAjax()) {
+                       if (DI::mode()->isAjax()) {
                                return;
                        }
 
index 0ef72773d29012c54b7f6c73475e7cce73b769b1..fc0d3301bff06a89062dd3260569cb9d115b8e97 100644 (file)
@@ -46,7 +46,7 @@ class Embed extends BaseAdminModule
 
                        info(L10n::t('Theme settings updated.'));
 
-                       if ($a->isAjax()) {
+                       if (DI::mode()->isAjax()) {
                                return;
                        }
 
index 8212ce38b5cafe6abf86ee9eecb251c2663fc029..d32e1f6c2dc8fd4fc5a33341e0669416fb7e679e 100644 (file)
@@ -31,7 +31,7 @@ class ItemBody extends BaseModule
                $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
 
                if (!empty($item)) {
-                       if ($app->isAjax()) {
+                       if (DI::mode()->isAjax()) {
                                echo str_replace("\n", '<br />', $item['body']);
                                exit();
                        } else {
index b3fe1ba53b04751948329f21921d48c1d3be689b..8de4c5033b1b2095734038fb9a686bb3db7b9f74 100644 (file)
@@ -24,7 +24,7 @@ class Group extends BaseModule
        {
                $a = DI::app();
 
-               if ($a->isAjax()) {
+               if (DI::mode()->isAjax()) {
                        self::ajaxPost();
                }