get_entity($guid) does not return the object with its subtype?

Hi experts,

I defined a ElggGroup entity with subtype 'a'. I then use get_entity($guid) to get this entity. However, when I query the subtype of the returned entity, the subtype is no longer 'a'. Can someone tell me if this is an expected behavior? i.e. get_entity just gets a copy of the object but the original one? Also, why not the subtype attribute be autopopulated?

Thanks,

 

  • Make sure you use the method getSubtype() to get the subtype

  • I simply check the subtype member. My code is following:

     

    $place = get_entity($place_guid);

     if ($place) {
              if($place->subtype != 'place')

                      echo "correct";

               else echo "wrong";

    }

     

    I created this group in the action/add.php as following:

    $place = new ElggGroup($place_guid); // load if present, if not create a new place
    $place->subtype = 'place';

    Can you advise me if there is anything wrong?

    Thanks,

     

     

  • Okay, I got it. Using getSubtype() method works. However, I am still wondering why assigining value to a private member works and there is no setSubtype() method...