/** * Create component container from description. * * @param \SimpleXMLElement $containerDescription Container description. * @param array $externalParams Additional attributes. * @return ComponentContainer * * @throws SystemException ERR_NO_CONTAINER_NAME */ public static function createFromDescription(\SimpleXMLElement $containerDescription, array $externalParams = []) { $properties['tag'] = $containerDescription->getName(); $attributes = $containerDescription->attributes(); if (in_array($containerDescription->getName(), ['page', 'content'])) { $properties['name'] = $properties['tag']; } elseif (!isset($attributes['name'])) { $properties['name'] = uniqid('name_'); } foreach ($attributes as $propertyName => $propertyValue) { $properties[(string) $propertyName] = (string) $propertyValue; } $name = $properties['name']; unset($properties['name']); $properties = array_merge($properties, $externalParams); $value = null; $containerDescriptionValue = trim((string) $containerDescription); if (!empty($containerDescriptionValue)) { $value = $containerDescriptionValue; } $result = new ComponentContainer($name, $properties, $value); foreach ($containerDescription as $blockDescription) { if ($c = ComponentManager::createBlockFromDescription($blockDescription, $externalParams)) { $result->add($c); } } return $result; }