Makes a widget object with the supplied configuration file.
@param string $class Widget class name
@param array $widgetConfig An array of config.
@return \Backend\Classes\WidgetBase The widget object
340191
public function makeWidget($class, $widgetConfig = [])
    {
        $controller = property_exists($this, 'controller') && $this->controller
            ? $this->controller
            : $this;

        if (!class_exists($class)) {
            throw new SystemException(Lang::get('backend::lang.widget.not_registered', [
                'name' => $class
            ]));
        }

        return new $class($controller, $widgetConfig);
    }
104962
static public function createObject($type, array $config = [])
	{
		if (is_string($type)) {
			return static::container()->get($type, $config);
		} elseif (is_array($type) && isset($type['class'])) {
			$class = $type['class'];
			unset($type['class']);
			if ($config) $type = array_merge($type, $config); 
			return static::container()->get($class, $type);
		} elseif (is_callable($type, false)) {
			return call_user_func($type, $config);
		} elseif (is_object($type)) {
			return $type;
		} elseif (is_array($type)) {
			throw new InvalidConfigException('object configuration must be an array containing a "class" element.');
		} else {
			throw new InvalidConfigException("Unsupported configuration type: " . gettype($type));
		}
	}
35278
public static function getPropertyAnnotations($class, $property)
    {
        $annotationBag = Bridge\Loader::getInstance()->getPropertyAnnotations($class, str_replace('$', '', $property));
        $annotationBag = self::explodeNamespaces($annotationBag);

        return new ConfigObject($annotationBag);
    }
1245092
def createWidget( self, parent ):
        
        widget = self.widgetClass()(parent, self.uiFile())
        widget.setPlugin(self)
        return widget
1330693
protected function makeReportWidget($alias, $widgetInfo)
    {
        $configuration = $widgetInfo['configuration'];
        $configuration['alias'] = $alias;

        $className = $widgetInfo['class'];
        if (!class_exists($className)) {
            return;
        }

        $widget = new $className($this->controller, $configuration);
        $widget->bindToController();

        return ['widget' => $widget, 'sortOrder' => $widgetInfo['sortOrder']];
    }
344052
public function renderWidget( $config = [] ) {

		$widgetHtml = $this->render( $this->template, [
			'login' => $this->login,
			'loginDisabled' => $this->loginDisabled,
			'loginMessage' => $this->loginMessage,
			'forgotPassword' => $this->forgotPassword,
			'registerDisabled' => $this->registerDisabled,
			'registerMessage' => $this->registerMessage,
			'register' => $this->register,
			'label' => $this->label,
			'fieldIcon' => $this->fieldIcon,
			'optionalFields' => $this->optionalFields,
			'actions' => $this->actions,
			'widget' => $this
		]);

		if( $this->wrap ) {

			return Html::tag( $this->wrapper, $widgetHtml, $this->options );
		}

		return $widgetHtml;
	}
1316016
protected function buildFactory($factoryClass)
    {
        $factory = $factoryClass::newInstance();
        $factory->setConfig($this->config);
        $factory->validateConfig();

        return $factory;
    }
1206331
protected function createProjectConfiguration(stdClass $config = null)
    {
        if (null === $config) {
            return new ProjectConfiguration(
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                $this->defaultCacheDir()
            );
        }

        $configData = new ObjectAccess($config);

        $cacheDir = $configData->getDefault('cache-dir');
        if (null === $cacheDir) {
            $cacheDir = $this->defaultCacheDir();
        }

        return new ProjectConfiguration(
            $configData->getDefault('process-timeout'),
            $configData->getDefault('use-include-path'),
            $this->createInstallationMethod(
                $configData->getDefault('preferred-install')
            ),
            $configData->getDefault('github-protocols'),
            $this->objectToArray($configData->getDefault('github-oauth')),
            $configData->getDefault('vendor-dir'),
            $configData->getDefault('bin-dir'),
            $cacheDir,
            $configData->getDefault('cache-files-dir'),
            $configData->getDefault('cache-repo-dir'),
            $configData->getDefault('cache-vcs-dir'),
            $configData->getDefault('cache-files-ttl'),
            $configData->getDefault('cache-files-maxsize'),
            $configData->getDefault('prepend-autoloader'),
            $configData->getDefault('autoloader-suffix'),
            $configData->getDefault('optimize-autoloader'),
            $configData->getDefault('github-domains'),
            $configData->getDefault('notify-on-install'),
            $this->createVcsChangePolicy(
                $configData->getDefault('discard-changes')
            ),
            $configData->data()
        );
    }
