FIX Use ModuleLoader for requirement resolution and typo in exception in Widget::getController

This commit is contained in:
Robbie Averill 2017-09-14 14:16:45 +12:00
parent 7c85b1b5d9
commit 9b12b602f5
2 changed files with 5 additions and 4 deletions

View File

@ -40,8 +40,9 @@ class WidgetAreaEditor extends FormField
*/
public function FieldHolder($properties = array())
{
Requirements::css('widgets/css/WidgetAreaEditor.css');
Requirements::javascript('widgets/javascript/WidgetAreaEditor.js');
$module = ModuleLoader::getModule('silverstripe/widgets');
Requirements::css($module->getRelativeResourcePath('css/WidgetAreaEditor.css'));
Requirements::javascript($module->getRelativeResourcePath('javascript/WidgetAreaEditor.js'));
return $this->renderWith(WidgetAreaEditor::class);
}

View File

@ -250,7 +250,7 @@ class Widget extends DataObject
}
/**
* @throws Exception
* @throws Exception If the widget controller's class name couldn't be found
*
* @return WidgetController
*/
@ -268,7 +268,7 @@ class Widget extends DataObject
}
if (!class_exists($controllerClass)) {
throw new Exception("Could not find controller class for get_class($this)name");
throw new Exception('Could not find controller class for ' . $controllerClass);
}
$this->controller = Injector::inst()->create($controllerClass, $this);