Parse input structure.

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

@return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeCreateStruct
517712
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('identifier', $data)) {
            throw new Exceptions\Parser("Missing 'identifier' element for ContentTypeCreate.");
        }

        $contentTypeCreateStruct = $this->contentTypeService->newContentTypeCreateStruct($data['identifier']);

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

        $contentTypeCreateStruct->mainLanguageCode = $data['mainLanguageCode'];

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

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

        // @todo XSD says that nameSchema is mandatory, but it is not in create struct
        if (array_key_exists('nameSchema', $data)) {
            $contentTypeCreateStruct->nameSchema = $data['nameSchema'];
        }

        // @todo XSD says that isContainer is mandatory, but it is not in create struct
        if (array_key_exists('isContainer', $data)) {
            $contentTypeCreateStruct->isContainer = $this->parserTools->parseBooleanValue($data['isContainer']);
        }

        // @todo XSD says that defaultSortField is mandatory, but it is not in create struct
        if (array_key_exists('defaultSortField', $data)) {
            $contentTypeCreateStruct->defaultSortField = $this->parserTools->parseDefaultSortField($data['defaultSortField']);
        }

        // @todo XSD says that defaultSortOrder is mandatory, but it is not in create struct
        if (array_key_exists('defaultSortOrder', $data)) {
            $contentTypeCreateStruct->defaultSortOrder = $this->parserTools->parseDefaultSortOrder($data['defaultSortOrder']);
        }

        // @todo XSD says that defaultAlwaysAvailable is mandatory, but it is not in create struct
        if (array_key_exists('defaultAlwaysAvailable', $data)) {
            $contentTypeCreateStruct->defaultAlwaysAvailable = $this->parserTools->parseBooleanValue($data['defaultAlwaysAvailable']);
        }

        if (array_key_exists('names', $data)) {
            if (!is_array($data['names'])
                || !array_key_exists('value', $data['names'])
                || !is_array($data['names']['value'])
            ) {
                throw new Exceptions\Parser("Invalid 'names' element for ContentTypeCreate.");
            }

            $contentTypeCreateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
        }

        // @todo XSD says that descriptions is mandatory, but content type can be created without descriptions
        if (array_key_exists('descriptions', $data)) {
            if (!is_array($data['descriptions'])
                || !array_key_exists('value', $data['descriptions'])
                || !is_array($data['descriptions']['value'])
            ) {
                throw new Exceptions\Parser("Invalid 'descriptions' element for ContentTypeCreate.");
            }

            $contentTypeCreateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
        }

        // @todo 1: XSD says that modificationDate is mandatory, but it is not in create struct
        // @todo 2: mismatch between XSD naming and create struct naming
        if (array_key_exists('modificationDate', $data)) {
            $contentTypeCreateStruct->creationDate = new DateTime($data['modificationDate']);
        }

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

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

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

        if (
            !is_array($data['FieldDefinitions'])
            || !array_key_exists('FieldDefinition', $data['FieldDefinitions'])
            || !is_array($data['FieldDefinitions']['FieldDefinition'])
        ) {
            throw new Exceptions\Parser("Invalid 'FieldDefinitions' element for ContentTypeCreate.");
        }

        // With no field definitions given and when ContentType is immediately published we must return HTTP 400 BadRequest,
        // instead of relying on service to throw InvalidArgumentException
        if (isset($data['__publish']) && $data['__publish'] === true && empty($data['FieldDefinitions']['FieldDefinition'])) {
            throw new Exceptions\Parser('ContentTypeCreate should provide at least one field definition.');
        }

        foreach ($data['FieldDefinitions']['FieldDefinition'] as $fieldDefinitionData) {
            if (!is_array($fieldDefinitionData)) {
                throw new Exceptions\Parser("Invalid 'FieldDefinition' element for ContentTypeCreate.");
            }

            $contentTypeCreateStruct->addFieldDefinition(
                $this->fieldDefinitionCreateParser->parse($fieldDefinitionData, $parsingDispatcher)
            );
        }

        return $contentTypeCreateStruct;
    }
224778
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $limitations = array();

        if (array_key_exists('limitations', $data)) {
            foreach ($data['limitations']['limitation'] as $limitation) {
                $limitations[] = $parsingDispatcher->parse(
                    $limitation,
                    $limitation['_media-type']
                );
            }
        }

        return new Client\Values\User\Policy(
            array(
                'id' => $data['id'],
                'module' => $data['module'],
                'function' => $data['function'],
                'limitations' => $limitations,
            )
        );
    }
250345
protected function _cbCharacterData($parser, $data)
	{
		if (!$this->_options["formatCData"]) {
			return;
		}
		
		$data = trim($data);
			
		if (strlen($data)) {
			$pad = $this->_getPaddingStr();
			
			if ($this->_options["multipleLineCData"]) {
				
				// remove all tabs
				$data = str_replace("\t", "", $data);
				
				// append each line with a padding string
				$data = implode($this->_options["inputEOL"] . $pad, explode($this->_options["inputEOL"], $data));
			}
			
			if ($this->_options["wordwrapCData"]) {
				$data = wordwrap($data, $this->_options["wordwrapCData"], $this->_options["outputEOL"] . $pad, false);
			}
			
			fwrite($this->_output, $pad . $data . "\n");
		}
	}
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
234758
public function deserialize($data, $content = null, array $options = [])
    {
        if ('text/html' === $data['type'] || 'text/plain' === $data['type']) {
            // HTML is directly stored in the choice entity
            $content->setData($data['data']);
            $content->setResourceNode(null);
        } else {
            // Other types require a ResourceNode
            $node = $this->resourceContentSerializer->deserialize($content);

            $content->setData('');
            $content->setResourceNode($node);
        }

        return $content;
    }
