I'm having a weird issue with my CMP. I have a grid of events, that returns shows information about different events and also a count of how many attendees each event has registered. Therein lies the problem.
I have several classes and the attendee data differs between event types. For this I specify a controller, to load the appropriate attendee class depending on event type. The schema for these looks as follows:
<object class="harbourEventAttendee" table="harbour_attendees_event" extends="xPDOSimpleObject">
<field key="userid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true"/>
<field key="eventid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false"/>
<field key="boatid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true"/>
<field key="additional" dbtype="text" phptype="string" null="true"/>
<index alias="userid" name="userid" primary="false" unique="false" type="BTREE">
<column key="userid" collation="A" null="false"/>
</index>
<index alias="eventid" name="eventid" primary="false" unique="false" type="BTREE">
<column key="eventid" collation="A" null="false"/>
</index>
<aggregate alias="Account" class="harbourAccount" local="userid" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="Event" class="harbourEvent" local="eventid" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="Boat" class="harbourBoat" local="boatid" foreign="id" cardinality="one" owner="foreign"/>
</object>
<object class="harbourContestAttendee" table="harbour_attendees_contest" extends="harbourEventAttendee">
<field key="spinnaker" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0"/>
<field key="skipper_name" dbtype="varchar" precision="50" phptype="string" null="false"/>
<field key="skipper_phone" dbtype="varchar" precision="24" phptype="string" null="false"/>
<field key="skipper_email" dbtype="varchar" precision="50" phptype="string" null="false"/>
<field key="deckhands" dbtype="text" phptype="string" null="true"/>
</object>
<object class="harbourCourseAttendee" table="harbour_attendees_course" extends="harbourEventAttendee">
<field key="fullname" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="email" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="phone" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="address" dbtype="text" phptype="string" null="false" default="" />
<field key="zip" dbtype="varchar" precision="25" phptype="string" null="false" default="" />
<field key="city" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="birthdate" dbtype="date" phptype="datetime" null="true"/>
<field key="guardian_name" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
<field key="guardian_phone" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
<field key="guardian_email" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
</object>
As you can see there's one main class that stores generic data, and specialized classes for the extra data. These work perfectly everywhere else, except to count the attendees in my events grid.
In the getList processor I run this to get the attendee count:
public function prepareRow(xPDOObject $object) {
$controller = $object->get('controller');
$attendeeClass = 'harbour'.ucfirst($controller).'Attendee';
$attendeeCount = $this->modx->getCount($attendeeClass,array(
'eventid' => $object->get('id')
));
$eventArray = $object->toArray();
$eventArray['attendees'] = $attendeeCount;
return $eventArray;
}
Now here's where it gets even weirder: This works perfectly fine when a filter is used to only return events of one type. When returning all types it counts attendees correctly for all classes that extend harbourEventAttendee, except for the main class itself. When it tried to do this I get the following in the error log:
[2014-05-07 13:11:52] (ERROR @ /assets/components/harbour/connector.php) harbourEventAttendee::getSelectColumns() is not a valid static method.
And the getCount returns 0.
I've tried using loadClass before the getCount to load it explicitly beforehand, but this makes no difference. harbourEventAttendee extends xPDOSimpleObject. Why can harbourEventAttendee not use getSelectColumns in getCount, while the classes that extend it can??
Any help is appreciated, I'm completely lost on this issue!