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


PHP modX::getObjectGraph方法代碼示例

本文整理匯總了PHP中modX::getObjectGraph方法的典型用法代碼示例。如果您正苦於以下問題:PHP modX::getObjectGraph方法的具體用法?PHP modX::getObjectGraph怎麽用?PHP modX::getObjectGraph使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在modX的用法示例。


在下文中一共展示了modX::getObjectGraph方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getElement

 /**
  * Get a modElement instance taking advantage of the modX::$sourceCache.
  *
  * @param string $class The modElement derivative class to load.
  * @param string $name An element name or raw tagName to identify the modElement instance.
  * @return modElement|null An instance of the specified modElement derivative class.
  */
 public function getElement($class, $name)
 {
     $realname = $this->realname($name);
     if (array_key_exists($class, $this->modx->sourceCache) && array_key_exists($realname, $this->modx->sourceCache[$class])) {
         /** @var modElement $element */
         $element = $this->modx->newObject($class);
         $element->fromArray($this->modx->sourceCache[$class][$realname]['fields'], '', true, true);
         $element->setPolicies($this->modx->sourceCache[$class][$realname]['policies']);
         if (!empty($this->modx->sourceCache[$class][$realname]['source'])) {
             if (!empty($this->modx->sourceCache[$class][$realname]['source']['class_key'])) {
                 $sourceClassKey = $this->modx->sourceCache[$class][$realname]['source']['class_key'];
                 $this->modx->loadClass('sources.modMediaSource');
                 /* @var modMediaSource $source */
                 $source = $this->modx->newObject($sourceClassKey);
                 $source->fromArray($this->modx->sourceCache[$class][$realname]['source'], '', true, true);
                 $element->addOne($source, 'Source');
             }
         }
     } else {
         /** @var modElement $element */
         $element = $this->modx->getObjectGraph($class, array('Source' => array()), array('name' => $realname), true);
         if ($element && array_key_exists($class, $this->modx->sourceCache)) {
             $this->modx->sourceCache[$class][$realname] = array('fields' => $element->toArray(), 'policies' => $element->getPolicies(), 'source' => $element->Source ? $element->Source->toArray() : array());
         }
     }
     if ($element instanceof modElement) {
         $element->set('name', $name);
     }
     return $element;
 }
開發者ID:semencov-com,項目名稱:affiliate,代碼行數:37,代碼來源:modparser.class.php

示例2: getElement

 /**
  * Get a modElement instance taking advantage of the modX::$sourceCache.
  *
  * @param string $class The modElement derivative class to load.
  * @param string $name An element name or raw tagName to identify the modElement instance.
  * @return modElement|null An instance of the specified modElement derivative class.
  */
 public function getElement($class, $name)
 {
     $realname = $this->realname($name);
     if (array_key_exists($class, $this->modx->sourceCache) && array_key_exists($realname, $this->modx->sourceCache[$class])) {
         /** @var modElement $element */
         $element = $this->modx->newObject($class);
         $element->fromArray($this->modx->sourceCache[$class][$realname]['fields'], '', true, true);
         $element->setPolicies($this->modx->sourceCache[$class][$realname]['policies']);
         if (!empty($this->modx->sourceCache[$class][$realname]['source'])) {
             if (!empty($this->modx->sourceCache[$class][$realname]['source']['class_key'])) {
                 $sourceClassKey = $this->modx->sourceCache[$class][$realname]['source']['class_key'];
                 $this->modx->loadClass('sources.modMediaSource');
                 /* @var modMediaSource $source */
                 $source = $this->modx->newObject($sourceClassKey);
                 $source->fromArray($this->modx->sourceCache[$class][$realname]['source'], '', true, true);
                 $element->addOne($source, 'Source');
             }
         }
     } else {
         /** @var modElement $element */
         $element = $this->modx->getObjectGraph($class, array('Source' => array()), array('name' => $realname), true);
         if ($element && array_key_exists($class, $this->modx->sourceCache)) {
             $this->modx->sourceCache[$class][$realname] = array('fields' => $element->toArray(), 'policies' => $element->getPolicies(), 'source' => $element->Source ? $element->Source->toArray() : array());
         } elseif (!$element) {
             $evtOutput = $this->modx->invokeEvent('OnElementNotFound', array('class' => $class, 'name' => $realname));
             $element = false;
             if ($evtOutput != false) {
                 foreach ((array) $evtOutput as $elm) {
                     if (!empty($elm) && is_string($elm)) {
                         $element = $this->modx->newObject($class, array('name' => $realname, 'snippet' => $elm));
                     } elseif ($elm instanceof modElement) {
                         $element = $elm;
                     }
                     if ($element) {
                         break;
                     }
                 }
             }
         }
     }
     if ($element instanceof modElement) {
         $element->set('name', $name);
     }
     return $element;
 }
開發者ID:OptimusCrime,項目名稱:revolution,代碼行數:52,代碼來源:modparser.class.php


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