Removed any remaining reference to AnnotatedFactory

This commit is contained in:
Alejandro Celaya 2017-07-22 14:20:40 +02:00
parent b93d65ddc1
commit 01a4f9f867
15 changed files with 46 additions and 142 deletions

View File

@ -22,9 +22,9 @@
"zendframework/zend-config": "^3.0",
"zendframework/zend-i18n": "^2.7",
"zendframework/zend-config-aggregator": "^0.1",
"acelaya/zsm-annotated-services": "^1.0",
"acelaya/ze-content-based-error-handler": "^2.0",
"doctrine/orm": "^2.5",
"doctrine/annotations": "^1.4 <1.5",
"doctrine/collections": "^1.4 <1.5",
"doctrine/common": "^2.7 <2.8",
"guzzlehttp/guzzle": "^6.2",

View File

@ -1,34 +1,62 @@
<?php
use Acelaya\ZsmAnnotatedServices\Factory\V3\AnnotatedFactory;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Options\AppOptions;
use Shlinkio\Shlink\Core\Service;
use Shlinkio\Shlink\Rest\Action;
use Shlinkio\Shlink\Rest\Authentication\JWTService;
use Shlinkio\Shlink\Rest\Middleware;
use Shlinkio\Shlink\Rest\Service;
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
use Zend\I18n\Translator\Translator;
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'dependencies' => [
'factories' => [
JWTService::class => AnnotatedFactory::class,
Service\ApiKeyService::class => AnnotatedFactory::class,
JWTService::class => ConfigAbstractFactory::class,
ApiKeyService::class => ConfigAbstractFactory::class,
Action\AuthenticateAction::class => AnnotatedFactory::class,
Action\CreateShortcodeAction::class => AnnotatedFactory::class,
Action\ResolveUrlAction::class => AnnotatedFactory::class,
Action\GetVisitsAction::class => AnnotatedFactory::class,
Action\ListShortcodesAction::class => AnnotatedFactory::class,
Action\EditShortcodeTagsAction::class => AnnotatedFactory::class,
Action\Tag\ListTagsAction::class => AnnotatedFactory::class,
Action\Tag\DeleteTagsAction::class => AnnotatedFactory::class,
Action\Tag\CreateTagsAction::class => AnnotatedFactory::class,
Action\Tag\UpdateTagAction::class => AnnotatedFactory::class,
Action\AuthenticateAction::class => ConfigAbstractFactory::class,
Action\CreateShortcodeAction::class => ConfigAbstractFactory::class,
Action\ResolveUrlAction::class => ConfigAbstractFactory::class,
Action\GetVisitsAction::class => ConfigAbstractFactory::class,
Action\ListShortcodesAction::class => ConfigAbstractFactory::class,
Action\EditShortcodeTagsAction::class => ConfigAbstractFactory::class,
Action\Tag\ListTagsAction::class => ConfigAbstractFactory::class,
Action\Tag\DeleteTagsAction::class => ConfigAbstractFactory::class,
Action\Tag\CreateTagsAction::class => ConfigAbstractFactory::class,
Action\Tag\UpdateTagAction::class => ConfigAbstractFactory::class,
Middleware\BodyParserMiddleware::class => AnnotatedFactory::class,
Middleware\BodyParserMiddleware::class => InvokableFactory::class,
Middleware\CrossDomainMiddleware::class => InvokableFactory::class,
Middleware\PathVersionMiddleware::class => InvokableFactory::class,
Middleware\CheckAuthenticationMiddleware::class => AnnotatedFactory::class,
Middleware\CheckAuthenticationMiddleware::class => ConfigAbstractFactory::class,
],
],
ConfigAbstractFactory::class => [
JWTService::class => [AppOptions::class],
ApiKeyService::class => ['em'],
Action\AuthenticateAction::class => [ApiKeyService::class, JWTService::class, 'translator', 'Logger_Shlink'],
Action\CreateShortcodeAction::class => [
Service\UrlShortener::class,
'translator',
'config.url_shortener.domain',
'Logger_Shlink'
],
Action\ResolveUrlAction::class => [Service\UrlShortener::class, 'translator'],
Action\GetVisitsAction::class => [Service\VisitsTracker::class, 'translator', 'Logger_Shlink'],
Action\ListShortcodesAction::class => [Service\ShortUrlService::class, 'translator', 'Logger_Shlink'],
Action\EditShortcodeTagsAction::class => [Service\ShortUrlService::class, 'translator', '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],
Middleware\CheckAuthenticationMiddleware::class => [JWTService::class, 'translator', 'Logger_Shlink'],
],
];

View File

