コード例 #1
0
ファイル: deprecated-1.9.php プロジェクト: gzachos/elgg_ellak
/**
 *  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;
    }
}
コード例 #2
0
ファイル: extender.php プロジェクト: elainenaomi/labxp2014
/**
 *  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;
    }
}