Create options

@param \SimpleXMLElement $node

@return array
180731
private function createOptions(\SimpleXMLElement $node)
    {
        $options = array();

        if (isset($node->attributes()->domain)) {
            $options['domain'] = (string) $node->attributes()->domain;
        }

        if (isset($node->attributes()->locale)) {
            $options['locale'] = (string) $node->attributes()->locale;
        }

        foreach ($node->parameter as $parameter) {
            $options['parameters'][(string) $parameter->attributes()->name] = (string) $parameter->attributes()->value;
        }

        return $options;
    }
1268297
public static function arrayToXml(\DOMDocument $xml, \DOMNode $node, $array = [])
    {
        foreach ($array as $el => $val) {
            if (is_array($val)) {
                self::arrayToXml($xml, $node->$el, $val);
            } else {
                $node->appendChild($xml->createElement($el, $val));
            }
        }
        return $xml;
    }
61063
protected function _getOptions(&$node)
	{
		$v = (int) $node['client_id'];
		$clientId = $v ? $v : 0;

		$options = array();
		$path1 = null;
		$path2 = null;

		// Load template entries for each menuid
		$db = App::get('db');
		$query = $db->getQuery()
			->select('template')
			->from('#__template_styles')
			->whereEquals('client_id', (int) $clientId)
			->whereEquals('home', '1');
		$db->setQuery($query->toString());
		$template = $db->loadResult();

		if ($module = (string) $node['module'])
		{
			$base = ($clientId == 1) ? PATH_CORE : PATH_CORE;
			$module = preg_replace('#\W#', '', $module);
			$path1 = PATH_CORE . '/modules/' . $module . '/tmpl';
			$path2 = PATH_APP . '/templates/' . $template . '/html/' . $module;
			$options[] = Builder\Select::option('', '');
		}

		if ($path1 && $path2)
		{
			$path1 = Util::normalizePath($path1);
			$path2 = Util::normalizePath($path2);

			$files = App::get('filesystem')->files($path1, '^[^_]*\.php$');
			foreach ($files as $file)
			{
				$options[] = Builder\Select::option(App::get('filesystem')->extension($file));
			}

			if (is_dir($path2) && $files = App::get('filesystem')->files($path2, '^[^_]*\.php$'))
			{
				$options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT'));
				foreach ($files as $file)
				{
					$options[] = Builder\Select::option(App::get('filesystem')->extension($file));
				}
				$options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT'));
			}
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::_getOptions($node), $options);

		return $options;
	}
1331195
protected static function DOMNodeAttributes(DOMNode $node)
    {
        $attributes = array();

        foreach ($node->attributes as $attribute) {
            $attributes[$attribute->name] = $attribute->value;
        }

        return $attributes;
    }
193428
protected function getHTMLNodeInner($node, $xml, $settings)
    {
        if (!empty($this->title)) {
            $node->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title]));
        }
        $node->appendChild(
            $inner = $xml->createElement('div', 'c-container' . (empty($this->title) ? ' no-title' : ''))
        );

        $inner->appendChild(
            $xml->createElement(
                'input',
                [
                    'type' => 'checkbox',
                    'name' => $this->variable,
                    'data-variable' => $this->variable,
                    'data-save-value' => $this->save,
                    'class' => 'switch',
                    'value' => $this->value,
                    'checked' => $this->checked ? 'checked' : null
                ]
            )
        );

        $inner->appendChild($switch = $xml->createElement('div'));
        $switch->appendChild($slider = $xml->createElement('div', ['class' => 'slider']));

        $slider->appendChild($xml->createElement('div', ['class' => 'on', 'text' => 'ON']));
        $slider->appendChild($xml->createElement('div', ['class' => 'divider']));
        $slider->appendChild($xml->createElement('div', ['class' => 'off', 'text' => 'OFF']));
    }
27247
private function parseAppenderReferences(\SimpleXMLElement $node) {
		$refs = array();
		foreach($node->appender_ref as $ref) {
			$refs[] = $this->getAttributeValue($ref, 'ref');
		}
		
		foreach($node->{'appender-ref'} as $ref) {
			$refs[] = $this->getAttributeValue($ref, 'ref');
		}

		return $refs;
	}
974369
protected function getOptionsNodes(NodeBuilder $node)
    {
        return $node
            ->scalarNode('branch')
                ->info('The branch to deploy')
                ->defaultValue('master')
            ->end()
            ->scalarNode('shallow')
                ->info("Whether your VCS should do a \"shallow\" clone of the repository or not - this means a clone with just the latest state of your application (no history).\nIf you're having problems cloning, try setting this to false")
                ->defaultTrue()
            ->end()
            ->scalarNode('submodules')
                ->info("Recursively pull in submodules.\nWorks only with Git")
                ->defaultTrue()
            ->end();
    }
