From 90732a4fad9a79d576861604f46db3d719772a30 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 18 Nov 2018 16:28:04 +0100 Subject: [PATCH] Removed translations from Rest module --- module/Rest/config/auth.config.php | 5 +- module/Rest/config/dependencies.config.php | 35 ++---- module/Rest/config/translator.config.php | 16 --- module/Rest/lang/es.mo | Bin 3049 -> 0 bytes module/Rest/lang/es.po | 110 ------------------ module/Rest/src/Action/AuthenticateAction.php | 13 +-- .../ShortUrl/AbstractCreateShortUrlAction.php | 19 +-- .../Action/ShortUrl/CreateShortUrlAction.php | 3 +- .../Action/ShortUrl/DeleteShortUrlAction.php | 20 +--- .../Action/ShortUrl/EditShortUrlAction.php | 17 +-- .../ShortUrl/EditShortUrlTagsAction.php | 17 +-- .../Action/ShortUrl/ListShortUrlsAction.php | 9 +- .../Action/ShortUrl/ResolveShortUrlAction.php | 16 +-- .../SingleStepCreateShortUrlAction.php | 10 +- .../Rest/src/Action/Tag/UpdateTagAction.php | 23 +--- .../Rest/src/Action/Visit/GetVisitsAction.php | 20 +--- .../Plugin/ApiKeyHeaderPlugin.php | 10 +- .../Plugin/AuthorizationHeaderPlugin.php | 24 ++-- .../Middleware/AuthenticationMiddleware.php | 16 +-- .../test/Action/AuthenticateActionTest.php | 7 +- .../ShortUrl/CreateShortUrlActionTest.php | 3 +- .../ShortUrl/DeleteShortUrlActionTest.php | 3 +- .../ShortUrl/EditShortUrlActionTest.php | 3 +- .../ShortUrl/EditShortUrlTagsActionTest.php | 3 +- .../ShortUrl/ListShortUrlsActionTest.php | 3 +- .../ShortUrl/ResolveShortUrlActionTest.php | 3 +- .../SingleStepCreateShortUrlActionTest.php | 2 - .../test/Action/Tag/UpdateTagActionTest.php | 3 +- .../test/Action/Visit/GetVisitsActionTest.php | 3 +- .../Plugin/ApiKeyHeaderPluginTest.php | 3 +- .../Plugin/AuthorizationHeaderPluginTest.php | 3 +- module/Rest/test/ConfigProviderTest.php | 1 - .../AuthenticationMiddlewareTest.php | 5 +- 33 files changed, 70 insertions(+), 358 deletions(-) delete mode 100644 module/Rest/config/translator.config.php delete mode 100644 module/Rest/lang/es.mo delete mode 100644 module/Rest/lang/es.po diff --git a/module/Rest/config/auth.config.php b/module/Rest/config/auth.config.php index 8786e202..1355d520 100644 --- a/module/Rest/config/auth.config.php +++ b/module/Rest/config/auth.config.php @@ -38,14 +38,13 @@ return [ ], ConfigAbstractFactory::class => [ - Authentication\Plugin\AuthorizationHeaderPlugin::class => [Authentication\JWTService::class, 'translator'], - Authentication\Plugin\ApiKeyHeaderPlugin::class => [Service\ApiKeyService::class, 'translator'], + Authentication\Plugin\AuthorizationHeaderPlugin::class => [Authentication\JWTService::class], + Authentication\Plugin\ApiKeyHeaderPlugin::class => [Service\ApiKeyService::class], Authentication\RequestToHttpAuthPlugin::class => [Authentication\AuthenticationPluginManager::class], Middleware\AuthenticationMiddleware::class => [ Authentication\RequestToHttpAuthPlugin::class, - 'translator', 'config.auth.routes_whitelist', 'Logger_Shlink', ], diff --git a/module/Rest/config/dependencies.config.php b/module/Rest/config/dependencies.config.php index 69f698bc..ab2d9901 100644 --- a/module/Rest/config/dependencies.config.php +++ b/module/Rest/config/dependencies.config.php @@ -7,7 +7,6 @@ use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Core\Options\AppOptions; use Shlinkio\Shlink\Core\Service; use Shlinkio\Shlink\Rest\Service\ApiKeyService; -use Zend\I18n\Translator\Translator; use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory; use Zend\ServiceManager\Factory\InvokableFactory; @@ -44,52 +43,32 @@ return [ Authentication\JWTService::class => [AppOptions::class], ApiKeyService::class => ['em'], - Action\AuthenticateAction::class => [ - ApiKeyService::class, - Authentication\JWTService::class, - 'translator', - 'Logger_Shlink', - ], + Action\AuthenticateAction::class => [ApiKeyService::class, Authentication\JWTService::class, 'Logger_Shlink'], Action\ShortUrl\CreateShortUrlAction::class => [ Service\UrlShortener::class, - 'translator', 'config.url_shortener.domain', 'Logger_Shlink', ], Action\ShortUrl\SingleStepCreateShortUrlAction::class => [ Service\UrlShortener::class, - 'translator', ApiKeyService::class, 'config.url_shortener.domain', 'Logger_Shlink', ], - Action\ShortUrl\EditShortUrlAction::class => [Service\ShortUrlService::class, 'translator', 'Logger_Shlink'], - Action\ShortUrl\DeleteShortUrlAction::class => [ - Service\ShortUrl\DeleteShortUrlService::class, - 'translator', - 'Logger_Shlink', - ], - Action\ShortUrl\ResolveShortUrlAction::class => [ - Service\UrlShortener::class, - 'translator', - 'config.url_shortener.domain', - ], - Action\Visit\GetVisitsAction::class => [Service\VisitsTracker::class, 'translator', 'Logger_Shlink'], + Action\ShortUrl\EditShortUrlAction::class => [Service\ShortUrlService::class, 'Logger_Shlink'], + Action\ShortUrl\DeleteShortUrlAction::class => [Service\ShortUrl\DeleteShortUrlService::class, 'Logger_Shlink'], + Action\ShortUrl\ResolveShortUrlAction::class => [Service\UrlShortener::class, 'config.url_shortener.domain'], + Action\Visit\GetVisitsAction::class => [Service\VisitsTracker::class, 'Logger_Shlink'], Action\ShortUrl\ListShortUrlsAction::class => [ Service\ShortUrlService::class, - 'translator', 'config.url_shortener.domain', 'Logger_Shlink', ], - Action\ShortUrl\EditShortUrlTagsAction::class => [ - Service\ShortUrlService::class, - 'translator', - 'Logger_Shlink', - ], + Action\ShortUrl\EditShortUrlTagsAction::class => [Service\ShortUrlService::class, 'Logger_Shlink'], Action\Tag\ListTagsAction::class => [Service\Tag\TagService::class, LoggerInterface::class], Action\Tag\DeleteTagsAction::class => [Service\Tag\TagService::class, LoggerInterface::class], Action\Tag\CreateTagsAction::class => [Service\Tag\TagService::class, LoggerInterface::class], - Action\Tag\UpdateTagAction::class => [Service\Tag\TagService::class, Translator::class, LoggerInterface::class], + Action\Tag\UpdateTagAction::class => [Service\Tag\TagService::class, LoggerInterface::class], ], ]; diff --git a/module/Rest/config/translator.config.php b/module/Rest/config/translator.config.php deleted file mode 100644 index 659d4cae..00000000 --- a/module/Rest/config/translator.config.php +++ /dev/null @@ -1,16 +0,0 @@ - [ - 'translation_file_patterns' => [ - [ - 'type' => 'gettext', - 'base_dir' => __DIR__ . '/../lang', - 'pattern' => '%s.mo', - ], - ], - ], - -]; diff --git a/module/Rest/lang/es.mo b/module/Rest/lang/es.mo deleted file mode 100644 index bd1f572331456c7c7c606abec23bc2657fc9ef8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3049 zcmaJ?%WfP+6m1~9Ob8GpBqSggOO^wqJ7bH7GsXxfnIH=%v0@tq0zx(2cV;T-sT#Vf z?Ko@pNJwm0AbEvYqT~ZW{ssgqq%2?$3&fIht9xFFNl86tx~u9w&VBuU{Kz*E*7JB? z!gB}D%Xrow!VlI@z!!i&15W^d18xET1*X7@4@c2y;E%x9fp>ufJo-o!CBPW?7VuNx zdEnQ;7lFUl`+ouF@J>gfXa#ryDEnUm&jP;#UIX3*iky{4qv%iQcEDHg{>kIe0o((2 zfZqcZ@YoYkv;-Ugmw`V3o4`MS?*Qq^C|U(x1&aJ{fhU3g)Zb6cRB{!th3{Vhg`Z!5 zSAc&54Y2i86uk+&1B6-8Q9QDa;en_KW`^|~evjjMrh1KVJS@-^mhdm@*$TohT#4Xz zSdZZsrbkd4fwHikmfuy{zOqic%8{|228G?x8E5#MYv;*!$g8fqf4_Bez^Uhqtl@B~ z$JDWTZg;imk}7?Vjn}F2+8XMy%D8Z+s9k!f!Hr!mc%B&f{G6MQE?HXLSfd-f7f2WqM79uxwYfVg*O?p@E<3h_unrE~ zV`;QevpbTQS+4x$n}Kb}bfirXmyC~#)H!U7_h_qtJz}Y%Om{k<(;!-gCvHg)Y@u&e zG4Oi>u7yaTT{#$lM$Qu226ty!6%6ghdBkc$NT$4+R6I879_Ir0AiK6+{O>D&=yA9* z?fAs0yzJIisvMEb_8^cD-Q)otZyO$FBNqjDw`p1y1+w^KTf(lLkVbXnKvu{y8 zbdGbir|4ZZ{POiDKJ1YdjJ) z-a;}q$@5KrdXOt^mMQJ2!m(f3-ntMkjn9dBNbb00Q19q0Osy8 zEsK=TRdzM0GHfIsd9sW6x^>hoJgI5q<$lU$L` zNH;-Y_Eg9oTcn7m$}E*eNtb!hwsdZ^1t#|Ti;}%^(I#FTa!|EZkbun`z0&D!sSyx# zp;V!d;s9!srGHoLJJkob%_+i7i^eSmNiJ8`9NZ>@kiei(1BcBJg~l3sH|M&qjVhoj zG)6d0oKt#mJJVeY4hrObXyK3uL&aH@r^?(CNBal+!Ip3!bZ>?B4GkTf9H~HF7;s($ zuZI2#y`st3ej7tz*vJ2m&NP=60k@^miw9s2ZlIGL?4z%%G1pwHgL$>7qbM0M6^A7=Fbl#cz#M4hvUj^SI0~yxWBO@f*NXGpV0twS%Ml{N4CnIEfKU_gWtGr|xC~$F#I`A~6 z?y`&zWWE?xO%!da^2uy;p4$k)gn}yfrlMRY4z<;Fa63vwgaWB@u-|8odK!+Kz5 z859SuPFxsI9JF71&&WYZ$h5(Pk)*GRZlWGA4pWb5g<3yM9TZ{O*x}>>MX1?fOF)h! F(SLE5wK)I) diff --git a/module/Rest/lang/es.po b/module/Rest/lang/es.po deleted file mode 100644 index 7998abc0..00000000 --- a/module/Rest/lang/es.po +++ /dev/null @@ -1,110 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: Shlink 1.0\n" -"POT-Creation-Date: 2018-09-29 10:08+0200\n" -"PO-Revision-Date: 2018-09-29 10:08+0200\n" -"Last-Translator: Alejandro Celaya \n" -"Language-Team: \n" -"Language: es_ES\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.0.6\n" -"X-Poedit-Basepath: ..\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-KeywordsList: translate;translatePlural\n" -"X-Poedit-SearchPath-0: config\n" -"X-Poedit-SearchPath-1: src\n" - -msgid "You have to provide a valid API key under the \"apiKey\" param name." -msgstr "" -"Debes proporcionar una clave de API válida bajo el nombre de parámetro " -"\"apiKey\"." - -msgid "Provided API key does not exist or is invalid." -msgstr "La clave de API proporcionada no existe o es inválida." - -#, php-format -msgid "Provided URL %s is invalid. Try with a different one." -msgstr "La URL proporcionada \"%s\" es inválida. Prueba con una diferente." - -#, php-format -msgid "Provided slug %s is already in use. Try with a different one." -msgstr "El slug proporcionado \"%s\" ya está en uso. Prueba con uno diferente." - -msgid "Unexpected error occurred" -msgstr "Ocurrió un error inesperado" - -msgid "A URL was not provided" -msgstr "No se ha proporcionado una URL" - -#, php-format -msgid "No URL found for short code \"%s\"" -msgstr "No se ha encontrado ninguna URL para el código corto \"%s\"" - -#, php-format -msgid "" -"It is not possible to delete URL with short code \"%s\" because it has " -"reached more than \"%s\" visits." -msgstr "" -"No es posible eliminar la URL con el código corto \"%s\" porque ha alcanzado " -"más de \"%s\" visitas." - -msgid "Provided data is invalid." -msgstr "Los datos proporcionados son inválidos." - -msgid "A list of tags was not provided" -msgstr "No se ha proporcionado una lista de etiquetas" - -#, php-format -msgid "Provided short code \"%s\" has an invalid format" -msgstr "El código corto proporcionado \"%s\" tiene un formato no inválido" - -msgid "No API key was provided or it is not valid" -msgstr "No se ha proporcionado una clave de API o esta es inválida" - -msgid "" -"You have to provide both 'oldName' and 'newName' params in order to properly " -"rename the tag" -msgstr "" -"Debes proporcionar tanto el parámetro 'oldName' como 'newName' para poder " -"renombrar la etiqueta correctamente" - -#, php-format -msgid "It wasn't possible to find a tag with name '%s'" -msgstr "No fue posible encontrar una etiqueta con el nombre '%s'" - -#, php-format -msgid "Provided short code %s does not exist" -msgstr "El código corto \"%s\" proporcionado no existe" - -#, php-format -msgid "You need to provide the Bearer type in the %s header." -msgstr "Debes proporcionar el typo Bearer en la cabecera %s." - -#, php-format -msgid "Provided authorization type %s is not supported. Use Bearer instead." -msgstr "" -"El tipo de autorización proporcionado %s no está soportado. En vez de eso " -"utiliza Bearer." - -#, fuzzy, php-format -#| msgid "" -#| "Missing or invalid auth token provided. Perform a new authentication " -#| "request and send provided token on every new request on the \"%s\" header" -msgid "" -"Missing or invalid auth token provided. Perform a new authentication request " -"and send provided token on every new request on the %s header" -msgstr "" -"No se ha proporcionado token de autenticación o este es inválido. Realiza " -"una nueva petición de autenticación y envía el token proporcionado en cada " -"nueva petición en la cabecera \"%s\"" - -#, php-format -msgid "" -"Expected one of the following authentication headers, but none were " -"provided, [\"%s\"]" -msgstr "" -"Se esperaba una de las siguientes cabeceras de autenticación, pero no se " -"proporcionó ninguna, [\"%s\"]" diff --git a/module/Rest/src/Action/AuthenticateAction.php b/module/Rest/src/Action/AuthenticateAction.php index 3a4d2fba..e7769219 100644 --- a/module/Rest/src/Action/AuthenticateAction.php +++ b/module/Rest/src/Action/AuthenticateAction.php @@ -11,17 +11,12 @@ use Shlinkio\Shlink\Rest\Service\ApiKeyService; use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; class AuthenticateAction extends AbstractRestAction { protected const ROUTE_PATH = '/authenticate'; protected const ROUTE_ALLOWED_METHODS = [self::METHOD_POST]; - /** - * @var TranslatorInterface - */ - private $translator; /** * @var ApiKeyService|ApiKeyServiceInterface */ @@ -34,11 +29,9 @@ class AuthenticateAction extends AbstractRestAction public function __construct( ApiKeyServiceInterface $apiKeyService, JWTServiceInterface $jwtService, - TranslatorInterface $translator, LoggerInterface $logger = null ) { parent::__construct($logger); - $this->translator = $translator; $this->apiKeyService = $apiKeyService; $this->jwtService = $jwtService; } @@ -54,9 +47,7 @@ class AuthenticateAction extends AbstractRestAction if (! isset($authData['apiKey'])) { return new JsonResponse([ 'error' => RestUtils::INVALID_ARGUMENT_ERROR, - 'message' => $this->translator->translate( - 'You have to provide a valid API key under the "apiKey" param name.' - ), + 'message' => 'You have to provide a valid API key under the "apiKey" param name.', ], self::STATUS_BAD_REQUEST); } @@ -65,7 +56,7 @@ class AuthenticateAction extends AbstractRestAction if ($apiKey === null || ! $apiKey->isValid()) { return new JsonResponse([ 'error' => RestUtils::INVALID_API_KEY_ERROR, - 'message' => $this->translator->translate('Provided API key does not exist or is invalid.'), + 'message' => 'Provided API key does not exist or is invalid.', ], self::STATUS_UNAUTHORIZED); } diff --git a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php index 5fd33714..0d7f944a 100644 --- a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php @@ -16,7 +16,6 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Throwable; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; abstract class AbstractCreateShortUrlAction extends AbstractRestAction @@ -29,20 +28,14 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction * @var array */ private $domainConfig; - /** - * @var TranslatorInterface - */ - protected $translator; public function __construct( UrlShortenerInterface $urlShortener, - TranslatorInterface $translator, array $domainConfig, LoggerInterface $logger = null ) { parent::__construct($logger); $this->urlShortener = $urlShortener; - $this->translator = $translator; $this->domainConfig = $domainConfig; } @@ -82,25 +75,19 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction $this->logger->warning('Provided Invalid URL. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf( - $this->translator->translate('Provided URL %s is invalid. Try with a different one.'), - $longUrl - ), + 'message' => sprintf('Provided URL %s is invalid. Try with a different one.', $longUrl), ], self::STATUS_BAD_REQUEST); } catch (NonUniqueSlugException $e) { $this->logger->warning('Provided non-unique slug. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf( - $this->translator->translate('Provided slug %s is already in use. Try with a different one.'), - $customSlug - ), + 'message' => sprintf('Provided slug %s is already in use. Try with a different one.', $customSlug), ], self::STATUS_BAD_REQUEST); } catch (Throwable $e) { $this->logger->error('Unexpected error creating short url. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::UNKNOWN_ERROR, - 'message' => $this->translator->translate('Unexpected error occurred'), + 'message' => 'Unexpected error occurred', ], self::STATUS_INTERNAL_SERVER_ERROR); } } diff --git a/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php index b7ba983c..b49fa522 100644 --- a/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php @@ -8,7 +8,6 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Shlinkio\Shlink\Core\Exception\InvalidArgumentException; use Shlinkio\Shlink\Core\Model\CreateShortUrlData; use Shlinkio\Shlink\Core\Model\ShortUrlMeta; -use Shlinkio\Shlink\Rest\Action\ShortUrl\AbstractCreateShortUrlAction; use Zend\Diactoros\Uri; class CreateShortUrlAction extends AbstractCreateShortUrlAction @@ -26,7 +25,7 @@ class CreateShortUrlAction extends AbstractCreateShortUrlAction { $postData = (array) $request->getParsedBody(); if (! isset($postData['longUrl'])) { - throw new InvalidArgumentException($this->translator->translate('A URL was not provided')); + throw new InvalidArgumentException('A URL was not provided'); } return new CreateShortUrlData( diff --git a/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php b/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php index e5c62e9b..a53365af 100644 --- a/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php @@ -12,7 +12,6 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\EmptyResponse; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; class DeleteShortUrlAction extends AbstractRestAction @@ -24,19 +23,11 @@ class DeleteShortUrlAction extends AbstractRestAction * @var DeleteShortUrlServiceInterface */ private $deleteShortUrlService; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct( - DeleteShortUrlServiceInterface $deleteShortUrlService, - TranslatorInterface $translator, - LoggerInterface $logger = null - ) { + public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService, LoggerInterface $logger = null) + { parent::__construct($logger); $this->deleteShortUrlService = $deleteShortUrlService; - $this->translator = $translator; } /** @@ -56,13 +47,12 @@ class DeleteShortUrlAction extends AbstractRestAction ); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode), + 'message' => sprintf('No URL found for short code "%s"', $shortCode), ], self::STATUS_NOT_FOUND); } catch (Exception\DeleteShortUrlException $e) { $this->logger->warning('Provided data is invalid. {e}', ['e' => $e]); - $messagePlaceholder = $this->translator->translate( - 'It is not possible to delete URL with short code "%s" because it has reached more than "%s" visits.' - ); + $messagePlaceholder = + 'It is not possible to delete URL with short code "%s" because it has reached more than "%s" visits.'; return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), diff --git a/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php b/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php index 414dcb73..ea70855a 100644 --- a/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php @@ -13,7 +13,6 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\EmptyResponse; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; class EditShortUrlAction extends AbstractRestAction @@ -25,19 +24,11 @@ class EditShortUrlAction extends AbstractRestAction * @var ShortUrlServiceInterface */ private $shortUrlService; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct( - ShortUrlServiceInterface $shortUrlService, - TranslatorInterface $translator, - LoggerInterface $logger = null - ) { + public function __construct(ShortUrlServiceInterface $shortUrlService, LoggerInterface $logger = null) + { parent::__construct($logger); $this->shortUrlService = $shortUrlService; - $this->translator = $translator; } /** @@ -64,13 +55,13 @@ class EditShortUrlAction extends AbstractRestAction $this->logger->warning('Provided data is invalid. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode), + 'message' => sprintf('No URL found for short code "%s"', $shortCode), ], self::STATUS_NOT_FOUND); } catch (Exception\ValidationException $e) { $this->logger->warning('Provided data is invalid. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => $this->translator->translate('Provided data is invalid.'), + 'message' => 'Provided data is invalid.', ], self::STATUS_BAD_REQUEST); } } diff --git a/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php b/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php index ad79ed0e..286bc998 100644 --- a/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php +++ b/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php @@ -11,7 +11,6 @@ use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface; use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; class EditShortUrlTagsAction extends AbstractRestAction @@ -23,19 +22,11 @@ class EditShortUrlTagsAction extends AbstractRestAction * @var ShortUrlServiceInterface */ private $shortUrlService; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct( - ShortUrlServiceInterface $shortUrlService, - TranslatorInterface $translator, - LoggerInterface $logger = null - ) { + public function __construct(ShortUrlServiceInterface $shortUrlService, LoggerInterface $logger = null) + { parent::__construct($logger); $this->shortUrlService = $shortUrlService; - $this->translator = $translator; } /** @@ -51,7 +42,7 @@ class EditShortUrlTagsAction extends AbstractRestAction if (! isset($bodyParams['tags'])) { return new JsonResponse([ 'error' => RestUtils::INVALID_ARGUMENT_ERROR, - 'message' => $this->translator->translate('A list of tags was not provided'), + 'message' => 'A list of tags was not provided', ], self::STATUS_BAD_REQUEST); } $tags = $bodyParams['tags']; @@ -62,7 +53,7 @@ class EditShortUrlTagsAction extends AbstractRestAction } catch (InvalidShortCodeException $e) { return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode), + 'message' => sprintf('No URL found for short code "%s"', $shortCode), ], self::STATUS_NOT_FOUND); } } diff --git a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php index 88267cf9..3e81c60d 100644 --- a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php +++ b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php @@ -13,7 +13,6 @@ use Shlinkio\Shlink\Core\Transformer\ShortUrlDataTransformer; use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; class ListShortUrlsAction extends AbstractRestAction { @@ -26,10 +25,6 @@ class ListShortUrlsAction extends AbstractRestAction * @var ShortUrlServiceInterface */ private $shortUrlService; - /** - * @var TranslatorInterface - */ - private $translator; /** * @var array */ @@ -37,13 +32,11 @@ class ListShortUrlsAction extends AbstractRestAction public function __construct( ShortUrlServiceInterface $shortUrlService, - TranslatorInterface $translator, array $domainConfig, LoggerInterface $logger = null ) { parent::__construct($logger); $this->shortUrlService = $shortUrlService; - $this->translator = $translator; $this->domainConfig = $domainConfig; } @@ -64,7 +57,7 @@ class ListShortUrlsAction extends AbstractRestAction $this->logger->error('Unexpected error while listing short URLs. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::UNKNOWN_ERROR, - 'message' => $this->translator->translate('Unexpected error occurred'), + 'message' => 'Unexpected error occurred', ], self::STATUS_INTERNAL_SERVER_ERROR); } } diff --git a/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php b/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php index b2c94858..25a640ec 100644 --- a/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php @@ -14,7 +14,6 @@ use Shlinkio\Shlink\Core\Transformer\ShortUrlDataTransformer; use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; class ResolveShortUrlAction extends AbstractRestAction @@ -26,10 +25,6 @@ class ResolveShortUrlAction extends AbstractRestAction * @var UrlShortenerInterface */ private $urlShortener; - /** - * @var TranslatorInterface - */ - private $translator; /** * @var array */ @@ -37,13 +32,11 @@ class ResolveShortUrlAction extends AbstractRestAction public function __construct( UrlShortenerInterface $urlShortener, - TranslatorInterface $translator, array $domainConfig, LoggerInterface $logger = null ) { parent::__construct($logger); $this->urlShortener = $urlShortener; - $this->translator = $translator; $this->domainConfig = $domainConfig; } @@ -64,22 +57,19 @@ class ResolveShortUrlAction extends AbstractRestAction $this->logger->warning('Provided short code with invalid format. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf( - $this->translator->translate('Provided short code "%s" has an invalid format'), - $shortCode - ), + 'message' => sprintf('Provided short code "%s" has an invalid format', $shortCode), ], self::STATUS_BAD_REQUEST); } catch (EntityDoesNotExistException $e) { $this->logger->warning('Provided short code couldn\'t be found. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::INVALID_ARGUMENT_ERROR, - 'message' => sprintf($this->translator->translate('No URL found for short code "%s"'), $shortCode), + 'message' => sprintf('No URL found for short code "%s"', $shortCode), ], self::STATUS_NOT_FOUND); } catch (Exception $e) { $this->logger->error('Unexpected error while resolving the URL behind a short code. {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::UNKNOWN_ERROR, - 'message' => $this->translator->translate('Unexpected error occurred'), + 'message' => 'Unexpected error occurred', ], self::STATUS_INTERNAL_SERVER_ERROR); } } diff --git a/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php index 52bee6c1..cb6284cf 100644 --- a/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php @@ -10,7 +10,6 @@ use Shlinkio\Shlink\Core\Model\CreateShortUrlData; use Shlinkio\Shlink\Core\Service\UrlShortenerInterface; use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Zend\Diactoros\Uri; -use Zend\I18n\Translator\TranslatorInterface; class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction { @@ -24,12 +23,11 @@ class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction public function __construct( UrlShortenerInterface $urlShortener, - TranslatorInterface $translator, ApiKeyServiceInterface $apiKeyService, array $domainConfig, LoggerInterface $logger = null ) { - parent::__construct($urlShortener, $translator, $domainConfig, $logger); + parent::__construct($urlShortener, $domainConfig, $logger); $this->apiKeyService = $apiKeyService; } @@ -44,13 +42,11 @@ class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction $query = $request->getQueryParams(); if (! $this->apiKeyService->check($query['apiKey'] ?? '')) { - throw new InvalidArgumentException( - $this->translator->translate('No API key was provided or it is not valid') - ); + throw new InvalidArgumentException('No API key was provided or it is not valid'); } if (! isset($query['longUrl'])) { - throw new InvalidArgumentException($this->translator->translate('A URL was not provided')); + throw new InvalidArgumentException('A URL was not provided'); } return new CreateShortUrlData(new Uri($query['longUrl'])); diff --git a/module/Rest/src/Action/Tag/UpdateTagAction.php b/module/Rest/src/Action/Tag/UpdateTagAction.php index b17ea940..7fb155cb 100644 --- a/module/Rest/src/Action/Tag/UpdateTagAction.php +++ b/module/Rest/src/Action/Tag/UpdateTagAction.php @@ -12,7 +12,6 @@ use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\EmptyResponse; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; class UpdateTagAction extends AbstractRestAction @@ -24,19 +23,11 @@ class UpdateTagAction extends AbstractRestAction * @var TagServiceInterface */ private $tagService; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct( - TagServiceInterface $tagService, - TranslatorInterface $translator, - LoggerInterface $logger = null - ) { + public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null) + { parent::__construct($logger); $this->tagService = $tagService; - $this->translator = $translator; } /** @@ -54,9 +45,8 @@ class UpdateTagAction extends AbstractRestAction if (! isset($body['oldName'], $body['newName'])) { return new JsonResponse([ 'error' => RestUtils::INVALID_ARGUMENT_ERROR, - 'message' => $this->translator->translate( - 'You have to provide both \'oldName\' and \'newName\' params in order to properly rename the tag' - ), + 'message' => + 'You have to provide both \'oldName\' and \'newName\' params in order to properly rename the tag', ], self::STATUS_BAD_REQUEST); } @@ -66,10 +56,7 @@ class UpdateTagAction extends AbstractRestAction } catch (EntityDoesNotExistException $e) { return new JsonResponse([ 'error' => RestUtils::NOT_FOUND_ERROR, - 'message' => sprintf( - $this->translator->translate('It wasn\'t possible to find a tag with name \'%s\''), - $body['oldName'] - ), + 'message' => sprintf('It was not possible to find a tag with name %s', $body['oldName']), ], self::STATUS_NOT_FOUND); } } diff --git a/module/Rest/src/Action/Visit/GetVisitsAction.php b/module/Rest/src/Action/Visit/GetVisitsAction.php index 8f1db5f3..c705a80f 100644 --- a/module/Rest/src/Action/Visit/GetVisitsAction.php +++ b/module/Rest/src/Action/Visit/GetVisitsAction.php @@ -14,7 +14,6 @@ use Shlinkio\Shlink\Core\Service\VisitsTrackerInterface; use Shlinkio\Shlink\Rest\Action\AbstractRestAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; -use Zend\I18n\Translator\TranslatorInterface; use function sprintf; class GetVisitsAction extends AbstractRestAction @@ -26,19 +25,11 @@ class GetVisitsAction extends AbstractRestAction * @var VisitsTrackerInterface */ private $visitsTracker; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct( - VisitsTrackerInterface $visitsTracker, - TranslatorInterface $translator, - LoggerInterface $logger = null - ) { + public function __construct(VisitsTrackerInterface $visitsTracker, LoggerInterface $logger = null) + { parent::__construct($logger); $this->visitsTracker = $visitsTracker; - $this->translator = $translator; } /** @@ -64,16 +55,13 @@ class GetVisitsAction extends AbstractRestAction $this->logger->warning('Provided nonexistent short code {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::getRestErrorCodeFromException($e), - 'message' => sprintf( - $this->translator->translate('Provided short code %s does not exist'), - $shortCode - ), + 'message' => sprintf('Provided short code %s does not exist', $shortCode), ], self::STATUS_NOT_FOUND); } catch (Exception $e) { $this->logger->error('Unexpected error while parsing short code {e}', ['e' => $e]); return new JsonResponse([ 'error' => RestUtils::UNKNOWN_ERROR, - 'message' => $this->translator->translate('Unexpected error occurred'), + 'message' => 'Unexpected error occurred', ], self::STATUS_INTERNAL_SERVER_ERROR); } } diff --git a/module/Rest/src/Authentication/Plugin/ApiKeyHeaderPlugin.php b/module/Rest/src/Authentication/Plugin/ApiKeyHeaderPlugin.php index fcf41b96..6ad5877e 100644 --- a/module/Rest/src/Authentication/Plugin/ApiKeyHeaderPlugin.php +++ b/module/Rest/src/Authentication/Plugin/ApiKeyHeaderPlugin.php @@ -8,7 +8,6 @@ use Psr\Http\Message\ServerRequestInterface; use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException; use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Shlinkio\Shlink\Rest\Util\RestUtils; -use Zend\I18n\Translator\TranslatorInterface; class ApiKeyHeaderPlugin implements AuthenticationPluginInterface { @@ -18,15 +17,10 @@ class ApiKeyHeaderPlugin implements AuthenticationPluginInterface * @var ApiKeyServiceInterface */ private $apiKeyService; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct(ApiKeyServiceInterface $apiKeyService, TranslatorInterface $translator) + public function __construct(ApiKeyServiceInterface $apiKeyService) { $this->apiKeyService = $apiKeyService; - $this->translator = $translator; } /** @@ -41,7 +35,7 @@ class ApiKeyHeaderPlugin implements AuthenticationPluginInterface throw VerifyAuthenticationException::withError( RestUtils::INVALID_API_KEY_ERROR, - $this->translator->translate('Provided API key does not exist or is invalid.') + 'Provided API key does not exist or is invalid.' ); } diff --git a/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php b/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php index 8500ed16..2be02f6b 100644 --- a/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php +++ b/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php @@ -9,7 +9,6 @@ use Shlinkio\Shlink\Rest\Authentication\JWTServiceInterface; use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException; use Shlinkio\Shlink\Rest\Util\RestUtils; use Throwable; -use Zend\I18n\Translator\TranslatorInterface; use function count; use function explode; use function sprintf; @@ -23,15 +22,10 @@ class AuthorizationHeaderPlugin implements AuthenticationPluginInterface * @var JWTServiceInterface */ private $jwtService; - /** - * @var TranslatorInterface - */ - private $translator; - public function __construct(JWTServiceInterface $jwtService, TranslatorInterface $translator) + public function __construct(JWTServiceInterface $jwtService) { $this->jwtService = $jwtService; - $this->translator = $translator; } /** @@ -45,10 +39,7 @@ class AuthorizationHeaderPlugin implements AuthenticationPluginInterface if (count($authTokenParts) === 1) { throw VerifyAuthenticationException::withError( RestUtils::INVALID_AUTHORIZATION_ERROR, - sprintf( - $this->translator->translate('You need to provide the Bearer type in the %s header.'), - self::HEADER_NAME - ) + sprintf('You need to provide the Bearer type in the %s header.', self::HEADER_NAME) ); } @@ -57,9 +48,7 @@ class AuthorizationHeaderPlugin implements AuthenticationPluginInterface if (strtolower($authType) !== 'bearer') { throw VerifyAuthenticationException::withError( RestUtils::INVALID_AUTHORIZATION_ERROR, - sprintf($this->translator->translate( - 'Provided authorization type %s is not supported. Use Bearer instead.' - ), $authType) + sprintf('Provided authorization type %s is not supported. Use Bearer instead.', $authType) ); } @@ -76,10 +65,11 @@ class AuthorizationHeaderPlugin implements AuthenticationPluginInterface { return VerifyAuthenticationException::withError( RestUtils::INVALID_AUTH_TOKEN_ERROR, - sprintf($this->translator->translate( + sprintf( 'Missing or invalid auth token provided. Perform a new authentication request and send provided ' - . 'token on every new request on the %s header' - ), self::HEADER_NAME), + . 'token on every new request on the %s header', + self::HEADER_NAME + ), $prev ); } diff --git a/module/Rest/src/Middleware/AuthenticationMiddleware.php b/module/Rest/src/Middleware/AuthenticationMiddleware.php index 164fb636..f19fc5d0 100644 --- a/module/Rest/src/Middleware/AuthenticationMiddleware.php +++ b/module/Rest/src/Middleware/AuthenticationMiddleware.php @@ -19,17 +19,12 @@ use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; use Zend\Expressive\Router\RouteResult; -use Zend\I18n\Translator\TranslatorInterface; use function Functional\contains; use function implode; use function sprintf; class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterface, RequestMethodInterface { - /** - * @var TranslatorInterface - */ - private $translator; /** * @var LoggerInterface */ @@ -45,14 +40,12 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa public function __construct( RequestToHttpAuthPluginInterface $requestToAuthPlugin, - TranslatorInterface $translator, array $routesWhitelist, LoggerInterface $logger = null ) { - $this->translator = $translator; $this->routesWhitelist = $routesWhitelist; - $this->logger = $logger ?: new NullLogger(); $this->requestToAuthPlugin = $requestToAuthPlugin; + $this->logger = $logger ?: new NullLogger(); } /** @@ -81,9 +74,10 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa $plugin = $this->requestToAuthPlugin->fromRequest($request); } catch (ContainerExceptionInterface | NoAuthenticationException $e) { $this->logger->warning('Invalid or no authentication provided. {e}', ['e' => $e]); - return $this->createErrorResponse(sprintf($this->translator->translate( - 'Expected one of the following authentication headers, but none were provided, ["%s"]' - ), implode('", "', RequestToHttpAuthPlugin::SUPPORTED_AUTH_HEADERS))); + return $this->createErrorResponse(sprintf( + 'Expected one of the following authentication headers, but none were provided, ["%s"]', + implode('", "', RequestToHttpAuthPlugin::SUPPORTED_AUTH_HEADERS) + )); } try { diff --git a/module/Rest/test/Action/AuthenticateActionTest.php b/module/Rest/test/Action/AuthenticateActionTest.php index 56db59a9..e282c46e 100644 --- a/module/Rest/test/Action/AuthenticateActionTest.php +++ b/module/Rest/test/Action/AuthenticateActionTest.php @@ -11,7 +11,6 @@ use Shlinkio\Shlink\Rest\Authentication\JWTService; use Shlinkio\Shlink\Rest\Entity\ApiKey; use Shlinkio\Shlink\Rest\Service\ApiKeyService; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; use function strpos; class AuthenticateActionTest extends TestCase @@ -35,11 +34,7 @@ class AuthenticateActionTest extends TestCase $this->jwtService = $this->prophesize(JWTService::class); $this->jwtService->create(Argument::cetera())->willReturn(''); - $this->action = new AuthenticateAction( - $this->apiKeyService->reveal(), - $this->jwtService->reveal(), - Translator::factory([]) - ); + $this->action = new AuthenticateAction($this->apiKeyService->reveal(), $this->jwtService->reveal()); } /** diff --git a/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php index eb355c44..b523cf25 100644 --- a/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php @@ -15,7 +15,6 @@ use Shlinkio\Shlink\Rest\Action\ShortUrl\CreateShortUrlAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\Uri; -use Zend\I18n\Translator\Translator; use function strpos; class CreateShortUrlActionTest extends TestCase @@ -32,7 +31,7 @@ class CreateShortUrlActionTest extends TestCase public function setUp() { $this->urlShortener = $this->prophesize(UrlShortener::class); - $this->action = new CreateShortUrlAction($this->urlShortener->reveal(), Translator::factory([]), [ + $this->action = new CreateShortUrlAction($this->urlShortener->reveal(), [ 'schema' => 'http', 'hostname' => 'foo.com', ]); diff --git a/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php index 593c70fc..0eaddc7c 100644 --- a/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php @@ -13,7 +13,6 @@ use Shlinkio\Shlink\Rest\Util\RestUtils; use Throwable; use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class DeleteShortUrlActionTest extends TestCase { @@ -29,7 +28,7 @@ class DeleteShortUrlActionTest extends TestCase public function setUp() { $this->service = $this->prophesize(DeleteShortUrlServiceInterface::class); - $this->action = new DeleteShortUrlAction($this->service->reveal(), Translator::factory([])); + $this->action = new DeleteShortUrlAction($this->service->reveal()); } /** diff --git a/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php index f6bf079f..2627abb0 100644 --- a/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php @@ -13,7 +13,6 @@ use Shlinkio\Shlink\Rest\Action\ShortUrl\EditShortUrlAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class EditShortUrlActionTest extends TestCase { @@ -29,7 +28,7 @@ class EditShortUrlActionTest extends TestCase public function setUp() { $this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class); - $this->action = new EditShortUrlAction($this->shortUrlService->reveal(), Translator::factory([])); + $this->action = new EditShortUrlAction($this->shortUrlService->reveal()); } /** diff --git a/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php b/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php index 2b71903a..bbdb84ff 100644 --- a/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php +++ b/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php @@ -10,7 +10,6 @@ use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException; use Shlinkio\Shlink\Core\Service\ShortUrlService; use Shlinkio\Shlink\Rest\Action\ShortUrl\EditShortUrlTagsAction; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class EditShortUrlTagsActionTest extends TestCase { @@ -26,7 +25,7 @@ class EditShortUrlTagsActionTest extends TestCase public function setUp() { $this->shortUrlService = $this->prophesize(ShortUrlService::class); - $this->action = new EditShortUrlTagsAction($this->shortUrlService->reveal(), Translator::factory([])); + $this->action = new EditShortUrlTagsAction($this->shortUrlService->reveal()); } /** diff --git a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php index a83a7dc0..dc416523 100644 --- a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php +++ b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php @@ -9,7 +9,6 @@ use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\Core\Service\ShortUrlService; use Shlinkio\Shlink\Rest\Action\ShortUrl\ListShortUrlsAction; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; use Zend\Paginator\Adapter\ArrayAdapter; use Zend\Paginator\Paginator; @@ -27,7 +26,7 @@ class ListShortUrlsActionTest extends TestCase public function setUp() { $this->service = $this->prophesize(ShortUrlService::class); - $this->action = new ListShortUrlsAction($this->service->reveal(), Translator::factory([]), [ + $this->action = new ListShortUrlsAction($this->service->reveal(), [ 'hostname' => 'doma.in', 'schema' => 'https', ]); diff --git a/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php index 58010acd..97ffdbb0 100644 --- a/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php @@ -13,7 +13,6 @@ use Shlinkio\Shlink\Core\Service\UrlShortener; use Shlinkio\Shlink\Rest\Action\ShortUrl\ResolveShortUrlAction; use Shlinkio\Shlink\Rest\Util\RestUtils; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; use function strpos; class ResolveShortUrlActionTest extends TestCase @@ -30,7 +29,7 @@ class ResolveShortUrlActionTest extends TestCase public function setUp() { $this->urlShortener = $this->prophesize(UrlShortener::class); - $this->action = new ResolveShortUrlAction($this->urlShortener->reveal(), Translator::factory([]), []); + $this->action = new ResolveShortUrlAction($this->urlShortener->reveal(), []); } /** diff --git a/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php index 3fa06c84..8edc79ea 100644 --- a/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php +++ b/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php @@ -14,7 +14,6 @@ use Shlinkio\Shlink\Rest\Action\ShortUrl\SingleStepCreateShortUrlAction; use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Zend\Diactoros\Response\JsonResponse; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class SingleStepCreateShortUrlActionTest extends TestCase { @@ -38,7 +37,6 @@ class SingleStepCreateShortUrlActionTest extends TestCase $this->action = new SingleStepCreateShortUrlAction( $this->urlShortener->reveal(), - Translator::factory([]), $this->apiKeyService->reveal(), [ 'schema' => 'http', diff --git a/module/Rest/test/Action/Tag/UpdateTagActionTest.php b/module/Rest/test/Action/Tag/UpdateTagActionTest.php index 27162ebe..1e460a5a 100644 --- a/module/Rest/test/Action/Tag/UpdateTagActionTest.php +++ b/module/Rest/test/Action/Tag/UpdateTagActionTest.php @@ -11,7 +11,6 @@ use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException; use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface; use Shlinkio\Shlink\Rest\Action\Tag\UpdateTagAction; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class UpdateTagActionTest extends TestCase { @@ -27,7 +26,7 @@ class UpdateTagActionTest extends TestCase public function setUp() { $this->tagService = $this->prophesize(TagServiceInterface::class); - $this->action = new UpdateTagAction($this->tagService->reveal(), Translator::factory([])); + $this->action = new UpdateTagAction($this->tagService->reveal()); } /** diff --git a/module/Rest/test/Action/Visit/GetVisitsActionTest.php b/module/Rest/test/Action/Visit/GetVisitsActionTest.php index a95868cb..dd76c928 100644 --- a/module/Rest/test/Action/Visit/GetVisitsActionTest.php +++ b/module/Rest/test/Action/Visit/GetVisitsActionTest.php @@ -13,7 +13,6 @@ use Shlinkio\Shlink\Common\Util\DateRange; use Shlinkio\Shlink\Core\Service\VisitsTracker; use Shlinkio\Shlink\Rest\Action\Visit\GetVisitsAction; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class GetVisitsActionTest extends TestCase { @@ -29,7 +28,7 @@ class GetVisitsActionTest extends TestCase public function setUp() { $this->visitsTracker = $this->prophesize(VisitsTracker::class); - $this->action = new GetVisitsAction($this->visitsTracker->reveal(), Translator::factory([])); + $this->action = new GetVisitsAction($this->visitsTracker->reveal()); } /** diff --git a/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php b/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php index 81256cfe..51149a41 100644 --- a/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php +++ b/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php @@ -11,7 +11,6 @@ use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException; use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; class ApiKeyHeaderPluginTest extends TestCase { @@ -27,7 +26,7 @@ class ApiKeyHeaderPluginTest extends TestCase public function setUp() { $this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class); - $this->plugin = new ApiKeyHeaderPlugin($this->apiKeyService->reveal(), Translator::factory([])); + $this->plugin = new ApiKeyHeaderPlugin($this->apiKeyService->reveal()); } /** diff --git a/module/Rest/test/Authentication/Plugin/AuthorizationHeaderPluginTest.php b/module/Rest/test/Authentication/Plugin/AuthorizationHeaderPluginTest.php index 2a5c7723..716f5d87 100644 --- a/module/Rest/test/Authentication/Plugin/AuthorizationHeaderPluginTest.php +++ b/module/Rest/test/Authentication/Plugin/AuthorizationHeaderPluginTest.php @@ -10,7 +10,6 @@ use Shlinkio\Shlink\Rest\Authentication\Plugin\AuthorizationHeaderPlugin; use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; -use Zend\I18n\Translator\Translator; use function sprintf; class AuthorizationHeaderPluginTest extends TestCase @@ -27,7 +26,7 @@ class AuthorizationHeaderPluginTest extends TestCase public function setUp() { $this->jwtService = $this->prophesize(JWTServiceInterface::class); - $this->plugin = new AuthorizationHeaderPlugin($this->jwtService->reveal(), Translator::factory([])); + $this->plugin = new AuthorizationHeaderPlugin($this->jwtService->reveal()); } /** diff --git a/module/Rest/test/ConfigProviderTest.php b/module/Rest/test/ConfigProviderTest.php index 36f95cc6..6fef55ef 100644 --- a/module/Rest/test/ConfigProviderTest.php +++ b/module/Rest/test/ConfigProviderTest.php @@ -28,6 +28,5 @@ class ConfigProviderTest extends TestCase $this->assertArrayHasKey('error_handler', $config); $this->assertArrayHasKey('routes', $config); $this->assertArrayHasKey('dependencies', $config); - $this->assertArrayHasKey('translator', $config); } } diff --git a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php index 4e3c70f9..a3434ff7 100644 --- a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php +++ b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php @@ -25,7 +25,6 @@ use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; use Zend\Expressive\Router\Route; use Zend\Expressive\Router\RouteResult; -use Zend\I18n\Translator\Translator; use function implode; use function sprintf; use function Zend\Stratigility\middleware; @@ -49,9 +48,7 @@ class AuthenticationMiddlewareTest extends TestCase public function setUp() { $this->requestToPlugin = $this->prophesize(RequestToHttpAuthPluginInterface::class); - $this->middleware = new AuthenticationMiddleware($this->requestToPlugin->reveal(), Translator::factory([]), [ - AuthenticateAction::class, - ]); + $this->middleware = new AuthenticationMiddleware($this->requestToPlugin->reveal(), [AuthenticateAction::class]); } /**