Forums | Mahara Community

Developers /
whats the use of Abstarct class


anonymous profile picture
Deleted user
Posts: 15

09 October 2014, 11:03 PM

I'm getting Fatal error: Class PluginBlocktypeInvite contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods

My code : in artefact\inviteprograms\blocktype\invite\lib.php

class PluginBlocktypeInvite extends PluginBlocktype {

public static abstract function get_title();

public static abstract function get_description();


public static abstract function get_categories();
public static abstract function render_instance(BlockInstance $instance, $editing=false);

}

i creating plugin for inviting Fb friends with wiki mahara develooper area.

 

Robert Lyon's profile picture
Posts: 444

10 October 2014, 8:23 AM

Hi Vignesh,

It turns out that Mahara was not implementing it's abstract methods correctly

To update the way you call the methods take a look at the patches here:

https://reviews.mahara.org/#/c/3474/

So for your code it would be something like:

interface IPluginBlocktypeInvite {
 public static function get_title();

 public static function get_description();

 public static function get_categories();

 public static function render_instance(BlockInstance $instance, $editing=false);
}

class PluginBlocktypeInvite extends PluginBlocktype implements IPluginBlocktypeInvite {
  // any non abstract functions
}

 

Aaron Wells's profile picture
Posts: 896

13 October 2014, 11:39 AM

The patch that Robert posted is actually just about something that throws an E_STRICT warning. What you're showing here is a fatal error, because you subclassed an abstract class, PluginBlocktype, but didn't provide implementations for the abstract methods you inherited.

See http://php.net/manual/en/language.oop5.abstract.php

Cheers,

Aaron

3 results