This function is for the manipulation of the attribute value
Must return the value in the format what is needed for MetaModels

@param $widget
@return mixed
162265
public function parseWidget($widget)
    {

        if(is_a($widget, 'Contao\FormTextArea') || is_a($widget, 'Contao\FormTextField')){

            if($this->field->getEval('allowHtml')){
                $value = strip_tags(\String::decodeEntities($widget->value), \Config::get('allowedTags'));
            }else{
                $value = strip_tags(\String::decodeEntities($widget->value));
            }

            if($this->field->getEval('decodeEntities')){
                return $value;
            }else{
                return specialchars($value);
            }
        }

        return $widget->value;
    }
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;
    }
861606
protected function renderWidget()
    {
        if ($this->hasModel()) {
            $this->model->{$this->attribute} = $this->model->{$this->attribute} ? Yii::$app->formatter->asDate($this->model->{$this->attribute}, 'medium') : null;
        }
        return parent::renderWidget();
    }
1283139
public static function get()
    {
        $list = new static;

        $widgets = StaticContainer::get('Piwik\Plugin\WidgetsProvider');

        $widgetContainerConfigs = $widgets->getWidgetContainerConfigs();
        foreach ($widgetContainerConfigs as $config) {
            if ($config->isEnabled()) {
                $list->addWidgetConfig($config);
            }
        }

        $widgetConfigs = $widgets->getWidgetConfigs();
        foreach ($widgetConfigs as $widget) {
            if ($widget->isEnabled()) {
                $list->addWidgetConfig($widget);
            }
        }

        $reports = StaticContainer::get('Piwik\Plugin\ReportsProvider');
        $reports = $reports->getAllReports();
        foreach ($reports as $report) {
            if ($report->isEnabled()) {
                $factory = new ReportWidgetFactory($report);
                $report->configureWidgets($list, $factory);
            }
        }

        /**
         * Triggered to filter widgets.
         *
         * **Example**
         *
         *     public function removeWidgetConfigs(Piwik\Widget\WidgetsList $list)
         *     {
         *         $list->remove($category='General_Visits'); // remove all widgets having this category
         *     }
         *
         * @param WidgetsList $list An instance of the WidgetsList. You can change the list of widgets this way.
         */
        Piwik::postEvent('Widget.filterWidgets', array($list));

        return $list;
    }
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;
    }
1170461
public function getWidget($widgetType, $widgetId, User $user)
    {
        /** @var \Icap\PortfolioBundle\Repository\Widget\AbstractWidgetRepository $abstractWidgetRepository */
        $abstractWidgetRepository = $this->entityManager->getRepository('IcapPortfolioBundle:Widget\AbstractWidget');
        $widget = $abstractWidgetRepository->findOneByWidgetType($widgetType, $widgetId, $user);

        return $widget;
    }
1164289
private function processWidget($options) {
		$property = str_replace('detail_', '', $options['widget']);
		// determine object
		if ($options['type'] == 'tabs' || $options['type'] == 'fields') {
			$object = & $this->collection_object->primary_model;
		} else if ($options['type'] == 'subdetails') {
			$object = \Factory::model($options['details_parent_key'], true);
		}
		if (!empty($object->{$property})) {
			return \Factory::model($object->{"{$property}_model"}, true)->formProcessWidget($this, $options);
		}
		return false;
	}
1115011
public function parameters($id, $widget)
    {
        $widget    = Widget::withoutGlobalScope('menu_assignment')->findOrNew($widget);
        $extension = $this->repository->findOrFail($id);
        $formView  = $extension->param('form');

        if (view()->exists($formView)) {
            return view($formView, compact('widget'));
        }

        return view('widgets.partials.none');
    }
1016888
def widgetValue( widget ):
    
    for wtype in reversed(_widgetValueTypes):
        if isinstance(widget, wtype[0]):
            try:
                return (wtype[1](widget), True)
            except:
                return (None, False)
    return (None, False)
