mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Basic short-úrl import implementation
This commit is contained in:
@@ -11,6 +11,7 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlsOrdering;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
|
||||
use function array_column;
|
||||
use function array_key_exists;
|
||||
@@ -254,4 +255,16 @@ DQL;
|
||||
|
||||
return $qb->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function importedUrlExists(ImportedShlinkUrl $url, string $source, bool $importShortCodes): bool
|
||||
{
|
||||
$findConditions = ['importSource' => $source];
|
||||
if ($importShortCodes) {
|
||||
$findConditions['shortCode'] = $url->shortCode();
|
||||
} else {
|
||||
$findConditions['longUrl'] = $url->longUrl();
|
||||
}
|
||||
|
||||
return $this->count($findConditions) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlsOrdering;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
|
||||
interface ShortUrlRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
@@ -30,4 +31,6 @@ interface ShortUrlRepositoryInterface extends ObjectRepository
|
||||
public function shortCodeIsInUse(string $slug, ?string $domain): bool;
|
||||
|
||||
public function findOneMatching(string $url, array $tags, ShortUrlMeta $meta): ?ShortUrl;
|
||||
|
||||
public function importedUrlExists(ImportedShlinkUrl $url, string $source, bool $importShortCodes): bool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user