]> git.mxchange.org Git - friendica.git/blobdiff - src/BaseModule.php
Merge remote-tracking branch 'upstream/develop' into api-rework
[friendica.git] / src / BaseModule.php
index b9db1953e5a3c6ef1c0550969383c4fb7245b73c..be4788045c2d283d73c5c30080c1ebf661ee7710 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica;
 
 use Friendica\Capabilities\ICanHandleRequests;
+use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Model\User;
 
@@ -37,75 +38,85 @@ use Friendica\Model\User;
 abstract class BaseModule implements ICanHandleRequests
 {
        /** @var array */
-       protected static $parameters = [];
+       protected $parameters = [];
 
-       public function __construct(array $parameters = [])
+       /** @var L10n */
+       protected $l10n;
+
+       public function __construct(L10n $l10n, array $parameters = [])
        {
-               static::$parameters = $parameters;
+               $this->parameters = $parameters;
+               $this->l10n       = $l10n;
        }
 
        /**
-        * {@inheritDoc}
+        * Wraps the L10n::t() function for Modules
+        *
+        * @see L10n::t()
         */
-       public static function init()
+       protected function t(string $s, ...$args): string
        {
+               return $this->l10n->t($s, $args);
        }
 
        /**
-        * {@inheritDoc}
+        * Wraps the L10n::tt() function for Modules
+        *
+        * @see L10n::tt()
         */
-       public static function rawContent()
+       protected function tt(string $singular, string $plurarl, int $count): string
        {
-               // echo '';
-               // exit;
+               return $this->l10n->tt($singular, $plurarl, $count);
        }
 
        /**
         * {@inheritDoc}
         */
-       public static function content()
+       public function rawContent()
        {
-               return '';
+               // echo '';
+               // exit;
        }
 
        /**
         * {@inheritDoc}
         */
-       public static function delete()
+       public function content(): string
        {
+               return '';
        }
 
        /**
         * {@inheritDoc}
         */
-       public static function patch()
+       public function delete()
        {
        }
 
        /**
         * {@inheritDoc}
         */
-       public static function post()
+       public function patch()
        {
-               // DI::baseurl()->redirect('module');
        }
 
        /**
         * {@inheritDoc}
         */
-       public static function afterpost()
+       public function post()
        {
+               // DI::baseurl()->redirect('module');
        }
 
        /**
         * {@inheritDoc}
         */
-       public static function put()
+       public function put()
        {
        }
 
        /** Gets the name of the current class */
-       public static function getClassName(): string
+       public function getClassName(): string
        {
                return static::class;
        }