@param mixed $widget

@return WidgetInterface
978637
protected function ___attainWidgetInstance($widget)
    {
        /** @var $widgetManager WidgetManager */
        $widgetManager = $this->sm->get('yimaWidgetator.WidgetManager');

        $options = [];
        if (is_array($widget)) {
            $wArg    = $widget;
            $widget  = $wArg['widget'];
            $options = (isset($wArg['params'])) ? $wArg['params'] : $options;
        }

        $instance = $widgetManager->get($widget, $options);

        return $instance;
    }
313401
protected static function initWidgetParameters($widget, array $parameters)
    {
        $param = var_export($parameters, true);
        $param = preg_replace("/'\\$(.*)',/isU", "\$\\1,", $param);
        $param = str_replace('\\\'', '\'', $param);

        return "<?php \$this->widget->setParameters($param);?>\n";
    }
74635
public function getWidgetData(AbstractWidget $widget)
    {
        $widgetViews = array(
            'views' => array('view' => $this->getView($widget, $widget->getWidgetType())),
        );

        return $widget->getCommonData() + $widgetViews + $widget->getData();
    }
570625
public function getResolverForWidget(Widget $widget)
    {
        $alias = $this->widgetHelper->getWidgetName($widget);

        return $this->getResolver($alias);
    }
640526
protected function runAjaxHandlerForWidget($widget, $handler)
    {
        $this->addViewPath($widget->getViewPaths());

        $result = call_user_func_array([$widget, $handler], $this->params);

        $this->vars = $widget->vars + $this->vars;

        return $result;
    }
297846
public function addType(WidgetTypeInterface $widget)
    {
        if (!$this->hasType($widget)) {
            $this->types[$widget->getName()] = $widget;
        } else {
            throw new \InvalidArgumentException(sprintf('Widget type "%s" is already registered.', $widget->getName()));
        }
    }
724563
public function getExtraCssClass(Widget $widget)
    {
        $cssClass = 'v-widget--'.strtolower($this->container->get('victoire_widget.widget_helper')->getWidgetName($widget));

        return $cssClass;
    }
853156
public function render(renderable $widget) {

        $namespacedclassname = get_class($widget);
        $plainclassname = preg_replace('/^.*\\\/', '', $namespacedclassname);
        $rendermethod = 'render_'.$plainclassname;

        if (method_exists($this, $rendermethod)) {
            // Explicit rendering method exists, fall back to the default behaviour.
            return parent::render($widget);
        }

        $interfaces = class_implements($namespacedclassname);

        if (isset($interfaces['templatable'])) {
            // Default implementation of template-based rendering.
            $data = $widget->export_for_template($this);
            return parent::render_from_template('tool_policy/'.$plainclassname, $data);

        } else {
            return parent::render($widget);
        }
    }
19986
public function run($widget)
    {
        $navigation = app('navigation')->findOrFail($widget->param('navigation_id'));

        if (! $navigation->menus()->count()) {
            return ''; // return empty string if navigation does not have menu items
        }

        return view($widget->present()->template(), [
            'config' => $this->config,
            'widget' => $widget,
            'menu'   => 'menu_' . $navigation->type,
        ]);
    }
421625
public function normalize($widget): void
    {
        list($controllerMethod, $ctrlClass) = $this->determineDataMethod($widget);

        $this->checkControllerExists($ctrlClass);
        $this->checkDataMethodExists($ctrlClass);

        $widget->controller = $controllerMethod;
    }
1103310
protected function addWidget(SharpWidget $widget)
    {
        $this->widgets[] = $widget;
        $this->dashboardBuilt = false;

        return $this;
    }
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;
    }
1220768
private function createWidget($widgetConfiguration, Plugin $plugin)
    {
        $widget = new Widget();
        $widget->setPlugin($plugin);

        $this->persistWidget($widgetConfiguration, $widget);

        return $widget;
    }
181021
public function getNewDataWidget($widgetType, User $user)
    {
        $widget = $this->widgetFactory->createDataWidget($widgetType);
        $widget
            ->setId(uniqid())
            ->setUser($user);

        return $widget;
    }
967832
function addWidget($regionBox, $widget, $priority = 0)
    {
        $this->__validateWidget($widget);

        $regionBox = (string) $regionBox;
        if (!array_key_exists($regionBox, $this->__widgets))
            $this->__widgets[$regionBox] = new PriorityQueue();

        /** @var PriorityQueue $queue */
        $queue = $this->__widgets[$regionBox];
        $queue->insert($widget, $priority);

        return $this;
    }
258526
public function layoutWidget($widget)
    {
        $cell = new TableCell;
        $cell->align( $this->labelColumnAlign );
        $cell->width( $this->labelColumnWidth );
        $cell->addClass( 'formkit-column-label' );
        if( $widget->label ) {
            $cell->addChild( new Label($widget->label) );
        }

        $cell2 = new TableCell;
        $cell2->align( $this->widgetColumnAlign );
        $cell2->width( $this->widgetColumnWidth );
        $cell2->addClass( 'formkit-column-widget' );
        $cell2->addChild( $widget );

        $row = new TableRow;
        $row->addChild($cell);
        $row->addChild($cell2);

        $this->body->addChild( $row );
        return $this;
    }
1275277
public function beginWidget($widget, $config = [])
    {
        $widget = $this->resolveClassName($widget);
        $this->widgets[] = $widget;
        return $this->call($widget, 'begin', [
            $config,
        ]);
    }