本文整理匯總了PHP中Control::loadFromXml方法的典型用法代碼示例。如果您正苦於以下問題:PHP Control::loadFromXml方法的具體用法?PHP Control::loadFromXml怎麽用?PHP Control::loadFromXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Control
的用法示例。
在下文中一共展示了Control::loadFromXml方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadFromXml
/**
* @copydoc Control::loadFromXml
*/
public function loadFromXml(\SimpleXMLElement $description)
{
parent::loadFromXml($description);
if ($description->options) {
foreach ($description->options->option as $item) {
$this->addItem((string) $item['id'], (string) $item);
}
}
}
示例2: loadFromXml
/**
* @copydoc Control::loadFromXml
*
* @throws SystemException 'ERR_DEV_NO_CONTROL_TYPE'
* @throws SystemException 'ERR_DEV_NO_CONTROL_CLASS'
*/
public function loadFromXml(\SimpleXMLElement $description)
{
parent::loadFromXml($description);
foreach ($description->control as $controlDescription) {
if (!isset($controlDescription['type'])) {
throw new SystemException('ERR_DEV_NO_CONTROL_TYPE', SystemException::ERR_DEVELOPER);
}
$controlClassName = ucfirst((string) $controlDescription['type']);
if (!class_exists($controlClassName, false)) {
throw new SystemException('ERR_DEV_NO_CONTROL_CLASS', SystemException::ERR_DEVELOPER, $controlClassName);
}
$control = new $controlClassName(isset($controlDescription['id']) ? (string) $controlDescription['id'] : null);
$this->attachControl($control);
$control->loadFromXml($controlDescription);
}
}