本文整理汇总了PHP中Transfer::_loadFromXml方法的典型用法代码示例。如果您正苦于以下问题:PHP Transfer::_loadFromXml方法的具体用法?PHP Transfer::_loadFromXml怎么用?PHP Transfer::_loadFromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transfer
的用法示例。
在下文中一共展示了Transfer::_loadFromXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _factoryFromXml
protected static function _factoryFromXml(\DOMDocument $xmlDoc)
{
$elems = $xmlDoc->getElementsByTagName('order');
if ($elems->length != 1) {
throw new \Exception('factoryFromXml order element not found', RequestAbstract::ERROR_FACTORY_BY_XML_ORDER_ELEM_NOT_FOUND);
}
$orderElem = $elems->item(0);
$attr = $orderElem->attributes->getNamedItem('type');
if ($attr == null || strlen($attr->nodeValue) == 0) {
throw new \Exception('factoryFromXml invalid payment request type=' . $attr->nodeValue, RequestAbstract::ERROR_FACTORY_BY_XML_ORDER_TYPE_ATTR_NOT_FOUND);
}
switch ($attr->nodeValue) {
case RequestAbstract::PAYMENT_TYPE_CARD:
$objPmReq = new Card();
break;
case RequestAbstract::PAYMENT_TYPE_SMS:
$objPmReq = new Sms();
break;
case RequestAbstract::PAYMENT_TYPE_ADMIN:
$objPmReq = new Admin();
break;
case RequestAbstract::PAYMENT_TYPE_INFO:
$objPmReq = new Info();
break;
case RequestAbstract::PAYMENT_TYPE_CASH:
$objPmReq = new Cash();
break;
case RequestAbstract::PAYMENT_TYPE_TRANSFER:
$objPmReq = new Transfer();
break;
default:
throw new \Exception('factoryFromXml invalid payment request type=' . $attr->nodeValue, RequestAbstract::ERROR_FACTORY_BY_XML_INVALID_TYPE);
break;
}
$objPmReq->_loadFromXml($orderElem);
return $objPmReq;
}