Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » DataObjectSet::append() is deprecated ?

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

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

Page: 1
Go to End
Author Topic: 2301 Views
  • OzziNL
    Avatar
    Community Member
    37 Posts

    DataObjectSet::append() is deprecated ? Link to this post

    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

  • OzziNL
    Avatar
    Community Member
    37 Posts

    Re: DataObjectSet::append() is deprecated ? Link to this post

    //just a kick for some attention ;)

  • FlorianH
    Avatar
    Community Member
    33 Posts

    Re: DataObjectSet::append() is deprecated ? Link to this post

    Use DataObjectSet::push() instead.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: DataObjectSet::append() is deprecated ? Link to this post

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

    $returnSet->push($newp);

    2301 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.