Parse input structure.

@param array $data
@param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher

@todo Error handling

@return \eZ\Publish\API\Repository\Values\ContentType\ContentType[]
544751
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $contentTypes = array();
        foreach ($data['ContentType'] as $rawContentTypeData) {
            $contentTypes[] = $parsingDispatcher->parse(
                $rawContentTypeData,
                $rawContentTypeData['_media-type']
            );
        }

        return $contentTypes;
    }
557018
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $creatorId = $this->parserTools->parseObjectElement($data['Creator'], $parsingDispatcher);
        $modifierId = $this->parserTools->parseObjectElement($data['Modifier'], $parsingDispatcher);

        return new Values\ContentType\ContentTypeGroup(
            array(
                'id' => $data['_href'],
                'identifier' => $data['identifier'],
                'creationDate' => new \DateTime($data['created']),
                'modificationDate' => new \DateTime($data['modified']),
                'creatorId' => $creatorId,
                'modifierId' => $modifierId,
            )
        );
    }
393595
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $roles = array();
        foreach ($data['Role'] as $rawRoleData) {
            $roles[] = $parsingDispatcher->parse(
                $rawRoleData,
                $rawRoleData['_media-type']
            );
        }

        return $roles;
    }
847204
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $contentInfoId = $this->requestParser->parseHref($data['Content']['_href'], 'contentId');

        return new Values\Content\VersionInfo(
            $this->contentService,
            array(
                'id' => $data['id'],
                'versionNo' => $data['versionNo'],
                'status' => $this->convertVersionStatus($data['status']),
                'modificationDate' => new \DateTime($data['modificationDate']),
                'creatorId' => $data['Creator']['_href'],
                'creationDate' => new \DateTime($data['creationDate']),
                'initialLanguageCode' => $data['initialLanguageCode'],
                'languageCodes' => explode(',', $data['languageCodes']),
                'names' => $this->parserTools->parseTranslatableList($data['names']),
                'contentInfoId' => $contentInfoId,
            )
        );
    }
934776
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('LocationCreate', $data) || !is_array($data['LocationCreate'])) {
            throw new Exceptions\Parser("Missing or invalid 'LocationCreate' element for ContentCreate.");
        }

        $locationCreateStruct = $this->locationCreateParser->parse($data['LocationCreate'], $parsingDispatcher);

        if (!array_key_exists('ContentType', $data) || !is_array($data['ContentType'])) {
            throw new Exceptions\Parser("Missing or invalid 'ContentType' element for ContentCreate.");
        }

        if (!array_key_exists('_href', $data['ContentType'])) {
            throw new Exceptions\Parser("Missing '_href' attribute for ContentType element in ContentCreate.");
        }

        if (!array_key_exists('mainLanguageCode', $data)) {
            throw new Exceptions\Parser("Missing 'mainLanguageCode' element for ContentCreate.");
        }

        $contentType = $this->contentTypeService->loadContentType(
            $this->requestParser->parseHref($data['ContentType']['_href'], 'contentTypeId')
        );

        $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, $data['mainLanguageCode']);

        if (array_key_exists('Section', $data) && is_array($data['Section'])) {
            if (!array_key_exists('_href', $data['Section'])) {
                throw new Exceptions\Parser("Missing '_href' attribute for Section element in ContentCreate.");
            }

            $contentCreateStruct->sectionId = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
        }

        if (array_key_exists('alwaysAvailable', $data)) {
            $contentCreateStruct->alwaysAvailable = $this->parserTools->parseBooleanValue($data['alwaysAvailable']);
        }

        if (array_key_exists('remoteId', $data)) {
            $contentCreateStruct->remoteId = $data['remoteId'];
        }

        if (array_key_exists('modificationDate', $data)) {
            $contentCreateStruct->modificationDate = new DateTime($data['modificationDate']);
        }

        if (array_key_exists('User', $data) && is_array($data['User'])) {
            if (!array_key_exists('_href', $data['User'])) {
                throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentCreate.");
            }

            $contentCreateStruct->ownerId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
        }

        if (!array_key_exists('fields', $data) || !is_array($data['fields']) || !is_array($data['fields']['field'])) {
            throw new Exceptions\Parser("Missing or invalid 'fields' element for ContentCreate.");
        }

        foreach ($data['fields']['field'] as $fieldData) {
            if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
                throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for ContentCreate.");
            }

            $fieldDefinition = $contentType->getFieldDefinition($fieldData['fieldDefinitionIdentifier']);
            if (!$fieldDefinition) {
                throw new Exceptions\Parser(
                    "'{$fieldData['fieldDefinitionIdentifier']}' is invalid field definition identifier for '{$contentType->identifier}' content type in ContentCreate."
                );
            }

            if (!array_key_exists('fieldValue', $fieldData)) {
                throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in ContentCreate.");
            }

            $fieldValue = $this->fieldTypeParser->parseValue($fieldDefinition->fieldTypeIdentifier,
                $fieldData['fieldValue']);

            $languageCode = null;
            if (array_key_exists('languageCode', $fieldData)) {
                $languageCode = $fieldData['languageCode'];
            }

            $contentCreateStruct->setField($fieldData['fieldDefinitionIdentifier'], $fieldValue, $languageCode);
        }

        return new RestContentCreateStruct($contentCreateStruct, $locationCreateStruct);
    }
