本文整理匯總了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;
}