Source of file HeadScript.php
Size: 1,024 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/Layout/Helper/HeadScript.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\Layout\Helper; use Bluz\Layout\Layout; use Bluz\Proxy\Registry; /** * Set or generate <script> code for <head> * * @param string $src * @param array $attributes * * @return null|string */ return function ($src = null, array $attributes = []) { /** * @var Layout $this */ // it's stack for <head> $headScripts = Registry::get('layout:headScripts') ?: []; if (is_null($src)) { // clear system vars Registry::set('layout:headScripts', []); $tags = []; foreach ($headScripts as $aSrc => $aData) { $tags[] = $this->script($aSrc, $aData); } return implode("\n", $tags); } $headScripts[$src] = $attributes; Registry::set('layout:headScripts', $headScripts); return null; }; |