public static function module_controller_for_request(ContentController $contentController, SS_HTTPRequest $request, $relationship = 'ContentModules') { $moduleURLSegment = $request->shift(); if ($module = $contentController->data()->{$relationship}()->filter('URLSegment', $moduleURLSegment)->first()) { $controller = self::controller_for($module, $contentController); //backwards compatibility support for modules handling actions directly //should move to using controllers to handle actions if ($controller instanceof ModuleController) { return $controller->handleRequest($request, new DataModel()); } else { $action = $request->shift(); if ($controller->hasMethod($action)) { return $controller->{$action}($request); } } } }
/** * Constructs a new controller for creating a registration. * * @param ContentController $parent * @param RegistrableDateTime $datetime */ public function __construct($parent, $datetime) { $this->parent = $parent; $this->datetime = $datetime; parent::__construct($parent->data()); }