]> git.mxchange.org Git - friendica.git/blobdiff - src/App/Module.php
Merge remote-tracking branch 'upstream/develop' into item-view
[friendica.git] / src / App / Module.php
index 891dc591461dc739e0928b2163393056f33b834c..fff7641b76059113bd194fa5ba9cbabeb9866a67 100644 (file)
@@ -1,4 +1,23 @@
 <?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\App;
 
@@ -11,6 +30,7 @@ use Friendica\Module\HTTPException\MethodNotAllowed;
 use Friendica\Module\HTTPException\PageNotFound;
 use Friendica\Network\HTTPException\MethodNotAllowedException;
 use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -149,15 +169,15 @@ class Module
        /**
         * Determine the class of the current module
         *
-        * @param Arguments                 $args   The Friendica execution arguments
-        * @param Router                    $router The Friendica routing instance
-        * @param Core\Config\IConfiguration $config The Friendica Configuration
+        * @param Arguments           $args   The Friendica execution arguments
+        * @param Router              $router The Friendica routing instance
+        * @param Core\Config\IConfig $config The Friendica Configuration
         *
         * @return Module The determined module of this call
         *
         * @throws \Exception
         */
-       public function determineClass(Arguments $args, Router $router, Core\Config\IConfiguration $config)
+       public function determineClass(Arguments $args, Router $router, Core\Config\IConfig $config)
        {
                $printNotAllowedAddon = false;
 
@@ -215,10 +235,10 @@ class Module
         *
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, array $server, array $post)
+       public function run(Core\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, Profiler $profiler, array $server, array $post)
        {
                if ($this->printNotAllowedAddon) {
-                       info($l10n->t("You must be logged in to use addons. "));
+                       notice($l10n->t("You must be logged in to use addons. "));
                }
 
                /* The URL provided does not resolve to a valid module.
@@ -247,10 +267,15 @@ class Module
 
                $placeholder = '';
 
+               $profiler->set(microtime(true), 'ready');
+               $timestamp = microtime(true);
+
                Core\Hook::callAll($this->module . '_mod_init', $placeholder);
 
                call_user_func([$this->module_class, 'init'], $this->module_parameters);
 
+               $profiler->set(microtime(true) - $timestamp, 'init');
+
                if ($server['REQUEST_METHOD'] === 'POST') {
                        Core\Hook::callAll($this->module . '_mod_post', $post);
                        call_user_func([$this->module_class, 'post'], $this->module_parameters);