123059
private function xmlCharacterData($parser, $data)
    {
        $count = $this->xmlCount - 1;
        if (!empty($this->xmlCData[$count])) {
            $this->xmlCData[$count] .= $data;
        } else {
            $this->xmlCData[$count] = $data;
        }
    }
1345751
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('User', $data) || !is_array($data['User'])) {
            throw new Exceptions\Parser("Missing 'User' element in UserRefList.");
        }

        // workaround for list with 1 items parsed as non arrays
        if (!isset($data['User'][0])) {
            $data['User'] = array($data['User']);
        }

        $userRefList = array();
        foreach ($data['User'] as $userRefData) {
            $hrefData = $this->requestParser->parse($userRefData['_href']);
            if (!isset($hrefData['userId'])) {
                throw new Exceptions\Parser("Invalid application/vnd.ez.api.User href");
            }
            $userRefList[] = $hrefData['userId'];
        }
        return $userRefList;
    }
1348448
private function parseDocument(array $data)
    {
        $result = null;

        $dataSegment = $this->getArrayValue($data, DocumentInterface::KEYWORD_DATA, null);
        if (empty($dataSegment) === false && is_array($dataSegment) === true) {
            $isProbablySingle = $this->isProbablySingleIdentity($dataSegment);
            $parsed           = $isProbablySingle === true ?
                $this->parseSinglePrimaryData($dataSegment) :
                $this->parseArrayOfPrimaryData($dataSegment);

            if ($parsed !== null) {
                $result = new DocumentObject($parsed);
            }
        } elseif ($dataSegment !== null) {
            $this->errors->addDataError('Invalid element.');
        }

        return $result;
    }
160333
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!is_array($data) || 'operations' !== key($data)) {
            throw new Exceptions\Parser('Invalid structure for BulkOperation.');
        }

        if (array_key_exists('uri', $data['operations'])) {
            $operationData[] = $data['operations'];
        } else {
            $operationData = $data['operations'];
        }

        $operations = [];
        foreach ($operationData as $operationId => $operation) {
            $operations[$operationId] = $parsingDispatcher->parse($operation, 'application/vnd.ez.api.internal.Operation');
        }

        return new BulkOperationValue($operations);
    }
684086
protected function createStructure( array $data )
    {
        if ( isset( $data['proxyData'] ) )
        {
            $proxyData = $data['proxyData'] ?: array();
            unset( $data['proxyData'] );
        }
        else
        {
            $proxyData = $data;
        }

        if ( isset( $data['tagIds'] ) )
        {
            $proxyData['tagIds'] = $data['tagIds'];
            unset( $data['tagIds'] );
        }

        if ( isset( $data['localeTags'] ) )
        {
            $proxyData['localeTags'] = $data['localeTags'];
            unset( $data['localeTags'] );
        }

        $proxyData['proxyBase'] = parent::createStructure( $data );
        $proxyData['type']      = $proxyData['proxyBase']->type;

        return $this->structureFactory
                    ->factory( $proxyData );
    }
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;
    }
26693
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $locationUpdateStruct = $this->locationService->newLocationUpdateStruct();

        if (array_key_exists('priority', $data)) {
            $locationUpdateStruct->priority = (int)$data['priority'];
        }

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

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

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

        $locationUpdateStruct->sortField = $this->parserTools->parseDefaultSortField($data['sortField']);

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

        $locationUpdateStruct->sortOrder = $this->parserTools->parseDefaultSortOrder($data['sortOrder']);

        return new RestLocationUpdateStruct($locationUpdateStruct, $hidden);
    }
822489
public function getParser() : ParserInterface
    {
        if (null === $this->parser) {
            $patternHelper = new Parser\Helper\GetPattern($this->cache, $this->logger);
            $dataHelper = new Parser\Helper\GetData($this->cache, $this->logger, new Quoter());

            $this->parser = new Parser\Ini($patternHelper, $dataHelper, $this->formatter);
        }

        return $this->parser;
    }
1094535
public function create($data)
    {
        $descriptor = new ThrowsDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());
        $descriptor->setTypes(
            $this->builder->buildDescriptor(new Collection($data->getTypes()))
        );

        return $descriptor;
    }
785791
public function createStructure( array $data )
    {
        $structure = parent::createStructure( $data );

        if ( $structure instanceof SiteInfoAwareInterface )
        {
            $structure->setSiteInfo( $this->getSiteInfo() );
        }

        return $structure;
    }
532156
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('Destination', $data) || !is_array($data['Destination'])) {
            throw new Exceptions\Parser("Missing or invalid 'Destination' element for RelationCreate.");
        }

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

        return $this->requestParser->parseHref($data['Destination']['_href'], 'contentId');
    }
85644
private function buildFromParser(SwaggerParser $parser)
    {
        $context = new DeserializationContext();

        $context->setVersion(
            $parser->getVersion()
        );

        return $this->serializer->deserialize($parser, Swagger::class, 'json', $context);
    }