* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\WebLink; use Psr\Link\LinkInterface; /** * Serializes a list of Link instances to a HTTP Link header. * * @see https://tools.ietf.org/html/rfc5988 * * @author Kévin Dunglas */ final class HttpHeaderSerializer { /** * Builds the value of the "Link" HTTP header. * * @param LinkInterface[]|\Traversable $links * * @return string|null */ public function serialize($links) { $elements = array(); foreach ($links as $link) { if ($link->isTemplated()) { continue; } $attributesParts = array('', sprintf('rel="%s"', implode(' ', $link->getRels()))); foreach ($link->getAttributes() as $key => $value) { if (is_array($value)) { foreach ($value as $v) { $attributesParts[] = sprintf('%s="%s"', $key, $v); } continue; } if (!is_bool($value)) { $attributesParts[] = sprintf('%s="%s"', $key, $value); continue; } if (true === $value) { $attributesParts[] = $key; } } $elements[] = sprintf('<%s>%s', $link->getHref(), implode('; ', $attributesParts)); } return $elements ? implode(',', $elements) : null; } } __halt_compiler();----SIGNATURE:----rWHv0Smt6JmWhXlQlDPuFb1wVIVd4KXglkkMK3v5+pLoiOzPHlAVrR6BG9nsp8gxO1rpOp/WcpLml2I24rRF0vRGBzrUT12XHhhf8K1JEy/MsNjIz/UUbEF/l82NZcsocim5bP/i3woQO3uLMuwSO84SI6pKTPnpsY4SGOeBx7p0wLHoSIGmsGMtzv3aqyNvu0rLQtOk8684migWjkkvXH1iNczLHrWSW8HV57ukXkE+5/HxdMKtIaDj69mWgZBXQC9BQPEb2REWfoPQq2npzIzdK/IdqXpn4BFFW14QfrXNsYUrSr1iM5CGgNl4jzScCedUUGJs868QdyrFAV4d8QW3T/firVHquSHE0khh1M2R14fSzQ09XUZJJFEWGoVSVOC7XvbLagfHeJoiS9oeePczz0JpMtk2xPh3Ee4RUPqVbX0OPct6AxSLT6ZcK30Y6XvccbYxI6Ab7MmdgkkepzBNmqu9wSzHL01sy8RNjGfmgTsLtzmZrKwBZ1SEmWXY00l8XiNUuLPtrSPsuQ5K0HnnDU64XLLGmLOl0Bdd9i6t6IxbDH4hJ6xyCMBEzw5yd01ijjX9+pAwDd6aJx1UE3HPI7oTKQsWITFXYCsnpM4BwmvVG+yzUMl1y+vgmnSCTPqTvvM8Y8hC9XdoI2t2v4bto8GLKxWt7SNTBD/8/u8=----ATTACHMENT:----MzAzOTY1OTQxMDI3MTcwNyA0OTM4MTk3MjU1ODQ5MDEgMTUzODczMjgwOTU3MTE3