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


PHP xPDO::fromJSON方法代码示例

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


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

示例1: fromJSON

 /**
  * Sets the object fields from a JSON object string.
  *
  * @param string $jsonSource A JSON object string.
  * @param string $keyPrefix An optional prefix to strip from the keys.
  * @param boolean $setPrimaryKeys Indicates if primary key fields should be set.
  * @param boolean $rawValues Indicates if values should be set raw or via
  * {@link xPDOObject::set()}.
  * @param boolean $adhocValues Indicates if ad hoc fields should be added to the
  * xPDOObject from the source object.
  */
 public function fromJSON($jsonSource, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
     $array= $this->xpdo->fromJSON($jsonSource, true);
     if ($array) {
         $this->fromArray($array, $keyPrefix, $setPrimaryKeys, $rawValues, $adhocValues);
     } else {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'xPDOObject::fromJSON() -- Could not convert jsonSource to a PHP array.');
     }
 }
开发者ID:ncrossland,项目名称:revolution,代码行数:19,代码来源:xpdoobject.class.php

示例2: findPolicy

 /**
  * Find all policies for this object
  * 
  * @param string $context
  * @return array
  */
 public function findPolicy($context = '')
 {
     $policy = array();
     $enabled = true;
     $context = 'mgr';
     if ($context === $this->xpdo->context->get('key')) {
         $enabled = (bool) $this->xpdo->getOption('access_media_source_enabled', null, true);
     } elseif ($this->xpdo->getContext($context)) {
         $enabled = (bool) $this->xpdo->contexts[$context]->getOption('access_media_source_enabled', true);
     }
     if ($enabled) {
         if (empty($this->_policies) || !isset($this->_policies[$context])) {
             $accessTable = $this->xpdo->getTableName('sources.modAccessMediaSource');
             $sourceTable = $this->xpdo->getTableName('sources.modMediaSource');
             $policyTable = $this->xpdo->getTableName('modAccessPolicy');
             $sql = "SELECT Acl.target, Acl.principal, Acl.authority, Acl.policy, Policy.data FROM {$accessTable} Acl " . "LEFT JOIN {$policyTable} Policy ON Policy.id = Acl.policy " . "JOIN {$sourceTable} Source ON Acl.principal_class = 'modUserGroup' " . "AND (Acl.context_key = :context OR Acl.context_key IS NULL OR Acl.context_key = '') " . "AND Source.id = Acl.target " . "WHERE Acl.target = :source " . "GROUP BY Acl.target, Acl.principal, Acl.authority, Acl.policy";
             $bindings = array(':source' => $this->get('id'), ':context' => $context);
             $query = new xPDOCriteria($this->xpdo, $sql, $bindings);
             if ($query->stmt && $query->stmt->execute()) {
                 while ($row = $query->stmt->fetch(PDO::FETCH_ASSOC)) {
                     $policy['sources.modAccessMediaSource'][$row['target']][] = array('principal' => $row['principal'], 'authority' => $row['authority'], 'policy' => $row['data'] ? $this->xpdo->fromJSON($row['data'], true) : array());
                 }
             }
             $this->_policies[$context] = $policy;
         } else {
             $policy = $this->_policies[$context];
         }
     }
     return $policy;
 }
开发者ID:WhisperingTree,项目名称:blog,代码行数:36,代码来源:modmediasource.class.php

示例3: validate

 /**
  * Validate any dependencies for the object represented in this vehicle.
  *
  * @param xPDOTransport &$transport A reference to the xPDOTransport in
  * which this vehicle is stored.
  * @param xPDOObject &$object An object reference to access during
  * validation.
  * @param array $options Additional options for the validation process.
  * @return boolean Indicating if the validation was successful.
  */
 public function validate(&$transport, &$object, $options = array())
 {
     $validated = true;
     if (isset($this->payload['validate'])) {
         while (list($rKey, $r) = each($this->payload['validate'])) {
             $type = $r['type'];
             $body = $r['body'];
             switch ($type) {
                 case 'php':
                     if (isset($options[xPDOTransport::VALIDATE_PHP]) && !$options[xPDOTransport::VALIDATE_PHP]) {
                         continue;
                     }
                     $fileMeta = xPDO::fromJSON($body, true);
                     $fileName = $fileMeta['name'];
                     $fileSource = $transport->path . $fileMeta['source'];
                     if (!($validated = (include $fileSource))) {
                         $transport->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error executing xPDOVehicle validator: type php ({$fileSource})");
                     }
                     break;
                 default:
                     $transport->xpdo->log(xPDO::LOG_LEVEL_WARN, "xPDOVehicle does not support validators of type {$type}.");
                     break;
             }
         }
     } else {
         $validated = true;
     }
     return $validated;
 }
开发者ID:Kleist,项目名称:xPDO,代码行数:39,代码来源:xpdovehicle.class.php


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