Update to latest shlink-common and remove deprecation references

This commit is contained in:
Alejandro Celaya
2024-07-29 19:39:31 +02:00
parent 6b0b52853c
commit b52ceaff9a
20 changed files with 62 additions and 83 deletions

View File

@@ -4,14 +4,14 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\EventDispatcher;
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Transformer\ShortUrlDataTransformerInterface;
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
final readonly class PublishingUpdatesGenerator implements PublishingUpdatesGeneratorInterface
{
public function __construct(private DataTransformerInterface $shortUrlTransformer)
public function __construct(private ShortUrlDataTransformerInterface $shortUrlTransformer)
{
}

View File

@@ -4,24 +4,17 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\ShortUrl\Transformer;
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlWithVisitsSummary;
/**
* @fixme Do not implement DataTransformerInterface, but a separate interface
*/
readonly class ShortUrlDataTransformer implements DataTransformerInterface
readonly class ShortUrlDataTransformer implements ShortUrlDataTransformerInterface
{
public function __construct(private ShortUrlStringifierInterface $stringifier)
{
}
/**
* @param ShortUrlWithVisitsSummary|ShortUrl $data
*/
public function transform($data): array // phpcs:ignore
public function transform(ShortUrlWithVisitsSummary|ShortUrl $data): array
{
$shortUrl = $data instanceof ShortUrlWithVisitsSummary ? $data->shortUrl : $data;
return [

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Core\ShortUrl\Transformer;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlWithVisitsSummary;
interface ShortUrlDataTransformerInterface
{
public function transform(ShortUrlWithVisitsSummary|ShortUrl $data): array;
}