/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/View/Compilers/Concerns/CompilesContexts.php
37 строк
1013 B
Martin Bean
Add @context Blade directive (#56146)
07 июл 2025, 17:41
Не верифицирован
07 июл 2025, 17:41
a944904
Код
Авторство
О чём код?
<?php namespace Illuminate\View\Compilers\Concerns; trait CompilesContexts { /** * Compile the context statements into valid PHP. * * @param string $expression * @return string */ protected function compileContext($expression) { $expression = $this->stripParentheses($expression); return '<?php $__contextArgs = ['.$expression.']; if (context()->has($__contextArgs[0])) : if (isset($value)) { $__contextPrevious[] = $value; } $value = context()->get($__contextArgs[0]); ?>'; } /** * Compile the endcontext statements into valid PHP. * * @param string $expression * @return string */ protected function compileEndcontext($expression) { return '<?php unset($value); if (isset($__contextPrevious) && !empty($__contextPrevious)) { $value = array_pop($__contextPrevious); } if (isset($__contextPrevious) && empty($__contextPrevious)) { unset($__contextPrevious); } endif; unset($__contextArgs); ?>'; } }