当前位置: 首页>>代码示例>>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;未经允许,请勿转载。