Create new entities for redirect rules

This commit is contained in:
Alejandro Celaya
2024-02-24 18:17:09 +01:00
parent 752100f1ce
commit c91a534d1a
8 changed files with 145 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace Shlinkio\Shlink\Core\RedirectRule\Entity;
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
use Shlinkio\Shlink\Core\RedirectRule\Model\RedirectConditionType;
class RedirectCondition extends AbstractEntity
{
public function __construct(
public readonly string $name,
public readonly RedirectConditionType $type,
public readonly string $matchValue,
public readonly ?string $matchKey = null,
) {
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Shlinkio\Shlink\Core\RedirectRule\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
class ShortUrlRedirectRule extends AbstractEntity
{
/**
* @param Collection<RedirectCondition> $conditions
*/
public function __construct(
private readonly ShortUrl $shortUrl, // No need to read this field. It's used by doctrine
public readonly int $priority,
public readonly string $longUrl,
public readonly Collection $conditions = new ArrayCollection(),
) {
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Shlinkio\Shlink\Core\RedirectRule\Model;
enum RedirectConditionType: string
{
case DEVICE = 'device';
// case LANGUAGE = 'language';
// case QUERY_PARAM = 'query';
}