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


PHP get_entity_from_uuid函数代码示例

本文整理汇总了PHP中get_entity_from_uuid函数的典型用法代码示例。如果您正苦于以下问题:PHP get_entity_from_uuid函数的具体用法?PHP get_entity_from_uuid怎么用?PHP get_entity_from_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: oddentity_to_elggentity

/**
 * Utility function used by import_entity_plugin_hook() to
 * process an ODDEntity into an unsaved ElggEntity.
 *
 * @param ODDEntity $element The OpenDD element
 *
 * @return ElggEntity the unsaved entity which should be populated by items.
 * @todo Remove this.
 * @access private
 */
function oddentity_to_elggentity(ODDEntity $element)
{
    $class = $element->getAttribute('class');
    $subclass = $element->getAttribute('subclass');
    // See if we already have imported this uuid
    $tmp = get_entity_from_uuid($element->getAttribute('uuid'));
    if (!$tmp) {
        // Construct new class with owner from session
        $classname = get_subtype_class($class, $subclass);
        if ($classname != "") {
            if (class_exists($classname)) {
                $tmp = new $classname();
                if (!$tmp instanceof ElggEntity) {
                    $msg = elgg_echo('ClassException:ClassnameNotClass', array($classname, get_class()));
                    throw new ClassException($msg);
                }
            } else {
                error_log(elgg_echo('ClassNotFoundException:MissingClass', array($classname)));
            }
        } else {
            switch ($class) {
                case 'object':
                    $tmp = new ElggObject($row);
                    break;
                case 'user':
                    $tmp = new ElggUser($row);
                    break;
                case 'group':
                    $tmp = new ElggGroup($row);
                    break;
                case 'site':
                    $tmp = new ElggSite($row);
                    break;
                default:
                    $msg = elgg_echo('InstallationException:TypeNotSupported', array($class));
                    throw new InstallationException($msg);
            }
        }
    }
    if ($tmp) {
        if (!$tmp->import($element)) {
            $msg = elgg_echo('ImportException:ImportFailed', array($element->getAttribute('uuid')));
            throw new ImportException($msg);
        }
        return $tmp;
    }
    return NULL;
}
开发者ID:nachopavon,项目名称:Elgg,代码行数:58,代码来源:entities.php

示例2: import_extender_plugin_hook

/**
 *  Handler called by trigger_plugin_hook on the "import" event.
 *
 * @param string $hook        volatile
 * @param string $entity_type metadata
 * @param string $returnvalue Return value from previous hook
 * @param array  $params      The parameters
 *
 * @return null
 * @elgg_plugin_hook_handler volatile metadata
 * @todo investigate more.
 * @throws ImportException
 * @access private
 * @deprecated 1.9
 */
function import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params)
{
    $element = $params['element'];
    $tmp = NULL;
    if ($element instanceof ODDMetaData) {
        /* @var ODDMetaData $element */
        // Recall entity
        $entity_uuid = $element->getAttribute('entity_uuid');
        $entity = get_entity_from_uuid($entity_uuid);
        if (!$entity) {
            throw new \ImportException("Entity '" . $entity_uuid . "' could not be found.");
        }
        oddmetadata_to_elggextender($entity, $element);
        // Save
        if (!$entity->save()) {
            $attr_name = $element->getAttribute('name');
            $msg = "There was a problem updating '" . $attr_name . "' on entity '" . $entity_uuid . "'";
            throw new \ImportException($msg);
        }
        return true;
    }
}
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:37,代码来源:deprecated-1.9.php

示例3: import

 /**
  * Import a relationship
  *
  * @param ODD $data ODD data
  * @return bool
  * @throws ImportException
  */
 public function import(ODD $data)
 {
     if (!$data instanceof ODDRelationship) {
         throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass'));
     }
     $uuid_one = $data->getAttribute('uuid1');
     $uuid_two = $data->getAttribute('uuid2');
     // See if this entity has already been imported, if so then we need to link to it
     $entity1 = get_entity_from_uuid($uuid_one);
     $entity2 = get_entity_from_uuid($uuid_two);
     if ($entity1 && $entity2) {
         // Set the item ID
         $this->attributes['guid_one'] = $entity1->getGUID();
         $this->attributes['guid_two'] = $entity2->getGUID();
         // Map verb to relationship
         //$verb = $data->getAttribute('verb');
         //$relationship = get_relationship_from_verb($verb);
         $relationship = $data->getAttribute('type');
         if ($relationship) {
             $this->attributes['relationship'] = $relationship;
             // save
             $result = $this->save();
             if (!$result) {
                 throw new ImportException(elgg_echo('ImportException:ProblemSaving', array(get_class())));
             }
             return true;
         }
     }
 }
开发者ID:redvabel,项目名称:Vabelgg,代码行数:36,代码来源:ElggRelationship.php

示例4: import_extender_plugin_hook

/**
 *  Handler called by trigger_plugin_hook on the "import" event.
 *
 * @param string $hook        volatile
 * @param string $entity_type metadata
 * @param string $returnvalue Return value from previous hook
 * @param array  $params      The parameters
 *
 * @return null
 * @elgg_plugin_hook_handler volatile metadata
 * @todo investigate more.
 * @throws ImportException
 * @access private
 */
function import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params)
{
    $element = $params['element'];
    $tmp = NULL;
    if ($element instanceof ODDMetaData) {
        /* @var ODDMetaData $element */
        // Recall entity
        $entity_uuid = $element->getAttribute('entity_uuid');
        $entity = get_entity_from_uuid($entity_uuid);
        if (!$entity) {
            throw new ImportException(elgg_echo('ImportException:GUIDNotFound', array($entity_uuid)));
        }
        oddmetadata_to_elggextender($entity, $element);
        // Save
        if (!$entity->save()) {
            $attr_name = $element->getAttribute('name');
            $msg = elgg_echo('ImportException:ProblemUpdatingMeta', array($attr_name, $entity_uuid));
            throw new ImportException($msg);
        }
        return true;
    }
}
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:36,代码来源:extender.php

示例5: import

 /**
  * Import a relationship
  *
  * @param ODD $data ODD data
  * @return bool
  * @throws ImportException|InvalidParameterException
  * @deprecated 1.9
  */
 public function import(ODD $data)
 {
     elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9);
     if (!$data instanceof ODDRelationship) {
         throw new \InvalidParameterException("import() passed an unexpected ODD class");
     }
     $uuid_one = $data->getAttribute('uuid1');
     $uuid_two = $data->getAttribute('uuid2');
     // See if this entity has already been imported, if so then we need to link to it
     $entity1 = get_entity_from_uuid($uuid_one);
     $entity2 = get_entity_from_uuid($uuid_two);
     if ($entity1 && $entity2) {
         // Set the item ID
         $this->attributes['guid_one'] = $entity1->getGUID();
         $this->attributes['guid_two'] = $entity2->getGUID();
         // Map verb to relationship
         //$verb = $data->getAttribute('verb');
         //$relationship = get_relationship_from_verb($verb);
         $relationship = $data->getAttribute('type');
         if ($relationship) {
             $this->attributes['relationship'] = $relationship;
             // save
             $result = $this->save();
             if (!$result) {
                 throw new \ImportException("There was a problem saving " . get_class());
             }
             return true;
         }
     }
     return false;
 }
开发者ID:ibou77,项目名称:elgg,代码行数:39,代码来源:ElggRelationship.php


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