Widget::class ]; private static $owns = [ 'Widgets', ]; private static $cascade_deletes = [ 'Widgets', ]; private static $extensions = [ Versioned::class . '.versioned', ]; private static $table_name = 'WidgetArea'; public $template = __CLASS__; /** * Used in template instead of {@link Widgets()} to wrap each widget in its * controller, making it easier to access and process form logic and * actions stored in {@link WidgetController}. * * @return SS_List - Collection of {@link WidgetController} instances. */ public function WidgetControllers() { $controllers = new ArrayList(); $items = $this->ItemsToRender(); if (!is_null($items)) { foreach ($items as $widget) { /** @var Widget $widget */ /** @var Controller $controller */ $controller = $widget->getController(); $controller->doInit(); $controllers->push($controller); } } return $controllers; } /** * @return HasManyList */ public function Items() { return $this->Widgets(); } /** * @return HasManyList */ public function ItemsToRender() { return $this->Items()->filter('Enabled', 1); } /** * @return string - HTML */ public function forTemplate() { return $this->renderWith($this->template); } /** * * @param string $template */ public function setTemplate($template) { $this->template = $template; } }