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


PHP eZContentClass::fetchAttributes方法代码示例

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


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

示例1: store

 /**
  * Store the modification made to an eZContentClass.
  *
  * @param eZContentClass Content class to be stored.
  * @param array[eZContentClassAttribute] Attributes of the new content class.
  * @param array Unordered view parameters
  */
 public function store(eZContentClass $class, array $attributes, array &$unorderedParameters)
 {
     $oldClassAttributes = $class->fetchAttributes($class->attribute('id'), true, eZContentClass::VERSION_STATUS_DEFINED);
     // Delete object attributes which have been removed.
     foreach ($oldClassAttributes as $oldClassAttribute) {
         $attributeExists = false;
         $oldClassAttributeID = $oldClassAttribute->attribute('id');
         foreach ($class->fetchAttributes() as $newClassAttribute) {
             if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
                 $attributeExists = true;
                 break;
             }
         }
         if (!$attributeExists) {
             foreach (eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID) as $objectAttribute) {
                 $objectAttribute->removeThis($objectAttribute->attribute('id'));
             }
         }
     }
     $class->storeDefined($attributes);
     // Add object attributes which have been added.
     foreach ($attributes as $newClassAttribute) {
         $attributeExists = false;
         $newClassAttributeID = $newClassAttribute->attribute('id');
         foreach ($oldClassAttributes as $oldClassAttribute) {
             if ($newClassAttributeID == $oldClassAttribute->attribute('id')) {
                 $attributeExists = true;
                 break;
             }
         }
         if (!$attributeExists) {
             $newClassAttribute->initializeObjectAttributes($objects);
         }
     }
 }
开发者ID:legende91,项目名称:ez,代码行数:42,代码来源:ezcontentclassedithandler.php

示例2: adjustClassAttributesPlacement

 /**
  * Updates placement for each attribute in a class instance
  *
  * @since 1.2.1
  * @param eZContentClass $class class instance to update
  */
 protected function adjustClassAttributesPlacement(eZContentClass $class)
 {
     $attributes = $class->fetchAttributes();
     $class->adjustAttributePlacements($attributes);
     foreach ($attributes as $attribute) {
         $attribute->store();
     }
 }
开发者ID:heliopsis,项目名称:ezxmlinstaller,代码行数:14,代码来源:ezcreateclass.php

示例3: sync

 public function sync($force = false, $removeExtras = false)
 {
     $modified = eZContentClass::fetch($this->id, true, eZContentClass::VERSION_STATUS_MODIFIED);
     if (is_object($modified)) {
         throw new Exception("Classe bloccata in modifica");
     }
     $this->compare();
     if ($this->getData()->hasError && !$force) {
         throw new Exception("La classe contiene campi che ne impediscono la sincronizzazione automatica");
     }
     $temporary = eZContentClass::fetch($this->id, true, eZContentClass::VERSION_STATUS_TEMPORARY);
     if (!is_object($temporary) or $temporary->attribute('id') == null) {
         $temporary = eZContentClass::fetch($this->id, true, eZContentClass::VERSION_STATUS_DEFINED);
         if ($temporary === null) {
             throw new Exception("La classe non esiste");
         }
         /** @var eZContentClassClassGroup[] $classGroups */
         $classGroups = eZContentClassClassGroup::fetchGroupList($this->id, eZContentClass::VERSION_STATUS_DEFINED);
         foreach ($classGroups as $classGroup) {
             $groupID = $classGroup->attribute('group_id');
             $groupName = $classGroup->attribute('group_name');
             $ingroup = eZContentClassClassGroup::create($this->id, eZContentClass::VERSION_STATUS_TEMPORARY, $groupID, $groupName);
             $ingroup->store();
         }
         if (count($classGroups) > 0) {
             $mainGroupID = $classGroups[0]->attribute('group_id');
             $mainGroupName = $classGroups[0]->attribute('group_name');
         }
     } else {
         $user = eZUser::currentUser();
         $contentIni = eZINI::instance('content.ini');
         $timeOut = $contentIni->variable('ClassSettings', 'DraftTimeout');
         /** @var eZContentClassClassGroup[] $groupList */
         $groupList = $temporary->fetchGroupList();
         if (count($groupList) > 0) {
             $mainGroupID = $groupList[0]->attribute('group_id');
             $mainGroupName = $groupList[0]->attribute('group_name');
         }
         if ($temporary->attribute('modifier_id') != $user->attribute('contentobject_id') && $temporary->attribute('modified') + $timeOut > time()) {
             throw new Exception("Modifica alla classe non permessa");
         }
     }
     /** @var eZContentClassAttribute[] $localeAttributes */
     $localeAttributes = array();
     foreach ($this->currentClass->fetchAttributes() as $attribute) {
         /** @var eZContentClassAttribute $attribute */
         $attribute->setAttribute('version', eZContentClass::VERSION_STATUS_TEMPORARY);
         $localeAttributes[$attribute->attribute('identifier')] = $attribute;
     }
     $this->currentClass->setAttribute('version', eZContentClass::VERSION_STATUS_TEMPORARY);
     $remote = $this->getRemote();
     if ($remote === null) {
         throw new Exception("Classe remota non trovata");
     }
     if ($force && $this->getData()->hasError) {
         foreach ($this->getData()->errors as $identifier => $value) {
             if (!$localeAttributes[$identifier] instanceof eZContentClassAttribute) {
                 throw new Exception('Errore forzando la sincronizzazione');
             }
             foreach ($remote->DataMap[0] as $originalAttribute) {
                 if ($originalAttribute->Identifier == $identifier) {
                     ezpEvent::getInstance()->notify('classtools/switch_class_attribute', array($localeAttributes[$identifier], $originalAttribute));
                     if ($value == 'data_type_string') {
                         $localeAttributes[$identifier]->setAttribute('data_type_string', $originalAttribute->DataTypeString);
                         $localeAttributes[$identifier]->store();
                         $this->changeContentObjectAttributeDataTypeString($localeAttributes[$identifier], $originalAttribute->DataTypeString);
                         unset($this->notifications[self::ERROR][$originalAttribute->Identifier]);
                     } else {
                         $this->data->missingAttributes[] = $originalAttribute;
                         $this->currentClass->removeAttributes(array($localeAttributes[$identifier]));
                         unset($localeAttributes[$identifier]);
                     }
                     break;
                 }
             }
         }
     }
     $attributes = array();
     foreach ($this->properties as $identifier => $remoteProperty) {
         if ($remote->{$remoteProperty} != $this->currentClass->attribute($identifier)) {
             $this->currentClass->setAttribute($identifier, $remote->{$remoteProperty});
             if ($identifier == 'serialized_name_list') {
                 $nameList = new eZContentClassNameList();
                 $nameList->initFromSerializedList($remote->{$remoteProperty});
                 $this->currentClass->NameList = $nameList;
             } elseif ($identifier == 'serialized_description_list') {
                 $descriptionList = new eZSerializedObjectNameList();
                 $descriptionList->initFromSerializedList($remote->{$remoteProperty});
                 $this->currentClass->DescriptionList = $descriptionList;
             }
         }
     }
     foreach ($this->getData()->missingAttributes as $originalAttribute) {
         $add = $this->addAttribute($originalAttribute);
         if ($add) {
             $attributes[] = $add;
         }
     }
     foreach ($remote->DataMap[0] as $originalAttribute) {
         if (isset($localeAttributes[$originalAttribute->Identifier])) {
//.........这里部分代码省略.........
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:101,代码来源:occlasstools.php


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