Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

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

How to implement on a dataobjectdecorator?[solved sort of]


Reply


5 Posts   604 Views

Avatar
cumquat

Community Member, 198 Posts

2 April 2012 at 10:09pm

Hi there,

I'm using Uncle Cheeses Mappable module and so far so good it works great for me on new dataobjects,

class POI extends DataObject implements Mappable {

- this all works great

that i have but what i want to do now is to implement it on the databojectdecorator im using for the members table and when i try with the code below the site just gives a 500 error so im guessing that im using the wrong syntax.

class MemberTeamExtension extends DataObjectDecorator implements Mappable {

- this doesn't

Any pointers?

regards

Mick

Avatar
cumquat

Community Member, 198 Posts

3 April 2012 at 9:08pm

*bump*

Avatar
Willr

Forum Moderator, 5513 Posts

5 April 2012 at 11:02pm

What is the actual error message? (turn on dev mode or check your php error log)

Avatar
cumquat

Community Member, 198 Posts

6 April 2012 at 12:00am

Hi Willr

Thanks for responding, the site is in dev mode but alas i'm getting no errors at all apart from just http 500 error no log files or anything. In firefox with firebug there is nothing either, below is the code for the php page, if i remove the implements mappable it works fine?

class MemberTeamExtension extends DataObjectDecorator implements Mappable {

   public function extraStatics() {
      return array (
         'db' => array (
            'DOB' => 'Date',
            'Address' => 'Varchar',
            'Town' => 'Varchar',
            'Postcode' => 'Varchar',
            'DefaultNum' => 'Varchar',
            'HomeNum' => 'Varchar',
            'OtherNum' => 'Varchar',
            'Callsign' => 'Varchar(20)',
            'KSAROperational' => "Enum('No, Yes')",
            'Sector' => "Enum('Sector2, Sector3, Sector4, Sector5, Sector6, No Sector')",
            'RecieveEmail' => 'Boolean',
            'JacketSize' => "Enum('Size, XS, S, M, L, XL, XXL, XXXL', 'Size')",
            'ShirtSize' => "Enum('Size, XS, S, M, L, XL, XXL, XXXL' , 'Size')",
            'PoliceVetted' => 'Boolean',
            'Lat' =>'Varchar',
            'Lon' =>'Varchar'
         ),
         'has_one' => array (
            'Photo' => 'Image'
         ),
         'has_many' => array (
            'Course' => 'Course',
            'SignedOut' => 'SignedOut',
            'StageAchieved' => 'StageAchieved'
         ),
         'many_many' => array (
            'Roles' => 'Role'
            ),
         
         'summary_fields' => array(
            'Sector' => 'Sector',
      'DefaultNum' => 'Number',
            'Postcode' => 'Postcode',
            'Town' => 'Town',
            'RecieveEmail' => 'Recieve Email',
            )
         
      );
   }
public function updateCMSFields( FieldSet &$fields )
{

   
       $fields->addFieldToTab("Root.Main", $dateField = new DateField("DOB","Date of Birth"));
      $dateField->setConfig('showcalendar', true);
   
       $fields->addFieldToTab( "Root.KSAR", new OptionSetField('Sector','Choose a Sector', singleton('Member')->dbObject('Sector')->enumValues()));
   $fields->addFieldToTab( "Root.KSAR", new DropDownField( "KSAROperational", "KSAR Operational", singleton('Member')->dbObject('KSAROperational')->enumValues()));
   $fields->addFieldToTab( "Root.Main", $upload = new ImageUploadField('Photo', 'Photo'));
      $upload->uploadFolder = 'assets/Uploads/Images/TeamMembers';
       
      $fields->removeByName('Lat');
      $fields->removeByName('Lon');
       $fields->addFieldToTab("Root.Location", new LatLongField(array(
      new TextField('Lat','Latitude'),
      new TextField('Lon','Longitude')
),
array('Postcode')
));
      
      
      $fields->removeByName('Roles');
      $fac = DataObject::get("Role");
      $map = $fac->map('ID','Title');
      
      
      $fields->addFieldToTab(   "Root.KSAR", new CheckboxSetField( 'Roles', 'Role', $map));
         
       $fields->removeByName("PublicFieldsRaw");
      $fields->removeByName("DateFormat");
      $fields->removeByName("TimeFormat");
   $fields->removeByName("Locale");

      if(!Member::currentUser()->isAdmin()){
         $fields->removeFieldFromTab("Root", "Groups");
         $fields->removeFieldFromTab("Root", "Permissions");
      }

}

   function MyCourses() {
      $ID = $this->owner->ID;
      return DataObject::get( "Course", "MemberID = '$ID'" );
         
}
   
   function MyCallouts() {
      $ID = $this->owner->ID;
      return DataObject::get( "SearchTeam", "MemberID = '$ID'" );
   
   }
   function MyKit() {
      $ID = $this->owner->ID;
      return DataObject::get( "SignedOut", "MemberID = '$ID'" );
   
   }
   
}

regards

Mick

Avatar
cumquat

Community Member, 198 Posts

6 April 2012 at 12:29am

Ok found a log file on the server, no mean feat as there was no real access and below is an entry.

[Thu Apr 05 13:19:44 2012] [error] [client 82.111.128.201] PHP Fatal error: Class MemberTeamExtension contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (Mappable::getLatitude, Mappable::getLongitude, Mappable::getMapPin, ...) in /home/sites/myriadtestsite.co.uk/public_html/subs/ksar/sar/code/MemberTeamExtension.php on line 135

Ok this has identified some missing functions have added them and now it doesn't error, doesn't work but hey doesn't error.

Surprised the dev mode didn't spit this out?

cheers

for your time

Mick