Convert config

@param \DOMDocument $source The source document

@return array
773652
public function convert($source)
    {
        $output = [];
        $xpath = new \DOMXPath($source);
        $this->metadata = [];

        /** @var $node \DOMNode */
        foreach ($xpath->query(implode(' | ', $this->nodeMap)) as $node) {
            $output = array_merge($output, $this->convertNode($node));
        }

        $result = ['data' => $output, 'metadata' => $this->metadata];

        return $result;
    }
263415
public function toXML( DOMDocument $dom )
    {
        if ( !$this->XMLStorable )
        {
            return false;
        }

        $itemNode = $dom->createElement( 'item' );

        foreach ( $this->attributes as $attrName => $attrValue )
        {
            switch ( $attrName )
            {
                case 'id':
                    $itemNode->setAttribute( 'id', $attrValue );
                    break;

                case 'action':
                    $itemNode->setAttribute( 'action', $attrValue );
                    break;

                default:
                    $node = $dom->createElement( $attrName );
                    $nodeValue = $dom->createTextNode( $attrValue );
                    $node->appendChild( $nodeValue );
                    $itemNode->appendChild( $node );
                    break;
            }
        }

        return $itemNode;
    }
155408
public function convert(DOMDocument $xmlDoc)
    {
        $xpath = new DOMXPath($xmlDoc);

        $elements = $xpath->query('//link|//embed|//embed-inline');

        /** @var \DOMElement $element */
        foreach ($elements as $element) {
            $location = null;

            if ($this->elementHasAttribute($element, 'object_id')) {
                try {
                    $contentInfo = $this->contentService->loadContentInfo(
                        $this->getElementAttribute($element, 'object_id')
                    );
                    $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
                } catch (APINotFoundException $e) {
                    if ($this->logger) {
                        $this->logger->warning(
                            'While generating links for xmltext, could not locate ' .
                            'Content object with ID ' . $this->getElementAttribute($element, 'object_id')
                        );
                    }
                } catch (APIUnauthorizedException $e) {
                    if ($this->logger) {
                        $this->logger->notice(
                            'While generating links for xmltext, unauthorized to load ' .
                            'Content object with ID ' . $this->getElementAttribute($element, 'object_id')
                        );
                    }
                }
            }

            if ($this->elementHasAttribute($element, 'node_id')) {
                try {
                    $location = $this->locationService->loadLocation(
                        $this->getElementAttribute($element, 'node_id')
                    );
                } catch (APINotFoundException $e) {
                    if ($this->logger) {
                        $this->logger->warning(
                            'While generating links for xmltext, could not locate ' .
                            'Location with ID ' . $this->getElementAttribute($element, 'node_id')
                        );
                    }
                } catch (APIUnauthorizedException $e) {
                    if ($this->logger) {
                        $this->logger->notice(
                            'While generating links for xmltext, unauthorized to load ' .
                            'Location with ID ' . $this->getElementAttribute($element, 'node_id')
                        );
                    }
                }
            }

            if ($location !== null) {
                $element->setAttribute('url', $this->urlAliasRouter->generate($location));
            }

            // Copy temporary URL if it exists and is not set at this point
            if (!$element->hasAttribute('url') && $element->hasAttribute(EmbedLinking::TEMP_PREFIX . 'url')) {
                $element->setAttribute('url', $element->getAttribute(EmbedLinking::TEMP_PREFIX . 'url'));
            }

            if ($this->elementHasAttribute($element, 'anchor_name')) {
                $anchor = '#' . $this->getElementAttribute($element, 'anchor_name');
                if (strpos($element->getAttribute('url'), $anchor) === false) {
                    $element->setAttribute(
                        'url',
                        $element->getAttribute('url') . '#' .
                        $this->getElementAttribute($element, 'anchor_name')
                    );
                }
            }
        }
    }
