Generate ASN.1 structure.

@throws \LogicException
@return Element
336594
public function toASN1(): Element
    {
        switch ($this->_type) {
            case Element::TYPE_OCTET_STRING:
                return new OctetString($this->_value);
            case Element::TYPE_UTF8_STRING:
                return new UTF8String($this->_value);
            case Element::TYPE_OBJECT_IDENTIFIER:
                return new ObjectIdentifier($this->_value);
        }
        throw new \LogicException(
            "Type " . Element::tagToName($this->_type) . " not supported.");
    }
174464
public function generate()
	{
		if (TL_MODE === 'BE') {
			return parent::generate();
		}

		$parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];
		if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])) {
			if (!$GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) {
				trigger_error('Missing column stop element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING);
			}
			unset($GLOBALS['TL_RS_COLUMNS'][$parentKey]);
		}
		else {
			trigger_error('Missing column wrapper start element before column wrapper stop element ID ' . $this->id . '.', E_USER_WARNING);
		}

		$htmlSuffix = '';

		if (!empty($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey])) {
			$GLOBALS['TL_RS_COLUMNS'][$parentKey] = array_pop($GLOBALS['TL_RS_COLUMNS_STACK'][$parentKey]);
			if ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']) {
				$htmlSuffix .= '</div>';
			}
		}

		return parent::generate() . $htmlSuffix;
	}
474439
public function root() : ContainerElement
    {
        // no need to check anything else, we are at the top
        if ($this instanceof Speak) {
            return $this;
        }

        // loop until we find an element that has no parent
        $currentParent = $this->parent;
        while ($currentParent->parent !== null) {
            $currentParent = $currentParent->parent;
        }

        return $currentParent;
    }
828257
public function generate(): string
    {
        $elements = [];
        if ($this->label != '') {
            $elements[] = Tags::legend($this->label, []);
        }
        foreach ($this->elements as $element) {
            /** @noinspection PhpUndefinedMethodInspection */
            $elements[] = $element->generate();
        }
        return Tags::fieldset($elements, $this->attributes);
    }
1032511
public function getDescription()
    {
        if (empty($this->description)) {
            throw new LogicException(
                sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'description')
            );
        }
        return $this->description;
    }
1022796
public function remove()
    {
        if ($this->node->parentNode === null) {
            throw new LogicException('Can not remove element without parent node');
        }

        $removedNode = $this->node->parentNode->removeChild($this->node);

        return new Element($removedNode);
    }
770021
protected function initialize()
    {
        if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) {
            throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName));
        }

        if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) {
            throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type')));
        }

        $this->value = null;
        $this->options = [];
        $this->multiple = false;

        if ('input' == $this->node->nodeName) {
            $this->type = strtolower($this->node->getAttribute('type'));
            $optionValue = $this->buildOptionValue($this->node);
            $this->options[] = $optionValue;

            if ($this->node->hasAttribute('checked')) {
                $this->value = $optionValue['value'];
            }
        } else {
            $this->type = 'select';
            if ($this->node->hasAttribute('multiple')) {
                $this->multiple = true;
                $this->value = [];
                $this->name = str_replace('[]', '', $this->name);
            }

            $found = false;
            foreach ($this->xpath->query('descendant::option', $this->node) as $option) {
                $optionValue = $this->buildOptionValue($option);
                $this->options[] = $optionValue;

                if ($option->hasAttribute('selected')) {
                    $found = true;
                    if ($this->multiple) {
                        $this->value[] = $optionValue['value'];
                    } else {
                        $this->value = $optionValue['value'];
                    }
                }
            }

            // if no option is selected and if it is a simple select box, take the first option as the value
            if (!$found && !$this->multiple && !empty($this->options)) {
                $this->value = $this->options[0]['value'];
            }
        }
    }
526310
protected function getURIElements()
    {
        if (isset($this->uriElements)) {
            return $this->uriElements;
        } elseif (!isset($this->request)) {
            return array();
        }

        $elements = array_slice(
            explode('/', $this->request->pathinfo),
            1,
            $this->elementNumber
        );

        // If one of the elements is empty, we do not match.
        foreach ($elements as $element) {
            if ($element === '') {
                throw new LogicException('One of the URI elements was empty');
            }
        }

        if (count($elements) !== $this->elementNumber) {
            throw new LogicException('The number of provided elements to consider is different than the number of elements found in the URI');
        }

        return $this->uriElements = $elements;
    }
