X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp%2FMode.php;h=59a47d8284360bf8838c826ebf52dc45f9105c14;hb=319857edaa1257c885ce7f3a91ee168b95feee10;hp=79d6d87ffa5b38de04e0bc1ab44bb5f4d7e7dde9;hpb=73a7df85f7bbbb8fd5c31626ab91c58b1e31e4a2;p=friendica.git diff --git a/src/App/Mode.php b/src/App/Mode.php index 79d6d87ffa..59a47d8284 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -1,6 +1,6 @@ isBackend(); + $isBackend = $isBackend || in_array($args->getModuleName(), static::BACKEND_MODULES); $isMobile = $mobileDetect->isMobile(); $isTablet = $mobileDetect->isTablet(); $isAjax = strtolower($server['HTTP_X_REQUESTED_WITH'] ?? '') == 'xmlhttprequest'; @@ -157,18 +200,43 @@ class Mode * * @return bool returns true, if the mode is set */ - public function has($mode) + public function has(int $mode): bool { return ($this->mode & $mode) > 0; } + /** + * Set the execution mode + * + * @param integer $executor Execution Mode + * @return void + */ + public function setExecutor(int $executor) + { + $this->executor = $executor; + + // Daemon and worker are always backend + if (in_array($executor, [self::DAEMON, self::WORKER])) { + $this->isBackend = true; + } + } + + /*isBackend = true;* + * get the execution mode + * + * @return int Execution Mode + */ + public function getExecutor(): int + { + return $this->executor; + } /** * Install mode is when the local config file is missing or the DB schema hasn't been installed yet. * - * @return bool + * @return bool Whether installation mode is active (local/database configuration files present or not) */ - public function isInstall() + public function isInstall(): bool { return !$this->has(Mode::LOCALCONFIGPRESENT) || !$this->has(MODE::DBCONFIGAVAILABLE); @@ -179,7 +247,7 @@ class Mode * * @return bool */ - public function isNormal() + public function isNormal(): bool { return $this->has(Mode::LOCALCONFIGPRESENT) && $this->has(Mode::DBAVAILABLE) && @@ -192,7 +260,7 @@ class Mode * * @return bool Is it a backend call */ - public function isBackend() + public function isBackend(): bool { return $this->isBackend; } @@ -202,7 +270,7 @@ class Mode * * @return bool true if it was an AJAX request */ - public function isAjax() + public function isAjax(): bool { return $this->isAjax; } @@ -212,7 +280,7 @@ class Mode * * @return bool true if it was an mobile request */ - public function isMobile() + public function isMobile(): bool { return $this->isMobile; } @@ -222,7 +290,7 @@ class Mode * * @return bool true if it was an tablet request */ - public function isTablet() + public function isTablet(): bool { return $this->isTablet; }