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


PHP eZContentObject::fetchByRemoteId方法代码示例

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


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

示例1: fetchPublisher

/**
 * Fetches publisher using his id (if number given) or remote id (if string given).
 * @param string|integer $publisher
 * @throws Exception
 * @return eZContentObject
 */
function fetchPublisher( $publisher )
{
	$publisherObject = null;

	if ( is_numeric( $publisher ) )
	{
		$publisherObjectID = trim( $publisher );
		$publisherObject   = eZContentObject::fetch( $publisherObjectID );

		if ( $publisherObject == null )
			throw new Exception( 'Invalid publisher objectID' );
	}
	else if ( is_string( $publisher ) )
	{
		$remotePath      = trim( $publisher );
		$publisherObject = eZContentObject::fetchByRemoteId( 'publisher_folder-' . $remotePath );

		if ( $publisherObject == null )
			throw new Exception( 'Invalid publisher remoteID' );
	}

	if ( $publisherObject->attribute( 'class_identifier' ) != 'publisher_folder' )

		throw new Exception( 'Given publisher is not publisher folder type' );

	return $publisherObject;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:33,代码来源:align_solr.php

示例2: createContentObject

    function createContentObject( $objectInformation )
    {
        $db = eZDB::instance();
        $contentObjectVersion = false;
        if ( $objectInformation['ownerID'] )
        {
            $userID = $objectInformation['ownerID'];
        }
        else
        {
            $user = eZUser::currentUser();
            $userID = $user->attribute( 'contentobject_id' );
        }
        if ( $objectInformation['remoteID'] )
        {
            $contentObject = eZContentObject::fetchByRemoteId( $objectInformation['remoteID'] );
            if (  $contentObject )
            {
                $this->writeMessage( "\t[".$objectInformation['remoteID']."] Object exists: " . $contentObject->attribute("name") . ". Creating new version.", 'notice' );
                $contentObjectVersion = $contentObject->createNewVersion();
            }
        }
        elseif ( $objectInformation['objectID'] )
        {
            $contentObject = eZContentObject::fetch( $objectInformation['objectID'] );
            if (  $contentObject )
            {
                $this->writeMessage( "\t[".$objectInformation['remoteID']."] Object exists: " . $contentObject->attribute("name") . ". Creating new version.", 'notice' );
                $contentObjectVersion = $contentObject->createNewVersion();
            }
        }

        if ( !$contentObjectVersion )
        {
            if ( is_numeric( $objectInformation['classID'] ) )
            {
                $contentClass = eZContentClass::fetch( $objectInformation['classID'] );
            }
            elseif ( is_string( $objectInformation['classID'] ) && $objectInformation['classID'] != "" )
            {
                $contentClass = eZContentClass::fetchByIdentifier( $objectInformation['classID'] );
            }
            else
            {
                $this->writeMessage( "\tNo class defined. Using class article.", 'warning' );
                $contentClass = eZContentClass::fetchByIdentifier( 'article' );
            }
            if ( !$contentClass )
            {
                $this->writeMessage( "\tCannot instantiate class '". $objectInformation['classID'] ."'." , 'error' );
                return false;
            }
            $contentObject = $contentClass->instantiate( $userID );
            $contentObject->setAttribute( 'remote_id',  $objectInformation['remoteID'] );
            if ( $contentObject )
            {
                $contentObjectVersion = $contentObject->currentVersion();
            }
        }
        if ( $contentObjectVersion )
        {
            $db->begin();
            $versionNumber  = $contentObjectVersion->attribute( 'version' );

            $sortField = intval( eZContentObjectTreeNode::sortFieldID( $objectInformation['sort_field'] ) );
            $sortOrder = strtolower( $objectInformation['sort_order'] ) == 'desc' ? eZContentObjectTreeNode::SORT_ORDER_DESC : eZContentObjectTreeNode::SORT_ORDER_ASC;

            $nodeAssignment = eZNodeAssignment::create(
                    array(  'contentobject_id'      => $contentObject->attribute( 'id' ),
                            'contentobject_version' => $versionNumber,
                            'parent_node'           => $objectInformation['parentNode'],
                            'is_main'               => 1,
                            'sort_field'			=> $sortField,
                            'sort_order'			=> $sortOrder,
                            )
            );
            $nodeAssignment->store();
            $dataMap = $contentObjectVersion->dataMap();
            foreach ( $objectInformation['attributes'] as $attributeName => $attributesContent )
            {
                if ( array_key_exists( $attributeName, $dataMap ) )
                {
                    $attribute = $dataMap[$attributeName];
                    $classAttributeID = $attribute->attribute( 'contentclassattribute_id' );
                    $dataType = $attribute->attribute( 'data_type_string' );
                    switch ( $dataType )
                    {
                        case 'ezstring':
                        case 'eztext':
                        case 'ezselection':
                        case 'ezemail':
                        {
                            if ( array_key_exists( 'parseReferences', $attributesContent ) && $attributesContent['parseReferences'] == "true" )
                            {
                                $attribute->setAttribute( 'data_text', $this->parseAndReplaceStringReferences( $attributesContent['content'] ) );
                            }
                            else
                            {
                                $attribute->setAttribute( 'data_text', $attributesContent['content'] );
                            }
//.........这里部分代码省略.........
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:101,代码来源:ezcreatecontent.php

示例3: interactiveCreateCountry

        $country = interactiveCreateCountry( $clusterIdentifier, $cli, $language );
        break;
    case TASK_UPDATE:
        $country = interactiveUpdateCountry( $country, $cli );
        break;
}

$applications = selectApplications( $clusterIdentifier, 'content_service' );
$tasksIdsToApplicationsIds = array();
$taskList = array();
foreach ( $applications as $id => $application )
{
    $remoteId = 'application_folder-' . $clusterIdentifier . '-' . $application['identifier'];
    $applications[$id]['remote_id'] = $remoteId;
    $applicationInternalName = $application['internal_name'];
    $applicationNode = eZContentObject::fetchByRemoteId( $remoteId );
    if ( $applicationNode != null )
    {
        if ( $applicationInternalName == $applicationNode->Name )
        {
            unset( $applications[$id] );
            continue;
        }
        $applications[$id]['old_name'] = $applicationNode->Name;
        $applications[$id]['task'] = TASK_UPDATE;
        $applications[$id]['object'] = $applicationNode;
        $taskList[] = "Update application {$applicationNode->Name} to {$applicationInternalName}";
    }
    else
    {
        $applications[$id]['task'] = TASK_CREATE;
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:build_application_tree.php


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