本文整理汇总了PHP中DOMElement::getQtiClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::getQtiClassName方法的具体用法?PHP DOMElement::getQtiClassName怎么用?PHP DOMElement::getQtiClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getQtiClassName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMarshaller
/**
* Create a marshaller for a given QtiComponent or DOMElement object, depending on the current mapping
* of the MarshallerFactory. If no mapping entry can be found, the factory will perform a ultimate
* trial in the qtism\\data\\storage\\xml\\marshalling namespace to find the relevant Marshaller object.
*
* The newly created marshaller will be set up with the MarshallerFactory itself as its MarshallerFactory
* object (yes, we know, this is highly recursive but necessary x)).
*
* @param \DOMElement|\qtism\data\QtiComponent $object A QtiComponent or DOMElement object you want to get the corresponding Marshaller object.
* @param array $args An optional array of arguments to be passed to the Marshaller constructor.
* @throws \InvalidArgumentException If $object is not a QtiComponent nor a DOMElement object.
* @throws \RuntimeException If no Marshaller object can be created for the given $object.
* @return \qtism\data\storage\xml\marshalling\Marshaller The corresponding Marshaller object.
*/
public function createMarshaller($object, array $args = array())
{
if ($object instanceof QtiComponent) {
$qtiClassName = $object->getQtiClassName();
} elseif ($object instanceof DOMElement) {
$qtiClassName = $object->localName;
}
if (isset($qtiClassName)) {
try {
// Look for a mapping entry.
if ($this->hasMappingEntry($qtiClassName)) {
$class = new ReflectionClass($this->getMappingEntry($qtiClassName));
} else {
// No qtiClassName/mapping entry found.
$msg = "No mapping entry found for QTI class name '{$qtiClassName}'.";
throw new MarshallerNotFoundException($msg, $qtiClassName);
}
} catch (ReflectionException $e) {
$msg = "No marshaller implementation could be found for component '{$qtiClassName}'.";
throw new MarshallerNotFoundException($msg, $qtiClassName, $e);
}
$marshaller = $this->instantiateMarshaller($class, $args);
$marshaller->setMarshallerFactory($this);
return $marshaller;
} else {
$msg = "The object argument must be a QtiComponent or a DOMElementObject, '" . gettype($object) . "' given.";
throw new InvalidArgumentException($msg);
}
}