Currently I am using codes below to get a page's controller from a page:
//check page existence
$pagename = 'ContactPage';
if($page = DataObject::get_one($pagename)) {
//check method existence
$page_controller = $pagename . '_Controller';
$page_controller = new $page_controller;
if ($page_controller->hasAction('confirmationEmail')) {
return Controller::join_links($page->AbsoluteLink(), 'confirmationEmail');
}
}
Is there any more effiecient method?