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()
Creates list object.
data
list - Krang::List object
parent_list_item (optional) - a Krang::ListItem object
order (optional) - will default to the next available slot
save()
Saves (inserts) list_item into the database, or updates if it already exists.
find()
Find and return list items with parameters specified.
Supported keys:
list_item_id
list_id
parent_list_item_id
no_parent
data
order
order_by
order_desc
limit
offset
count
ids_only
delete()
Delete list item specified.
Serialize as XML. See Krang::DataSet for details.
$list_item = Krang::ListItem->deserialize_xml(xml => $xml, set => $set, no_update => 0)
Deserialize XML. See Krang::DataSet for details.
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