forked from GNUsocial/gnu-social
[ENTITY][ActorTag] Add 'canonical' field to actor_tag
This commit is contained in:
parent
798a5f3796
commit
f986f59424
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
// {{{ License
|
// {{{ License
|
||||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
//
|
//
|
||||||
@ -19,9 +21,9 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Core\Cache;
|
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\Entity;
|
use App\Core\Entity;
|
||||||
|
use Component\Tag\Tag;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +47,8 @@ class ActorTag extends Entity
|
|||||||
private int $tagger;
|
private int $tagger;
|
||||||
private int $tagged;
|
private int $tagged;
|
||||||
private string $tag;
|
private string $tag;
|
||||||
private \DateTimeInterface $modified;
|
private string $canonical;
|
||||||
|
private DateTimeInterface $modified;
|
||||||
|
|
||||||
public function setTagger(int $tagger): self
|
public function setTagger(int $tagger): self
|
||||||
{
|
{
|
||||||
@ -80,6 +83,17 @@ class ActorTag extends Entity
|
|||||||
return $this->tag;
|
return $this->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCanonical(string $canonical): self
|
||||||
|
{
|
||||||
|
$this->canonical = $canonical;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCanonical(): string
|
||||||
|
{
|
||||||
|
return $this->canonical;
|
||||||
|
}
|
||||||
|
|
||||||
public function setModified(DateTimeInterface $modified): self
|
public function setModified(DateTimeInterface $modified): self
|
||||||
{
|
{
|
||||||
$this->modified = $modified;
|
$this->modified = $modified;
|
||||||
@ -101,7 +115,8 @@ class ActorTag extends Entity
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'actor making the tag'],
|
'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'actor making the tag'],
|
||||||
'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'],
|
'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'],
|
||||||
'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'],
|
'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this actor'],
|
||||||
|
'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of tag'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['tagger', 'tagged', 'tag'],
|
'primary key' => ['tagger', 'tagged', 'tag'],
|
||||||
|
@ -111,8 +111,8 @@ class Language extends Entity
|
|||||||
public static function getFromId(int $id): self
|
public static function getFromId(int $id): self
|
||||||
{
|
{
|
||||||
return Cache::getHashMapKey(
|
return Cache::getHashMapKey(
|
||||||
'languages-id',
|
map_key: 'languages-id',
|
||||||
(string) $id,
|
key: (string) $id,
|
||||||
calculate_map: fn () => F\reindex(DB::dql('select l from language l'), fn (self $l) => (string) $l->getId()),
|
calculate_map: fn () => F\reindex(DB::dql('select l from language l'), fn (self $l) => (string) $l->getId()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
// {{{ License/
|
// {{{ License/
|
||||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
//
|
//
|
||||||
@ -44,7 +46,7 @@ class NoteTag extends Entity
|
|||||||
private string $tag;
|
private string $tag;
|
||||||
private string $canonical;
|
private string $canonical;
|
||||||
private int $note_id;
|
private int $note_id;
|
||||||
private \DateTimeInterface $created;
|
private DateTimeInterface $created;
|
||||||
|
|
||||||
public function setTag(string $tag): self
|
public function setTag(string $tag): self
|
||||||
{
|
{
|
||||||
@ -100,7 +102,7 @@ class NoteTag extends Entity
|
|||||||
'description' => 'Hash tags on notes',
|
'description' => 'Hash tags on notes',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this note'],
|
'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this note'],
|
||||||
'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of hash tag'],
|
'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of tag'],
|
||||||
'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to tagged note'],
|
'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to tagged note'],
|
||||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user