@ -1,12 +1,10 @@
<?php
namespace Shlinkio\Shlink\Rest\Action;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Rest\Authentication\JWTService;
use Shlinkio\Shlink\Rest\Authentication\JWTServiceInterface;
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
@ -29,15 +27,6 @@ class AuthenticateAction extends AbstractRestAction
*/
private $jwtService;
/**
* AuthenticateAction constructor.
* @param ApiKeyServiceInterface|ApiKeyService $apiKeyService
* @param JWTServiceInterface|JWTService $jwtService
* @param TranslatorInterface $translator
* @param LoggerInterface|null $logger
*
* @Inject({ApiKeyService::class, JWTService::class, "translator", "Logger_Shlink"})
*/
public function __construct(
ApiKeyServiceInterface $apiKeyService,
JWTServiceInterface $jwtService,

View File

@ -1,13 +1,11 @@
<?php
namespace Shlinkio\Shlink\Rest\Action;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\Core\Service\UrlShortenerInterface;
use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse;
@ -29,16 +27,6 @@ class CreateShortcodeAction extends AbstractRestAction
*/
private $translator;
/**
* GenerateShortcodeMiddleware constructor.
*
* @param UrlShortenerInterface $urlShortener
* @param TranslatorInterface $translator
* @param array $domainConfig
* @param LoggerInterface|null $logger
*
* @Inject({UrlShortener::class, "translator", "config.url_shortener.domain", "Logger_Shlink"})
*/
public function __construct(
UrlShortenerInterface $urlShortener,
TranslatorInterface $translator,

View File

@ -1,13 +1,11 @@
<?php
namespace Shlinkio\Shlink\Rest\Action;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
use Shlinkio\Shlink\Core\Service\ShortUrlService;
use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface;
use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse;
@ -24,14 +22,6 @@ class EditShortcodeTagsAction extends AbstractRestAction
*/
private $translator;
/**
* EditShortcodeTagsAction constructor.
* @param ShortUrlServiceInterface $shortUrlService
* @param TranslatorInterface $translator
* @param LoggerInterface|null $logger
*
* @Inject({ShortUrlService::class, "translator", "Logger_Shlink"})
*/
public function __construct(
ShortUrlServiceInterface $shortUrlService,
TranslatorInterface $translator,

View File

@ -1,14 +1,12 @@
<?php
namespace Shlinkio\Shlink\Rest\Action;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Common\Util\DateRange;
use Shlinkio\Shlink\Core\Service\VisitsTracker;
use Shlinkio\Shlink\Core\Service\VisitsTrackerInterface;
use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse;
@ -25,14 +23,6 @@ class GetVisitsAction extends AbstractRestAction
*/
private $translator;
/**
* GetVisitsAction constructor.
* @param VisitsTrackerInterface $visitsTracker
* @param TranslatorInterface $translator
* @param LoggerInterface $logger
*
* @Inject({VisitsTracker::class, "translator", "Logger_Shlink"})
*/
public function __construct(
VisitsTrackerInterface $visitsTracker,
TranslatorInterface $translator,

View File

@ -1,13 +1,11 @@
<?php
namespace Shlinkio\Shlink\Rest\Action;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Common\Paginator\Util\PaginatorUtilsTrait;
use Shlinkio\Shlink\Core\Service\ShortUrlService;
use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface;
use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse;
@ -26,14 +24,6 @@ class ListShortcodesAction extends AbstractRestAction
*/
private $translator;
/**
* ListShortcodesAction constructor.
* @param ShortUrlServiceInterface|ShortUrlService $shortUrlService
* @param TranslatorInterface $translator
* @param LoggerInterface $logger
*
* @Inject({ShortUrlService::class, "translator", "Logger_Shlink"})
*/
public function __construct(
ShortUrlServiceInterface $shortUrlService,
TranslatorInterface $translator,

View File

@ -1,13 +1,11 @@
<?php
namespace Shlinkio\Shlink\Rest\Action;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\Core\Service\UrlShortenerInterface;
use Shlinkio\Shlink\Rest\Util\RestUtils;
use Zend\Diactoros\Response\JsonResponse;
@ -24,14 +22,6 @@ class ResolveUrlAction extends AbstractRestAction
*/
private $translator;
/**
* ResolveUrlAction constructor.
* @param UrlShortenerInterface|UrlShortener $urlShortener
* @param TranslatorInterface $translator
* @param LoggerInterface $logger
*
* @Inject({UrlShortener::class, "translator"})
*/
public function __construct(
UrlShortenerInterface $urlShortener,
TranslatorInterface $translator,

View File

@ -1,12 +1,10 @@
<?php
namespace Shlinkio\Shlink\Rest\Action\Tag;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Service\Tag\TagService;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
use Zend\Diactoros\Response\JsonResponse;
@ -18,13 +16,6 @@ class CreateTagsAction extends AbstractRestAction
*/
private $tagService;
/**
* CreateTagsAction constructor.
* @param TagServiceInterface $tagService
* @param LoggerInterface|null $logger
*
* @DI\Inject({TagService::class, LoggerInterface::class})
*/
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
{
parent::__construct($logger);

View File

@ -1,12 +1,10 @@
<?php
namespace Shlinkio\Shlink\Rest\Action\Tag;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Service\Tag\TagService;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
use Zend\Diactoros\Response\EmptyResponse;
@ -18,13 +16,6 @@ class DeleteTagsAction extends AbstractRestAction
*/
private $tagService;
/**
* DeleteTagsAction constructor.
* @param TagServiceInterface $tagService
* @param LoggerInterface|null $logger
*
* @DI\Inject({TagService::class, LoggerInterface::class})
*/
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
{
parent::__construct($logger);

View File

@ -1,12 +1,10 @@
<?php
namespace Shlinkio\Shlink\Rest\Action\Tag;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Service\Tag\TagService;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
use Zend\Diactoros\Response\JsonResponse;
@ -18,13 +16,6 @@ class ListTagsAction extends AbstractRestAction
*/
private $tagService;
/**
* ListTagsAction constructor.
* @param TagServiceInterface $tagService
* @param LoggerInterface|null $logger
*
* @DI\Inject({TagService::class, LoggerInterface::class})
*/
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
{
parent::__construct($logger);

View File

@ -1,19 +1,16 @@
<?php
namespace Shlinkio\Shlink\Rest\Action\Tag;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;
use Shlinkio\Shlink\Core\Service\Tag\TagService;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
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\Translator;
use Zend\I18n\Translator\TranslatorInterface;
class UpdateTagAction extends AbstractRestAction
@ -27,14 +24,6 @@ class UpdateTagAction extends AbstractRestAction
*/
private $translator;
/**
* UpdateTagAction constructor.
* @param TagServiceInterface $tagService
* @param TranslatorInterface $translator
* @param LoggerInterface|null $logger
*
* @DI\Inject({TagService::class, Translator::class, LoggerInterface::class})
*/
public function __construct(
TagServiceInterface $tagService,
TranslatorInterface $translator,

View File

@ -1,7 +1,6 @@
<?php
namespace Shlinkio\Shlink\Rest\Authentication;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Firebase\JWT\JWT;
use Shlinkio\Shlink\Core\Options\AppOptions;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
@ -14,12 +13,6 @@ class JWTService implements JWTServiceInterface
*/
private $appOptions;
/**
* JWTService constructor.
* @param AppOptions $appOptions
*
* @Inject({AppOptions::class})
*/
public function __construct(AppOptions $appOptions)
{
$this->appOptions = $appOptions;

View File

@ -1,7 +1,6 @@
<?php
namespace Shlinkio\Shlink\Rest\Middleware;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Fig\Http\Message\StatusCodeInterface;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
@ -10,7 +9,6 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Shlinkio\Shlink\Rest\Action\AuthenticateAction;
use Shlinkio\Shlink\Rest\Authentication\JWTService;
use Shlinkio\Shlink\Rest\Authentication\JWTServiceInterface;
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
use Shlinkio\Shlink\Rest\Util\RestUtils;
@ -36,14 +34,6 @@ class CheckAuthenticationMiddleware implements MiddlewareInterface, StatusCodeIn
*/
private $logger;
/**
* CheckAuthenticationMiddleware constructor.
* @param JWTServiceInterface|JWTService $jwtService
* @param TranslatorInterface $translator
* @param LoggerInterface $logger
*
* @Inject({JWTService::class, "translator", "Logger_Shlink"})
*/
public function __construct(
JWTServiceInterface $jwtService,
TranslatorInterface $translator,
@ -62,6 +52,7 @@ class CheckAuthenticationMiddleware implements MiddlewareInterface, StatusCodeIn
* @param DelegateInterface $delegate
*
* @return Response
* @throws \InvalidArgumentException
*/
public function process(Request $request, DelegateInterface $delegate)
{

View File

@ -1,7 +1,6 @@
<?php
namespace Shlinkio\Shlink\Rest\Service;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Doctrine\ORM\EntityManagerInterface;
use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
@ -13,12 +12,6 @@ class ApiKeyService implements ApiKeyServiceInterface
*/
private $em;
/**
* ApiKeyService constructor.
* @param EntityManagerInterface $em
*
* @Inject({"em"})
*/
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;