Remove some legacy code, no need to pipe WidgetMaker thru WidgetManager

This commit is contained in:
Samuel Georges 2015-01-05 13:12:48 +11:00
parent b74b19741b
commit f4487076b7
2 changed files with 10 additions and 35 deletions

View File

@ -2,12 +2,10 @@
use Str;
use File;
use Lang;
use Closure;
use October\Rain\Support\Yaml;
use Illuminate\Container\Container;
use System\Classes\PluginManager;
use System\Classes\SystemException;
/**
* Widget manager
@ -57,34 +55,6 @@ class WidgetManager
$this->pluginManager = PluginManager::instance();
}
/**
* Makes a widget object with configuration set.
* @param string $className A widget class name.
* @param Controller $controller The Backend controller that spawned this widget.
* @param array $configuration Configuration values.
* @return WidgetBase The widget object.
*/
public function makeWidget($className, $controller = null, $configuration = null)
{
/*
* Build configuration
*/
if ($configuration === null) {
$configuration = [];
}
/*
* Create widget object
*/
if (!class_exists($className)) {
throw new SystemException(Lang::get('backend::lang.widget.not_registered', [
'name' => $className
]));
}
return new $className($controller, $configuration);
}
//
// Form Widgets
//

View File

@ -1,5 +1,6 @@
<?php namespace Backend\Traits;
use Lang;
use Backend\Classes\WidgetManager;
use System\Classes\SystemException;
@ -19,14 +20,18 @@ trait WidgetMaker
* Makes a widget object with the supplied configuration file.
* @param string $class Widget class name
* @param array $configuration An array of config.
* @return WidgetBase The widget or null
* @return WidgetBase The widget object
*/
public function makeWidget($class, $configuration = null)
public function makeWidget($class, $configuration = [])
{
$controller = ($this->controller) ?: $this;
$manager = WidgetManager::instance();
$widget = $manager->makeWidget($class, $controller, $configuration);
return $widget;
if (!class_exists($class)) {
throw new SystemException(Lang::get('backend::lang.widget.not_registered', [
'name' => $class
]));
}
return new $class($controller, $configuration);
}
}