368062
private function reformatArray($source)
    {
        $result = array();

        foreach ($source as $data) {
            $result[$data[0]] = (isset($data[1])) ? $data[1] : '';
        }

        return $result;
    }
1193862
protected function getElementConfig(DOMElement $element)
	{
		$config = [];
		foreach ($element->attributes as $attribute)
		{
			$config[$attribute->name][] = $attribute->value;
		}
		foreach ($element->childNodes as $childNode)
		{
			if ($childNode instanceof DOMElement)
			{
				$config[$childNode->nodeName][] = $this->getValueFromElement($childNode);
			}
		}

		return $this->flattenConfig($this->convertValueTypes($config));
	}
888942
protected function parse($configuration)
    {
        $result = [];

        // Extract commands of Doozr from configuration
        foreach ($configuration as $root => $children) {
            foreach ($children as $key => $values) {
                foreach ($values as $node => $value) {
                    $dom   = [];
                    $doozr = [];

                    switch ($node) {
                        case 'tag':
                            $tag = $value;
                            break;
                        case 'properties':
                            $properties = $value;

                            // Get commands of form
                            foreach ($properties as $property => $value) {
                                if ($this->containsCommand($property) === true) {
                                    $doozr[] = [
                                        'method' => $this->getMethodByKey($property),
                                        'value'  => $value,
                                    ];
                                } else {
                                    $dom[$property] = $value;
                                }
                            }
                            break;
                    }
                }

                if (isset($result[$root]) === false) {
                    $result[$root] = [];
                }

                $result[$root][] = [
                    'dom'   => $dom,
                    'doozr' => $doozr,
                ];
            }
        }

        // After iterating all parts with the same logic shift child form to root -> only one possible!
        $result['form'] = $result['form'][0];

        $this->setConfiguration(array_to_object($result));
    }
1177347
protected function processNoDataDocument($source): NoDataDocument
    {
        $document = new NoDataDocument();

        $this->hydrateObject($document, $source);

        return $document;
    }
961994
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        return [
            '__identity' => $this->persistenceManager->getIdentifierByObject($source),
            '__type' => TypeHandling::getTypeForValue($source)
        ];
    }
433694
public static function fromPattern($source) {
        $source = preg_replace('/([\[\]\(\)\|]|\.\.\.)/', ' $1 ', $source);
        $source = preg_split('/\s+|(\S*<.*?'.'>)/', $source, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        return new static($source, DocoptFormatError::class);
    }
1187153
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        if (is_array($source)) {
            $result = [];
            /** @var NodeInterface $node */
            foreach ($source as $node) {
                $result[] = $node->getIdentifier();
            }
        } else {
            if ($source instanceof NodeInterface) {
                $result = $source->getIdentifier();
            } else {
                $result = '';
            }
        }

        return $result;
    }
516644
public function transform(string $config = ''): array
    {
        $config = \preg_replace('/^(<\?xml\ version="[^"]+"\ encoding="[^"]+"\?>)?(\n)?/i', '', $config);
        $parsed = [];
        if (!empty($config)) {
            $node = new \SimpleXMLElement($config);
            if ($node->count() > 0) {
                $parsed = $this->processNode($node->children());
            }
        }
        return $parsed;
    }
1144048
public static function getDOMDocument($source) 
    {
        if ($source instanceof DOMDOCUMENT) {
            return $source;
        }
        $source = self::getDocumentID($source);
        return $source
        ? self::$documents[$id]['document']
        : null;
    }
