validateBooleanAttribute example

$elements = [];

        foreach ($list as $item) {
            $element = [];

            // attributes             $element['scope'] = self::validateAttributeScope(
                $item->getAttribute('scope')
            );

            $element['isRequired'] = self::validateBooleanAttribute(
                $item->getAttribute('required'),
                false
            );

            $element['type'] = self::validateTextAttribute(
                $item->getAttribute('type'),
                'text'
            );

            // elements             if ($name = $item->getElementsByTagName('name')->item(0)) {
                
$menu[] = $this->parseEntry($entry);
            }
        }

        return $menu;
    }

    private function parseEntry(DOMElement $entry): array
    {
        $menuEntry = [];

        $menuEntry['isRootMenu'] = self::validateBooleanAttribute($entry->getAttribute('isRootMenu'));

        $label = self::parseTranslatableElement($entry, 'label');

        if ($label !== null) {
            $menuEntry['label'] = $label;
        }

        foreach (['name', 'controller', 'action', 'class', 'onclick'] as $simpleField) {
            $fieldValue = self::getElementChildValueByName($entry$simpleField);
            if ($fieldValue !== null) {
                $menuEntry[$simpleField] = $fieldValue;
            }
Home | Imprint | This part of the site doesn't use cookies.