1002951
public function toASN1(): Sequence
    {
        $values = array_map(
            function (AttributeValue $value) {
                return $value->toASN1();
            }, $this->_values);
        $valueset = new Set(...$values);
        return new Sequence($this->_type->toASN1(), $valueset->sortedSetOf());
    }
1271595
public function writeEndElement(): self
    {
        if ($this->isFinished()) {
            throw new \LogicException('Can not write end elements, no element open.');
        }

        $this->doWriteEndElement();
        $this->depth--;
        return $this;
    }
121640
protected function getElementsArrayText()
    {
        $elements = array();
        foreach ($this->elements as $element) {
            $elementId            = $element->getItem()
                                            ->getId();
            $elements[$elementId] = $element->getControl()
                                            ->getId();
        }
        return Builder::getArray($elements, true);
    }
639787
public function style()
    {
        if ($this->styleAttribute !== null) {
            return $this->styleAttribute;
        }

        if (!$this->isElementNode()) {
            throw new LogicException('Style attribute is available only for element nodes');
        }

        $this->styleAttribute = new StyleAttribute($this);

        return $this->styleAttribute;
    }
878945
public function toASN1(): Sequence
    {
        $elements = array_values(
            array_map(
                function ($ext) {
                    return $ext->toASN1();
                }, $this->_extensions));
        return new Sequence(...$elements);
    }
1279838
public function generate()
	{
		$this->loadLanguageFile('rocksolid_custom_elements');

		$toolbar = '<div class="rsce_list_toolbar">';
		$toolbar .= '<a class="header_new" href="" onclick="rsceNewElement(this);return false;">' . $GLOBALS['TL_LANG']['rocksolid_custom_elements']['new_list_item'] . '</a> ';
		$toolbar .= '</div>';

		$classes = ['tl_box', 'rsce_list'];
		$fs = \System::getContainer()->get('session')->getBag('contao_backend')->get('fieldset_states');

		if (
			(isset($fs[$this->strTable][$this->strId]) && !$fs[$this->strTable][$this->strId])
			|| (!isset($fs[$this->strTable][$this->strId]) && !empty($this->arrConfiguration['collapsed']))
		) {
			$classes[] = 'collapsed';
		}

		$config = array(
			'minItems' => $this->minItems,
			'maxItems' => $this->maxItems,
		);

		return '</fieldset>'
			. '<div class="clear"></div>'
			. '<fieldset'
			. ' id="pal_' . $this->strId . '"'
			. ' class="' . implode(' ', $classes) . '"'
			. ' data-config="' . htmlspecialchars(json_encode($config), ENT_QUOTES) . '"'
			. '>'
			. '<legend'
			. ' onclick="AjaxRequest.toggleFieldset(this, &quot;' . $this->strId . '&quot;, &quot;' . $this->strTable . '&quot;)"'
			. '>' . $this->strLabel
			. '</legend>'
			. $toolbar
			. ($this->description ? '<p class="rsce_list_description">' . $this->description . '</p>' : '');
	}
494687
public function create()
    {
        $pdo = null;
        try {
            $pdo = $this->connect();
        } catch (\Exception $e) {
            $pdo = null;
            if ($this->isLostConnection($e)) {
                $pdo = $this->reconnect();
            }

            throw new \LogicException('Connection lost and no reconnector available.');
        }

        return $pdo;
    }
546432
public static function generate()
    {
        $registry = static::create();

        // Look in a cache (if provided) for type details
        if (static::$cache && ($types = static::$cache->get(self::CACHE_KEY))) {
            $registry->elementTypes = $types;
            return $registry;
        }

        // Find all element types
        $classNames = ClassInfo::getValidSubClasses(BaseElement::class);
        foreach ($classNames as $class) {
            // Skip the "abstract" element
            if ($class === BaseElement::class) {
                continue;
            }
            $registry->registerElement($class);
        }

        return $registry;
    }
962921
public function renderContent()
    {
        if (is_object($this->content) && !method_exists($this->content, '__toString')) {
            throw new \LogicException('Cannot render content: it is an object without __toString method!');
        }

        if (is_array($this->content)) {
            throw new \LogicException('Cannot render content: it is an array!');
        }

        return (string) $this->content;
    }