Creating an eZEnumObjectValue

Author Message

Rib Rdb

Sunday 01 June 2003 8:21:40 pm

I'm trying to create a new content object with a single enum attribute. I use the following code to try to create an eZEnumObjectValue to store in the attribute:

$attributes = $version->contentObjectAttributes();
$enum = $attributes[0]->content();
$enumobjectList = $enum->attribute('enumobject_list');
$enumobjectList[0] =&
eZEnumObjectValue::create(
$enum->attribute('contentclass_attributeid'),
$enum->attribute('contentclass_attributeversion'),
$ids[$Rating],
$elements[$Rating],
$values[$Rating]);
$enumobjectList[0]->store();

The value appears to be stored to the database, but isn't associated with the object. The contentclass_attributeid always seems to be the id of the enum in the class definition, instead of an id specific to the instantiated object. I've tried this code both before and after publishing the object. Do I need to publish it and then fetch it to do this? Do I somehow need to create an attribute? What am I doing wrong?

Rib Rdb

Sunday 01 June 2003 9:28:06 pm

Well, I got what I asked for. Here's the modified code that works, if anyone else is trying this:

$attributes = $version->contentObjectAttributes();
$attribute = $attributes[0];
$enum = $attribute->content();
$enumobjectList = $enum->attribute('enumobject_list');
$enumobjectList[0] =&
eZEnumObjectValue::create(
$attribute->attribute('id'),
$attribute->attribute('version'),
$ids[$Rating],
$elements[$Rating],
$values[$Rating]);
$enumobjectList[0]->store();

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 19:04:24
Script start
Timing: Jan 30 2025 19:04:24
Module start 'layout'
Timing: Jan 30 2025 19:04:24
Module start 'content'
Timing: Jan 30 2025 19:04:24
Module end 'content'
Timing: Jan 30 2025 19:04:24
Script end

Main resources:

Total runtime0.0323 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0080 588.1406151.2109
Module start 'layout' 0.00800.0048 739.3516220.6875
Module start 'content' 0.01280.0174 960.0391997.6797
Module end 'content' 0.03020.0020 1,957.718829.9922
Script end 0.0323  1,987.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00268.1723140.0002
Check MTime0.00103.1773140.0001
Mysql Total
Database connection0.00154.486710.0015
Mysqli_queries0.004012.392730.0013
Looping result0.00000.043510.0000
Template Total0.00164.910.0016
Template load0.00123.777810.0012
Template processing0.00031.076310.0003
Override
Cache load0.00082.432210.0008
General
dbfile0.00309.149780.0004
String conversion0.00000.021440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs