@param DOMElement $definition

@return array
178557
protected function parseOperationData($definition)
    {
        $crawler = new Crawler($definition);

        $operationFilter = $crawler->filter('h2');
        $operation = str_replace(' ', '', $operationFilter->first()->text());

        $uriData = $crawler->filter('.uri div');

        preg_match('|[^/]*([^\n]*)\n|', $uriData->text(), $matches);
        $uri = $matches[1];

        $uriParams = array();
        if (strpos($uri, ':') !== false) {
            preg_match_all('|(:[^/]*)|', $uri, $uriParams);
            $uriParams = array_shift($uriParams);
        }

        $method = $uriData->filter('.muted')->text();

        $summaryNode = $crawler->filter('.leading-top p');
        $summary = ($summaryNode->count() > 0) ? $summaryNode->text() : null;

        $parameterList = $crawler->filter('dl.rounded-all dt span');
        $params = array();
        foreach ($parameterList as $parameter) {
            /* @var $parameter DOMElement */

            $params[$parameter->textContent] = array(
                'required' => ($parameter->getAttribute('class') == 'param_required'),
                'location' => ($method == 'GET') ? 'query' : 'postField',
            );
        }

        if (isset($uriParams) && count($uriParams) > 0) {
            foreach ($uriParams as $param) {
                $params[str_replace(':', '', $param)] = array(
                    'required' => true,
                    'location' => 'uri',
                );
            }
        }

        //Update Operation
        if ($method == 'GET') {
            $operation = ucfirst(strtolower($method).$operation);
        }

        return array(
            'operation'  => $operation,
            'httpMethod' => $method,
            'uri'        => $uri,
            'summary'    => $summary,
            'parameters' => $params,
        );
    }
772898
public function getNamespaces(\DOMElement $element = null)
    {
        if ($this->xpath === null) {
            $this->xpath = new \DOMXPath($this);
        }

        if ($element === null) {
            $nodes = $this->xpath->query('namespace::*');
        } else {
            $nodes = $this->xpath->query('namespace::*', $element);
        }

        $ns = array();

        if ($nodes) {
            foreach ($nodes as $node) {
                $arr = $element->getAttribute($node->nodeName);

                if ($arr) {
                    $ns[$node->nodeName] = $arr;
                }
            }

            $nodes = null;
        }

        return $ns;
    }
593
protected function parseArgs(DOMElement $element)
    {
        $args = XmlUtil::getChildElements($element, 'arg');
        foreach ($args as $arg) {
            $name = XmlUtil::getRequiredAttributeValue($arg, 'name');
            $this->args[$name] = XmlUtil::getText($arg);
        }
    }
49134
public function arrayToFunctionElement(array $definition)
    {
        $function = new Functions;
        if (isset($definition['docblock'])) {
            $docblock = $this->arrayToDocblockElement($definition['docblock']);
            $function->setDocbloc($docblock);
        }
        if (isset($definition['public'])) {
            $function->isPublic(true);
        }
        if (isset($definition['name'])) {
            $function->setName($definition['name']);
        }
        if (isset($definition['params'])) {
            foreach ($definition['params'] as $name => $type) {
                $function->addParam($name, $type);
            }
        }
        if (isset($definition['content'])) {
            $function->setContent($definition['content']);
        }
        return $function;
    }
429044
public function getRootMF(DOMElement $context = null) {
		// start with mf2 root class name xpath
		$xpaths = array(
			'contains(concat(" ",normalize-space(@class)), " h-")'
		);

		// add mf1 root class names
		foreach ( $this->classicRootMap as $old => $new ) {
			$xpaths[] = '( contains(concat(" ",normalize-space(@class), " "), " ' . $old . ' ") )';
		}

		// final xpath with OR
		$xpath = '//*[' . implode(' or ', $xpaths) . ']';

		$mfElements = (null === $context)
			? $this->xpath->query($xpath)
			: $this->xpath->query('.' . $xpath, $context);

		return $mfElements;
	}
