]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/MessageParts/EntityPathMessageLine.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Activity / Notifications / MessageParts / EntityPathMessageLine.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\MessageParts;
4
5 use BookStack\Entities\Models\Entity;
6 use Illuminate\Contracts\Support\Htmlable;
7 use Stringable;
8
9 /**
10  * A link to a specific entity in the system, with the text showing its name.
11  */
12 class EntityPathMessageLine implements Htmlable, Stringable
13 {
14     /**
15      * @var EntityLinkMessageLine[]
16      */
17     protected array $entityLinks;
18
19     public function __construct(
20         protected array $entities
21     ) {
22         $this->entityLinks = array_map(fn (Entity $entity) => new EntityLinkMessageLine($entity, 24), $this->entities);
23     }
24
25     public function toHtml(): string
26     {
27         $entityHtmls = array_map(fn (EntityLinkMessageLine $line) => $line->toHtml(), $this->entityLinks);
28         return implode(' &gt; ', $entityHtmls);
29     }
30
31     public function __toString(): string
32     {
33         return implode(' > ', $this->entityLinks);
34     }
35 }