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


PHP eZContentObjectAttribute::removeThis方法代码示例

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


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

示例1: updateClass

function updateClass($classId, $scheduledScript)
{
    $cli = eZCLI::instance();
    /*
    // If the class is not stored yet, store it now
    $class = eZContentClass::fetch( $classId, true, eZContentClass::VERSION_STATUS_TEMPORARY );
    if ( $class )
    {
        $cli->output( "Storing class" );
        $class->storeDefined( $class->fetchAttributes() );
    }
    */
    // Fetch the stored class
    $class = eZContentClass::fetch($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
    if (!$class) {
        $cli->error('No class in a modified version status with ID: ' . $classId);
        return;
    }
    // Fetch attributes and definitions
    $attributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
    $oldClassAttributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_DEFINED);
    // Delete object attributes which have been removed.
    foreach ($oldClassAttributes as $oldClassAttribute) {
        $attributeExist = false;
        $oldClassAttributeID = $oldClassAttribute->attribute('id');
        foreach ($attributes as $newClassAttribute) {
            if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
                $attributeExist = true;
            }
        }
        if (!$attributeExist) {
            $ezscriptmonitorINI = eZINI::instance('ezscriptmonitor.ini');
            $objectLimit = $ezscriptmonitorINI->variable('GeneralSettings', 'ObjectLimit');
            $limit = array('offset' => 0, 'length' => $objectLimit);
            do {
                $objectAttributes = eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID, false, false, false, $limit);
                $objectAttributeCount = count($objectAttributes);
                $conditions = array("contentclassattribute_id" => $oldClassAttributeID);
                $totalObjectAttributeCount = eZContentObjectAttribute::count(eZContentObjectAttribute::definition(), array("contentclassattribute_id" => $oldClassAttributeID));
                if (is_array($objectAttributes) && $objectAttributeCount > 0) {
                    $db = eZDB::instance();
                    $db->begin();
                    foreach ($objectAttributes as $objectAttribute) {
                        $objectAttribute = new eZContentObjectAttribute($objectAttribute);
                        $objectAttribute->removeThis($objectAttribute->attribute('id'));
                    }
                    $db->commit();
                    $limit['offset'] += $objectAttributeCount;
                    $percentage = round(100 * $limit['offset'] / $totalObjectAttributeCount, 2);
                    // for ezscriptmonitor 100 means the script is all the way done
                    if ($percentage < 100 && $scheduledScript !== false) {
                        $scheduledScript->updateProgress($percentage);
                    }
                    $cli->output("Removing attributes - Progress: " . $percentage . " %");
                }
            } while ($objectAttributeCount == $objectLimit);
        }
    }
    $class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
    // Add object attributes which have been added.
    foreach ($attributes as $newClassAttribute) {
        $attributeExist = false;
        foreach ($oldClassAttributes as $oldClassAttribute) {
            if ($oldClassAttribute->attribute('id') == $newClassAttribute->attribute('id')) {
                $attributeExist = true;
                break;
            }
        }
        if (!$attributeExist) {
            $objects = null;
            $cli->output("Adding attribute : " . $newClassAttribute->attribute('name'));
            $newClassAttribute->initializeObjectAttributes($objects);
        }
    }
    if ($scheduledScript !== false) {
        $scheduledScript->updateProgress(100);
    }
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:78,代码来源:syncobjectattributes.php


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