1170230
public function equals(Definition $definition): bool
    {
        if (get_class($this) !== get_class($definition)) {
            return false;
        }

        if (null !== $this->type xor null !== $definition->type) {
            return false;
        }

        if (null !== $this->type && null !== $definition->type && !$this->type->equals($definition->type)) {
            return false;
        }

        if (null !== $this->moreInfo xor null !== $definition->moreInfo) {
            return false;
        }

        if (null !== $this->moreInfo && null !== $definition->moreInfo && !$this->moreInfo->equals($definition->moreInfo)) {
            return false;
        }

        if (null !== $this->extensions xor null !== $definition->extensions) {
            return false;
        }

        if (null !== $this->name xor null !== $definition->name) {
            return false;
        }

        if (null !== $this->description xor null !== $definition->description) {
            return false;
        }

        if (null !== $this->name) {
            if (count($this->name) !== count($definition->name)) {
                return false;
            }

            foreach ($this->name as $language => $value) {
                if (!isset($definition->name[$language])) {
                    return false;
                }

                if ($value !== $definition->name[$language]) {
                    return false;
                }
            }
        }

        if (null !== $this->description) {
            if (count($this->description) !== count($definition->description)) {
                return false;
            }

            foreach ($this->description as $language => $value) {
                if (!isset($definition->description[$language])) {
                    return false;
                }

                if ($value !== $definition->description[$language]) {
                    return false;
                }
            }
        }

        if (null !== $this->extensions && null !== $definition->extensions && !$this->extensions->equals($definition->extensions)) {
            return false;
        }

        return true;
    }
870894
protected function extractParameters(\stdClass $definition)
    {
        $parameters = [];

        if (isset($definition->parameters)) {
            foreach ($definition->parameters as $parameterDefinition) {
                $parameters[] = $this->createParameter($parameterDefinition);
            }
        }

        return $parameters;
    }
882451
public function newInputFilter(array $definition = array())
    {
        if (!empty($definition)) {
            $this->_definition = $definition;
        }
        $this->_inputFilter = new InputFilter();

        foreach ($this->_definition as $key => $item) {
            if (!is_string($key)) {
                $key = $item['name'];
            }
            $this->_addInput($item, $key);
        }

        return $this->_inputFilter;
    }
996428
private function buildOptionValue(\DOMElement $node): array
    {
        $option = array();

        $defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
        $defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
        $option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue;
        $option['disabled'] = $node->hasAttribute('disabled');

        return $option;
    }
1274726
public function splitDefinition(InputDefinition $definition)
    {
        /** @var InputDefinition[] $ret */
        $ret = array(
            new InputDefinition(),
            new InputDefinition()
        );

        foreach ($definition->getArguments() as $arg) {
            $ret[0]->addArgument($arg);
            $ret[1]->addArgument($arg);
        }
        foreach ($definition->getOptions() as $opt) {
            $ret[$this->isHiddenOption($opt) ? 1 : 0]->addOption($opt);
        }
        return $ret;
    }
234794
private function convertDefinitionToPhpArray(Definition $definition)
    {
        $definitionArray = [];
        if ($definition->isSynthetic()) {
            $definitionArray = $this->convertSyntheticDefinitionToPhpArray($definition);
        }

        $this->hydrateDefinitionClass($definition, $definitionArray);
        $this->hydrateDefinitionArguments($definition, $definitionArray);
        $this->hydrateDefinitionFactory($definition, $definitionArray);
        $this->hydrateDefinitionTags($definition, $definitionArray);
        $this->hydrateDefinitionMethodCalls($definition, $definitionArray);
        $this->hydrateDefinitionConfigurator($definition, $definitionArray);
        $this->hydrateDefinitionParent($definition, $definitionArray);
        $this->hydrateDefinitionScopeProperty($definition, $definitionArray);
        $this->hydrateDefinitionPublicProperty($definition, $definitionArray);
        $this->hydrateDefinitionAbstractProperty($definition, $definitionArray);
        $this->hydrateDefinitionFileProperty($definition, $definitionArray);

        return $definitionArray;
    }