278282
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        return new Values\Content\Section(
            array(
                'id' => $data['_href'],
                'identifier' => $data['identifier'],
                'name' => $data['name'],
            )
        );
    }
240982
public function decode(string $data): array
    {
        $document = new \DOMDocument();

        if (!@$document->loadXML($data)) {
            throw DeserializerRuntimeException::createNotParsable($this->getContentType());
        }

        return $this->transformType($document->getElementsByTagName('object')->item(0));
    }
688683
private function parse(array $data)
    {
        // generate id
        $enumId = EnumId::fromString(sprintf('%s:%s', $data['namespace'], $data['name']));

        // force default type to be "string"
        if (!isset($data['type'])) {
            $data['type'] = 'string';
        }

        $values = [];
        $keys = $this->fixArray($data['option'], 'key');
        foreach ($keys as $key) {
            $values[strtoupper($key['key'])] = $data['type'] == 'int'
                ? intval($key['value'])
                : (string)$key['value'];
        }

        if (count($values) === 0) {
            return;
        }

        if (array_search('unknown', array_map('strtolower', array_keys($values))) === false) {
            throw new \InvalidArgumentException(sprintf(
                'Enum "%s" require an "UNKNOWN" key that will be used as default value.',
                $enumId->toString()
            ));
        }

        // add enums language options
        $languages = $this->getLanguageOptions($data);

        $isDeprecated = isset($data['deprecated']) && $data['deprecated'];

        return new EnumDescriptor($enumId, $data['type'], $values, $languages, $isDeprecated);
    }
105273
protected function parseTexts(array $data)
    {
        foreach ($this->parseKeys as $key) {

            if (!isset($data[$key]) || !is_string($data[$key])) {
                continue;
            }

            $data[$key] = $this->textParser->parse($data[$key], $data);

        }

        return $data;
    }
574139
public static function getDispatcherFromParametersData(array $data): string
    {
        assert(array_key_exists(self::KEY_ROUTER_PARAMS__DISPATCHER, $data));
        $result = $data[self::KEY_ROUTER_PARAMS__DISPATCHER];
        assert(empty($result) === false);
        assert(static::classImplements($result, Dispatcher::class));

        return $result;
    }
805561
public function parse(string $data, callable $cast = null, string $delimiter = ','): array
    {
        $data = \trim($data);

        $parser = $this->parser($data, $cast, $delimiter);
        $data = \iterator_to_array($parser);

        if ($parser->getReturn() !== '') {
            throw new ParseException("Data left in buffer after parsing");
        }

        return $data;
    }
241382
private function parse(array $data)
    {
        $config = [];

        foreach ($data as $section => $value) {
            if (is_array($value)) {
                if (strpos($section, $this->nestSeparator) !== false) {
                    $sections = explode($this->nestSeparator, $section);
                    $config = array_merge_recursive($config, $this->buildNestedSection($sections, $value));
                } else {
                    $config[$section] = $this->parseSection($value);
                }
            } else {
                $this->parseKey($section, $value, $config);
            }
        }

        return $config;
    }
