Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Multiple DataObject::get in one function

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1894 Views
  • markuse
    Avatar
    Community Member
    4 Posts

    Multiple DataObject::get in one function Link to this post

    Dear all,
    I have a function "MyFunction" from where I can call two different objects. Each on its own work fine, I get either "Result A" or "Result B". Both getManyManyComponents() from both DataObject::get are calling the same class.

    So Result A and result B have a common subset of results. Is there a simple way to combine two DataObject::get?
    Thank for your help

    class DoResults_Controller extends Page_Controller {
    function MyFunction(){
    ....
    //$result = DataObject::get("TheOneObject","TheOneFilter");//Result A
    $result = DataObject::get("TheOtherObject","TheOtherFilter");//Result B
    return $result;
    }
    ...
    }

    class TheOneObject extends DataObject {
    ....
    static $belongs_many_many = array(
    'Topics' => 'Topic'
    );
    function GetThisOne(){
    return $this->getManyManyComponents("Topics");
    }
    }

    class TheOtherObject extends DataObject {
    ....
    static $belongs_many_many = array(
    'Topics' => 'Topic'
    );

    function GetTheOtherOne(){
    return $this->getManyManyComponents("Topics");
    }
    }

  • B-Side
    Avatar
    Community Member
    42 Posts

    Re: Multiple DataObject::get in one function Link to this post

    Hi there - I was wondering if you worked out a solution to this issue? I have the same question!

    Cheers, Jayne

    1894 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.