Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis committed Jan 22, 2025
1 parent 4a80110 commit 611abb9
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions app/Services/MentionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class MentionsService
/** @var array List of mentioned private entities (their ids) */
protected array $hiddenEntities = [];

/** @var array List of mentioned entity types (type_id) */
protected array $mentionedEntityTypes = [];

/** @var array List of mentioned attributes (their ids) */
protected array $mentionedAttributes = [];

Expand Down Expand Up @@ -609,6 +606,7 @@ protected function hiddenEntity(int $id): Entity|null
}

if (!Arr::has($this->entities, (string) $id) && !Arr::has($this->privateEntities, (string) $id)) {
// @phpstan-ignore-next-line
$this->privateEntities[$id] = Entity::where(['id' => $id])->withInvisible()->first();
}

Expand Down Expand Up @@ -655,20 +653,10 @@ protected function prepareEntities(): void
preg_replace_callback('`\[([a-z_]+):(.*?)\]`i', function ($matches) {
$segments = explode('|', $matches[2]);
$id = (int) $segments[0];
$entityType = $matches[1];

if (!in_array($id, $this->mentionedEntities)) {
$this->mentionedEntities[] = $id;
}
// If the mentioned entity wasn't there yet, but the map also doesn't map to "entity"
if (!in_array($matches[1], $this->mentionedEntityTypes) && $this->validEntityType($entityType)) {
if ($matches[1] == 'attribute_template') {
$matches[1] = 'attributeTemplate';
} elseif ($matches[1] == 'dice_roll') {
$matches[1] = 'diceRoll';
}
$this->mentionedEntityTypes[] = $matches[1];
}
return $matches[0];
}, $this->text);

Expand Down

0 comments on commit 611abb9

Please sign in to comment.