本文整理汇总了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);
}
}