mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Updated entities mapping config so that they return a function
This commit is contained in:
parent
a737eed5c5
commit
96350c8b8f
@ -47,7 +47,7 @@
|
||||
"phly/phly-event-dispatcher": "^1.0",
|
||||
"predis/predis": "^1.1",
|
||||
"pugx/shortid-php": "^0.5",
|
||||
"shlinkio/shlink-common": "^2.6.0",
|
||||
"shlinkio/shlink-common": "^2.7.0",
|
||||
"shlinkio/shlink-event-dispatcher": "^1.3",
|
||||
"shlinkio/shlink-installer": "^4.0.1",
|
||||
"shlinkio/shlink-ip-geolocation": "^1.3.1",
|
||||
|
@ -9,6 +9,7 @@ return [
|
||||
'entity_manager' => [
|
||||
'orm' => [
|
||||
'proxies_dir' => 'data/proxies',
|
||||
'load_mappings_using_functional_style' => true,
|
||||
],
|
||||
'connection' => [
|
||||
'user' => '',
|
||||
|
@ -6,20 +6,21 @@ namespace Shlinkio\Shlink\Core;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
|
||||
/** @var $metadata ClassMetadata */ // @codingStandardsIgnoreLine
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
return static function (ClassMetadata $metadata): void {
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable('domains');
|
||||
$builder->setTable('domains');
|
||||
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$builder->createField('authority', Types::STRING)
|
||||
->unique()
|
||||
->build();
|
||||
$builder->createField('authority', Types::STRING)
|
||||
->unique()
|
||||
->build();
|
||||
};
|
||||
|
@ -6,65 +6,66 @@ namespace Shlinkio\Shlink\Core;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
|
||||
|
||||
/** @var $metadata ClassMetadata */ // @codingStandardsIgnoreLine
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
return static function (ClassMetadata $metadata): void {
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable('short_urls')
|
||||
->setCustomRepositoryClass(Repository\ShortUrlRepository::class);
|
||||
$builder->setTable('short_urls')
|
||||
->setCustomRepositoryClass(Repository\ShortUrlRepository::class);
|
||||
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$builder->createField('longUrl', Types::STRING)
|
||||
->columnName('original_url')
|
||||
->length(2048)
|
||||
->build();
|
||||
$builder->createField('longUrl', Types::STRING)
|
||||
->columnName('original_url')
|
||||
->length(2048)
|
||||
->build();
|
||||
|
||||
$builder->createField('shortCode', Types::STRING)
|
||||
->columnName('short_code')
|
||||
->length(255)
|
||||
->build();
|
||||
$builder->createField('shortCode', Types::STRING)
|
||||
->columnName('short_code')
|
||||
->length(255)
|
||||
->build();
|
||||
|
||||
$builder->createField('dateCreated', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('date_created')
|
||||
->build();
|
||||
$builder->createField('dateCreated', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('date_created')
|
||||
->build();
|
||||
|
||||
$builder->createField('validSince', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('valid_since')
|
||||
->nullable()
|
||||
->build();
|
||||
$builder->createField('validSince', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('valid_since')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('validUntil', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('valid_until')
|
||||
->nullable()
|
||||
->build();
|
||||
$builder->createField('validUntil', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('valid_until')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('maxVisits', Types::INTEGER)
|
||||
->columnName('max_visits')
|
||||
->nullable()
|
||||
->build();
|
||||
$builder->createField('maxVisits', Types::INTEGER)
|
||||
->columnName('max_visits')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createOneToMany('visits', Entity\Visit::class)
|
||||
->mappedBy('shortUrl')
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
$builder->createOneToMany('visits', Entity\Visit::class)
|
||||
->mappedBy('shortUrl')
|
||||
->fetchExtraLazy()
|
||||
->build();
|
||||
|
||||
$builder->createManyToMany('tags', Entity\Tag::class)
|
||||
->setJoinTable('short_urls_in_tags')
|
||||
->addInverseJoinColumn('tag_id', 'id', true, false, 'CASCADE')
|
||||
->addJoinColumn('short_url_id', 'id', true, false, 'CASCADE')
|
||||
->build();
|
||||
$builder->createManyToMany('tags', Entity\Tag::class)
|
||||
->setJoinTable('short_urls_in_tags')
|
||||
->addInverseJoinColumn('tag_id', 'id', true, false, 'CASCADE')
|
||||
->addJoinColumn('short_url_id', 'id', true, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createManyToOne('domain', Entity\Domain::class)
|
||||
->addJoinColumn('domain_id', 'id', true, false, 'RESTRICT')
|
||||
->cascadePersist()
|
||||
->build();
|
||||
$builder->createManyToOne('domain', Entity\Domain::class)
|
||||
->addJoinColumn('domain_id', 'id', true, false, 'RESTRICT')
|
||||
->cascadePersist()
|
||||
->build();
|
||||
|
||||
$builder->addUniqueConstraint(['short_code', 'domain_id'], 'unique_short_code_plus_domain');
|
||||
$builder->addUniqueConstraint(['short_code', 'domain_id'], 'unique_short_code_plus_domain');
|
||||
};
|
||||
|
@ -6,21 +6,22 @@ namespace Shlinkio\Shlink\Core;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
|
||||
/** @var $metadata ClassMetadata */ // @codingStandardsIgnoreLine
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
return static function (ClassMetadata $metadata): void {
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable('tags')
|
||||
->setCustomRepositoryClass(Repository\TagRepository::class);
|
||||
$builder->setTable('tags')
|
||||
->setCustomRepositoryClass(Repository\TagRepository::class);
|
||||
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$builder->createField('name', Types::STRING)
|
||||
->unique()
|
||||
->build();
|
||||
$builder->createField('name', Types::STRING)
|
||||
->unique()
|
||||
->build();
|
||||
};
|
||||
|
@ -6,49 +6,50 @@ namespace Shlinkio\Shlink\Core;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
|
||||
/** @var $metadata ClassMetadata */ // @codingStandardsIgnoreLine
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
return static function (ClassMetadata $metadata): void {
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable('visits')
|
||||
->setCustomRepositoryClass(Repository\VisitRepository::class);
|
||||
$builder->setTable('visits')
|
||||
->setCustomRepositoryClass(Repository\VisitRepository::class);
|
||||
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$builder->createField('referer', Types::STRING)
|
||||
->nullable()
|
||||
->length(Visitor::REFERER_MAX_LENGTH)
|
||||
->build();
|
||||
$builder->createField('referer', Types::STRING)
|
||||
->nullable()
|
||||
->length(Visitor::REFERER_MAX_LENGTH)
|
||||
->build();
|
||||
|
||||
$builder->createField('date', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('`date`')
|
||||
->build();
|
||||
$builder->createField('date', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('`date`')
|
||||
->build();
|
||||
|
||||
$builder->createField('remoteAddr', Types::STRING)
|
||||
->columnName('remote_addr')
|
||||
->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH)
|
||||
->nullable()
|
||||
->build();
|
||||
$builder->createField('remoteAddr', Types::STRING)
|
||||
->columnName('remote_addr')
|
||||
->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH)
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('userAgent', Types::STRING)
|
||||
->columnName('user_agent')
|
||||
->length(Visitor::USER_AGENT_MAX_LENGTH)
|
||||
->nullable()
|
||||
->build();
|
||||
$builder->createField('userAgent', Types::STRING)
|
||||
->columnName('user_agent')
|
||||
->length(Visitor::USER_AGENT_MAX_LENGTH)
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createManyToOne('shortUrl', Entity\ShortUrl::class)
|
||||
->addJoinColumn('short_url_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
$builder->createManyToOne('shortUrl', Entity\ShortUrl::class)
|
||||
->addJoinColumn('short_url_id', 'id', false, false, 'CASCADE')
|
||||
->build();
|
||||
|
||||
$builder->createManyToOne('visitLocation', Entity\VisitLocation::class)
|
||||
->addJoinColumn('visit_location_id', 'id', true, false, 'Set NULL')
|
||||
->cascadePersist()
|
||||
->build();
|
||||
$builder->createManyToOne('visitLocation', Entity\VisitLocation::class)
|
||||
->addJoinColumn('visit_location_id', 'id', true, false, 'Set NULL')
|
||||
->cascadePersist()
|
||||
->build();
|
||||
};
|
||||
|
@ -6,41 +6,42 @@ namespace Shlinkio\Shlink\Core;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
|
||||
/** @var $metadata ClassMetadata */ // @codingStandardsIgnoreLine
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
return static function (ClassMetadata $metadata): void {
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable('visit_locations');
|
||||
$builder->setTable('visit_locations');
|
||||
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$columns = [
|
||||
'country_code' => 'countryCode',
|
||||
'country_name' => 'countryName',
|
||||
'region_name' => 'regionName',
|
||||
'city_name' => 'cityName',
|
||||
'timezone' => 'timezone',
|
||||
];
|
||||
|
||||
foreach ($columns as $columnName => $fieldName) {
|
||||
$builder->createField($fieldName, Types::STRING)
|
||||
->columnName($columnName)
|
||||
->nullable()
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->columnName('id')
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
}
|
||||
|
||||
$builder->createField('latitude', Types::FLOAT)
|
||||
->columnName('lat')
|
||||
->nullable(false)
|
||||
->build();
|
||||
$columns = [
|
||||
'country_code' => 'countryCode',
|
||||
'country_name' => 'countryName',
|
||||
'region_name' => 'regionName',
|
||||
'city_name' => 'cityName',
|
||||
'timezone' => 'timezone',
|
||||
];
|
||||
|
||||
$builder->createField('longitude', Types::FLOAT)
|
||||
->columnName('lon')
|
||||
->nullable(false)
|
||||
->build();
|
||||
foreach ($columns as $columnName => $fieldName) {
|
||||
$builder->createField($fieldName, Types::STRING)
|
||||
->columnName($columnName)
|
||||
->nullable()
|
||||
->build();
|
||||
}
|
||||
|
||||
$builder->createField('latitude', Types::FLOAT)
|
||||
->columnName('lat')
|
||||
->nullable(false)
|
||||
->build();
|
||||
|
||||
$builder->createField('longitude', Types::FLOAT)
|
||||
->columnName('lon')
|
||||
->nullable(false)
|
||||
->build();
|
||||
};
|
||||
|
@ -6,29 +6,30 @@ namespace Shlinkio\Shlink\Rest;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
|
||||
|
||||
/** @var $metadata ClassMetadata */ // @codingStandardsIgnoreLine
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
return static function (ClassMetadata $metadata): void {
|
||||
$builder = new ClassMetadataBuilder($metadata);
|
||||
|
||||
$builder->setTable('api_keys');
|
||||
$builder->setTable('api_keys');
|
||||
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
$builder->createField('id', Types::BIGINT)
|
||||
->makePrimaryKey()
|
||||
->generatedValue('IDENTITY')
|
||||
->option('unsigned', true)
|
||||
->build();
|
||||
|
||||
$builder->createField('key', Types::STRING)
|
||||
->columnName('`key`')
|
||||
->unique()
|
||||
->build();
|
||||
$builder->createField('key', Types::STRING)
|
||||
->columnName('`key`')
|
||||
->unique()
|
||||
->build();
|
||||
|
||||
$builder->createField('expirationDate', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('expiration_date')
|
||||
->nullable()
|
||||
->build();
|
||||
$builder->createField('expirationDate', ChronosDateTimeType::CHRONOS_DATETIME)
|
||||
->columnName('expiration_date')
|
||||
->nullable()
|
||||
->build();
|
||||
|
||||
$builder->createField('enabled', Types::BOOLEAN)
|
||||
->build();
|
||||
$builder->createField('enabled', Types::BOOLEAN)
|
||||
->build();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user