From ef543d3c9300f3d2af49302fc9bc6b9f1ac17350 Mon Sep 17 00:00:00 2001 From: duchnoun Date: Thu, 2 Jun 2022 14:55:43 +0200 Subject: [PATCH 01/77] test --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e815d10..b88c611 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ } ], "require": { - "php": "~5.6|~7.0", + "php": "~5.6|~7.0|~8.0", "symfony/framework-bundle": "~2.6|~3.0", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", @@ -47,4 +47,4 @@ "config": { "bin-dir": "bin" } -} +} \ No newline at end of file From c96e4b4a42bc1d7706b0b15303c5af5de519033b Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:08:59 +0200 Subject: [PATCH 02/77] test --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index b88c611..4ef7ab2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "leopardd/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", + "version": "1.1.0", "type": "symfony-bundle", "license": "MIT", "keywords": [ From 20f276f18a8d31fadaf3bfd18419a8d12b51eba4 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:15:15 +0200 Subject: [PATCH 03/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ef7ab2..115fd1d 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "leopardd/url-shortener-bundle", + "name": "respawnsive/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", "version": "1.1.0", "type": "symfony-bundle", From 3515b563fa8e7866de5fe8b0fe684eca7ec44346 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:17:42 +0200 Subject: [PATCH 04/77] test --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 115fd1d..88cd3fd 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "respawnsive/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", "version": "1.1.0", + "stability": "stable", "type": "symfony-bundle", "license": "MIT", "keywords": [ From 337493feb8db94368fec429895330dbd0365f047 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:19:11 +0200 Subject: [PATCH 05/77] test --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 88cd3fd..8fba920 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,7 @@ { "name": "respawnsive/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", - "version": "1.1.0", - "stability": "stable", + "version": "1.1", "type": "symfony-bundle", "license": "MIT", "keywords": [ From d841d8c7f2e37634b94e9bcab575fcfb971cea56 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:20:15 +0200 Subject: [PATCH 06/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8fba920..83320cc 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "respawnsive/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", - "version": "1.1", + "version": "1.2", "type": "symfony-bundle", "license": "MIT", "keywords": [ From 13fb557251d5bfba57676185abb9793e30caaee5 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:23:05 +0200 Subject: [PATCH 07/77] test --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 83320cc..68fb287 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "description": "Symfony Bundle to generate and redirect short url", "version": "1.2", "type": "symfony-bundle", + "minimum-stability": "stable", "license": "MIT", "keywords": [ "url", From 9c957269cafb870197ec2b9518172d5afdc142d8 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:28:43 +0200 Subject: [PATCH 08/77] update composer --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 68fb287..2749723 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "respawnsive/url-shortener-bundle", + "name": "leopardd/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", - "version": "1.2", + "version": "1.1", "type": "symfony-bundle", "minimum-stability": "stable", "license": "MIT", From 7b0dcc7adc5a96cb0458c9382696da73502a186a Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:31:07 +0200 Subject: [PATCH 09/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2749723..37035e7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ ], "require": { "php": "~5.6|~7.0|~8.0", - "symfony/framework-bundle": "~2.6|~3.0", + "symfony/framework-bundle": "~2.6|~3.0|~5.3", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", "hashids/hashids": "^2.0", From 921bd32ab50a3b5a480fa8eb490618cd0f2dbbea Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:31:41 +0200 Subject: [PATCH 10/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 37035e7..bdf5cb8 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "php": "~5.6|~7.0|~8.0", "symfony/framework-bundle": "~2.6|~3.0|~5.3", "doctrine/orm": "^2.5", - "doctrine/doctrine-bundle": "^1.6", + "doctrine/doctrine-bundle": "^1.6|^2.4", "hashids/hashids": "^2.0", "jms/serializer-bundle": "^1.3" }, From 497d0a9b62cacf111af33f1af7c21db1f9a3f3ff Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:32:38 +0200 Subject: [PATCH 11/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bdf5cb8..6ba5e98 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "symfony/framework-bundle": "~2.6|~3.0|~5.3", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6|^2.4", - "hashids/hashids": "^2.0", + "hashids/hashids": "^4.1.0", "jms/serializer-bundle": "^1.3" }, "require-dev": { From 4b5e42149355103b413df47cf221b4843275cca9 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:33:36 +0200 Subject: [PATCH 12/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6ba5e98..a7852cf 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6|^2.4", "hashids/hashids": "^4.1.0", - "jms/serializer-bundle": "^1.3" + "jms/serializer-bundle": "^1.3|^1.5" }, "require-dev": { "phpspec/phpspec": "^3.1", From c6e0e343c12c7ce66c5fd6e13aa61d7b937a53a0 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:34:40 +0200 Subject: [PATCH 13/77] test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a7852cf..605159e 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6|^2.4", "hashids/hashids": "^4.1.0", - "jms/serializer-bundle": "^1.3|^1.5" + "jms/serializer-bundle": "^1.3|^3.0.0" }, "require-dev": { "phpspec/phpspec": "^3.1", From db9b26a7e219ab4869830ea55bfc3eefa7ee3c58 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:38:06 +0200 Subject: [PATCH 14/77] test --- DependencyInjection/Configuration.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 80ec0a9..9b3042d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,9 +17,8 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('leopardd_url_shortener'); - + $builder = new TreeBuilder('leopardd_url_shortener'); + $rootNode = $builder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for // more information on that topic. @@ -34,6 +33,6 @@ public function getConfigTreeBuilder() ->end() ->end(); - return $treeBuilder; + return $builder; } -} +} \ No newline at end of file From 3bc3b152c4a2f5df891765f54c21661a671237d5 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:38:19 +0200 Subject: [PATCH 15/77] update configuration tree builder --- DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 9b3042d..3eb5b96 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -33,6 +33,7 @@ public function getConfigTreeBuilder() ->end() ->end(); + return $builder; } } \ No newline at end of file From 64809c63fa6fd5632f19ecd5d9aa4a5df0221fd4 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 15:55:46 +0200 Subject: [PATCH 16/77] test --- Controller/EncodeController.php | 6 +++--- Controller/RedirectController.php | 6 +++--- Event/ShortUrlCreatedEvent.php | 4 ++-- Event/ShortUrlRedirectedEvent.php | 4 ++-- Resources/config/routing.yml | 2 +- Service/EncodeService.php | 4 ++-- Service/RedirectService.php | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Controller/EncodeController.php b/Controller/EncodeController.php index bf7e48c..6c4260a 100644 --- a/Controller/EncodeController.php +++ b/Controller/EncodeController.php @@ -2,15 +2,15 @@ namespace Leopardd\Bundle\UrlShortenerBundle\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; use Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory; use Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService; use Leopardd\Bundle\UrlShortenerBundle\Exception\InvalidUrlException; -class EncodeController extends Controller +class EncodeController extends AbstractController { /** * @param Request $request @@ -39,4 +39,4 @@ public function indexAction(Request $request) 'code' => $shortUrl->getCode() ]); } -} +} \ No newline at end of file diff --git a/Controller/RedirectController.php b/Controller/RedirectController.php index 22e861a..884e605 100644 --- a/Controller/RedirectController.php +++ b/Controller/RedirectController.php @@ -2,12 +2,12 @@ namespace Leopardd\Bundle\UrlShortenerBundle\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; use Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService; use Leopardd\Bundle\UrlShortenerBundle\Exception\InvalidCodeException; -class RedirectController extends Controller +class RedirectController extends AbstractController { /** * @param string $code @@ -24,4 +24,4 @@ public function indexAction($code) return $response; } -} +} \ No newline at end of file diff --git a/Event/ShortUrlCreatedEvent.php b/Event/ShortUrlCreatedEvent.php index 315b926..046533f 100644 --- a/Event/ShortUrlCreatedEvent.php +++ b/Event/ShortUrlCreatedEvent.php @@ -2,8 +2,8 @@ namespace Leopardd\Bundle\UrlShortenerBundle\Event; -use Symfony\Component\EventDispatcher\Event; use Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrlInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * Class ShortUrlCreatedEvent @@ -30,4 +30,4 @@ public function getShortUrl() { return $this->shortUrl; } -} +} \ No newline at end of file diff --git a/Event/ShortUrlRedirectedEvent.php b/Event/ShortUrlRedirectedEvent.php index 4d59795..27798b7 100644 --- a/Event/ShortUrlRedirectedEvent.php +++ b/Event/ShortUrlRedirectedEvent.php @@ -2,8 +2,8 @@ namespace Leopardd\Bundle\UrlShortenerBundle\Event; -use Symfony\Component\EventDispatcher\Event; use Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrlInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * Class ShortUrlRedirectedEvent @@ -30,4 +30,4 @@ public function getShortUrl() { return $this->shortUrl; } -} +} \ No newline at end of file diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 73f82c2..0baac7b 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -8,4 +8,4 @@ leopardd_url_shortener_redirect: leopardd_url_shortener_encode: path: / defaults: { _controller: LeoparddUrlShortenerBundle:Encode:index } - methods: POST + methods: POST \ No newline at end of file diff --git a/Service/EncodeService.php b/Service/EncodeService.php index 6f5557b..4b5dc75 100644 --- a/Service/EncodeService.php +++ b/Service/EncodeService.php @@ -55,8 +55,8 @@ public function process($shortUrl) $shortUrl = $this->shortUrlRepository->save($shortUrl); $event = new ShortUrlCreatedEvent($shortUrl); - $this->dispatcher->dispatch(ShortUrlEvent::SHORT_URL_CREATED, $event); + $this->dispatcher->dispatch($event,ShortUrlEvent::SHORT_URL_CREATED); return $shortUrl; } -} +} \ No newline at end of file diff --git a/Service/RedirectService.php b/Service/RedirectService.php index 6cde606..07ab7a4 100644 --- a/Service/RedirectService.php +++ b/Service/RedirectService.php @@ -53,8 +53,8 @@ public function getRedirectResponse($code) if (!$shortUrl) return null; $event = new ShortUrlRedirectedEvent($shortUrl); - $this->dispatcher->dispatch(ShortUrlEvent::SHORT_URL_REDIRECTED, $event); + $this->dispatcher->dispatch($event,ShortUrlEvent::SHORT_URL_REDIRECTED); return new RedirectResponse($shortUrl->getUrl()); } -} +} \ No newline at end of file From 670a01b08b34173526bbfe9c2151b5c66833cf5b Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:13:33 +0200 Subject: [PATCH 17/77] test --- Resources/config/routing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 0baac7b..854da4c 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,11 +1,11 @@ leopardd_url_shortener_redirect: path: /{code} - defaults: { _controller: LeoparddUrlShortenerBundle:Redirect:index } + controller: Leopardd\Bundle\UrlShortenerBundle\Controller\RedirectController::indexAction methods: GET requirements: code: \S+ leopardd_url_shortener_encode: path: / - defaults: { _controller: LeoparddUrlShortenerBundle:Encode:index } + controller: Leopardd\Bundle\UrlShortenerBundle\Controller\EncodeController::indexAction methods: POST \ No newline at end of file From ed4dc82dec036c5c4fc1ad57e26b5f265fa2fea5 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:20:14 +0200 Subject: [PATCH 18/77] update routing --- Resources/config/routing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 854da4c..5041886 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -5,6 +5,7 @@ leopardd_url_shortener_redirect: requirements: code: \S+ + leopardd_url_shortener_encode: path: / controller: Leopardd\Bundle\UrlShortenerBundle\Controller\EncodeController::indexAction From 5e3a0832d76b9b34938eba41dc906617fbe06054 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:21:58 +0200 Subject: [PATCH 19/77] update routing --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 605159e..fa744c2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "leopardd/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", - "version": "1.1", + "version": "1.1.2", "type": "symfony-bundle", "minimum-stability": "stable", "license": "MIT", From 3f70c83a3f3ec5a53d26e25356c1895d9299be23 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:24:10 +0200 Subject: [PATCH 20/77] update routing --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fa744c2..df36459 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "leopardd/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", - "version": "1.1.2", + "version": "1.2", "type": "symfony-bundle", "minimum-stability": "stable", "license": "MIT", From 3dbe3392a7f29735ea92497416fedca1d1108e07 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:29:58 +0200 Subject: [PATCH 21/77] add autowiring --- Resources/config/services.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index c326346..8f0dec1 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -7,6 +7,21 @@ parameters: leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository services: + _defaults: + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + + Leopardd\Bundle\UrlShortenerBundle\: + resource: '../../' + exclude: + - '../../DependencyInjection/' + - '../../Resources/' + - '../../Tests/' + - '../../spec/' + - '../../Event/' + - '../../Exception/' + - '../../Entity/' + leopardd_url_shortener.hash.hashid: class: Hashids\Hashids arguments: @@ -37,4 +52,4 @@ services: arguments: - "@leopardd_url_shortener.hash.hashid" - "@leopardd_url_shortener.repository.short_url" - - "@event_dispatcher" + - "@event_dispatcher" \ No newline at end of file From 6df692640ed0a37252e60c8c117788cb9fe397dd Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:31:31 +0200 Subject: [PATCH 22/77] update routing --- Resources/config/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 8f0dec1..25b1fba 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -10,6 +10,7 @@ services: _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + public: true Leopardd\Bundle\UrlShortenerBundle\: resource: '../../' From 939ee1a0229cfc205b30494223a3d12e23f676f0 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:35:38 +0200 Subject: [PATCH 23/77] update routing --- Controller/EncodeController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Controller/EncodeController.php b/Controller/EncodeController.php index 6c4260a..c505022 100644 --- a/Controller/EncodeController.php +++ b/Controller/EncodeController.php @@ -12,6 +12,11 @@ class EncodeController extends AbstractController { + + public function __construct(private ShortUrlFactory $shortUrlFactory,private EncodeService $encodeService) + { + + } /** * @param Request $request * @throws InvalidUrlException @@ -20,10 +25,11 @@ class EncodeController extends AbstractController public function indexAction(Request $request) { /** @var ShortUrlFactory $shortUrlFactory */ - $shortUrlFactory = $this->get('leopardd_url_shortener.factory.short_url'); +// $shortUrlFactory = $this->get('leopardd_url_shortener.factory.short_url'); + /** @var EncodeService $encodeService */ - $encodeService = $this->get('leopardd_url_shortener.service.encode'); +// $encodeService = $this->get('leopardd_url_shortener.service.encode'); $url = $request->request->get('url'); @@ -31,8 +37,8 @@ public function indexAction(Request $request) if (filter_var($url, FILTER_VALIDATE_URL) === false) throw new InvalidUrlException(); $url = rtrim($url, '/'); - $shortUrl = $shortUrlFactory->create($url); - $shortUrl = $encodeService->process($shortUrl); + $shortUrl = $this->shortUrlFactory->create($url); + $shortUrl = $this->encodeService->process($shortUrl); return new JsonResponse([ 'url' => $shortUrl->getUrl(), From 8b25abc7f3cd32726149e23f4a73ee099e3b7f38 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:38:03 +0200 Subject: [PATCH 24/77] update routing --- Factory/ShortUrlFactory.php | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Factory/ShortUrlFactory.php b/Factory/ShortUrlFactory.php index b601c82..b85ad5c 100644 --- a/Factory/ShortUrlFactory.php +++ b/Factory/ShortUrlFactory.php @@ -17,7 +17,7 @@ class ShortUrlFactory implements ShortUrlFactoryInterface * ShortUrlFactory constructor. * @param string $shortUrl shortUrl class */ - public function __construct($shortUrl) + public function __construct($shortUrl = 'ShortUrl') { $this->shortUrl = new $shortUrl(); } @@ -31,4 +31,4 @@ public function create($url) return $this->shortUrl; } -} +} \ No newline at end of file diff --git a/composer.json b/composer.json index df36459..9cb5c44 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "leopardd/url-shortener-bundle", "description": "Symfony Bundle to generate and redirect short url", - "version": "1.2", + "version": "dev-master", "type": "symfony-bundle", "minimum-stability": "stable", "license": "MIT", From e2ec1534e375ad361038d6936877bd0c96fc5942 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 16:54:32 +0200 Subject: [PATCH 25/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 25b1fba..13015a1 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -36,7 +36,7 @@ services: - "%leopardd_url_shortener.class.entity%" leopardd_url_shortener.repository.short_url: - class: "%leopardd_url_shortener.class.repository%" +# class: "%leopardd_url_shortener.class.repository%" factory: 'doctrine.orm.entity_manager:getRepository' arguments: - "%leopardd_url_shortener.class.entity%" From 49d5495a9528507e2bbeb2c76199a26af2b7244a Mon Sep 17 00:00:00 2001 From: david Date: Thu, 2 Jun 2022 17:00:41 +0200 Subject: [PATCH 26/77] update routing --- Controller/RedirectController.php | 9 ++++++-- Factory/ShortUrlFactory.php | 2 +- Resources/config/services.yml | 34 +++++++++++++++---------------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Controller/RedirectController.php b/Controller/RedirectController.php index 884e605..a91a417 100644 --- a/Controller/RedirectController.php +++ b/Controller/RedirectController.php @@ -9,6 +9,11 @@ class RedirectController extends AbstractController { + + public function __construct(private RedirectService $redirectService) + { + + } /** * @param string $code * @throws InvalidCodeException @@ -17,9 +22,9 @@ class RedirectController extends AbstractController public function indexAction($code) { /** @var RedirectService $redirectService */ - $redirectService = $this->get('leopardd_url_shortener.service.redirect'); +// $redirectService = $this->get('leopardd_url_shortener.service.redirect'); - $response = $redirectService->getRedirectResponse($code); + $response = $this->redirectService->getRedirectResponse($code); if ($response === null) throw new InvalidCodeException(); return $response; diff --git a/Factory/ShortUrlFactory.php b/Factory/ShortUrlFactory.php index b85ad5c..9ab07a0 100644 --- a/Factory/ShortUrlFactory.php +++ b/Factory/ShortUrlFactory.php @@ -17,7 +17,7 @@ class ShortUrlFactory implements ShortUrlFactoryInterface * ShortUrlFactory constructor. * @param string $shortUrl shortUrl class */ - public function __construct($shortUrl = 'ShortUrl') + public function __construct(string $shortUrl) { $this->shortUrl = new $shortUrl(); } diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 13015a1..ab5be7e 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -35,22 +35,22 @@ services: arguments: - "%leopardd_url_shortener.class.entity%" - leopardd_url_shortener.repository.short_url: -# class: "%leopardd_url_shortener.class.repository%" - factory: 'doctrine.orm.entity_manager:getRepository' - arguments: - - "%leopardd_url_shortener.class.entity%" +# leopardd_url_shortener.repository.short_url: +## class: "%leopardd_url_shortener.class.repository%" +# factory: 'doctrine.orm.entity_manager:getRepository' +# arguments: +# - "%leopardd_url_shortener.class.entity%" - leopardd_url_shortener.service.encode: - class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService - arguments: - - "@leopardd_url_shortener.hash.hashid" - - "@leopardd_url_shortener.repository.short_url" - - "@event_dispatcher" +# leopardd_url_shortener.service.encode: +# class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService +# arguments: +# - "@leopardd_url_shortener.hash.hashid" +# - "@leopardd_url_shortener.repository.short_url" +# - "@event_dispatcher" - leopardd_url_shortener.service.redirect: - class: Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService - arguments: - - "@leopardd_url_shortener.hash.hashid" - - "@leopardd_url_shortener.repository.short_url" - - "@event_dispatcher" \ No newline at end of file +# leopardd_url_shortener.service.redirect: +# class: Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService +# arguments: +# - "@leopardd_url_shortener.hash.hashid" +# - "@leopardd_url_shortener.repository.short_url" +# - "@event_dispatcher" \ No newline at end of file From a11fee3e702ecd4715b8f2f5bb94763f05e7d69d Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:22:52 +0200 Subject: [PATCH 27/77] update routing --- Resources/config/services.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index ab5be7e..6a6a3af 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -35,11 +35,11 @@ services: arguments: - "%leopardd_url_shortener.class.entity%" -# leopardd_url_shortener.repository.short_url: + leopardd_url_shortener.repository.short_url: ## class: "%leopardd_url_shortener.class.repository%" -# factory: 'doctrine.orm.entity_manager:getRepository' -# arguments: -# - "%leopardd_url_shortener.class.entity%" + factory: 'doctrine.orm.entity_manager:getRepository' + arguments: + - "%leopardd_url_shortener.class.entity%" # leopardd_url_shortener.service.encode: # class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService From 3353fda8859a114e6ae843b1fb8746eaa77ea13c Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:27:02 +0200 Subject: [PATCH 28/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 6a6a3af..4a8e91c 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -5,7 +5,7 @@ parameters: leopardd_url_shortener.class.entity: Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrl leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository - + leopardd_url_shortener.repository.short_url: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory services: _defaults: autowire: true # Automatically injects dependencies in your services. From 8bf1614e0d4814b4eddaf22b072df0a18536bfaa Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:30:42 +0200 Subject: [PATCH 29/77] update routing --- Resources/config/services.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 4a8e91c..367ff48 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -5,7 +5,6 @@ parameters: leopardd_url_shortener.class.entity: Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrl leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository - leopardd_url_shortener.repository.short_url: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory services: _defaults: autowire: true # Automatically injects dependencies in your services. @@ -35,8 +34,11 @@ services: arguments: - "%leopardd_url_shortener.class.entity%" + + '%leopardd_url_shortener.class.repository%' : ~ + leopardd_url_shortener.repository.short_url: -## class: "%leopardd_url_shortener.class.repository%" +# class: "%leopardd_url_shortener.class.repository%" factory: 'doctrine.orm.entity_manager:getRepository' arguments: - "%leopardd_url_shortener.class.entity%" From 036db54057048f78589a902340f3f01558817509 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:36:03 +0200 Subject: [PATCH 30/77] update routing --- Resources/config/services.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 367ff48..c2965d4 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -34,13 +34,11 @@ services: arguments: - "%leopardd_url_shortener.class.entity%" - - '%leopardd_url_shortener.class.repository%' : ~ - leopardd_url_shortener.repository.short_url: -# class: "%leopardd_url_shortener.class.repository%" - factory: 'doctrine.orm.entity_manager:getRepository' + class: "%leopardd_url_shortener.class.repository%" +# factory: 'doctrine.orm.entity_manager:getRepository' arguments: + - '@Doctrine\Common\Persistence\ManagerRegistry' - "%leopardd_url_shortener.class.entity%" # leopardd_url_shortener.service.encode: From eecf48767be82cb5a9520f7f361b369ec30c988b Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:38:49 +0200 Subject: [PATCH 31/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index c2965d4..93934e1 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -32,7 +32,7 @@ services: leopardd_url_shortener.factory.short_url: class: "%leopardd_url_shortener.class.factory%" arguments: - - "%leopardd_url_shortener.class.entity%" + - "ShortUrl" leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" From c5d7815bccc7eee721cb4d43267f85c1b0704eba Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:41:33 +0200 Subject: [PATCH 32/77] update routing --- Resources/config/services.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 93934e1..78bae05 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -29,10 +29,14 @@ services: - "%leopardd_url_shortener.hashids.min_length%" - "%leopardd_url_shortener.hashids.alphabet%" + leopardd_url_shortener.class.factory: + arguments: + - "ShortUrl" + leopardd_url_shortener.factory.short_url: class: "%leopardd_url_shortener.class.factory%" arguments: - - "ShortUrl" + - "%leopardd_url_shortener.class.entity%" leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" From a4426bf30133ebca19c872e037bcdf8ba2cac01b Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:43:30 +0200 Subject: [PATCH 33/77] update routing --- Resources/config/services.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 78bae05..43a1890 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,7 +3,7 @@ parameters: leopardd_url_shortener.hashids.min_length: 5 leopardd_url_shortener.hashids.alphabet: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 leopardd_url_shortener.class.entity: Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrl - leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory +# leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository services: _defaults: @@ -30,8 +30,7 @@ services: - "%leopardd_url_shortener.hashids.alphabet%" leopardd_url_shortener.class.factory: - arguments: - - "ShortUrl" + factory: [ Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory , 'ShortUrl' ] leopardd_url_shortener.factory.short_url: class: "%leopardd_url_shortener.class.factory%" From 1c56117f0f8b18aa89996160758ef682404d86ce Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:44:31 +0200 Subject: [PATCH 34/77] update routing --- Resources/config/services.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 43a1890..bbe70f8 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -30,7 +30,9 @@ services: - "%leopardd_url_shortener.hashids.alphabet%" leopardd_url_shortener.class.factory: - factory: [ Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory , 'ShortUrl' ] + class: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory + arguments: + - "ShortUrl" leopardd_url_shortener.factory.short_url: class: "%leopardd_url_shortener.class.factory%" From 6b2d128a13ba1672d141edfd086dfc88a5e5d1f7 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:46:21 +0200 Subject: [PATCH 35/77] update routing --- Resources/config/services.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index bbe70f8..e5ea3ff 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,7 +3,7 @@ parameters: leopardd_url_shortener.hashids.min_length: 5 leopardd_url_shortener.hashids.alphabet: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 leopardd_url_shortener.class.entity: Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrl -# leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory + leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository services: _defaults: @@ -30,7 +30,7 @@ services: - "%leopardd_url_shortener.hashids.alphabet%" leopardd_url_shortener.class.factory: - class: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory + class: '%leopardd_url_shortener.class.factory%' arguments: - "ShortUrl" From 2423adb71b04936ff8ca8e2ed0b3be02fd8dc636 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:47:39 +0200 Subject: [PATCH 36/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index e5ea3ff..d8c2442 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -9,7 +9,7 @@ services: _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - public: true + public: false Leopardd\Bundle\UrlShortenerBundle\: resource: '../../' From 197037e8518f4894cf2436a030ce2d2ac97b6ca2 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:49:13 +0200 Subject: [PATCH 37/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index d8c2442..1d39f40 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -30,7 +30,7 @@ services: - "%leopardd_url_shortener.hashids.alphabet%" leopardd_url_shortener.class.factory: - class: '%leopardd_url_shortener.class.factory%' + class: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory arguments: - "ShortUrl" From dcdc1ec8e2d3d0b69b73655ab14418c335c93cad Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:54:55 +0200 Subject: [PATCH 38/77] update routing --- Resources/config/services.yml | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 1d39f40..55293bc 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -5,23 +5,8 @@ parameters: leopardd_url_shortener.class.entity: Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrl leopardd_url_shortener.class.factory: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository -services: - _defaults: - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - public: false - - Leopardd\Bundle\UrlShortenerBundle\: - resource: '../../' - exclude: - - '../../DependencyInjection/' - - '../../Resources/' - - '../../Tests/' - - '../../spec/' - - '../../Event/' - - '../../Exception/' - - '../../Entity/' +services: leopardd_url_shortener.hash.hashid: class: Hashids\Hashids arguments: @@ -29,11 +14,6 @@ services: - "%leopardd_url_shortener.hashids.min_length%" - "%leopardd_url_shortener.hashids.alphabet%" - leopardd_url_shortener.class.factory: - class: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory - arguments: - - "ShortUrl" - leopardd_url_shortener.factory.short_url: class: "%leopardd_url_shortener.class.factory%" arguments: @@ -41,18 +21,18 @@ services: leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" -# factory: 'doctrine.orm.entity_manager:getRepository' + factory: 'doctrine.orm.entity_manager:getRepository' arguments: - - '@Doctrine\Common\Persistence\ManagerRegistry' - "%leopardd_url_shortener.class.entity%" + # leopardd_url_shortener.service.encode: # class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService # arguments: # - "@leopardd_url_shortener.hash.hashid" # - "@leopardd_url_shortener.repository.short_url" # - "@event_dispatcher" - +# # leopardd_url_shortener.service.redirect: # class: Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService # arguments: From b9ec5a46590c6b59c39b330710bc63c80dfe9586 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:56:38 +0200 Subject: [PATCH 39/77] update routing --- Resources/config/services.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 55293bc..3d748d6 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -7,6 +7,10 @@ parameters: leopardd_url_shortener.class.repository: Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository services: + + Leopardd\Bundle\UrlShortenerBundle\Controller: + resource: '../../Controller/' + leopardd_url_shortener.hash.hashid: class: Hashids\Hashids arguments: From d5ec9781b955320bb89bbb4372f822a851e9c96b Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:57:00 +0200 Subject: [PATCH 40/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 3d748d6..7963ea5 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -8,7 +8,7 @@ parameters: services: - Leopardd\Bundle\UrlShortenerBundle\Controller: + Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' leopardd_url_shortener.hash.hashid: From f9a3de81256f5f7fef5898fcecc6f677ebfd4290 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:57:54 +0200 Subject: [PATCH 41/77] update routing --- Resources/config/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 7963ea5..2049e2e 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -10,6 +10,7 @@ services: Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' + tags: ['controller.service_arguments'] leopardd_url_shortener.hash.hashid: class: Hashids\Hashids From 0aae999f18d043275b0f0f77970714f898007ef2 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 08:59:56 +0200 Subject: [PATCH 42/77] update routing --- Resources/config/services.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 2049e2e..00bf529 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -10,6 +10,9 @@ services: Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + public: false tags: ['controller.service_arguments'] leopardd_url_shortener.hash.hashid: From f00050a10d306f70f296c2b3e9f69b2a7c2902dd Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:01:51 +0200 Subject: [PATCH 43/77] update routing --- Resources/config/services.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 00bf529..57c5640 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -8,6 +8,11 @@ parameters: services: + leopardd_url_shortener.factory.short_url: + class: "%leopardd_url_shortener.class.factory%" + arguments: + - "%leopardd_url_shortener.class.entity%" + Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' autowire: true # Automatically injects dependencies in your services. @@ -22,10 +27,6 @@ services: - "%leopardd_url_shortener.hashids.min_length%" - "%leopardd_url_shortener.hashids.alphabet%" - leopardd_url_shortener.factory.short_url: - class: "%leopardd_url_shortener.class.factory%" - arguments: - - "%leopardd_url_shortener.class.entity%" leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" From 4992a679ec739e188fa52cb5b8b8e35ae55e6555 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:03:27 +0200 Subject: [PATCH 44/77] update routing --- Resources/config/services.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 57c5640..c2ea615 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -8,10 +8,7 @@ parameters: services: - leopardd_url_shortener.factory.short_url: - class: "%leopardd_url_shortener.class.factory%" - arguments: - - "%leopardd_url_shortener.class.entity%" + Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory: '@leopardd_url_shortener.factory.short_url' Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' @@ -20,6 +17,8 @@ services: public: false tags: ['controller.service_arguments'] + + leopardd_url_shortener.hash.hashid: class: Hashids\Hashids arguments: @@ -27,6 +26,12 @@ services: - "%leopardd_url_shortener.hashids.min_length%" - "%leopardd_url_shortener.hashids.alphabet%" + leopardd_url_shortener.factory.short_url: + class: "%leopardd_url_shortener.class.factory%" + arguments: + - "%leopardd_url_shortener.class.entity%" + + leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" From 806f3b76dfc6643f6418ccfdca592a517933c534 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:04:32 +0200 Subject: [PATCH 45/77] update routing --- Resources/config/services.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index c2ea615..297c314 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -10,6 +10,12 @@ services: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory: '@leopardd_url_shortener.factory.short_url' + Leopardd\Bundle\UrlShortenerBundle\Service\: + resource: '../../Service/' + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + public: true + Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' autowire: true # Automatically injects dependencies in your services. From 3f940fdef69797cff29f588b00720abfee39abcc Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:06:03 +0200 Subject: [PATCH 46/77] update routing --- Service/EncodeService.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Service/EncodeService.php b/Service/EncodeService.php index 4b5dc75..1151376 100644 --- a/Service/EncodeService.php +++ b/Service/EncodeService.php @@ -15,14 +15,6 @@ */ class EncodeService { - /** @var Hashids */ - private $hashids; - - /** @var ShortUrlRepositoryInterface */ - private $shortUrlRepository; - - /** @var EventDispatcherInterface */ - private $dispatcher; /** * ProcessShortUrlService constructor. @@ -30,11 +22,9 @@ class EncodeService * @param ShortUrlRepositoryInterface $shortUrlRepository * @param EventDispatcherInterface $dispatcher */ - public function __construct($hashids, $shortUrlRepository, $dispatcher) + public function __construct(private Hashids $hashids, private ShortUrlRepositoryInterface $shortUrlRepository, private EventDispatcherInterface $dispatcher) { - $this->hashids = $hashids; - $this->shortUrlRepository = $shortUrlRepository; - $this->dispatcher = $dispatcher; + } /** From f4c9f3c9415be944f1a2f9c9e88e100eb2b93539 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:10:09 +0200 Subject: [PATCH 47/77] update routing --- Resources/config/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 297c314..f71264e 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -9,6 +9,7 @@ parameters: services: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory: '@leopardd_url_shortener.factory.short_url' + Hashids\Hashids: '@leopardd_url_shortener.hash.hashid' Leopardd\Bundle\UrlShortenerBundle\Service\: resource: '../../Service/' From 126a677f113f335cacd5d4c4415b052a339d7251 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:11:06 +0200 Subject: [PATCH 48/77] update routing --- Resources/config/services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index f71264e..efca962 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -10,6 +10,7 @@ services: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory: '@leopardd_url_shortener.factory.short_url' Hashids\Hashids: '@leopardd_url_shortener.hash.hashid' + Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepositoryInterface: '@leopardd_url_shortener.repository.short_url' Leopardd\Bundle\UrlShortenerBundle\Service\: resource: '../../Service/' From 1ba49571a6735d677d504f7af0a84d1f04038b59 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:12:00 +0200 Subject: [PATCH 49/77] update routing --- Service/RedirectService.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Service/RedirectService.php b/Service/RedirectService.php index 07ab7a4..37cf650 100644 --- a/Service/RedirectService.php +++ b/Service/RedirectService.php @@ -16,14 +16,6 @@ */ class RedirectService { - /** @var Hashids */ - private $hashids; - - /** @var ShortUrlRepositoryInterface $repository */ - private $shortUrlRepository; - - /** @var EventDispatcherInterface $dispatcher */ - private $dispatcher; /** * ProcessShortUrlService constructor. @@ -31,11 +23,9 @@ class RedirectService * @param ShortUrlRepositoryInterface $shortUrlRepository * @param EventDispatcherInterface $dispatcher */ - public function __construct($hashids, $shortUrlRepository, $dispatcher) + public function __construct(private Hashids $hashids, private ShortUrlRepositoryInterface $shortUrlRepository, private EventDispatcherInterface $dispatcher) { - $this->hashids = $hashids; - $this->shortUrlRepository = $shortUrlRepository; - $this->dispatcher = $dispatcher; + } /** From 90e3cc7cfeca4e37e39b6482b887efe7de716744 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:14:18 +0200 Subject: [PATCH 50/77] update routing --- Resources/config/services.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index efca962..17b53ef 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -43,8 +43,9 @@ services: leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" - factory: 'doctrine.orm.entity_manager:getRepository' +# factory: 'doctrine.orm.entity_manager:getRepository' arguments: + - 'doctrine.doctrine.orm.entity_manager' - "%leopardd_url_shortener.class.entity%" From 08d75c2d0e036d973ce7d12445e5d653086ca609 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:14:31 +0200 Subject: [PATCH 51/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 17b53ef..98f8c4c 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -45,7 +45,7 @@ services: class: "%leopardd_url_shortener.class.repository%" # factory: 'doctrine.orm.entity_manager:getRepository' arguments: - - 'doctrine.doctrine.orm.entity_manager' + - '@doctrine.orm.entity_manager' - "%leopardd_url_shortener.class.entity%" From 7c28bbdb9c29ee7a83fbd6ea046833b67e1c1540 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:18:40 +0200 Subject: [PATCH 52/77] update routing --- Resources/config/services.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 98f8c4c..aa3c03a 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -42,10 +42,9 @@ services: leopardd_url_shortener.repository.short_url: - class: "%leopardd_url_shortener.class.repository%" -# factory: 'doctrine.orm.entity_manager:getRepository' +# class: "%leopardd_url_shortener.class.repository%" + factory: [ '@doctrine.orm.entity_manager' , getRepository ] arguments: - - '@doctrine.orm.entity_manager' - "%leopardd_url_shortener.class.entity%" From 61b6bedf6bdc79c0599fa9f3d0ffb8becc87be1d Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:19:29 +0200 Subject: [PATCH 53/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index aa3c03a..6806864 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -42,7 +42,7 @@ services: leopardd_url_shortener.repository.short_url: -# class: "%leopardd_url_shortener.class.repository%" + $class: "%leopardd_url_shortener.class.repository%" factory: [ '@doctrine.orm.entity_manager' , getRepository ] arguments: - "%leopardd_url_shortener.class.entity%" From b36f8144a759aefba2496a1f07b64f647dfcf000 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:20:14 +0200 Subject: [PATCH 54/77] update routing --- Resources/config/services.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 6806864..f2d7829 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -42,10 +42,10 @@ services: leopardd_url_shortener.repository.short_url: - $class: "%leopardd_url_shortener.class.repository%" +# $class: "%leopardd_url_shortener.class.repository%" factory: [ '@doctrine.orm.entity_manager' , getRepository ] arguments: - - "%leopardd_url_shortener.class.entity%" + $class: "%leopardd_url_shortener.class.entity%" # leopardd_url_shortener.service.encode: From 6cac26b74bb984ebb35a251e93b508de824c833d Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:23:09 +0200 Subject: [PATCH 55/77] update routing --- Resources/config/services.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index f2d7829..6806864 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -42,10 +42,10 @@ services: leopardd_url_shortener.repository.short_url: -# $class: "%leopardd_url_shortener.class.repository%" + $class: "%leopardd_url_shortener.class.repository%" factory: [ '@doctrine.orm.entity_manager' , getRepository ] arguments: - $class: "%leopardd_url_shortener.class.entity%" + - "%leopardd_url_shortener.class.entity%" # leopardd_url_shortener.service.encode: From 995463a1a5806237fc35139252a899512c0e0449 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:24:27 +0200 Subject: [PATCH 56/77] update routing --- Resources/config/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 6806864..4799cd1 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -42,7 +42,7 @@ services: leopardd_url_shortener.repository.short_url: - $class: "%leopardd_url_shortener.class.repository%" + class: "%leopardd_url_shortener.class.repository%" factory: [ '@doctrine.orm.entity_manager' , getRepository ] arguments: - "%leopardd_url_shortener.class.entity%" From d30e6ebead0727bd3cbedbbb845283b4c0846c97 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:25:35 +0200 Subject: [PATCH 57/77] update routing --- Resources/config/services.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 4799cd1..d35c3d3 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -12,11 +12,6 @@ services: Hashids\Hashids: '@leopardd_url_shortener.hash.hashid' Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepositoryInterface: '@leopardd_url_shortener.repository.short_url' - Leopardd\Bundle\UrlShortenerBundle\Service\: - resource: '../../Service/' - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - public: true Leopardd\Bundle\UrlShortenerBundle\Controller\: resource: '../../Controller/' @@ -48,16 +43,16 @@ services: - "%leopardd_url_shortener.class.entity%" -# leopardd_url_shortener.service.encode: -# class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService -# arguments: -# - "@leopardd_url_shortener.hash.hashid" -# - "@leopardd_url_shortener.repository.short_url" -# - "@event_dispatcher" + leopardd_url_shortener.service.encode: + class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService + arguments: + - "@leopardd_url_shortener.hash.hashid" + - "@leopardd_url_shortener.repository.short_url" + - "@event_dispatcher" # -# leopardd_url_shortener.service.redirect: -# class: Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService -# arguments: -# - "@leopardd_url_shortener.hash.hashid" -# - "@leopardd_url_shortener.repository.short_url" -# - "@event_dispatcher" \ No newline at end of file + leopardd_url_shortener.service.redirect: + class: Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService + arguments: + - "@leopardd_url_shortener.hash.hashid" + - "@leopardd_url_shortener.repository.short_url" + - "@event_dispatcher" \ No newline at end of file From feaaa9468237e26e69e4e990e9181743438bf9eb Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:26:56 +0200 Subject: [PATCH 58/77] update routing --- Resources/config/services.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index d35c3d3..9d4bc78 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -11,6 +11,8 @@ services: Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory: '@leopardd_url_shortener.factory.short_url' Hashids\Hashids: '@leopardd_url_shortener.hash.hashid' Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepositoryInterface: '@leopardd_url_shortener.repository.short_url' + Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService: '@leopardd_url_shortener.service.encode' + Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService: '@leopardd_url_shortener.service.redirect' Leopardd\Bundle\UrlShortenerBundle\Controller\: From 1882de83f41978f31b9c3eb49df64463f342419a Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:28:15 +0200 Subject: [PATCH 59/77] update services --- Resources/config/services.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 9d4bc78..9413a97 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -23,7 +23,6 @@ services: tags: ['controller.service_arguments'] - leopardd_url_shortener.hash.hashid: class: Hashids\Hashids arguments: @@ -36,15 +35,12 @@ services: arguments: - "%leopardd_url_shortener.class.entity%" - - leopardd_url_shortener.repository.short_url: class: "%leopardd_url_shortener.class.repository%" factory: [ '@doctrine.orm.entity_manager' , getRepository ] arguments: - "%leopardd_url_shortener.class.entity%" - leopardd_url_shortener.service.encode: class: Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService arguments: From 5b6118f3459c90b287d58a4bb51abec58a78f930 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:33:56 +0200 Subject: [PATCH 60/77] update routing --- Controller/EncodeController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Controller/EncodeController.php b/Controller/EncodeController.php index c505022..b0aea32 100644 --- a/Controller/EncodeController.php +++ b/Controller/EncodeController.php @@ -33,6 +33,8 @@ public function indexAction(Request $request) $url = $request->request->get('url'); + dd($url); + // validate and sanitize if (filter_var($url, FILTER_VALIDATE_URL) === false) throw new InvalidUrlException(); $url = rtrim($url, '/'); From eca4b32dc97198c1d2e3e70c7bb995a469bdb14d Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:36:47 +0200 Subject: [PATCH 61/77] update routing --- Controller/EncodeController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Controller/EncodeController.php b/Controller/EncodeController.php index b0aea32..c505022 100644 --- a/Controller/EncodeController.php +++ b/Controller/EncodeController.php @@ -33,8 +33,6 @@ public function indexAction(Request $request) $url = $request->request->get('url'); - dd($url); - // validate and sanitize if (filter_var($url, FILTER_VALIDATE_URL) === false) throw new InvalidUrlException(); $url = rtrim($url, '/'); From 4821d5f439c84d4944f4a1ad3214815673c8d4aa Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:39:12 +0200 Subject: [PATCH 62/77] update routing --- composer.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9cb5c44..709fe0b 100644 --- a/composer.json +++ b/composer.json @@ -20,15 +20,21 @@ "email": "inid3a@gmail.com", "homepage": "https://github.com/jojoee", "role": "Developer" + }, + { + "name": "David Nurdin", + "email": "david.nurdin@respawnsive.com", + "homepage": "https://github.com/davidnurdin", + "role": "Developer" } ], "require": { - "php": "~5.6|~7.0|~8.0", - "symfony/framework-bundle": "~2.6|~3.0|~5.3", + "php": "~8.0", + "symfony/framework-bundle": "~5.3", "doctrine/orm": "^2.5", - "doctrine/doctrine-bundle": "^1.6|^2.4", + "doctrine/doctrine-bundle": "^2.4", "hashids/hashids": "^4.1.0", - "jms/serializer-bundle": "^1.3|^3.0.0" + "jms/serializer-bundle": "^3.0.0" }, "require-dev": { "phpspec/phpspec": "^3.1", From 832b27c541e555f141f66819cd4ef82fdd424607 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:39:34 +0200 Subject: [PATCH 63/77] update composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 709fe0b..cc8faf8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "leopardd/url-shortener-bundle", - "description": "Symfony Bundle to generate and redirect short url", + "description": "Symfony Bundle to generate and redirect short url working with symfony 5 and php 8", "version": "dev-master", "type": "symfony-bundle", "minimum-stability": "stable", From 84d7ef03fc73454a74f057460d3e87a19f5fcb0d Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 09:47:55 +0200 Subject: [PATCH 64/77] update routing --- .gitignore | 11 -- Controller/EncodeController.php | 6 - Controller/RedirectController.php | 2 - .../LeoparddUrlShortenerExtension.php | 43 ------ Entity/ShortUrl.php | 125 ------------------ Entity/ShortUrlInterface.php | 37 ------ Event/ShortUrlEvent.php | 13 -- Exception/InvalidCodeException.php | 17 --- Exception/InvalidUrlException.php | 17 --- Factory/ShortUrlFactoryInterface.php | 19 --- LICENSE | 21 +++ LICENSE.md | 21 --- LeoparddUrlShortenerBundle.php | 9 -- Repository/ShortUrlRepository.php | 48 ------- Repository/ShortUrlRepositoryInterface.php | 30 ----- phpspec.yml | 4 - ruleset.xml | 7 - spec/Service/EncodeServiceSpec.php | 84 ------------ spec/Service/RedirectServiceSpec.php | 93 ------------- 19 files changed, 21 insertions(+), 586 deletions(-) delete mode 100644 .gitignore delete mode 100644 DependencyInjection/LeoparddUrlShortenerExtension.php delete mode 100644 Entity/ShortUrl.php delete mode 100644 Entity/ShortUrlInterface.php delete mode 100644 Event/ShortUrlEvent.php delete mode 100644 Exception/InvalidCodeException.php delete mode 100644 Exception/InvalidUrlException.php delete mode 100644 Factory/ShortUrlFactoryInterface.php create mode 100644 LICENSE delete mode 100644 LICENSE.md delete mode 100644 LeoparddUrlShortenerBundle.php delete mode 100644 Repository/ShortUrlRepository.php delete mode 100644 Repository/ShortUrlRepositoryInterface.php delete mode 100644 phpspec.yml delete mode 100644 ruleset.xml delete mode 100644 spec/Service/EncodeServiceSpec.php delete mode 100644 spec/Service/RedirectServiceSpec.php diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c563bc2..0000000 --- a/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -# IDE -.idea - -# Binary -bin - -# Dependency -vendor - -# Lock -composer.lock diff --git a/Controller/EncodeController.php b/Controller/EncodeController.php index c505022..3beb968 100644 --- a/Controller/EncodeController.php +++ b/Controller/EncodeController.php @@ -24,12 +24,6 @@ public function __construct(private ShortUrlFactory $shortUrlFactory,private Enc */ public function indexAction(Request $request) { - /** @var ShortUrlFactory $shortUrlFactory */ -// $shortUrlFactory = $this->get('leopardd_url_shortener.factory.short_url'); - - - /** @var EncodeService $encodeService */ -// $encodeService = $this->get('leopardd_url_shortener.service.encode'); $url = $request->request->get('url'); diff --git a/Controller/RedirectController.php b/Controller/RedirectController.php index a91a417..eedf97f 100644 --- a/Controller/RedirectController.php +++ b/Controller/RedirectController.php @@ -21,8 +21,6 @@ public function __construct(private RedirectService $redirectService) */ public function indexAction($code) { - /** @var RedirectService $redirectService */ -// $redirectService = $this->get('leopardd_url_shortener.service.redirect'); $response = $this->redirectService->getRedirectResponse($code); if ($response === null) throw new InvalidCodeException(); diff --git a/DependencyInjection/LeoparddUrlShortenerExtension.php b/DependencyInjection/LeoparddUrlShortenerExtension.php deleted file mode 100644 index 5bdb9db..0000000 --- a/DependencyInjection/LeoparddUrlShortenerExtension.php +++ /dev/null @@ -1,43 +0,0 @@ -processConfiguration($configuration, $configs); - - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); - $loader->load('services.yml'); - - // Hashids Config - if (isset($config['hashids'])) { - if (isset($config['hashids']['salt'])) { - $container->setParameter('leopardd_url_shortener.hashids.salt', $config['hashids']['salt']); - } - - if (isset($config['hashids']['min_length'])) { - $container->setParameter('leopardd_url_shortener.hashids.min_length', $config['hashids']['min_length']); - } - - if (isset($config['hashids']['alphabet'])) { - $container->setParameter('leopardd_url_shortener.hashids.alphabet', $config['hashids']['alphabet']); - } - } - } -} diff --git a/Entity/ShortUrl.php b/Entity/ShortUrl.php deleted file mode 100644 index 32e0d58..0000000 --- a/Entity/ShortUrl.php +++ /dev/null @@ -1,125 +0,0 @@ -") - * @JMS\Expose() - */ - private $created; - - /** - * ShortUrl constructor. - */ - public function __construct() - { - $this->created = new DateTime(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getCode() - { - return $this->code; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getUrl() - { - return $this->url; - } - - /** - * {@inheritdoc} - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * @return DateTime - */ - public function getCreated() - { - return $this->created; - } - - /** - * @param DateTime $created - * @return ShortUrl - */ - public function setCreated($created) - { - $this->created = $created; - - return $this; - } -} diff --git a/Entity/ShortUrlInterface.php b/Entity/ShortUrlInterface.php deleted file mode 100644 index 2372ae6..0000000 --- a/Entity/ShortUrlInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. diff --git a/LeoparddUrlShortenerBundle.php b/LeoparddUrlShortenerBundle.php deleted file mode 100644 index ffe83d4..0000000 --- a/LeoparddUrlShortenerBundle.php +++ /dev/null @@ -1,9 +0,0 @@ -createQueryBuilder('s'); - $qb->where('s.id = :id') - ->setParameter('id', $id); - - return $qb->getQuery()->getOneOrNullResult(); - } - - /** - * {@inheritdoc} - */ - public function findOneByUrl($url) - { - $qb = $this->createQueryBuilder('s'); - $qb->where('s.url = :url') - ->setParameter('url', $url); - - return $qb->getQuery()->getOneOrNullResult(); - } - - /** - * {@inheritdoc} - */ - public function save(ShortUrlInterface $shortUrl) - { - $this->_em->persist($shortUrl); - $this->_em->flush($shortUrl); - - return $shortUrl; - } -} diff --git a/Repository/ShortUrlRepositoryInterface.php b/Repository/ShortUrlRepositoryInterface.php deleted file mode 100644 index 0b34109..0000000 --- a/Repository/ShortUrlRepositoryInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - diff --git a/spec/Service/EncodeServiceSpec.php b/spec/Service/EncodeServiceSpec.php deleted file mode 100644 index 93a74e6..0000000 --- a/spec/Service/EncodeServiceSpec.php +++ /dev/null @@ -1,84 +0,0 @@ -beConstructedWith($hashids, $shortUrlRepository, $dispatcher); - } - - function it_is_initializable() - { - $this->shouldHaveType(EncodeService::class); - } - - function it_process_existent_url( - ShortUrlInterface $shortUrl, - ShortUrlInterface $existentShortUrl, - ShortUrlRepositoryInterface $shortUrlRepository - ) { - $url = 'https://www.google.com'; - - $shortUrl->getUrl() - ->shouldBeCalled() - ->willReturn($url); - $shortUrlRepository->findOneByUrl($url) - ->shouldBeCalled() - ->willReturn($existentShortUrl); - - $this->process($shortUrl)->shouldReturn($existentShortUrl); - } - - function it_process( - EventDispatcherInterface $dispatcher, - Hashids $hashids, - ShortUrlInterface $shortUrl, - ShortUrlRepositoryInterface $shortUrlRepository - ) { - $id = 8; - $url = 'https://www.google.com'; - $code = 'abc'; - - $shortUrl->getUrl() - ->shouldBeCalled() - ->willReturn($url); - $shortUrlRepository->findOneByUrl($url) - ->shouldBeCalled() - ->willReturn(null); - $shortUrlRepository->save($shortUrl) - ->shouldBeCalledTimes(2) - ->willReturn($shortUrl); - $shortUrl->getId() - ->shouldBeCalled() - ->willReturn($id); - $hashids->encode($id) - ->willReturn($code); - $shortUrl->setCode($code) - ->shouldBeCalled(); - - $event = new ShortUrlCreatedEvent($shortUrl->getWrappedObject()); - $dispatcher->dispatch(ShortUrlEvent::SHORT_URL_CREATED, $event) - ->shouldBeCalled(); - - $this->process($shortUrl)->shouldReturn($shortUrl); - } -} diff --git a/spec/Service/RedirectServiceSpec.php b/spec/Service/RedirectServiceSpec.php deleted file mode 100644 index 8a91a72..0000000 --- a/spec/Service/RedirectServiceSpec.php +++ /dev/null @@ -1,93 +0,0 @@ -beConstructedWith($hashids, $shortUrlRepository, $dispatcher); - } - - function it_is_initializable() - { - $this->shouldHaveType(RedirectService::class); - } - - function it_get_redirect_response_by_invalid_code( - Hashids $hashids - ) { - $id = 'not numeric'; - $code = 'abc'; - - $hashids->decode($code) - ->shouldBeCalled() - ->willReturn($id); - - $this->shouldThrow(InvalidCodeException::class)->duringGetRedirectResponse($code); - } - - function it_get_redirect_response_by_nonexistent_code( - Hashids $hashids, - ShortUrlRepositoryInterface $shortUrlRepository - ) { - $ids = [8]; - $id = $ids[0]; - $code = 'abc'; - - $hashids->decode($code) - ->shouldBeCalled() - ->willReturn($ids); - $shortUrlRepository->findOneById($id) - ->shouldBeCalled() - ->willReturn(null); - - $this->getRedirectResponse($code)->shouldReturn(null); - } - - function it_get_redirect_response( - EventDispatcherInterface $dispatcher, - Hashids $hashids, - ShortUrlInterface $shortUrl, - ShortUrlRepositoryInterface $shortUrlRepository - ) { - $ids = [8]; - $id = $ids[0]; - $url = 'https://www.google.com'; - $code = 'abc'; - $redirectResponse = new RedirectResponse($url); - - $hashids->decode($code) - ->shouldBeCalled() - ->willReturn($ids); - $shortUrlRepository->findOneById($id) - ->shouldBeCalled() - ->willReturn($shortUrl); - $dispatcher->dispatch(ShortUrlEvent::SHORT_URL_REDIRECTED, Argument::type(ShortUrlRedirectedEvent::class)) - ->shouldBeCalled(); - $shortUrl->getUrl() - ->shouldBeCalled() - ->willReturn($url); - - $this->getRedirectResponse($code)->shouldBeLike($redirectResponse); - } -} From d23f63558bbf2fffa689918d60c4d853a5c9fed3 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 10:08:45 +0200 Subject: [PATCH 65/77] Missing file --- LeoparddUrlShortenerBundle.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LeoparddUrlShortenerBundle.php diff --git a/LeoparddUrlShortenerBundle.php b/LeoparddUrlShortenerBundle.php new file mode 100644 index 0000000..d38fb48 --- /dev/null +++ b/LeoparddUrlShortenerBundle.php @@ -0,0 +1,9 @@ + Date: Fri, 3 Jun 2022 10:16:37 +0200 Subject: [PATCH 66/77] Missing file --- .../LeoparddUrlShortenerExtension.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 DependencyInjection/LeoparddUrlShortenerExtension.php diff --git a/DependencyInjection/LeoparddUrlShortenerExtension.php b/DependencyInjection/LeoparddUrlShortenerExtension.php new file mode 100644 index 0000000..d9994d9 --- /dev/null +++ b/DependencyInjection/LeoparddUrlShortenerExtension.php @@ -0,0 +1,43 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader->load('services.yml'); + + // Hashids Config + if (isset($config['hashids'])) { + if (isset($config['hashids']['salt'])) { + $container->setParameter('leopardd_url_shortener.hashids.salt', $config['hashids']['salt']); + } + + if (isset($config['hashids']['min_length'])) { + $container->setParameter('leopardd_url_shortener.hashids.min_length', $config['hashids']['min_length']); + } + + if (isset($config['hashids']['alphabet'])) { + $container->setParameter('leopardd_url_shortener.hashids.alphabet', $config['hashids']['alphabet']); + } + } + } +} \ No newline at end of file From 27fcd82e30f9373e5b378b1612432e3efcd66452 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 10:21:56 +0200 Subject: [PATCH 67/77] Missing file --- Entity/ShortUrl.php | 125 +++++++++++++++++++++++++++++ Entity/ShortUrlInterface.php | 37 +++++++++ Exception/InvalidCodeException.php | 17 ++++ Exception/InvalidUrlException.php | 17 ++++ 4 files changed, 196 insertions(+) create mode 100644 Entity/ShortUrl.php create mode 100644 Entity/ShortUrlInterface.php create mode 100644 Exception/InvalidCodeException.php create mode 100644 Exception/InvalidUrlException.php diff --git a/Entity/ShortUrl.php b/Entity/ShortUrl.php new file mode 100644 index 0000000..32e0d58 --- /dev/null +++ b/Entity/ShortUrl.php @@ -0,0 +1,125 @@ +") + * @JMS\Expose() + */ + private $created; + + /** + * ShortUrl constructor. + */ + public function __construct() + { + $this->created = new DateTime(); + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getCode() + { + return $this->code; + } + + /** + * {@inheritdoc} + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getUrl() + { + return $this->url; + } + + /** + * {@inheritdoc} + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * @param DateTime $created + * @return ShortUrl + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } +} diff --git a/Entity/ShortUrlInterface.php b/Entity/ShortUrlInterface.php new file mode 100644 index 0000000..2372ae6 --- /dev/null +++ b/Entity/ShortUrlInterface.php @@ -0,0 +1,37 @@ + Date: Fri, 3 Jun 2022 10:37:00 +0200 Subject: [PATCH 68/77] Missing file --- Repository/ShortUrlRepository.php | 48 ++++++++++++++++++++++ Repository/ShortUrlRepositoryInterface.php | 30 ++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Repository/ShortUrlRepository.php create mode 100644 Repository/ShortUrlRepositoryInterface.php diff --git a/Repository/ShortUrlRepository.php b/Repository/ShortUrlRepository.php new file mode 100644 index 0000000..46feebb --- /dev/null +++ b/Repository/ShortUrlRepository.php @@ -0,0 +1,48 @@ +createQueryBuilder('s'); + $qb->where('s.id = :id') + ->setParameter('id', $id); + + return $qb->getQuery()->getOneOrNullResult(); + } + + /** + * {@inheritdoc} + */ + public function findOneByUrl($url) + { + $qb = $this->createQueryBuilder('s'); + $qb->where('s.url = :url') + ->setParameter('url', $url); + + return $qb->getQuery()->getOneOrNullResult(); + } + + /** + * {@inheritdoc} + */ + public function save(ShortUrlInterface $shortUrl) + { + $this->_em->persist($shortUrl); + $this->_em->flush($shortUrl); + + return $shortUrl; + } +} diff --git a/Repository/ShortUrlRepositoryInterface.php b/Repository/ShortUrlRepositoryInterface.php new file mode 100644 index 0000000..0b34109 --- /dev/null +++ b/Repository/ShortUrlRepositoryInterface.php @@ -0,0 +1,30 @@ + Date: Fri, 3 Jun 2022 10:42:38 +0200 Subject: [PATCH 69/77] Missing file --- Event/ShortUrlEvent.php | 13 +++++++++++ Factory/ShortUrlRepositoryInterface.php | 30 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Event/ShortUrlEvent.php create mode 100644 Factory/ShortUrlRepositoryInterface.php diff --git a/Event/ShortUrlEvent.php b/Event/ShortUrlEvent.php new file mode 100644 index 0000000..f1547f3 --- /dev/null +++ b/Event/ShortUrlEvent.php @@ -0,0 +1,13 @@ + Date: Fri, 3 Jun 2022 10:52:14 +0200 Subject: [PATCH 70/77] Missing file --- Factory/ShortUrlFactoryInterface.php | 19 ++++++++++++++++ Factory/ShortUrlRepositoryInterface.php | 30 ------------------------- 2 files changed, 19 insertions(+), 30 deletions(-) create mode 100644 Factory/ShortUrlFactoryInterface.php delete mode 100644 Factory/ShortUrlRepositoryInterface.php diff --git a/Factory/ShortUrlFactoryInterface.php b/Factory/ShortUrlFactoryInterface.php new file mode 100644 index 0000000..6e89782 --- /dev/null +++ b/Factory/ShortUrlFactoryInterface.php @@ -0,0 +1,19 @@ + Date: Fri, 3 Jun 2022 11:10:49 +0200 Subject: [PATCH 71/77] Missing file --- Entity/ShortUrl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Entity/ShortUrl.php b/Entity/ShortUrl.php index 32e0d58..bd38910 100644 --- a/Entity/ShortUrl.php +++ b/Entity/ShortUrl.php @@ -36,10 +36,10 @@ class ShortUrl implements ShortUrlInterface * @var string * @Assert\NotBlank(message="The url should not be blank") * @Assert\Length( - * max = 255, + * max = 2000, * maxMessage = "The url cannot be longer than {{ limit }} characters" * ) - * @ORM\Column(name="url", type="string", length=255) + * @ORM\Column(name="url", type="string", length=2000) * @JMS\Expose() */ protected $url; @@ -122,4 +122,4 @@ public function setCreated($created) return $this; } -} +} \ No newline at end of file From 2986677eb522f69bd0a7e0de6cead9ea0ac63015 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 11:15:03 +0200 Subject: [PATCH 72/77] Missing file --- Entity/ShortUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Entity/ShortUrl.php b/Entity/ShortUrl.php index bd38910..2911bf6 100644 --- a/Entity/ShortUrl.php +++ b/Entity/ShortUrl.php @@ -27,7 +27,7 @@ class ShortUrl implements ShortUrlInterface /** * @var string * @Assert\NotBlank(message="The code should not be blank") - * @ORM\Column(name="code", type="string", unique=true, nullable=true, options={"collation":"utf8_bin"}) + * @ORM\Column(name="code", type="text", unique=true, nullable=true, options={"collation":"utf8_bin"}) * @JMS\Expose() */ protected $code; From 720b74bf9f072477be5dcfa4357d328dd0679e1c Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 11:15:56 +0200 Subject: [PATCH 73/77] update length url (2000 max in rfc) --- Entity/ShortUrl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Entity/ShortUrl.php b/Entity/ShortUrl.php index 2911bf6..d2f66aa 100644 --- a/Entity/ShortUrl.php +++ b/Entity/ShortUrl.php @@ -27,7 +27,7 @@ class ShortUrl implements ShortUrlInterface /** * @var string * @Assert\NotBlank(message="The code should not be blank") - * @ORM\Column(name="code", type="text", unique=true, nullable=true, options={"collation":"utf8_bin"}) + * @ORM\Column(name="code", type="string", unique=true, nullable=true, options={"collation":"utf8_bin"}) * @JMS\Expose() */ protected $code; @@ -39,7 +39,7 @@ class ShortUrl implements ShortUrlInterface * max = 2000, * maxMessage = "The url cannot be longer than {{ limit }} characters" * ) - * @ORM\Column(name="url", type="string", length=2000) + * @ORM\Column(name="url", type="text", length=2000) * @JMS\Expose() */ protected $url; From 58643bd5c7db73e9e1eedaa63aeb4a3b3b615449 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 11:29:32 +0200 Subject: [PATCH 74/77] fix url length index --- Entity/ShortUrl.php | 217 ++++++++++++++++++++++---------------------- 1 file changed, 109 insertions(+), 108 deletions(-) diff --git a/Entity/ShortUrl.php b/Entity/ShortUrl.php index d2f66aa..e954ede 100644 --- a/Entity/ShortUrl.php +++ b/Entity/ShortUrl.php @@ -11,115 +11,116 @@ * Class ShortUrl * @package Leopardd\Bundle\UrlShortenerBundle\Entity * @ORM\Entity(repositoryClass="Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepository") - * @ORM\Table(name="short_url", indexes={@ORM\Index(name="idx", columns={"id", "url"})}) + * @ORM\Table(name="short_url", indexes={@ORM\Index(name="idx", columns={"id", "url"}, options={"lengths": { null , 255 } })}) */ class ShortUrl implements ShortUrlInterface { - /** - * @var int - * @ORM\Id - * @ORM\Column(name="id", type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - * @JMS\Expose() - */ - protected $id; - - /** - * @var string - * @Assert\NotBlank(message="The code should not be blank") - * @ORM\Column(name="code", type="string", unique=true, nullable=true, options={"collation":"utf8_bin"}) - * @JMS\Expose() - */ - protected $code; - - /** - * @var string - * @Assert\NotBlank(message="The url should not be blank") - * @Assert\Length( - * max = 2000, - * maxMessage = "The url cannot be longer than {{ limit }} characters" - * ) - * @ORM\Column(name="url", type="text", length=2000) - * @JMS\Expose() - */ - protected $url; - - /** - * @var DateTime - * @ORM\Column(name="created", type="datetime") - * @JMS\Type("DateTime<'Y-m-d H:i:s', 'UTC'>") - * @JMS\Expose() - */ - private $created; - - /** - * ShortUrl constructor. - */ - public function __construct() - { - $this->created = new DateTime(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getCode() - { - return $this->code; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getUrl() - { - return $this->url; - } - - /** - * {@inheritdoc} - */ - public function setUrl($url) - { - $this->url = $url; - - return $this; - } - - /** - * @return DateTime - */ - public function getCreated() - { - return $this->created; - } - - /** - * @param DateTime $created - * @return ShortUrl - */ - public function setCreated($created) - { - $this->created = $created; - - return $this; - } + /** + * @var int + * @ORM\Id + * @ORM\Column(name="id", type="integer") + * @ORM\GeneratedValue(strategy="AUTO") + * @JMS\Expose() + */ + protected $id; + + /** + * @var string + * @Assert\NotBlank(message="The code should not be blank") + * @ORM\Column(name="code", type="string", unique=true, nullable=true, options={"collation":"utf8_bin"}) + * @JMS\Expose() + */ + protected $code; + + /** + * @var string + * @Assert\NotBlank(message="The url should not be blank") + * @Assert\Length( + * max = 2000, + * maxMessage = "The url cannot be longer than {{ limit }} characters" + * ) + * @ORM\Column(name="url", type="text", length=2000) + * @JMS\Expose() + */ + protected $url; + + + /** + * @var DateTime + * @ORM\Column(name="created", type="datetime") + * @JMS\Type("DateTime<'Y-m-d H:i:s', 'UTC'>") + * @JMS\Expose() + */ + private $created; + + /** + * ShortUrl constructor. + */ + public function __construct() + { + $this->created = new DateTime(); + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getCode() + { + return $this->code; + } + + /** + * {@inheritdoc} + */ + public function setCode($code) + { + $this->code = $code; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getUrl() + { + return $this->url; + } + + /** + * {@inheritdoc} + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return DateTime + */ + public function getCreated() + { + return $this->created; + } + + /** + * @param DateTime $created + * @return ShortUrl + */ + public function setCreated($created) + { + $this->created = $created; + + return $this; + } } \ No newline at end of file From 66af8ebeb2eb680ceaa6b5279c275fb2365f490e Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 11:38:56 +0200 Subject: [PATCH 75/77] fix url length index --- Resources/config/services.yml | 1 + Service/EncodeService.php | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 9413a97..71585af 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -47,6 +47,7 @@ services: - "@leopardd_url_shortener.hash.hashid" - "@leopardd_url_shortener.repository.short_url" - "@event_dispatcher" + - "@router" # leopardd_url_shortener.service.redirect: class: Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService diff --git a/Service/EncodeService.php b/Service/EncodeService.php index 1151376..7afe1bc 100644 --- a/Service/EncodeService.php +++ b/Service/EncodeService.php @@ -8,6 +8,7 @@ use Leopardd\Bundle\UrlShortenerBundle\Repository\ShortUrlRepositoryInterface; use Leopardd\Bundle\UrlShortenerBundle\Event\ShortUrlEvent; use Leopardd\Bundle\UrlShortenerBundle\Event\ShortUrlCreatedEvent; +use Symfony\Component\Routing\RouterInterface; /** * Class EncodeService @@ -22,11 +23,18 @@ class EncodeService * @param ShortUrlRepositoryInterface $shortUrlRepository * @param EventDispatcherInterface $dispatcher */ - public function __construct(private Hashids $hashids, private ShortUrlRepositoryInterface $shortUrlRepository, private EventDispatcherInterface $dispatcher) + public function __construct(private Hashids $hashids, private ShortUrlRepositoryInterface $shortUrlRepository, private EventDispatcherInterface $dispatcher,private RouterInterface $router) { } + + public function getShortUrl($shortUrl) + { + + return $this->router->generate('leopardd_url_shortener_redirect',['code' => $shortUrl->getCode() ]) ; + + } /** * @param ShortUrlInterface $shortUrl * @return ShortUrlInterface From b63e4becc5ec44f72a283878fcf0eea3a8be4390 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 3 Jun 2022 11:43:33 +0200 Subject: [PATCH 76/77] fix url length index --- Service/EncodeService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Service/EncodeService.php b/Service/EncodeService.php index 7afe1bc..5f3cd85 100644 --- a/Service/EncodeService.php +++ b/Service/EncodeService.php @@ -29,10 +29,10 @@ public function __construct(private Hashids $hashids, private ShortUrlRepository } - public function getShortUrl($shortUrl) + public function getShortUrl($shortUrl,$referenceType = RouterInterface::ABSOLUTE_URL) // absolute url { - return $this->router->generate('leopardd_url_shortener_redirect',['code' => $shortUrl->getCode() ]) ; + return $this->router->generate('leopardd_url_shortener_redirect',['code' => $shortUrl->getCode() ] , $referenceType) ; } /** From 87a90e936944774f5419bccb94c801b40ed30381 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 7 Jun 2022 15:48:41 +0200 Subject: [PATCH 77/77] fix url length index --- Factory/ShortUrlFactoryInterface.php | 4 +++- Repository/ShortUrlRepositoryInterface.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Factory/ShortUrlFactoryInterface.php b/Factory/ShortUrlFactoryInterface.php index 6e89782..40032c0 100644 --- a/Factory/ShortUrlFactoryInterface.php +++ b/Factory/ShortUrlFactoryInterface.php @@ -4,6 +4,8 @@ use Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrlInterface; +// ok + /** * Interface ShortUrlFactoryInterface * @package Leopardd\Bundle\UrlShortenerBundle\Factory @@ -16,4 +18,4 @@ interface ShortUrlFactoryInterface * @return ShortUrlInterface */ public function create($url); -} +} \ No newline at end of file diff --git a/Repository/ShortUrlRepositoryInterface.php b/Repository/ShortUrlRepositoryInterface.php index 0b34109..f917e30 100644 --- a/Repository/ShortUrlRepositoryInterface.php +++ b/Repository/ShortUrlRepositoryInterface.php @@ -2,6 +2,8 @@ namespace Leopardd\Bundle\UrlShortenerBundle\Repository; +// ok + use Leopardd\Bundle\UrlShortenerBundle\Entity\ShortUrlInterface; /** @@ -27,4 +29,4 @@ public function findOneByUrl($url); * @return ShortUrlInterface */ public function save(ShortUrlInterface $shortUrl); -} +} \ No newline at end of file