當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DOMElement::getQtiClassName方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:nagyist,項目名稱:qti-sdk,代碼行數:43,代碼來源:MarshallerFactory.php


注:本文中的DOMElement::getQtiClassName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。