The default language returned is always 'en'.
public getLocalizedString ( string $name, mixed $default = self::REQUIRED_OPTION ) : array | ||
$name | string | The name of the option. |
$default | mixed | The default value. If no default is given, and the option isn't found, an exception will be thrown. |
Résultat | array | Associative array with language => string pairs. |
/** * Add an AttributeConsumingService element to the metadata. * * @param \SAML2\XML\md\SPSSODescriptor $spDesc The SPSSODescriptor element. * @param SimpleSAML_Configuration $metadata The metadata. */ private function addAttributeConsumingService(\SAML2\XML\md\SPSSODescriptor $spDesc, SimpleSAML_Configuration $metadata) { $attributes = $metadata->getArray('attributes', array()); $name = $metadata->getLocalizedString('name', null); if ($name === null || count($attributes) == 0) { // we cannot add an AttributeConsumingService without name and attributes return; } $attributesrequired = $metadata->getArray('attributes.required', array()); /* * Add an AttributeConsumingService element with information as name and description and list * of requested attributes */ $attributeconsumer = new \SAML2\XML\md\AttributeConsumingService(); $attributeconsumer->index = 0; $attributeconsumer->ServiceName = $name; $attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', array()); $nameFormat = $metadata->getString('attributes.NameFormat', \SAML2\Constants::NAMEFORMAT_UNSPECIFIED); foreach ($attributes as $friendlyName => $attribute) { $t = new \SAML2\XML\md\RequestedAttribute(); $t->Name = $attribute; if (!is_int($friendlyName)) { $t->FriendlyName = $friendlyName; } if ($nameFormat !== \SAML2\Constants::NAMEFORMAT_UNSPECIFIED) { $t->NameFormat = $nameFormat; } if (in_array($attribute, $attributesrequired)) { $t->isRequired = true; } $attributeconsumer->RequestedAttribute[] = $t; } $spDesc->AttributeConsumingService[] = $attributeconsumer; }
/** * Add an AttributeConsumingService element to the metadata. * * @param DOMElement $spDesc The SPSSODescriptor element. * @param SimpleSAML_Configuration $metadata The metadata. */ private function addAttributeConsumingService(SAML2_XML_md_SPSSODescriptor $spDesc, SimpleSAML_Configuration $metadata) { $attributes = $metadata->getArray('attributes', array()); $name = $metadata->getLocalizedString('name', NULL); if ($name === NULL || count($attributes) == 0) { /* We cannot add an AttributeConsumingService without name and attributes. */ return; } /* * Add an AttributeConsumingService element with information as name and description and list * of requested attributes */ $attributeconsumer = new SAML2_XML_md_AttributeConsumingService(); $attributeconsumer->index = 0; $attributeconsumer->ServiceName = $name; $attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', array()); $nameFormat = $metadata->getString('attributes.NameFormat', SAML2_Const::NAMEFORMAT_UNSPECIFIED); foreach ($attributes as $attribute) { $t = new SAML2_XML_md_RequestedAttribute(); $t->Name = $attribute; if ($nameFormat !== SAML2_Const::NAMEFORMAT_UNSPECIFIED) { $t->NameFormat = $nameFormat; } $attributeconsumer->RequestedAttribute[] = $t; } $spDesc->AttributeConsumingService[] = $attributeconsumer; }