687517
public function getAssociatedTags(EntityDefinition $definition, Entity $entity, Context $context): array
    {
        $associations = $definition->getFields()->filterInstance(AssociationField::class);

        $keys = [$this->getEntityTag($entity->getUniqueIdentifier(), $definition)];

        foreach ($context->getLanguageIdChain() as $languageId) {
            $keys[] = $this->getEntityTag($languageId, $this->languageDefinition);
        }

        $translationDefinition = $definition->getTranslationDefinition();

        if ($translationDefinition) {
            /* @var EntityDefinition $translationDefinition */
            $keys[] = $translationDefinition->getEntityName() . '.language_id';
        }

        /** @var AssociationField[] $associations */
        foreach ($associations as $association) {
            if ($association->is(Extension::class)) {
                $value = $entity->getExtension($association->getPropertyName());
            } else {
                try {
                    $value = $entity->get($association->getPropertyName());
                } catch (\Exception $e) {
                    continue;
                }
            }

            if (!$value) {
                continue;
            }

            if ($association instanceof ManyToOneAssociationField || $association instanceof OneToOneAssociationField) {
                /* @var Entity $value */
                $nested = $this->getAssociatedTags($association->getReferenceDefinition(), $value, $context);
                foreach ($nested as $key) {
                    $keys[] = $key;
                }

                continue;
            }

            if ($association instanceof OneToManyAssociationField) {
                /** @var Entity[] $value */
                foreach ($value as $item) {
                    $nested = $this->getAssociatedTags($association->getReferenceDefinition(), $item, $context);
                    foreach ($nested as $key) {
                        $keys[] = $key;
                    }
                }

                continue;
            }

            if ($association instanceof ManyToManyAssociationField) {
                /** @var Entity[] $value */
                foreach ($value as $item) {
                    $nested = $this->getAssociatedTags($association->getToManyReferenceDefinition(), $item, $context);
                    foreach ($nested as $key) {
                        $keys[] = $key;
                    }
                }
            }
        }

        return array_keys(array_flip($keys));
    }
1007482
public function listGetConfig($definition = null)
    {
        if (!$definition) {
            $definition = $this->primaryDefinition;
        }

        if (!$config = array_get($this->listConfig, $definition)) {
            $config = $this->listConfig[$definition] = $this->makeConfig($this->listDefinitions[$definition], $this->requiredConfig);
        }

        return $config;
    }
126229
private function loadProperties(&$tags, \DOMXPath $xpath, \DOMNode $context): array
    {
        $result = [];

        /** @var \DOMElement $node */
        foreach ($xpath->query('x:*', $context) as $node) {
            if ('property' === $node->tagName) {
                $value = $this->loadProperty($xpath, $node, $tags);
                $result[$value['name']] = $value;
            } elseif ('block' === $node->tagName) {
                $value = $this->loadBlock($xpath, $node, $tags);
                $result[$value['name']] = $value;
            } elseif ('section' === $node->tagName) {
                $value = $this->loadSection($xpath, $node, $tags);
                $result[$value['name']] = $value;
            }
        }

        return $result;
    }
907602
protected function getFieldsetElements(ElementInterface $element, FieldsetInterface $fieldset)
    {
        $elementName = $this->normalizeElementName($element->getName());

        if ($fieldset->has($elementName) && $fieldset->get($elementName) === $element) {
            return array_merge($fieldset->getElements(), $fieldset->getFieldsets());
        }

        if ($fieldset instanceof Element\Collection && (
            ($elements = $this->getFieldsetElements($element, $fieldset->getTargetElement())) ||
            (($template = $fieldset->getTemplateElement()) &&
                ($elements = $this->getFieldsetElements($element, $template)))
        )) {
            return $elements;
        }

        foreach ($fieldset->getFieldsets() as $fieldsetElement) {
            if ($elements = $this->getFieldsetElements($element, $fieldsetElement)) {
                return $elements;
            }
        }

        return [];
    }
1098406
protected function cloneAndEmpty(DOMElement $element)
    {
        $clone = $element->cloneNode(true);

        $children = [];

        // Collect child nodes first, as we can't iterate and
        // remove from \DOMNodeList directly
        foreach ($clone->childNodes as $node) {
            $children[] = $node;
        }

        foreach ($children as $node) {
            $clone->removeChild($node);
        }

        return $clone;
    }
189470
public static function run($definition) {
		$definition = Helper::isEnabledComponent($definition);
		if(!$definition) {
			return null;
		}
		$object = self::create($definition);
		if(method_exists($object, 'isEnabled') && !$object->isEnabled()) {
			return null;
		}
		$result = $object->run();
		return [
			'object' => $object,
			'config' => $definition,
			'result' => $result,
		];
	}