mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Updated to latest shlink dependencies
This commit is contained in:
@@ -94,31 +94,31 @@ class ShortUrl extends AbstractEntity
|
||||
): self {
|
||||
$meta = [
|
||||
ShortUrlInputFilter::VALIDATE_URL => false,
|
||||
ShortUrlInputFilter::LONG_URL => $url->longUrl(),
|
||||
ShortUrlInputFilter::DOMAIN => $url->domain(),
|
||||
ShortUrlInputFilter::TAGS => $url->tags(),
|
||||
ShortUrlInputFilter::TITLE => $url->title(),
|
||||
ShortUrlInputFilter::MAX_VISITS => $url->meta()->maxVisits(),
|
||||
ShortUrlInputFilter::LONG_URL => $url->longUrl,
|
||||
ShortUrlInputFilter::DOMAIN => $url->domain,
|
||||
ShortUrlInputFilter::TAGS => $url->tags,
|
||||
ShortUrlInputFilter::TITLE => $url->title,
|
||||
ShortUrlInputFilter::MAX_VISITS => $url->meta->maxVisits,
|
||||
];
|
||||
if ($importShortCode) {
|
||||
$meta[ShortUrlInputFilter::CUSTOM_SLUG] = $url->shortCode();
|
||||
$meta[ShortUrlInputFilter::CUSTOM_SLUG] = $url->shortCode;
|
||||
}
|
||||
|
||||
$instance = self::fromMeta(ShortUrlMeta::fromRawData($meta), $relationResolver);
|
||||
|
||||
$validSince = $url->meta()->validSince();
|
||||
$validSince = $url->meta->validSince;
|
||||
if ($validSince !== null) {
|
||||
$instance->validSince = Chronos::instance($validSince);
|
||||
}
|
||||
|
||||
$validUntil = $url->meta()->validUntil();
|
||||
$validUntil = $url->meta->validUntil;
|
||||
if ($validUntil !== null) {
|
||||
$instance->validUntil = Chronos::instance($validUntil);
|
||||
}
|
||||
|
||||
$instance->importSource = $url->source();
|
||||
$instance->importOriginalShortCode = $url->shortCode();
|
||||
$instance->dateCreated = Chronos::instance($url->createdAt());
|
||||
$instance->importSource = $url->source->value;
|
||||
$instance->importOriginalShortCode = $url->shortCode;
|
||||
$instance->dateCreated = Chronos::instance($url->createdAt);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ class Visit extends AbstractEntity implements JsonSerializable
|
||||
public static function fromImport(ShortUrl $shortUrl, ImportedShlinkVisit $importedVisit): self
|
||||
{
|
||||
$instance = new self($shortUrl, VisitType::IMPORTED);
|
||||
$instance->userAgent = $importedVisit->userAgent();
|
||||
$instance->userAgent = $importedVisit->userAgent;
|
||||
$instance->potentialBot = isCrawler($instance->userAgent);
|
||||
$instance->referer = $importedVisit->referer();
|
||||
$instance->date = Chronos::instance($importedVisit->date());
|
||||
$instance->referer = $importedVisit->referer;
|
||||
$instance->date = Chronos::instance($importedVisit->date);
|
||||
|
||||
$importedLocation = $importedVisit->location();
|
||||
$importedLocation = $importedVisit->location;
|
||||
$instance->visitLocation = $importedLocation !== null ? VisitLocation::fromImport($importedLocation) : null;
|
||||
|
||||
return $instance;
|
||||
|
||||
@@ -28,13 +28,13 @@ class VisitLocation extends AbstractEntity implements JsonSerializable
|
||||
{
|
||||
$instance = new self();
|
||||
|
||||
$instance->countryCode = $location->countryCode();
|
||||
$instance->countryName = $location->countryName();
|
||||
$instance->regionName = $location->regionName();
|
||||
$instance->cityName = $location->city();
|
||||
$instance->latitude = $location->latitude();
|
||||
$instance->longitude = $location->longitude();
|
||||
$instance->timezone = $location->timeZone();
|
||||
$instance->countryCode = $location->countryCode;
|
||||
$instance->countryName = $location->countryName;
|
||||
$instance->regionName = $location->regionName;
|
||||
$instance->cityName = $location->city;
|
||||
$instance->latitude = $location->latitude;
|
||||
$instance->longitude = $location->longitude;
|
||||
$instance->timezone = $location->timeZone;
|
||||
$instance->computeIsEmpty();
|
||||
|
||||
return $instance;
|
||||
@@ -44,13 +44,13 @@ class VisitLocation extends AbstractEntity implements JsonSerializable
|
||||
{
|
||||
$instance = new self();
|
||||
|
||||
$instance->countryCode = $location->countryCode();
|
||||
$instance->countryName = $location->countryName();
|
||||
$instance->regionName = $location->regionName();
|
||||
$instance->cityName = $location->cityName();
|
||||
$instance->latitude = $location->latitude();
|
||||
$instance->longitude = $location->longitude();
|
||||
$instance->timezone = $location->timeZone();
|
||||
$instance->countryCode = $location->countryCode;
|
||||
$instance->countryName = $location->countryName;
|
||||
$instance->regionName = $location->regionName;
|
||||
$instance->cityName = $location->cityName;
|
||||
$instance->latitude = $location->latitude;
|
||||
$instance->longitude = $location->longitude;
|
||||
$instance->timezone = $location->timezone;
|
||||
$instance->computeIsEmpty();
|
||||
|
||||
return $instance;
|
||||
|
||||
@@ -38,6 +38,6 @@ class NonUniqueSlugException extends InvalidArgumentException implements Problem
|
||||
|
||||
public static function fromImport(ImportedShlinkUrl $importedUrl): self
|
||||
{
|
||||
return self::fromSlug($importedUrl->shortCode(), $importedUrl->domain());
|
||||
return self::fromSlug($importedUrl->shortCode, $importedUrl->domain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
use Symfony\Component\Console\Style\StyleInterface;
|
||||
use Throwable;
|
||||
@@ -26,10 +26,10 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
private ShortUrlRepositoryInterface $shortUrlRepo;
|
||||
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private ShortUrlRelationResolverInterface $relationResolver,
|
||||
private ShortCodeUniquenessHelperInterface $shortCodeHelper,
|
||||
private DoctrineBatchHelperInterface $batchHelper,
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly ShortUrlRelationResolverInterface $relationResolver,
|
||||
private readonly ShortCodeUniquenessHelperInterface $shortCodeHelper,
|
||||
private readonly DoctrineBatchHelperInterface $batchHelper,
|
||||
) {
|
||||
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
||||
}
|
||||
@@ -39,19 +39,19 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
*/
|
||||
public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void
|
||||
{
|
||||
$importShortCodes = $params->importShortCodes();
|
||||
$source = $params->source();
|
||||
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSources::SHLINK ? 10 : 100);
|
||||
$importShortCodes = $params->importShortCodes;
|
||||
$source = $params->source;
|
||||
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSource::SHLINK ? 10 : 100);
|
||||
|
||||
/** @var ImportedShlinkUrl $importedUrl */
|
||||
foreach ($iterable as $importedUrl) {
|
||||
$skipOnShortCodeConflict = static fn (): bool => $io->choice(sprintf(
|
||||
'Failed to import URL "%s" because its short-code "%s" is already in use. Do you want to generate '
|
||||
. 'a new one or skip it?',
|
||||
$importedUrl->longUrl(),
|
||||
$importedUrl->shortCode(),
|
||||
$importedUrl->longUrl,
|
||||
$importedUrl->shortCode,
|
||||
), ['Generate new short-code', 'Skip'], 1) === 'Skip';
|
||||
$longUrl = $importedUrl->longUrl();
|
||||
$longUrl = $importedUrl->longUrl;
|
||||
|
||||
try {
|
||||
$shortUrlImporting = $this->resolveShortUrl($importedUrl, $importShortCodes, $skipOnShortCodeConflict);
|
||||
@@ -68,7 +68,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$resultMessage = $shortUrlImporting->importVisits($importedUrl->visits(), $this->em);
|
||||
$resultMessage = $shortUrlImporting->importVisits($importedUrl->visits, $this->em);
|
||||
$io->text(sprintf('%s: %s', $longUrl, $resultMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ final class ShortUrlImporting
|
||||
$importedVisits = 0;
|
||||
foreach ($visits as $importedVisit) {
|
||||
// Skip visits which are older than the most recent already imported visit's date
|
||||
if ($mostRecentImportedDate?->gte(Chronos::instance($importedVisit->date()))) {
|
||||
if ($mostRecentImportedDate?->gte(Chronos::instance($importedVisit->date))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,12 +284,12 @@ class ShortUrlRepository extends EntitySpecificationRepository implements ShortU
|
||||
{
|
||||
$qb = $this->createQueryBuilder('s');
|
||||
$qb->andWhere($qb->expr()->eq('s.importOriginalShortCode', ':shortCode'))
|
||||
->setParameter('shortCode', $url->shortCode())
|
||||
->setParameter('shortCode', $url->shortCode)
|
||||
->andWhere($qb->expr()->eq('s.importSource', ':importSource'))
|
||||
->setParameter('importSource', $url->source())
|
||||
->setParameter('importSource', $url->source->value)
|
||||
->setMaxResults(1);
|
||||
|
||||
$this->whereDomainIs($qb, $url->domain());
|
||||
$this->whereDomainIs($qb, $url->domain);
|
||||
|
||||
return $qb->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user