862253
public function importSourceNode($source)
    {
        $DOMDocument = new self();
        $DOMDocument->loadHTML($source);

        $this->metaNodes->import($DOMDocument->metaNodes);
        $this->headScriptNodes->import($DOMDocument->headScriptNodes);
        $this->bodyScriptNodes->import($DOMDocument->bodyScriptNodes);
        $this->linkNodes->import($DOMDocument->linkNodes);
        $this->styleContent->import($DOMDocument->styleContent);
        $this->headScriptContent->import($DOMDocument->headScriptContent);
        $this->bodyScriptContent->import($DOMDocument->bodyScriptContent);

        $bodyElement = $DOMDocument->getElementsByTagName('body')->item(0);

        if ($bodyElement->firstChild instanceof Dom\Element) {
            return $bodyElement->firstChild;
        } elseif ($bodyElement->firstChild instanceof \DOMText) {
            foreach ($bodyElement->childNodes as $childNode) {
                if ($childNode instanceof Dom\Element) {
                    return $childNode->cloneNode(true);
                    break;
                }
            }
        }

        return $bodyElement;
    }
147537
public function formatSource($source)
    {
        if (! is_object($source)) {
            return '';
        }

        $parts = [];

        if ($source->namespace) {
            $parts['namespace'] = $source->namespace . '::';
        }

        $parts['name'] = $source->name;
        $parts['line'] = ':' . $source->line;

        return implode($parts);
    }
388184
function convert($source) {

        $this->onConvert();

        $lines = explode(PHP_EOL, $source);
        $sectionName = null;
        $msgid = null;
        $msgstr = null;

        foreach ($lines as $line) {
            if (!empty($line)) {
                if ($line[0] === '#') { // Section
                    if ($msgid != null) { // If there is an Entry to send, send it
                        $this->onEntry($msgid, $msgstr);
                    }
                    if ($sectionName !== null) { // If there is an Section to end, end it
                        $this->afterSection($sectionName);
                    }

                    $sectionName = trim(str_replace('#', '', $line));

                    $msgid = null;
                    $msgstr = null;

                    $this->beforeSection($sectionName);

                } elseif (substr($line, 0, 6) === 'msgid ') { // Msg Id
                    if ($msgid != null) { // If there is an entry to send, send it
                        $this->onEntry($msgid, $msgstr);
                    }
                    preg_match('/^msgid \"(.*)\"\s*$/', $line, $matches);
                    $msgid = $matches[1];
                    $msgstr = null;

                } elseif (substr($line, 0, 7) === 'msgstr ') { // Msg Str
                    preg_match('/^msgstr \"(.*)\"\s*$/', $line, $matches);
                    $msgstr = $matches[1];

                } elseif (preg_match('/^\s*\"(.*)\"\s*$/', $line, $matches)) { // Add on MsgId or MsgStr
                    if ($msgstr === null) {
                        $msgid .= $matches[1];
                    } else {
                        $msgstr .= $matches[1];
                    }

                }
            }
        }

        if ($msgid != null) {
            $this->onEntry($msgid, $msgstr);
        }
        if ($sectionName !== null) {
            $this->afterSection($sectionName);
        }
        return $this->toString();
    }
786270
private function getDeletedFields(Source $source)
    {
        $fields = array();
        $fields += array(
            'undelete' => array(
                'type' => 'button',
                'value' => $this->t('undelete'),
                'ajax' => array(
                    'service' => 'entry_deletestatus_set',
                    'parent_type' => $this->source->getType(),
                    'parent_source' => $this->source->getId(),
                    'type' => $source->getType(),
                    'source' => $source->getId(),
                    'value' => API::Entry_Delete,
                ),
            ),
            'send' => array(
                'type' => 'button',
                'value' => $this->t('send_again'),
                'ajax' => array(
                    'service' => 'invoice_add',
                    'parent_type' => $this->source->getType(),
                    'parent_source' => $this->source->getId(),
                    'type' => $source->getType(),
                    'source' => $source->getId(),
                    'value' => 1,
                ),
            ),
        );
        return $fields;
    }
959791
public function defineTableAttributes($source = null)
    {
        $attributes = array(
            'title' => Craft::t('Title'),
        );

        // Allow plugins to modify the attributes
        craft()->plugins->call('modifyTagManagerTableAttributes', array(&$attributes, $source));

        return $attributes;
    }