Generate the widget and return it as string

@return string
425529
public function generate()
	{
		$arrSet = array();
		$arrValues = array();
		$blnHasOrder = ($this->orderField != '' && \is_array($this->{$this->orderField}));

		if (!empty($this->varValue)) // can be an array
		{
			$objArticles = \ArticleModel::findMultipleByIds((array) $this->varValue);

			if ($objArticles !== null)
			{
				while ($objArticles->next())
				{
					$arrSet[] = $objArticles->id;
					$arrValues[$objArticles->id] = \Image::getHtml('articles' . ((!$objArticles->published || ($objArticles->start != '' && $objArticles->start > time()) || ($objArticles->stop != '' && $objArticles->stop < time())) ? '_' : '') . '.svg') . ' ' . $objArticles->title . ' (' . $objArticles->alias . \Config::get('urlSuffix') . ')';
				}
			}

			// Apply a custom sort order
			if ($blnHasOrder)
			{
				$arrNew = array();

				foreach ((array) $this->{$this->orderField} as $i)
				{
					if (isset($arrValues[$i]))
					{
						$arrNew[$i] = $arrValues[$i];
						unset($arrValues[$i]);
					}
				}

				if (!empty($arrValues))
				{
					foreach ($arrValues as $k=>$v)
					{
						$arrNew[$k] = $v;
					}
				}

				$arrValues = $arrNew;
				unset($arrNew);
			}
		}

		$return = '<input type="hidden" name="'.$this->strName.'" id="ctrl_'.$this->strId.'" value="'.implode(',', $arrSet).'">' . ($blnHasOrder ? '
  <input type="hidden" name="'.$this->strOrderName.'" id="ctrl_'.$this->strOrderId.'" value="'.$this->{$this->orderField}.'">' : '') . '
  <div class="selector_container">' . (($blnHasOrder && \count($arrValues) > 1) ? '
    <p class="sort_hint">' . $GLOBALS['TL_LANG']['MSC']['dragItemsHint'] . '</p>' : '') . '
    <ul id="sort_'.$this->strId.'" class="'.($blnHasOrder ? 'sortable' : '').'">';

		foreach ($arrValues as $k=>$v)
		{
			$return .= '<li data-id="'.$k.'">'.$v.'</li>';
		}

		$return .= '</ul>';

		if (!\System::getContainer()->get('contao.picker.builder')->supportsContext('article'))
		{
			$return .= '
	<p><button class="tl_submit" disabled>'.$GLOBALS['TL_LANG']['MSC']['changeSelection'].'</button></p>';
		}
		else
		{
			$extras = array
			(
				'fieldType' => $this->fieldType,
				'source' => $this->strTable.'.'.$this->currentRecord,
			);

			if (\is_array($this->rootNodes))
			{
				$extras['rootNodes'] = array_values($this->rootNodes);
			}

			$return .= '
	<p><a href="' . ampersand(\System::getContainer()->get('contao.picker.builder')->getUrl('article', $extras)) . '" class="tl_submit" id="at_' . $this->strName . '">'.$GLOBALS['TL_LANG']['MSC']['changeSelection'].'</a></p>
	<script>
	  $("at_' . $this->strName . '").addEvent("click", function(e) {
		e.preventDefault();
		Backend.openModalSelector({
		  "id": "tl_listing",
		  "title": "' . \StringUtil::specialchars(str_replace("'", "\\'", $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['label'][0])) . '",
		  "url": this.href + document.getElementById("ctrl_'.$this->strId.'").value,
		  "callback": function(table, value) {
			new Request.Contao({
			  evalScripts: false,
			  onSuccess: function(txt, json) {
				$("ctrl_' . $this->strId . '").getParent("div").set("html", json.content);
				json.javascript && Browser.exec(json.javascript);
			  }
			}).post({"action":"reloadArticletree", "name":"' . $this->strId . '", "value":value.join("\t"), "REQUEST_TOKEN":"' . REQUEST_TOKEN . '"});
		  }
		});
	  });
	</script>' . ($blnHasOrder ? '
	<script>Backend.makeMultiSrcSortable("sort_'.$this->strId.'", "ctrl_'.$this->strOrderId.'", "ctrl_'.$this->strId.'")</script>' : '');
		}

		$return = '<div>' . $return . '</div></div>';

		return $return;
	}
798136
public function toString()
    {
        $string = '';
        $properties = $this->getIterator();
        foreach ($properties as $property) {
            $string .= $property->toString();
        }

        return $string;
    }
464124
public function toString()
    {
        $serviceLocator = $this->getServiceLocator();
        
        $config = $serviceLocator->get('Config');
        
        $configWidgets = isset($config['modules']['Grid\Core']['beforeContentWidget'])
                         ? $config['modules']['Grid\Core']['beforeContentWidget']
                         : array();
        
        foreach ( $configWidgets as $serviceClass )
        {
            $service = $serviceLocator->get( $serviceClass );
            
            if ( $service instanceof ServiceLocatorAwareInterface )
            {
                $service->setServiceLocator( $serviceLocator );
            }
            
            $this->addWidget($service);
        }
        
        $view    = $this->getView();
        $content = '';

        /* @var $widget \Grid\Core\View\BeforeContentWidget\BeforeContentWidgetInterface */
        foreach ( $this->widgets as $widget )
        {
            $content .= $widget->render($view);
        }

        return $content;
    }
17931
public function render()
    {
        try {
            $this->vars['all'] = $this->getCounts()['all'];
            $this->vars['counts'] = $this->getCounts()['counts'];

        } catch (Exception $ex) {
            $this->vars['error'] = $ex->getMessage();
            $this->vars['all'] = 0;
            $this->vars['counts'] = [];
        }

        return $this->makePartial('widget');
    }
639219
public function make()
    {
        try {
            $args = func_get_args();
            $active = $args[1]['active'] ?? true;

            // If widget has non active status.
            if (! $active) {
                return false;
            }

            $this->widgetName = trim((string) array_shift($args));
            $this->widgetParams = (array) array_shift($args);
            $this->widget = $this->getWidget();

            return $this->getContentFromCache();
        } catch (\Exception $e) {
            return sprintf(
                trans('common.msg.error'), $e->getMessage()
            );
        }
    }
1371241
public function render()
    {
        if ($this->enable == false)
        {
            return '';
        }

        $widgetDir = $this->config->get('theme.containerDir.widget');

        $path = $this->theme->getThemeNamespace($widgetDir.'.'.$this->template);

        // If not found in theme widgets directory, try to watch in views/widgets again.
        if ($this->watch === true and ! $this->view->exists($path))
        {
            $path = $widgetDir.'.'.$this->template;
        }

        // Error file not exists.
        if ( ! $this->view->exists($path))
        {
            throw new UnknownWidgetFileException("Widget view [$this->template] not found.");
        }

        $widget = $this->view->make($path, $this->data)->render();

        return $widget;
    }
1172100
public function ToString()
	{
		$result = $this->LocalName;

		if ( ! empty( $this->Prefix ) )
		{
		    $result = $this->Prefix . ':' . $result;
		}
		return $result;
	}
760825
public function __toHtml()
    {
        try {
            $this->parse();
            $str = \Library\Helper\Html::writeHtmlTag(
                'script', null, array(
                    'src'=>$this->transformed_data['src'],
                    'type'=>$this->transformed_data['type']
                ), true
            );
        } catch (\Exception $e) {
            $str = $e->getMessage();
        }
        return $str;
    }
250971
public function generateLabel()
    {
        if ($this->strLabel === '') {
            return '';
        }

        return sprintf(
            '<span %s>%s%s</span>',
            ('' !== $this->strClass ? ' class="' . $this->strClass . '"' : ''),
            $this->strLabel,
            ($this->required ? '<span class="mandatory">*</span>' : '')
        );
    }
859985
public function generate(): string
    {
        // The tag name is required
        if ($this->getTag() === '') {
            return '';
        }

        // Generate the attribute string
        $tagAttributes = $this->generateTagAttributes();

        // When attributes are provided, add a space between the tag and the attributes
        $tagSeparator = '';
        if ($tagAttributes !== '') {
            $tagSeparator = ' ';
        }

        // Create the opening tag
        $openingTag = sprintf(
            '<%s%s%s>',
            $this->getTag(),
            $tagSeparator,
            $tagAttributes
        );

        // Create the closing tag
        $closingTag = '';
        if (! in_array($this->getTag(), self::SELF_CLOSING_TAGS)) {
            $closingTag = sprintf('</%s>', $this->getTag());
        }

        // Collect the tag information
        return $openingTag . $this->getText() . $closingTag;
    }
820002
public function renderBegin()
	{
		if($this->getParent() instanceof self)
			return '';
		else
		{
			$options=$this->activeForm;
			if(isset($options['class']))
			{
				$class=$options['class'];
				unset($options['class']);
			}
			else
				$class='CActiveForm';
			$options['action']=$this->action;
			$options['method']=$this->method;
			if(isset($options['htmlOptions']))
			{
				foreach($this->attributes as $name=>$value)
					$options['htmlOptions'][$name]=$value;
			}
			else
				$options['htmlOptions']=$this->attributes;
			ob_start();
			$this->_activeForm=$this->getOwner()->beginWidget($class, $options);
			return ob_get_clean() . "<div style=\"display:none\">".CHtml::hiddenField($this->getUniqueID(),1)."</div>\n";
		}
	}
945831
public function generate(): string
    {
        $classCode = $this->generator->generate();

        return $classCode
            // Inject advices on call
            . '\\' . __CLASS__ . '::injectJoinPoints(' . $this->generator->getName() . '::class);';
    }
290812
public function generate()
    {
        $toggle = clone $this->toggle;
        $toggle->addAttributes($this->attributes);
        $toggle->setLabel($toggle->getLabel() . ' ' . Bootstrap::getConfigVar('dropdown.toggle'));

        return sprintf(
            '%s<ul class="dropdown-menu">%s%s</ul>',
            $toggle,
            PHP_EOL,
            $this->generateChildren()
        );
    }
268273
public function render() {
		
		$model = $this->getParent()->getModel();
		$attribute = $this->name;
		$options = $this->generateGroupOptions();

		if (isset(self::$inputTypes[$this->type])) {
			$method = self::$inputTypes[$this->type];
			// FIXME ... why we are passing $this->attributes ... most all TbActiveForm method only require $options 
			return $this->getParent()->getActiveFormWidget()->$method($model, $attribute, $this->attributes, $options);
			/* no need for this as now data goes inside $options['widgetOptions']['data']
			switch ($method) {
				case 'listBoxGroup':
				case 'dropDownListGroup':
				case 'checkBoxListGroup':
				case 'radioButtonListGroup': 
					return $this->getParent()->getActiveFormWidget()->$method($model, $attribute, $this->attributes, $this->items, $options);

				default:
					return $this->getParent()->getActiveFormWidget()->$method($model, $attribute, $this->attributes, $options);
			}
			*/
		} else {
			$attributes = $this->attributes;
			$attributes['model'] = $this->getParent()->getModel();
			$attributes['attribute'] = $this->name;

			return $this->getParent()->getActiveFormWidget()->customFieldGroup(
				array(array($this->getParent()->getOwner(), 'widget'), array($this->type, $attributes, true)),
				$model,
				$attribute,
				$options
			);
		}
	}
735143
public function getWidget()
    {
        if ($this->widget === null) {
            $this->widget = $this->createWidget();
        }

        return $this->widget;
    }
495734
protected function renderIcon()
    {
        if (!$this->icon) {
            return '';
        }

        return Icon::widget([
            'name' => ArrayHelper::getValue($this->icon, 'name', null),
            'position' => ArrayHelper::getValue($this->icon, 'position', null),
            'options' => ArrayHelper::getValue($this->icon, 'options', [])
        ]);
    }
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;
    }