Source of file Meta.php
Size: 1,171 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/Layout/Helper/Meta.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\View\Helper; use Bluz\Proxy\Registry; /** * Set or generate <meta> code for <head> * * @param string|array|null $name * @param string|null $content * * @return string|null */ return function ($name = null, $content = null) { // it's stack for <head> $meta = Registry::get('layout:meta') ?: []; if (is_null($name) && is_null($content)) { // clear system vars Registry::set('layout:meta', []); // prepare to output $tags = []; foreach ($meta as $aName => $aContent) { $tags[] = '<meta name="' . $aName . '" ' . 'content="' . htmlspecialchars((string)$aContent, ENT_QUOTES) . '"/>'; } return implode("\n", $tags); } elseif (is_null($name)) { // if exists only $content, do nothing return null; } $meta[$name] = $content; Registry::set('layout:meta', $meta); return null; }; |