/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Container/Attributes/Context.php
36 строк
1 KB
AJ
[12.x] Allowing `Context` Attribute to Interact with Hidden (#55799)
21 май 2025, 16:18
Не верифицирован
21 май 2025, 16:18
b47abb5
Код
Авторство
О чём код?
<?php namespace Illuminate\Container\Attributes; use Attribute; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\ContextualAttribute; use Illuminate\Log\Context\Repository; #[Attribute(Attribute::TARGET_PARAMETER)] class Context implements ContextualAttribute { /** * Create a new attribute instance. */ public function __construct(public string $key, public mixed $default = null, public bool $hidden = false) { } /** * Resolve the context value. * * @param self $attribute * @param \Illuminate\Contracts\Container\Container $container * @return mixed */ public static function resolve(self $attribute, Container $container): mixed { $repository = $container->make(Repository::class); return match ($attribute->hidden) { true => $repository->getHidden($attribute->key, $attribute->default), false => $repository->get($attribute->key, $attribute->default), }; } }