202034
private function addNodeJSConfiguration(NodeBuilder $node)
    {
        $node
            ->arrayNode('node')
            ->addDefaultsIfNotSet()
            ->children()
                ->arrayNode('binary')
                    ->addDefaultsIfNotSet()
                    ->beforeNormalization()
                    ->ifString()
                        ->then(function ($value) {
                            return [
                                'win32'     => $value,
                                'win64'     => $value,
                                'linux_x32' => $value,
                                'linux_x64' => $value,
                                'darwin'    => $value,
                                'fallback'  => $value,
                            ];
                        })
                    ->end()
                    ->children()
                        ->scalarNode('win32')->defaultValue('node')->end()
                        ->scalarNode('win64')->defaultValue('node')->end()
                        ->scalarNode('linux_x32')->defaultValue('node')->end()
                        ->scalarNode('linux_x64')->defaultValue('node')->end()
                        ->scalarNode('darwin')->defaultValue('node')->end()
                        ->scalarNode('fallback')->defaultValue('node')->end()
                    ->end()
                ->end()
                ->scalarNode('npm_packages_path')->defaultNull()->end()
                ->scalarNode('node_modules_path')->defaultNull()->end()
            ->end();
    }
107576
public function getParamTypeInfos(Node $node): array
    {
        if ($node->getDocComment() === null) {
            return [];
        }

        $phpDocInfo = $this->createPhpDocInfoFromNode($node);
        $types = $phpDocInfo->getParamTagValues();

        if ($types === []) {
            return [];
        }

        $fqnTypes = $phpDocInfo->getParamTagValues();

        $paramTypeInfos = [];
        /** @var AttributeAwareParamTagValueNode $paramTagValueNode */
        foreach ($types as $i => $paramTagValueNode) {
            $fqnParamTagValueNode = $fqnTypes[$i];

            $paramTypeInfo = new ParamTypeInfo(
                $paramTagValueNode->parameterName,
                $this->typeAnalyzer,
                $paramTagValueNode->getAttribute(Attribute::TYPE_AS_ARRAY),
                $fqnParamTagValueNode->getAttribute(Attribute::RESOLVED_NAMES)
            );

            $paramTypeInfos[$paramTypeInfo->getName()] = $paramTypeInfo;
        }

        return $paramTypeInfos;
    }
180175
private function createOptionElement($xml, $key, $value)
    {
        $option = $xml->createElement('option');
        $this->addAttributes($option, ['value' => $key]);

        $text = $xml->createTextNode($value);
        $option->appendChild($text);

        return $option;
    }
1099908
public function create(DOMElement $node)
    {
        $item = new Item();
        $this->setProperties($node, $item);
        $this->setLink($node, $item);
        $this->setAuthor($node, $item);
        $this->setDate($node, $item);
        $this->setTags($node, $item);
        $this->executeAggregators($node, $item);

        if (!$item->getIntro()) {
            $item->setIntro($item->getContent());
        }

        return $item;
    }
1156536
private function createUses_(GroupUse $node): array
    {
        return array_map(
            static function (UseUse $use) use ($node): Use_ {
                $newUse = new UseUse(
                    Name::concat($node->prefix, $use->name, $use->name->getAttributes()),
                    $use->alias,
                    $use->type,
                    $use->getAttributes()
                );

                return new Use_(
                    [$newUse],
                    $node->type,
                    $node->getAttributes()
                );
            },
            $node->uses
        );
    }
746448
public function mutate(Node $node)
    {
        return new Node\Expr\Assign($node->var, $node->expr, $node->getAttributes());
    }
1077722
public static function getChildElements($node)
    {
        $ret = array();
        $nodes = $node->childNodes;
        foreach ($nodes as $node) {
            if ($node instanceof DOMElement) {
                array_push($ret, $node);
            }
        }
        return $ret;
    }
312554
final protected function _setRoot($node = 'root')
	{
		if (is_string($node)) {
			$this->body = $this->appendChild($this->createElement($node));
		} elseif (is_object($node) and $node instanceof \DOMNode) {
			$this->body = $this->appendChild($node);
		} else {
			trigger_error(
				sprintf('$node must be either a DOMNode or string, %s given', gettype($node)),
				E_USER_WARNING
			);
		}
		return $this;
	}
1367902
public static function dom2str($node)
    {
        $doc = $node instanceof DOMDocument? $node : $node->ownerDocument;
        return $doc->saveXML($node);
    }
1238844
protected function getOptions()
	{
		$options = array();

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $option */
		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			$text = $this->translateOptions
				? $this->getText()->alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname))
				: trim((string) $option);

			// Create a new option object based on the <option /> element.
			$tmp = $select->option((string) $option['value'], $text, 'value', 'text', ((string) $option['disabled'] == 'true'));

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}