/** * @throws Exception * * @return BlockController */ public function getController() { if ($this->controller) { return $this->controller; } foreach (array_reverse(ClassInfo::ancestry($this->class)) as $blockClass) { $controllerClass = "{$blockClass}_Controller"; if (class_exists($controllerClass)) { break; } } if (!class_exists($controllerClass)) { throw new Exception("Could not find controller class for {$this->classname}"); } $this->controller = Injector::inst()->create($controllerClass, $this); $this->controller->init(); return $this->controller; }