Jump to:

23487 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Potential issues & side-effects with having an abstract (parent) Page Controller.

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: 173 Views
  • vwd
    Avatar
    Community Member
    158 Posts

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

    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.

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