@param ElementInterface|Element\CollectionElement $element

@throws InvalidClassException

@return string
175211
public function render(ElementInterface $element): string
    {
        if (! $element instanceof Element\CollectionElement) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" has to implement "%s"',
                    $element->name(),
                    Element\CollectionElement::class
                )
            );
        }

        $row = $this->factory->create(FormRow::class);

        $html = array_reduce(
            $element->elements(),
            function ($html, ElementInterface $next) use ($element, $row) {
                // adding the CollectionElement name to the Element name and ID as prefix.
                $next->withAttribute('id', $element->name().'_'.$next->id());
                $next->withAttribute('name', $element->name().'['.$next->name().']');

                $html .= $row->render($next);

                return $html;
            },
            ''
        );

        $errors = $this->factory->create(Errors::class)
            ->render($element);
        $class = $errors !== ''
            ? 'form-table--has-errors'
            : '';

        return sprintf('%1$s<table class="form-table %2$s">%3$s</table>', $errors, $class, $html);
    }
97971
public function render(ElementInterface $element): string
    {
        if (! $element instanceof ErrorAwareInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" does not implement "%s"',
                    $element->name(),
                    ErrorAwareInterface::class
                )
            );
        }

        $errors = $element->errors();
        if (count($errors) < 1) {
            return '';
        }

        $html = array_reduce(
            $errors,
            function ($html, $error): string {
                $html .= sprintf(
                    $this->options['error'],
                    $error
                );

                return $html;
            },
            ''
        );

        return sprintf(
            $this->options['wrapper'],
            $html
        );
    }
521488
public function render(ElementInterface $element): string
    {
        if (! $element instanceof DescriptionAwareInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" does not implement "%s"',
                    $element->name(),
                    DescriptionAwareInterface::class
                )
            );
        }

        $description = $element->description();
        if ($description === '') {
            return '';
        }

        return sprintf(
            '<p %s>%s</p>',
            $this->attributesToString(
                [
                    'class' => 'form-row__description',
                ]
            ),
            $description
        );
    }
120366
public function resolveElement(Element $element)
    {
        $elementtype = $this->elementService->findElementtype($element);

        return $this->resolveElementtype($elementtype);
    }
493119
public function classNamespace(string $element, string $name = ''): string
    {
        $localNamespace = trim($this->getOption($element, 'namespace', ''), '\\');
        list($namespace, $name) = $this->parseName($name);

        if (!empty($namespace)) {
            $localNamespace .= '\\' . Inflector::classify($namespace);
        }

        if (empty($this->baseNamespace())) {
            return $localNamespace;
        }

        return trim($this->baseNamespace() . '\\' . $localNamespace, '\\');
    }
182077
public function convert(ElementInterface $element)
    {
        // Contents should have already been converted to Markdown by this point,
        // so we just need to add '>' symbols to each line.

        $markdown = '';

        $quote = trim($element->getValue());

        $lines = preg_split('/\r\n|\r|\n/', $quote);

        $total = count((array) $lines);

        foreach ($lines as $i => $line)
        {
            $markdown .= '> ' . $line . "\n";

            $newline = $i + 1 === $total;

            $newline && $markdown .= "\n";
        }

        return "\n\n" . $markdown;
    }
415899
public function className(string $element, string $name): string
    {
        list($namespace, $name) = $this->parseName($name);

        return Inflector::classify($name) . $this->elementPostfix($element);
    }
1216297
private function renderElementAsRow(Element $element) : string
    {
        $tr = new Tag('tr');

        $html = $this->renderCell('th', $element->getLabel()->render() . $this->renderErrors($element));
        $html .= $this->renderCell('td', $element->render());

        $tr->setHtmlContent($html);

        return $tr->render();
    }
790690
protected function renderElementIcon(ElementInterface $element)
    {
        $render = '';
        $icon   = $element->getOption('icon');
        if ($icon) {
            $iconHelper = $this->getIconHelper();
            $render     = $iconHelper($icon);
        }
        return $render;
    }
1069662
public function render(ElementInterface $element)
    {
        $escapeHtmlHelper    = $this->getEscapeHtmlHelper();
        $labelHelper         = $this->getLabelHelper();
        $elementHelper       = $this->getElementHelper();
        $elementErrorsHelper = $this->getElementErrorsHelper();

        $label           = $element->getLabel();
        $inputErrorClass = $this->getInputErrorClass();
        $elementErrors   = $elementErrorsHelper->render($element);

        // Does this element have errors ?
        if (!empty($elementErrors) && !empty($inputErrorClass)) {
            $classAttributes = ($element->hasAttribute('class') ? $element->getAttribute('class') . ' ' : '');
            $classAttributes = $classAttributes . $inputErrorClass;

            $element->setAttribute('class', $classAttributes);
        }

        $elementString = $elementHelper->render($element);

        if (isset($label) && '' !== $label) {
            // Translate the label
            if (null !== ($translator = $this->getTranslator())) {
                $label = $translator->translate(
                    $label,
                    $this->getTranslatorTextDomain()
                );
            }

            $label = $escapeHtmlHelper($label);
            $labelAttributes = $element->getLabelAttributes();

            if (empty($labelAttributes)) {
                $labelAttributes = $this->labelAttributes;
            }

            // Multicheckbox elements have to be handled differently as the HTML standard does not allow nested
            // labels. The semantic way is to group them inside a fieldset
            $type = $element->getAttribute('type');
            if ($type === 'multi_checkbox' || $type === 'radio') {
                $markup = sprintf(
                    '<fieldset><legend>%s</legend>%s</fieldset>',
                    $label,
                    $elementString
                );
            } else {
                if ($element->hasAttribute('id')) {
                    $labelOpen = $labelHelper($element);
                    $labelClose = '';
                    $label = '';
                } else {
                    $labelOpen  = $labelHelper->openTag($labelAttributes);
                    $labelClose = $labelHelper->closeTag();
                }

                if ($label !== '') {
                    $label = '<span>' . $label . '</span>';
                }

                switch ($this->labelPosition) {
                    case self::LABEL_PREPEND:
                        $markup = $labelOpen . $label . $elementString . $labelClose;
                        break;
                    case self::LABEL_APPEND:
                    default:
                        $markup = $labelOpen . $elementString . $label . $labelClose;
                        break;
                }
            }

            if ($this->renderErrors) {
                //$markup .= $elementErrors;
            }
        } else {
            if ($this->renderErrors) {
                $markup = $elementString;  //. $elementErrors;
            } else {
                $markup = $elementString;
            }
        }

        return $markup;
    }
