mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Expose the fact that a short URL has redirect rules attached to it
This commit is contained in:
parent
228bf093d3
commit
3149adebdb
@ -141,6 +141,14 @@
|
|||||||
"crawlable": {
|
"crawlable": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Tells if this URL will be included as 'Allow' in Shlink's robots.txt."
|
"description": "Tells if this URL will be included as 'Allow' in Shlink's robots.txt."
|
||||||
|
},
|
||||||
|
"forwardQuery": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Tells if this URL will forward the query params to the long URL when visited, as explained in [the docs](https://shlink.io/documentation/some-features/#query-params-forwarding)."
|
||||||
|
},
|
||||||
|
"hasRedirectRules": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether this short URL has redirect rules attached to it or not. Use [this endpoint](https://api-spec.shlink.io/#/Redirect%20rules/listShortUrlRedirectRules) to get the actual list of rules."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"example": {
|
"example": {
|
||||||
@ -164,7 +172,9 @@
|
|||||||
},
|
},
|
||||||
"domain": "example.com",
|
"domain": "example.com",
|
||||||
"title": "The title",
|
"title": "The title",
|
||||||
"crawlable": false
|
"crawlable": false,
|
||||||
|
"forwardQuery": false,
|
||||||
|
"hasRedirectRules": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ShortUrlMeta": {
|
"ShortUrlMeta": {
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"domain",
|
"domain",
|
||||||
"title",
|
"title",
|
||||||
"crawlable",
|
"crawlable",
|
||||||
"forwardQuery"
|
"forwardQuery",
|
||||||
|
"hasRedirectRules"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"shortCode": {
|
"shortCode": {
|
||||||
@ -59,6 +60,10 @@
|
|||||||
"forwardQuery": {
|
"forwardQuery": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Tells if this URL will forward the query params to the long URL when visited, as explained in [the docs](https://shlink.io/documentation/some-features/#query-params-forwarding)."
|
"description": "Tells if this URL will forward the query params to the long URL when visited, as explained in [the docs](https://shlink.io/documentation/some-features/#query-params-forwarding)."
|
||||||
|
},
|
||||||
|
"hasRedirectRules": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether this short URL has redirect rules attached to it or not. Use [this endpoint](https://api-spec.shlink.io/#/Redirect%20rules/listShortUrlRedirectRules) to get the actual list of rules."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,4 +110,9 @@ return static function (ClassMetadata $metadata, array $emConfig): void {
|
|||||||
->columnName('forward_query')
|
->columnName('forward_query')
|
||||||
->option('default', true)
|
->option('default', true)
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
|
$builder->createOneToMany('redirectRules', RedirectRule\Entity\ShortUrlRedirectRule::class)
|
||||||
|
->mappedBy('shortUrl')
|
||||||
|
->fetchExtraLazy()
|
||||||
|
->build();
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@ use Doctrine\Common\Collections\Selectable;
|
|||||||
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
||||||
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
||||||
use Shlinkio\Shlink\Core\Exception\ShortCodeCannotBeRegeneratedException;
|
use Shlinkio\Shlink\Core\Exception\ShortCodeCannotBeRegeneratedException;
|
||||||
|
use Shlinkio\Shlink\Core\RedirectRule\Entity\ShortUrlRedirectRule;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
|
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlEdition;
|
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlEdition;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlMode;
|
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlMode;
|
||||||
@ -39,6 +40,7 @@ class ShortUrl extends AbstractEntity
|
|||||||
* @param Collection<int, Tag> $tags
|
* @param Collection<int, Tag> $tags
|
||||||
* @param Collection<int, Visit> & Selectable<int, Visit> $visits
|
* @param Collection<int, Visit> & Selectable<int, Visit> $visits
|
||||||
* @param Collection<int, ShortUrlVisitsCount> & Selectable<int, ShortUrlVisitsCount> $visitsCounts
|
* @param Collection<int, ShortUrlVisitsCount> & Selectable<int, ShortUrlVisitsCount> $visitsCounts
|
||||||
|
* @param Collection<int, ShortUrlRedirectRule> $redirectRules
|
||||||
*/
|
*/
|
||||||
private function __construct(
|
private function __construct(
|
||||||
private string $longUrl,
|
private string $longUrl,
|
||||||
@ -60,6 +62,7 @@ class ShortUrl extends AbstractEntity
|
|||||||
private bool $forwardQuery = true,
|
private bool $forwardQuery = true,
|
||||||
private ?string $importSource = null,
|
private ?string $importSource = null,
|
||||||
private ?string $importOriginalShortCode = null,
|
private ?string $importOriginalShortCode = null,
|
||||||
|
private Collection $redirectRules = new ArrayCollection(),
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,6 +286,7 @@ class ShortUrl extends AbstractEntity
|
|||||||
Criteria::create()->where(Criteria::expr()->eq('potentialBot', false)),
|
Criteria::create()->where(Criteria::expr()->eq('potentialBot', false)),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
'hasRedirectRules' => count($this->redirectRules) > 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user