[ENTITY][Actor] Nickname is lower case transformed when generating 'actor_view_nickname', making sure that actor pages are linked accordingly

This commit is contained in:
Eliseu Amaro 2022-01-27 17:19:50 +00:00
parent a17a514bfd
commit 5036b72a71
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5
1 changed files with 9 additions and 12 deletions

View File

@ -436,24 +436,21 @@ class Actor extends Entity
/** /**
* Get a URL for this actor, i.e. a user friendly URL, using the nickname * Get a URL for this actor, i.e. a user friendly URL, using the nickname
*
* @param int $type
* @return string
* @throws BugFoundException
*/ */
public function getUrl(int $type = Router::ABSOLUTE_URL): string public function getUrl(int $type = Router::ABSOLUTE_URL): string
{ {
if ($this->getIsLocal()) { if ($this->getIsLocal()) {
$url = null; $url = null;
if (Event::handle('StartGetActorUrl', [$this, $type, &$url]) === Event::next) { if (Event::handle('StartGetActorUrl', [$this, $type, &$url]) === Event::next) {
switch ($this->type) { $url = match ($this->type) {
case self::PERSON: self::PERSON, self::ORGANISATION, self::BOT => Router::url('actor_view_nickname', ['nickname' => mb_strtolower($this->getNickname())], $type),
case self::ORGANISATION: self::GROUP => Router::url('group_actor_view_nickname', ['nickname' => $this->getNickname()], $type),
case self::BOT: default => throw new BugFoundException('Actor type added but `Actor::getUrl` was not updated'),
$url = Router::url('actor_view_nickname', ['nickname' => $this->getNickname()], $type); };
break;
case self::GROUP:
$url = Router::url('group_actor_view_nickname', ['nickname' => $this->getNickname()], $type);
break;
default:
throw new BugFoundException('Actor type added but `Actor::getUrl` was not updated');
}
Event::handle('EndGetActorUrl', [$this, $type, &$url]); Event::handle('EndGetActorUrl', [$this, $type, &$url]);
} }
} else { } else {