[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <[email protected]> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\WebLink; 13 14 use Psr\Link\LinkInterface; 15 16 /** 17 * Serializes a list of Link instances to an HTTP Link header. 18 * 19 * @see https://tools.ietf.org/html/rfc5988 20 * 21 * @author Kévin Dunglas <[email protected]> 22 */ 23 final class HttpHeaderSerializer 24 { 25 /** 26 * Builds the value of the "Link" HTTP header. 27 * 28 * @param LinkInterface[]|\Traversable $links 29 */ 30 public function serialize(iterable $links): ?string 31 { 32 $elements = []; 33 foreach ($links as $link) { 34 if ($link->isTemplated()) { 35 continue; 36 } 37 38 $attributesParts = ['', sprintf('rel="%s"', implode(' ', $link->getRels()))]; 39 foreach ($link->getAttributes() as $key => $value) { 40 if (\is_array($value)) { 41 foreach ($value as $v) { 42 $attributesParts[] = sprintf('%s="%s"', $key, preg_replace('/(?<!\\\\)"/', '\"', $v)); 43 } 44 45 continue; 46 } 47 48 if (!\is_bool($value)) { 49 $attributesParts[] = sprintf('%s="%s"', $key, preg_replace('/(?<!\\\\)"/', '\"', $value)); 50 51 continue; 52 } 53 54 if (true === $value) { 55 $attributesParts[] = $key; 56 } 57 } 58 59 $elements[] = sprintf('<%s>%s', $link->getHref(), implode('; ', $attributesParts)); 60 } 61 62 return $elements ? implode(',', $elements) : null; 63 } 64 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |