mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Create new entities for redirect rules
This commit is contained in:
17
module/Core/src/RedirectRule/Entity/RedirectCondition.php
Normal file
17
module/Core/src/RedirectRule/Entity/RedirectCondition.php
Normal 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,
|
||||
) {
|
||||
}
|
||||
}
|
||||
22
module/Core/src/RedirectRule/Entity/ShortUrlRedirectRule.php
Normal file
22
module/Core/src/RedirectRule/Entity/ShortUrlRedirectRule.php
Normal 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(),
|
||||
) {
|
||||
}
|
||||
}
|
||||
10
module/Core/src/RedirectRule/Model/RedirectConditionType.php
Normal file
10
module/Core/src/RedirectRule/Model/RedirectConditionType.php
Normal 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';
|
||||
}
|
||||
Reference in New Issue
Block a user