1267499
public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        $url = $this->escapeUrl($this->getAuthoriseUrl());
        $disabled = false;
        //disable for ssl missing
        if (! $this->_isSecureUrl()) {
            $disabled = true;
        }

        $adminUser = $this->auth->getUser();
        $refreshToken = $adminUser->getRefreshToken();

        $title = ($refreshToken) ? __('Disconnect') : __('Connect');

        $url = ($refreshToken) ? $this->escapeUrl($this->getUrl(
            'dotdigitalgroup_email/studio/disconnect'
        )) : $url;

        return $this->getLayout()->createBlock(
            \Magento\Backend\Block\Widget\Button::class
        )
            ->setType('button')
            ->setLabel($title)
            ->setDisabled($disabled)
            ->setOnClick("window.location.href='" . $url . "'")
            ->toHtml();
    }
782447
public function render(ElementInterface $element): string
    {
        if (! $element instanceof LabelAwareInterface) {
            throw new InvalidClassException(
                sprintf(
                    'The given element "%s" does not implement "%s"',
                    $element->name(),
                    LabelAwareInterface::class
                )
            );
        }

        if ($element->label() === '') {
            return '';
        }

        $attributes = $element->labelAttributes();
        if (! isset($attributes['for'])) {
            $attributes['for'] = $element->id();
        }

        return sprintf(
            '<label %s>%s</label>',
            $this->attributesToString($attributes),
            $element->label()
        );
    }
130302
public function convert(ElementInterface $element)
    {
        $regex = '(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})';

        preg_match($regex, $value = $element->getValue(), $matches);

        if (! isset($matches[0]))
        {
            $value = mb_convert_case($value, MB_CASE_UPPER, 'UTF-8');
        }

        return "\n" . $value . "\n";
    }
1143596
protected function assertElement($element)
	{
		if ( !is_a($element, $this->elementClass) ) {
			$message = 'Collection element must be of "%s" class, but element of "%s" class given';

			throw new ElementCollectionException(
				sprintf($message, $this->elementClass, get_class($element)),
				ElementCollectionException::TYPE_ELEMENT_CLASS_MISMATCH
			);
		}

		return $this->acceptElement($element);
	}
301889
protected static function getName( ElementInterface $element )
    {
        $name = $element->getName();

        if ( $name === null || $name === '' )
        {
            throw new Exception\DomainException( sprintf(
                '%s requires that the element has an assigned name; none discovered',
                __METHOD__
            ) );
        }

        return $name . '[]';
    }
1343657
public function render(ElementInterface $element)
    {
        if (!$element instanceof SelectElement) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s requires that the element is of type Zend\Form\Element\Select',
                __METHOD__
            ));
        }

        $name   = $element->getName();
        if (empty($name) && $name !== 0) {
            throw new Exception\DomainException(sprintf(
                '%s requires that the element has an assigned name; none discovered',
                __METHOD__
            ));
        }

        $options = $element->getValueOptions();

        if (($emptyOption = $element->getEmptyOption()) !== null) {
            $options = array('' => $emptyOption) + $options;
        }

        $attributes = $element->getAttributes();
        $value      = $this->validateMultiValue($element->getValue(), $attributes);

        $attributes['name'] = $name;
        if (array_key_exists('multiple', $attributes) && $attributes['multiple']) {
            $attributes['name'] .= '[]';
        }
        $this->validTagAttributes = $this->validSelectAttributes;

        $figlet =  sprintf(
            '<div %s>
				<button class="btn btn-primary" type="button">' . $element->getLabel() . '</button>
				<button data-toggle="dropdown" class="btn btn-primary dropdown-toggle" type="button"><span class="caret"></span></button>
				<ul class="dropdown-menu">
        			%s
        		</ul>
			</div>',
			$this->createAttributesString($attributes),
            $this->renderOptions($options, $value)
        );

        $separator = $this->getSeparator();

        $captchaInput = $this->renderInputs($element);
        
        $pattern = '%s%s%s';
        return sprintf($pattern, $figlet, $separator, $captchaInput);
    }
1171100
protected function renderInstance(ElementInterface $element)
    {
        $value = $this->getElementValue($element);

        foreach ($this->classMap as $class => $pluginName) {
            if ($value instanceof $class) {
                return $this->renderHelper($pluginName, $value, $element);
            }
        }

        return;
    }