widgets = WidgetTypesWithHandlers::getSimple(); } /** * Method used for registering new widgets * * @param $classname */ public function register($classname) { $class = new $classname; if (!$class instanceof PublicWidget) { throw new InvalidArgumentException($class . ' must implement PublicWidget interface.'); } // register widget as new widget type if (!in_array($classname, $this->widgets)) { $widgetName = call_user_func($classname . '::getName'); $widgetDescription = call_user_func($classname . '::getDescription'); // create row in widget types WidgetType::create([ 'handler' => $classname, 'name' => $widgetName, 'description' => $widgetDescription ]); // install widget (if neccessary) call_user_func($classname . '::install'); } } }