Jump to:

22999 Posts in 11854 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Working through the book, Subscribers() problem

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1075 Views
  • Phill
    Avatar
    Community Member
    75 Posts

    Working through the book, Subscribers() problem Link to this post

    Hi

    I'v started working my way through the Silverstripe book but i'm getting an error which i cant seem to solve.

    The error happens when this method is called (page 154 of the book), it appear that it does not like $this->Subscribers()

    function MemberIsSubscribed($member = null)
       {
          if(!$member) $member = Member::CurrentMember();
          $idList = $this->Subscribers()->getIdList();
          return in_array($member->ID,$idList);
          return false;
       }

    Heres the error returned
    [Warning] reset() expects parameter 1 to be array, null given
    GET /ssbook/jobs/programming

    Line 101 in C:\wamp\www\ssbook\sapphire\core\ClassInfo.php

    Source

    92     * Return the root data class for that class.
    93     * This root table has a lot of special use in the DataObject system.
    94     *
    95     * @param mixed $class string of the classname or instance of the class
    96     * @return array
    97     */
    98    static function baseDataClass($class) {
    99       global $_ALL_CLASSES;
    100       if (is_object($class)) $class = get_class($class);
    101       reset($_ALL_CLASSES['parents'][$class]);
    102       while($val = next($_ALL_CLASSES['parents'][$class])) {
    103          if($val == 'DataObject') break;
    104       }
    105       $baseDataClass = next($_ALL_CLASSES['parents'][$class]);
    106       return $baseDataClass ? $baseDataClass : $class;
    107    }

    any ideas on what might be causing this?

    Thanks
    Phil

  • Phill
    Avatar
    Community Member
    75 Posts

    Re: Working through the book, Subscribers() problem Link to this post

    Sorry guys, I've solved the problem it was because i have written

       static $many_many = array(
          'Subscribers' => 'Members'
       );

    instead of

       static $many_many = array(
          'Subscribers' => 'Member'
       );

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