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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Potential issues & side-effects with having an abstract (parent) Page Controller.


Go to End


820 Views

Avatar
vwd

Community Member, 166 Posts

19 February 2014 at 3:07pm

Edited: 19/02/2014 3:11pm

Hi,

I have implemented an abstract page controller of a parent page class, since I want the children to implement the abstract functions.

So far everything seems to be working well. But can you anticipate any issues or side-effects of having abstract parent page controllers?

Parent Page with abstract Page_Controller:

class MyParentPage extends Page {
	// ...
}

abstract class MyParentPage_Controller extends Page_Controller {

	abstract protected function myAbstractFunction();
	
	public function myFunction() {
		// ...
		return $this->myAbstractFunction();
	}
}

Child Page

class MyChildPage extends MyParentPage {
	// …
	private static $hide_ancestor = 'MyParentPage';
}

abstract class MyChildPage_Controller extends MyParentPage_Controller {

	protected function myAbstractFunction() {
		return 'Something';
	}

}

Thanks.
VWD.