1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:44:04 +00:00

TelescopeTags add user callback

This commit is contained in:
Samuel Štancl 2019-09-08 11:35:00 +02:00
parent d68d221c4f
commit 29ad8e60f9

View file

@ -11,6 +11,9 @@ use Stancl\Tenancy\Contracts\Feature;
class TelescopeTags implements Feature
{
/** @var callable User-specific callback that returns tags. */
protected $callback;
public function bootstrap(TenantManager $tenantManager): void
{
if (! class_exists(Telescope::class)) {
@ -33,8 +36,12 @@ class TelescopeTags implements Feature
public function getTags(IncomingEntry $entry): array
{
return array_reduce($this->callbacks, function ($tags, $listener) use ($entry) {
return array_merge($tags, $listener($entry));
}, []);
return ($this->callback)($entry);
}
// todo name?
public function tagUsing(callable $callback)
{
$this->callback = $callback;
}
}