Remember me? forgot password | register

SilverStripe Forum

10689 Posts in 2796 Topics by 1518 members

Jump to:

Site Builders

If this is your first visit, you will need to register before you can post. However, you can browse all messages below.

Community » SilverStripe Forum » Site Builders » DataObjectSet::append() is deprecated ?
Page: 1 go to end Reply
Author Topic: DataObjectSet::append() is deprecated ? 368 views
  • OzziNL
    avatar
    Community Member
    24 posts
    5 SilverStripe Sites

    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
    24 posts
    5 SilverStripe Sites

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

    //just a kick for some attention ;)

  • FlorianH
    FlorianH's avatar
    Community Member
    30 posts

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

    Use DataObjectSet::push() instead.

  • willr
    avatar
    Core Development Team
    1263 posts
    3 SilverStripe Sites 2 SilverStripe Themes

    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);

    368 views
go to top Reply

Currently Online:

François, eljefe, Dig, patrics, simon_w, Aster

Welcome to our latest member: patrics