mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Moved constants to its own file inside config folder
This commit is contained in:
parent
c7d8c1cab5
commit
cbec4a4e81
@ -83,6 +83,7 @@
|
|||||||
"Shlinkio\\Shlink\\Core\\": "module/Core/src"
|
"Shlinkio\\Shlink\\Core\\": "module/Core/src"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
"config/constants.php",
|
||||||
"module/Core/functions/functions.php"
|
"module/Core/functions/functions.php"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ namespace Shlinkio\Shlink;
|
|||||||
|
|
||||||
use function Shlinkio\Shlink\Common\env;
|
use function Shlinkio\Shlink\Common\env;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_DELETE_SHORT_URL_THRESHOLD;
|
use const Shlinkio\Shlink\DEFAULT_DELETE_SHORT_URL_THRESHOLD;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use Symfony\Component\Lock;
|
|||||||
|
|
||||||
use function Shlinkio\Shlink\Common\env;
|
use function Shlinkio\Shlink\Common\env;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
|
use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use function Shlinkio\Shlink\Common\env;
|
use function Shlinkio\Shlink\Common\env;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_CACHE_LIFETIME;
|
use const Shlinkio\Shlink\DEFAULT_REDIRECT_CACHE_LIFETIME;
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_STATUS_CODE;
|
use const Shlinkio\Shlink\DEFAULT_REDIRECT_STATUS_CODE;
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH;
|
use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH;
|
||||||
use const Shlinkio\Shlink\Core\MIN_SHORT_CODES_LENGTH;
|
use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH;
|
||||||
|
|
||||||
return (static function (): array {
|
return (static function (): array {
|
||||||
$webhooks = env('VISITS_WEBHOOKS');
|
$webhooks = env('VISITS_WEBHOOKS');
|
||||||
|
16
config/constants.php
Normal file
16
config/constants.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Shlinkio\Shlink;
|
||||||
|
|
||||||
|
use Fig\Http\Message\StatusCodeInterface;
|
||||||
|
|
||||||
|
const DEFAULT_DELETE_SHORT_URL_THRESHOLD = 15;
|
||||||
|
const DEFAULT_SHORT_CODES_LENGTH = 5;
|
||||||
|
const MIN_SHORT_CODES_LENGTH = 4;
|
||||||
|
const DEFAULT_REDIRECT_STATUS_CODE = StatusCodeInterface::STATUS_FOUND;
|
||||||
|
const DEFAULT_REDIRECT_CACHE_LIFETIME = 30;
|
||||||
|
const LOCAL_LOCK_FACTORY = 'Shlinkio\Shlink\LocalLockFactory';
|
||||||
|
const CUSTOM_SLUGS_REGEXP = '/[^\pL\pN._~]/u'; // Any unicode letter or number, plus ".", "_" and "~" chars
|
||||||
|
const TITLE_TAG_VALUE = '/<title[^>]*>(.*?)<\/title>/i'; // Matches the value inside an html title tag
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
use Laminas\ServiceManager\ServiceManager;
|
use Laminas\ServiceManager\ServiceManager;
|
||||||
use Symfony\Component\Lock;
|
use Symfony\Component\Lock;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
|
use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY;
|
||||||
|
|
||||||
chdir(dirname(__DIR__));
|
chdir(dirname(__DIR__));
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use Symfony\Component\Console as SymfonyCli;
|
|||||||
use Symfony\Component\Lock\LockFactory;
|
use Symfony\Component\Lock\LockFactory;
|
||||||
use Symfony\Component\Process\PhpExecutableFinder;
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
|
use const Shlinkio\Shlink\LOCAL_LOCK_FACTORY;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ namespace Shlinkio\Shlink\Core;
|
|||||||
|
|
||||||
use Cake\Chronos\Chronos;
|
use Cake\Chronos\Chronos;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Fig\Http\Message\StatusCodeInterface;
|
|
||||||
use Jaybizzle\CrawlerDetect\CrawlerDetect;
|
use Jaybizzle\CrawlerDetect\CrawlerDetect;
|
||||||
use Laminas\InputFilter\InputFilter;
|
use Laminas\InputFilter\InputFilter;
|
||||||
use PUGX\Shortid\Factory as ShortIdFactory;
|
use PUGX\Shortid\Factory as ShortIdFactory;
|
||||||
@ -22,15 +21,6 @@ use function str_repeat;
|
|||||||
use function str_replace;
|
use function str_replace;
|
||||||
use function ucwords;
|
use function ucwords;
|
||||||
|
|
||||||
const DEFAULT_DELETE_SHORT_URL_THRESHOLD = 15;
|
|
||||||
const DEFAULT_SHORT_CODES_LENGTH = 5;
|
|
||||||
const MIN_SHORT_CODES_LENGTH = 4;
|
|
||||||
const DEFAULT_REDIRECT_STATUS_CODE = StatusCodeInterface::STATUS_FOUND;
|
|
||||||
const DEFAULT_REDIRECT_CACHE_LIFETIME = 30;
|
|
||||||
const LOCAL_LOCK_FACTORY = 'Shlinkio\Shlink\LocalLockFactory';
|
|
||||||
const CUSTOM_SLUGS_REGEXP = '/[^\pL\pN._~]/u'; // Any unicode letter or number, plus ".", "_" and "~" chars
|
|
||||||
const TITLE_TAG_VALUE = '/<title[^>]*>(.*?)<\/title>/i'; // Matches the value inside an html title tag
|
|
||||||
|
|
||||||
function generateRandomShortCode(int $length): string
|
function generateRandomShortCode(int $length): string
|
||||||
{
|
{
|
||||||
static $shortIdFactory;
|
static $shortIdFactory;
|
||||||
|
@ -14,7 +14,7 @@ use function Shlinkio\Shlink\Core\getOptionalBoolFromInputFilter;
|
|||||||
use function Shlinkio\Shlink\Core\getOptionalIntFromInputFilter;
|
use function Shlinkio\Shlink\Core\getOptionalIntFromInputFilter;
|
||||||
use function Shlinkio\Shlink\Core\parseDateField;
|
use function Shlinkio\Shlink\Core\parseDateField;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH;
|
use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH;
|
||||||
|
|
||||||
final class ShortUrlMeta implements TitleResolutionModelInterface
|
final class ShortUrlMeta implements TitleResolutionModelInterface
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ namespace Shlinkio\Shlink\Core\Options;
|
|||||||
|
|
||||||
use Laminas\Stdlib\AbstractOptions;
|
use Laminas\Stdlib\AbstractOptions;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_DELETE_SHORT_URL_THRESHOLD;
|
use const Shlinkio\Shlink\DEFAULT_DELETE_SHORT_URL_THRESHOLD;
|
||||||
|
|
||||||
class DeleteShortUrlsOptions extends AbstractOptions
|
class DeleteShortUrlsOptions extends AbstractOptions
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,8 @@ use Laminas\Stdlib\AbstractOptions;
|
|||||||
|
|
||||||
use function Functional\contains;
|
use function Functional\contains;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_CACHE_LIFETIME;
|
use const Shlinkio\Shlink\DEFAULT_REDIRECT_CACHE_LIFETIME;
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_REDIRECT_STATUS_CODE;
|
use const Shlinkio\Shlink\DEFAULT_REDIRECT_STATUS_CODE;
|
||||||
|
|
||||||
class UrlShortenerOptions extends AbstractOptions
|
class UrlShortenerOptions extends AbstractOptions
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
|||||||
use function preg_match;
|
use function preg_match;
|
||||||
use function trim;
|
use function trim;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\TITLE_TAG_VALUE;
|
use const Shlinkio\Shlink\TITLE_TAG_VALUE;
|
||||||
|
|
||||||
class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
|
class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,8 @@ use Shlinkio\Shlink\Common\Validation;
|
|||||||
use Shlinkio\Shlink\Core\Util\CocurSymfonySluggerBridge;
|
use Shlinkio\Shlink\Core\Util\CocurSymfonySluggerBridge;
|
||||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\CUSTOM_SLUGS_REGEXP;
|
use const Shlinkio\Shlink\CUSTOM_SLUGS_REGEXP;
|
||||||
use const Shlinkio\Shlink\Core\MIN_SHORT_CODES_LENGTH;
|
use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH;
|
||||||
|
|
||||||
class ShortUrlInputFilter extends InputFilter
|
class ShortUrlInputFilter extends InputFilter
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ use function Functional\map;
|
|||||||
use function range;
|
use function range;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
|
|
||||||
use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH;
|
use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH;
|
||||||
|
|
||||||
class ShortUrlTest extends TestCase
|
class ShortUrlTest extends TestCase
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user