[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace Negotiation; 4 5 class LanguageNegotiator extends AbstractNegotiator 6 { 7 /** 8 * {@inheritdoc} 9 */ 10 protected function acceptFactory($accept) 11 { 12 return new AcceptLanguage($accept); 13 } 14 15 /** 16 * {@inheritdoc} 17 */ 18 protected function match(AcceptHeader $acceptLanguage, AcceptHeader $priority, $index) 19 { 20 if (!$acceptLanguage instanceof AcceptLanguage || !$priority instanceof AcceptLanguage) { 21 return null; 22 } 23 24 $ab = $acceptLanguage->getBasePart(); 25 $pb = $priority->getBasePart(); 26 27 $as = $acceptLanguage->getSubPart(); 28 $ps = $priority->getSubPart(); 29 30 $baseEqual = !strcasecmp((string)$ab, (string)$pb); 31 $subEqual = !strcasecmp((string)$as, (string)$ps); 32 33 if (($ab == '*' || $baseEqual) && ($as === null || $subEqual || null === $ps)) { 34 $score = 10 * $baseEqual + $subEqual; 35 36 return new AcceptMatch($acceptLanguage->getQuality() * $priority->getQuality(), $score, $index); 37 } 38 39 return null; 40 } 41 }
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 |