864833
private function updateWidget($widgetConfiguration, Plugin $plugin)
    {
        /** @var Widget $widget */
        $widget = $this->em
            ->getRepository('ClarolineCoreBundle:Widget\Widget')
            ->findOneBy(['name' => $widgetConfiguration['name']]);

        if (is_null($widget)) {
            return $this->createWidget($widgetConfiguration, $plugin);
        } else {
            return $this->persistWidget($widgetConfiguration, $widget);
        }
    }
687357
protected function _resolveWidget($widget)
    {
        $type = gettype($widget);
        if ($type === 'object') {
            return $widget;
        }

        if ($type === 'string') {
            $widget = [$widget];
        }

        $class = array_shift($widget);
        $className = App::className($class, 'View/Widget', 'Widget');
        if ($className === false || !class_exists($className)) {
            throw new RuntimeException(sprintf('Unable to locate widget class "%s"', $class));
        }
        if ($type === 'array' && count($widget)) {
            $reflection = new ReflectionClass($className);
            $arguments = [$this->_templates];
            foreach ($widget as $requirement) {
                $arguments[] = $this->get($requirement);
            }
            $instance = $reflection->newInstanceArgs($arguments);
        } else {
            $instance = new $className($this->_templates);
        }
        if (!($instance instanceof WidgetInterface)) {
            throw new RuntimeException(sprintf('"%s" does not implement the WidgetInterface', $className));
        }

        return $instance;
    }
1176711
public function widget(string $widgetType): WidgetInterface
    {
        //====================================================================//
        // Build Widgets Type Index Key
        $index = get_class($this->getConnector())."::".$widgetType;

        //====================================================================//
        // If Widgets Manager is New
        if (!isset($this->widgetManagers[$index])) {
            $this->widgetManagers[$index] = new Manager($this->getConnector(), $widgetType);
        }

        //====================================================================//
        // Return Widgets Manager
        return $this->widgetManagers[$index];
    }
247540
protected function widgetFactory()
    {
        if ($this->widgetFactory === null) {
            throw new RuntimeException(sprintf(
                'Widget Factory is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->widgetFactory;
    }
163220
protected function createWidget($widget): Widget
    {
        if (is_string($widget)) {
            return new Widget($widget);
        } elseif (is_array($widget)) {
            return new Widget($widget[0], $widget[1]);
        }

        throw new \InvalidArgumentException('Could not create widget from the passed arguments');
    }
558609
public function renderWidget( $config = [] ) {

		if( !isset( $this->title ) ) {

			switch( $this->template ) {

				case 'message': {

					$this->title = 'Message';

					break;
				}
				case 'success': {

					$this->title = 'Success';

					break;
				}
				case 'warning': {

					$this->title = 'Alert';

					break;
				}
				case 'error': {

					$this->title = 'Error';

					break;
				}
			}
		}

		if( !isset( $this->size ) ) {

			if( $this->modal && in_array( $this->template, [ 'message', 'success', 'warning', 'error' ] ) ) {

				$this->size = 'medium';
			}
		}

		$widgetHtml = $this->render( $this->template, [
			'widget' => $this
		]);

		return $widgetHtml;
	}
534784
public function getConfig($class)
    {
        $key = strtolower($class);
        if (isset($this->cache)) {
            $found = false;
            $cached = $this->cache->get($key, "JsonConfig", $found);
            if ($found) {
                return $cached;
            }
        }
        $config = $this->_getConfig($class);

        if (isset($this->cache)) {
            $this->cache->set($key, $config, "JsonConfig");
        }
        return $config;
    }
763958
private function persistWidget($widgetConfiguration, Widget $widget)
    {
        $widget->setName($widgetConfiguration['name']);
        $widget->setContext(isset($widgetConfiguration['context']) ? $widgetConfiguration['context'] : []);
        $widget->setSources(isset($widgetConfiguration['sources']) ? $widgetConfiguration['sources'] : []);
        $widget->setClass(isset($widgetConfiguration['class']) ? $widgetConfiguration['class'] : null);
        $widget->setExportable($widgetConfiguration['exportable']);
        $widget->setTags(isset($widgetConfiguration['tags']) ? $widgetConfiguration['tags'] : []);

        $this->em->persist($widget);

        return $widget;
    }
915820
public function renderWidget( $config = [] ) {

		$gallery		= $this->gallery;
		$items 			= [];
		$galleryHtml	= '';

		// Paths
		$wrapperPath	= $this->template . '/wrapper';
		$itemPath		= $this->template . '/item';

		// Generate Items Html

		$gitems = $gallery->files;

	    foreach( $gitems as $item ) {

	        $items[] = $this->render( $itemPath, [ 'item' => $item ] );
	    }

		$itemsHtml		= implode( "\n", $items );

		$galleryHtml	= $this->render( $wrapperPath, [ 'gallery' => $gallery, 'itemsHtml' => $itemsHtml ] );

		return $galleryHtml;
	}