当前位置: 首页>>代码示例>>PHP>>正文


PHP xPDO::call方法代码示例

本文整理汇总了PHP中xPDO::call方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::call方法的具体用法?PHP xPDO::call怎么用?PHP xPDO::call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xPDO的用法示例。


在下文中一共展示了xPDO::call方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getGraph

 /**
  * Load a graph of related objects to the current object.
  *
  * @param boolean|string|array|integer $graph An option to tell how to deal with related objects. If integer, will
  * traverse related objects up to a $graph level of depth and load them to the object.
  * If an array, will traverse required related object and load them to the object.
  * If true, will traverse the entire graph and append all related objects to the object (default behavior).
  * @param xPDOCriteria|array|string|integer $criteria A valid xPDO criteria representation.
  * @param boolean|integer $cacheFlag Indicates if the objects should be cached and optionally, by specifying an
  * integer value, for how many seconds.
  * @return array|boolean The graph that was loaded or false if nothing was loaded.
  */
 public function getGraph($graph = true, $criteria = null, $cacheFlag = true)
 {
     /* graph is true, get all relations to max depth */
     if ($graph === true) {
         $graph = $this->xpdo->getGraph($this->_class);
     }
     /* graph is an int, get relations to depth of graph */
     if (is_int($graph)) {
         $graph = $this->xpdo->getGraph($this->_class, $graph);
     }
     /* graph defined as JSON, convert to array */
     if (is_string($graph)) {
         $graph = $this->xpdo->fromJSON($graph);
     }
     /* graph as an array */
     if (is_array($graph)) {
         foreach ($graph as $alias => $branch) {
             $fkMeta = $this->getFKDefinition($alias);
             if ($fkMeta) {
                 $fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : null;
                 if ($criteria === null) {
                     $query = array($fkMeta['foreign'] => $this->get($fkMeta['local']));
                     if ($fkCriteria !== null) {
                         $query = array($fkCriteria, $query);
                     }
                 } else {
                     $query = $this->xpdo->newQuery($fkMeta['class'], $criteria);
                     $addCriteria = array("{$query->getAlias()}.{$fkMeta['foreign']}" => $this->get($fkMeta['local']));
                     if ($fkCriteria !== null) {
                         $fkAddCriteria = array();
                         foreach ($fkCriteria as $fkCritKey => $fkCritVal) {
                             if (is_numeric($fkCritKey)) {
                                 continue;
                             }
                             $fkAddCriteria["{$criteria->getAlias()}.{$fkCritKey}"] = $fkCritVal;
                         }
                         if (!empty($fkAddCriteria)) {
                             $addCriteria = array($fkAddCriteria, $addCriteria);
                         }
                     }
                     $query->andCondition($addCriteria);
                 }
                 $collection = $this->xpdo->call($fkMeta['class'], 'loadCollectionGraph', array(&$this->xpdo, $fkMeta['class'], $branch, $query, $cacheFlag));
                 if (!empty($collection)) {
                     if ($fkMeta['cardinality'] == 'many') {
                         $this->_relatedObjects[$alias] = $collection;
                     } else {
                         $this->_relatedObjects[$alias] = reset($collection);
                     }
                 }
             }
         }
     } else {
         $graph = false;
     }
     return $graph;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:69,代码来源:xpdoobject.class.php

示例2: loadAttributes

 /**
  * Loads the principal attributes that define a modUser security profile.
  *
  * {@inheritdoc}
  */
 public function loadAttributes($target, $context = '', $reload = false)
 {
     $context = !empty($context) ? $context : $this->xpdo->context->get('key');
     $id = $this->get('id') ? (string) $this->get('id') : '0';
     if ($this->get('id') && !$reload) {
         $staleContexts = $this->get('session_stale');
         $staleContexts = !empty($staleContexts) ? $staleContexts : array();
         $stale = array_search($context, $staleContexts);
         if ($stale !== false) {
             $reload = true;
             $staleContexts = array_diff($staleContexts, array($context));
             $this->set('session_stale', $staleContexts);
             $this->save();
         }
     }
     if ($this->_attributes === null || $reload) {
         $this->_attributes = array();
         if (isset($_SESSION["modx.user.{$id}.attributes"])) {
             if ($reload) {
                 unset($_SESSION["modx.user.{$id}.attributes"]);
             } else {
                 $this->_attributes = $_SESSION["modx.user.{$id}.attributes"];
             }
         }
     }
     if (!isset($this->_attributes[$context])) {
         $this->_attributes[$context] = array();
     }
     $target = (array) $target;
     foreach ($target as $t) {
         if (!isset($this->_attributes[$context][$t])) {
             $this->_attributes[$context][$t] = $this->xpdo->call($t, 'loadAttributes', array(&$this->xpdo, $context, $this->get('id')));
             if (!isset($this->_attributes[$context][$t]) || !is_array($this->_attributes[$context][$t])) {
                 $this->_attributes[$context][$t] = array();
             }
         }
     }
     $_SESSION["modx.user.{$id}.attributes"] = $this->_attributes;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:44,代码来源:moduser.class.php


注:本文中的xPDO::call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。