Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

DataObjectSet::append() is deprecated ?


Reply


4 Posts   2349 Views

Avatar
OzziNL

Community Member, 37 Posts

7 August 2008 at 12:43am

Hi,
I get this notice after upgrading to 2.2.2 : DataObjectSet::append() is deprecated. Use DataObjectSet::merge() instead.

But DataObjectSet::merge() is not 'compatible' with append. In the append method it is possible to append a DataObject to a DataObjectSet. With merge this is not possible.

So when I have a DataObjectSet, how can I append one DataObect to it?

$returnSet = new DataObjectSet();
$pages = DataObject::get("SiteTree","ParentID = " . $this->ID,"","");
      if (!$pages) return null;
      foreach ($pages as $p) {
         
         if ($p->ClassName == 'VirtualPage') // VP
         {
            $np = DataObject::get_by_id('VirtualPage', $p->ID);
            $newp = DataObject::get_by_id("SiteTree", $np->CopyContentFromID);
            $returnSet->append($newp);
// cut // cut // cut

Avatar
OzziNL

Community Member, 37 Posts

29 September 2008 at 7:54pm

//just a kick for some attention ;)

Avatar
FlorianH

Community Member, 33 Posts

30 September 2008 at 2:12am

Use DataObjectSet::push() instead.

Avatar
Willr

Forum Moderator, 5513 Posts

30 September 2008 at 5:42pm

Im pretty sure you can just call push() which should add it to the end, just like FlorianH has said

$returnSet->push($newp);