From ce9d6642d4fb978b35c79dc495033146261fcc75 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 7 Jan 2018 21:13:06 +0100 Subject: [PATCH] Fixed edit short code action not being properly registered --- module/Core/src/Service/UrlShortener.php | 5 ++--- module/Rest/config/dependencies.config.php | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/module/Core/src/Service/UrlShortener.php b/module/Core/src/Service/UrlShortener.php index c0e19d1e..87621060 100644 --- a/module/Core/src/Service/UrlShortener.php +++ b/module/Core/src/Service/UrlShortener.php @@ -7,7 +7,6 @@ use Cocur\Slugify\Slugify; use Cocur\Slugify\SlugifyInterface; use Doctrine\Common\Cache\Cache; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\ORMException; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\GuzzleException; use Psr\Http\Message\UriInterface; @@ -119,14 +118,14 @@ class UrlShortener implements UrlShortenerInterface $this->em->flush(); // Generate the short code and persist it - $shortCode = $customSlug ?? $this->convertAutoincrementIdToShortCode($shortUrl->getId()); + $shortCode = $customSlug ?? $this->convertAutoincrementIdToShortCode((float) $shortUrl->getId()); $shortUrl->setShortCode($shortCode) ->setTags($this->tagNamesToEntities($this->em, $tags)); $this->em->flush(); $this->em->commit(); return $shortCode; - } catch (ORMException $e) { + } catch (\Throwable $e) { if ($this->em->getConnection()->isTransactionActive()) { $this->em->rollback(); $this->em->close(); diff --git a/module/Rest/config/dependencies.config.php b/module/Rest/config/dependencies.config.php index 760f46c8..bfd1a774 100644 --- a/module/Rest/config/dependencies.config.php +++ b/module/Rest/config/dependencies.config.php @@ -21,6 +21,7 @@ return [ Action\AuthenticateAction::class => ConfigAbstractFactory::class, Action\CreateShortcodeAction::class => ConfigAbstractFactory::class, + Action\EditShortCodeAction::class => ConfigAbstractFactory::class, Action\ResolveUrlAction::class => ConfigAbstractFactory::class, Action\GetVisitsAction::class => ConfigAbstractFactory::class, Action\ListShortcodesAction::class => ConfigAbstractFactory::class, @@ -48,6 +49,7 @@ return [ 'config.url_shortener.domain', 'Logger_Shlink', ], + Action\EditShortCodeAction::class => [Service\ShortUrlService::class, 'translator', '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'],