@param string|array $widget

@return Widget
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');
    }
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;
    }
119148
public function getWidgetName(Widget $widget)
    {
        $widgets = $this->container->getParameter('victoire_core.widgets');
        foreach ($widgets as $widgetParams) {
            if ($widgetParams['class'] === ClassUtils::getClass($widget)) {
                return $widgetParams['name'];
            }
        }

        throw new \Exception('Widget name not found for widget '.get_class($widget).'. Is this widget right declared in AppKernel ?');
    }
1058170
public function cmsWidget($widget)
    {
        $widget->setCurrentView($this->currentViewHelper->getCurrentView());

        try {
            $response = $this->widgetRenderer->renderContainer($widget, $widget->getCurrentView());
        } catch (\Exception $ex) {
            $response = $this->widgetExceptionHandler->handle($ex, $widget);
        }

        return $response;
    }
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";
    }
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;
    }
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;
    }
839246
public function removeWidget($id)
    {
        if (!(int)$id) return $this;
                    
		foreach($this->widgets as $key => $w) {
			if ($w->getId() == $id) {
				unset($this->widgets[$key]);
				return $this;  
			}
		}        
        return $this;  
    }
523101
public function getWidgetStaticContent(Widget $widget)
    {
        $reflect = new \ReflectionClass($widget);
        $widgetProperties = $reflect->getProperties();
        $parameters = ['widget' => $widget];
        $accessor = PropertyAccess::createPropertyAccessor();

        foreach ($widgetProperties as $property) {
            if (!$property->isStatic()) {
                $value = $accessor->getValue($widget, $property->getName());
                $parameters[$property->getName()] = $value;
            }
        }

        return $parameters;
    }
1137182
protected function addFullWidthWidget(string $widgetKey)
    {
        $this->layoutBuilt = false;

        $this->addRow(function(DashboardLayoutRow $row) use ($widgetKey) {
            $row->addWidget(12, $widgetKey);
        });

        return $this;
    }
212816
public function beginWidget($options=[],$tag='div')
    {
        $widget = Html::beginTag($tag,$options);
        $this->_widgets[] = $widget;
        return $widget;
        
    }
706815
public function normalize($widget): void
    {
        if (! property_exists($widget, 'cacheTags')) {
            $widget->cacheTags = [];
        } elseif (is_array($widget->cacheTags)) {
            $this->checkTagForString($widget);
        } else {
            $this->errorOut($widget);
        }
    }
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;
    }
997537
private function getWidgetContent(WidgetInterface $widget)
    {
        if (!isset($this->widgetContents[$widget->getName()])) {
            try {
                $this->widgetContents[$widget->getName()] = $widget->getContent();
            } catch (KernelHttpException $ex) {
                throw new HttpException($ex);
            }
        }

        return $this->widgetContents[$widget->getName()];
    }
870860
public function setWidgets($widgets)
    {
        $this->widgets = $widgets;

        foreach ($widgets as $widget) {
            $widget->setView($this);
        }

        return $this;
    }
444226
public function setWidgets(array $widgets)
    {
        $this->widgets = [];

        foreach ($widgets as $widgetIdent => $widget) {
            $this->addWidget($widgetIdent, $widget);
        }

        return $this;
    }
1350027
public function parseWidget($widget)
    {

        /**
         * Check if file in session exists
         */
        if(!isset($_SESSION['FILES'][$this->field->getColName()])){
            return false;
        }

        /**
         * Rename the file (move) to the new location with the new name
         */
        $ext = pathinfo($_SESSION['FILES'][$this->field->getColName()]['name'], PATHINFO_EXTENSION);
        $name = $this->field->uploadPath . '/' . $this->item->get('id') . '_' . $this->field->getColName() . '.' . $ext;

        if (move_uploaded_file($_SESSION['FILES'][$this->field->getColName()]['tmp_name'], TL_ROOT . '/' . $name)) {

            /**
             * Add File to the DBAFS
             */
            $dbafsFile = \Dbafs::addResource($name);

            /**
             * Remove file from session
             */
            unset($_SESSION['FILES'][$this->field->getColName()]);

            /**
             * Return UUID
             */

            return $dbafsFile->uuid;

        }

        return false;

    }