602435
public function getWidget($alias)
    {
        if (!isset($this->widgets[$alias])) {
            throw new WidgetException(sprintf('View widget with alias "%s" does not exist.', $alias));
        }

        return $this->widgets[$alias];
    }
122752
public function widgetId()
    {
        if (!$this->widgetId) {
            $type = $this->type();
            switch ($type) {
                case static::PROPERTY_DISPLAY:
                    $id = $this->display()->displayId();
                    break;

                case static::PROPERTY_CONTROL:
                    $id = $this->input()->inputId();
                    break;

                default:
                    $id = 'widget_'.uniqid();
                    break;
            }

            $this->widgetId = $id;
        }

        return $this->widgetId;
    }
498514
public function hasWidget($widgets): bool
    {
        // Single Widget id
        if (is_string($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget id
        if (is_int($widgets)) {
            return $this->widgets->contains('id', $widgets);
        }

        // Single Widget model
        if ($widgets instanceof WidgetModelContract) {
            return $this->widgets->contains('id', $widgets->id);
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_string($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Array of Widget ids
        if (is_array($widgets) && isset($widgets[0]) && is_int($widgets[0])) {
            return ! $this->widgets->pluck('id')->intersect($widgets)->isEmpty();
        }

        // Collection of Widget models
        if ($widgets instanceof Collection) {
            return ! $widgets->intersect($this->widgets->pluck('id'))->isEmpty();
        }

        return false;
    }
1141987
public function loadRichTextEditor($buffer, Widget $widget)
    {
        if ((null === $widget->rte)
            || ((0 !== (\strncmp($widget->rte, 'tiny', 4)))
                && (0 !== \strncmp($widget->rte, 'ace', 3)))
        ) {
            return $buffer;
        }

        $backendAdapter        = $this->framework->getAdapter(Backend::class);
        $templateLoaderAdapter = $this->framework->getAdapter(TemplateLoader::class);

        [$file, $type] = \explode('|', $widget->rte);

        $templateName = 'be_' . $file;
        // This test if the rich text editor template exist.
        $templateLoaderAdapter->getDefaultPath($templateName, 'html5');

        $template = new ContaoBackendViewTemplate($templateName);
        $template
            ->set('selector', 'ctrl_' . $widget->id)
            ->set('type', $type);

        if (0 !== \strncmp($widget->rte, 'tiny', 4)) {
            /** @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0 */
            $template->set('language', $backendAdapter->getTinyMceLanguage());
        }

        $buffer .= $template->parse();

        return $buffer;
    }
229201
public function decodeValue(DecodePropertyValueForWidgetEvent $event)
    {
        if (('attr_id' !== $event->getProperty())
            || ('tl_metamodel_filtersetting' !== $event->getEnvironment()->getDataDefinition()->getName())
        ) {
            return;
        }

        $model     = $event->getModel();
        $metaModel = $this->filterFactory->createCollection($model->getProperty('fid'))->getMetaModel();
        $value     = $event->getValue();

        if (!($metaModel && $value)) {
            return;
        }

        $attribute = $metaModel->getAttributeById($value);
        if ($attribute) {
            $event->setValue($metaModel->getTableName() .'_' . $attribute->getColName());
        }
    }
392855
public function getWidgetQueryContent(Widget $widget)
    {
        $parameters = $this->getWidgetStaticContent($widget);

        $entity = $this->getWidgetQueryBuilder($widget)
                        ->setMaxResults(1)
                        ->getQuery()
                        ->getOneOrNullResult();

        $fields = $widget->getFields();
        $this->populateParametersWithWidgetFields($widget, $entity, $parameters);

        return $parameters;
    }
247024
public function normalizeWidgetConfig($widget): void
    {
        // to avoid normalizing a widget multiple times unnecessarily :
        if (isset($widget->isNormalized)) {
            return;
        }

        foreach ($this->normalizers as $normalizer) {
            $normalizer->normalize($widget);
        }

        $widget->isNormalized = true;
    }
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;
    }