mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 15:05:54 +00:00
Updated AvailableWidgets
I updated AvailableWidgets to check for a static array called $only_available_in. This way you can determine which Widget you want to show up in which WidgetArea
This commit is contained in:
parent
6167c701f3
commit
df56737d3c
@ -37,12 +37,19 @@ class WidgetAreaEditor extends FormField {
|
||||
public function AvailableWidgets() {
|
||||
|
||||
$widgets= new ArrayList();
|
||||
|
||||
|
||||
foreach($this->widgetClasses as $widgetClass) {
|
||||
$classes = ClassInfo::subclassesFor($widgetClass);
|
||||
if(count($classes) > 1) array_shift($classes);
|
||||
array_shift($classes);
|
||||
foreach($classes as $class) {
|
||||
$widgets->push(singleton($class));
|
||||
|
||||
if (!empty($class::$only_available_in) && is_array($class::$only_available_in)){
|
||||
if(in_array($this->Name, $class::$only_available_in)) {
|
||||
$widgets->push(singleton($class));
|
||||
}
|
||||
}else {
|
||||
$widgets->push(singleton($class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user