mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
2cc0d016f4
FEATURE Added Widget_Controller class to enable nested forms within Wiget class. ENHANCEMENT Changed WidgetArea.ss to iterate over $WidgetControllers instead of $Widgets, to allow forms rendered within to retain their controller context (through Widget_Controller and $failover mechanisms). ENHANCEMENT Added handleWidgets() to ContentController to support new Widget_Controller class git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@85789 467b73ca-7a2a-4603-9d3b-597d59a354a9
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Represents a set of widgets shown on a page.
|
|
* @package sapphire
|
|
* @subpackage widgets
|
|
*/
|
|
class WidgetArea extends DataObject {
|
|
|
|
static $db = array();
|
|
|
|
static $has_one = array();
|
|
|
|
static $has_many = array(
|
|
"Widgets" => "Widget"
|
|
);
|
|
|
|
static $many_many = array();
|
|
|
|
static $belongs_many_many = array();
|
|
|
|
/**
|
|
* 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 Widget_Controller}.
|
|
*
|
|
* @return DataObjectSet Collection of {@link Widget_Controller}
|
|
*/
|
|
function WidgetControllers() {
|
|
$controllers = new DataObjectSet();
|
|
foreach($this->Widgets() as $widget) {
|
|
// find controller
|
|
$controllerClass = '';
|
|
foreach(array_reverse(ClassInfo::ancestry($widget->class)) as $widgetClass) {
|
|
$controllerClass = "{$widgetClass}_Controller";
|
|
if(class_exists($controllerClass)) break;
|
|
}
|
|
$controllers->push(new $controllerClass($widget));
|
|
}
|
|
|
|
return $controllers;
|
|
}
|
|
|
|
function forTemplate() {
|
|
return $this->renderWith($this->class);
|
|
}
|
|
}
|
|
|
|
?>
|