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: Feb 16 2025 07:20:08
Script start
Timing: Feb 16 2025 07:20:08
Module start 'layout'
Timing: Feb 16 2025 07:20:08
Module start 'content'
Timing: Feb 16 2025 07:20:08
Module end 'content'
Timing: Feb 16 2025 07:20:08
Script end

Main resources:

Total runtime0.0155 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 588.8281151.2109
Module start 'layout' 0.00590.0024 740.039136.6484
Module start 'content' 0.00820.0058 776.687590.0313
Module end 'content' 0.01400.0015 866.718829.9922
Script end 0.0155  896.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003019.6298140.0002
Check MTime0.00159.6491140.0001
Mysql Total
Database connection0.00106.199910.0010
Mysqli_queries0.002113.379230.0007
Looping result0.00000.070610.0000
Template Total0.00127.510.0012
Template load0.00085.427810.0008
Template processing0.00032.092210.0003
Override
Cache load0.00063.869810.0006
General
dbfile0.00127.492480.0001
String conversion0.00000.039940.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