307335
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        // Since ContentTypeGroupInput is used both for creating and updating ContentTypeGroup and identifier is not
        // required when updating ContentTypeGroup, we need to rely on PAPI to throw the exception on missing
        // identifier when creating a ContentTypeGroup
        // @todo Bring in line with XSD which says that identifier is required always

        $contentTypeGroupIdentifier = null;
        if (array_key_exists('identifier', $data)) {
            $contentTypeGroupIdentifier = $data['identifier'];
        }

        $contentTypeGroupCreateStruct = $this->contentTypeService->newContentTypeGroupCreateStruct($contentTypeGroupIdentifier);

        if (array_key_exists('modificationDate', $data)) {
            $contentTypeGroupCreateStruct->creationDate = new DateTime($data['modificationDate']);
        }

        // @todo mainLanguageCode, names, descriptions?

        if (array_key_exists('User', $data) && is_array($data['User'])) {
            if (!array_key_exists('_href', $data['User'])) {
                throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentTypeGroupInput.");
            }

            $contentTypeGroupCreateStruct->creatorId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
        }

        return $contentTypeGroupCreateStruct;
    }
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
613023
private function processCriteriaArray(array $criteriaArray, ParsingDispatcher $parsingDispatcher)
    {
        if (count($criteriaArray) === 0) {
            return null;
        }

        $criteria = array();
        foreach ($criteriaArray as $criterionName => $criterionData) {
            $criteria[] = $this->dispatchCriterion($criterionName, $criterionData, $parsingDispatcher);
        }

        return (count($criteria) === 1) ? $criteria[0] : new CriterionValue\LogicalAnd($criteria);
    }
440684
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $query = $this->buildQuery();

        // @deprecated Criteria
        // -- FullTextCriterion
        if (array_key_exists('Criteria', $data) && is_array($data['Criteria'])) {
            $message = 'The Criteria element is deprecated since ezpublish-kernel 6.6, and will be removed in 8.0. Use Filter instead, or Query for criteria that should affect scoring.';
            if (array_key_exists('Filter', $data) && is_array($data['Filter'])) {
                $message .= ' The Criteria element will be merged into Filter.';
                $data['Filter'] = array_merge($data['Filter'], $data['Criteria']);
            } else {
                $data['Filter'] = $data['Criteria'];
            }

            @trigger_error($message, E_USER_DEPRECATED);
        }

        if (array_key_exists('Filter', $data) && is_array($data['Filter'])) {
            $query->filter = $this->processCriteriaArray($data['Filter'], $parsingDispatcher);
        }

        if (array_key_exists('Query', $data) && is_array($data['Query'])) {
            $query->query = $this->processCriteriaArray($data['Query'], $parsingDispatcher);
        }

        // limit
        if (array_key_exists('limit', $data)) {
            $query->limit = (int)$data['limit'];
        }

        // offset
        if (array_key_exists('offset', $data)) {
            $query->offset = (int)$data['offset'];
        }

        // SortClauses
        // -- [SortClauseName: direction|data]
        if (array_key_exists('SortClauses', $data)) {
            $query->sortClauses = $this->processSortClauses($data['SortClauses'], $parsingDispatcher);
        }

        // FacetBuilders
        // -- facetBuilderListType
        if (array_key_exists('FacetBuilders', $data)) {
            $facetBuilders = [];
            foreach ($data['FacetBuilders'] as $facetBuilderName => $facetBuilderData) {
                $facetBuilders[] = $this->dispatchFacetBuilder($facetBuilderName, $facetBuilderData, $parsingDispatcher);
            }
            $query->facetBuilders = $facetBuilders;
        }

        return $query;
    }
115820
protected function parseArray($data)
    {
        $pattern = '/(\[[^\[\]]*\])/';

        set_error_handler([__CLASS__, 'handleError']);

        while (true) {
            if (!preg_match($pattern, $data, $matches) > 0) {
                break;
            }

            $stringMatches = trim($matches[0]);

            $items = explode(',', $stringMatches);

            $currentData = $this->filterItems($items);


            $data = str_replace($stringMatches, serialize($currentData), $data);
        }

        $result = unserialize($data);

        restore_error_handler();

        return $result;
    }