pkg('ListItem') - interface to manage items within a pkg('List').
use Krang::ClassLoader 'ListItem';
# create and save new list item in a Krang::List
my $list_item = pkg('ListItem')->new( list => $list_object,
data => 'item data here'
);
$list_item->save();
# will return what order in the list this item is; in this case 1
# as it is the only item currently in the list
my $order = $list_item->order;
# create new list item in same list, assigning it to order 1
# and thus moving $list_item to order 2
my $list_item2 = pkg('ListItem')->new( list => $list_object,
order => 1,
data => 'data here' );
$list_item2->save();
# find and return list items in list
my @found = pkg('ListItem')->find( list => $list_object );
# create new list item, a member of another Krang::List
# and child of another list item
my $list_item3 = pkg('ListItem')->new( list => $list_object2,
parent_list_item => $list_item,
data => 'data here' );
$list_item3->save;
# find list items that are children of a given list item
my @found = pkg('ListItem')->find( parent_list_item_id => $list_item->list_item_id );
# delete them both
$list_item->delete;
$list_item2->delete;
This class handles management of data items within krang lists.
new()save()find()Supported keys:
delete()$list_item = Krang::ListItem->deserialize_xml(xml => $xml, set => $set, no_update => 0)Note that currently update will not work as there is no identifying field other than data, which can change. However, if an identical list item is found, it will not be replicated.
Krang::List, Krang::ListGroup, Krang::ElementClass::ListGroup, The Krang Element System