Feed the pci instance with data provided in the pci dom node

@param ParserFactory $parser
@param DOMElement $data
@throws InvalidArgumentException
@throws QtiModelException
193659
public function feed(ParserFactory $parser, DOMElement $data, QtiNamespace $xmlns = null){

        $this->setNamespace($xmlns);
        $xmlnsName = $xmlns->getName();

        $pciNodes = $parser->queryXPathChildren(array('portableCustomInteraction'), $data, $xmlnsName);
        if(!$pciNodes->length) {
            $xmlnsName = '';//even if a namespace has been defined, it may not be used
            $pciNodes = $parser->queryXPathChildren(array('portableCustomInteraction'), $data, $xmlnsName);
        }
        if(!$pciNodes->length) {
            throw new QtiModelException('no ims portableCustomInteraction node found');
        }

        $typeIdentifier = $pciNodes->item(0)->getAttribute('customInteractionTypeIdentifier');
        if(empty($typeIdentifier)){
            throw new QtiModelException('the type identifier of the pci is missing');
        }else{
            $this->setTypeIdentifier($typeIdentifier);
        }

        $version = $pciNodes->item(0)->getAttribute('data-version');
        if($version){
            $this->setVersion($version);
        }

        $rootModulesNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'modules'), $data, $xmlnsName);
        foreach($rootModulesNodes as $rootModulesNode){
            $config = [];
            if($rootModulesNode->getAttribute('primaryConfiguration')){
                $config[] = $rootModulesNode->getAttribute('primaryConfiguration');
            }
            if($rootModulesNode->getAttribute('fallbackConfiguration')){
                $config[] = $rootModulesNode->getAttribute('fallbackConfiguration');
            }
            $this->setConfig($config);
        }

        $moduleNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'modules', 'module'), $data, $xmlnsName);
        foreach($moduleNodes as $libNode){
            $id = $libNode->getAttribute('id');
            $paths = [];
            if($libNode->getAttribute('primaryPath')){
                $paths[] = $libNode->getAttribute('primaryPath');
            }
            if($libNode->getAttribute('fallbackPath')){
                $paths[] = $libNode->getAttribute('fallbackPath');
            }
            $this->addModule($id, $paths);
        }

        $propertyNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'properties'), $data, $xmlnsName);
        if($propertyNodes->length){
            $properties = $this->extractProperties($propertyNodes->item(0), $xmlnsName);
            $this->setProperties($properties);
        }

        $markupNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'markup'), $data, $xmlnsName);
        if($markupNodes->length){
            $markup = $parser->getBodyData($markupNodes->item(0), true, true);
            $this->setMarkup($markup);
        }
    }
666816
protected function characterData($parser, $data): void
    {
        if ($this->print_data && $this->process_gedcoms === 0 && $this->process_ifs === 0 && $this->process_repeats === 0) {
            $this->current_element->addText($data);
        }
    }
1182761
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $contentTypeUpdateStruct = $this->contentTypeService->newContentTypeUpdateStruct();

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

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

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

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

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

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

        if (array_key_exists('defaultSortField', $data)) {
            $contentTypeUpdateStruct->defaultSortField = $this->parserTools->parseDefaultSortField($data['defaultSortField']);
        }

        if (array_key_exists('defaultSortOrder', $data)) {
            $contentTypeUpdateStruct->defaultSortOrder = $this->parserTools->parseDefaultSortOrder($data['defaultSortOrder']);
        }

        if (array_key_exists('defaultAlwaysAvailable', $data)) {
            $contentTypeUpdateStruct->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 ContentTypeUpdate.");
            }

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

        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 ContentTypeUpdate.");
            }

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

        if (array_key_exists('modificationDate', $data)) {
            $contentTypeUpdateStruct->modificationDate = 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 ContentTypeUpdate.");
            }

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

        return $contentTypeUpdateStruct;
    }
1266178
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('_identifier', $data)) {
            throw new Exceptions\Parser("Missing '_identifier' attribute for Limitation.");
        }

        $limitationObject = $this->buildLimitation();

        if (!isset($data['values']['ref']) || !is_array($data['values']['ref'])) {
            throw new Exceptions\Parser('Invalid format for data values in Limitation.');
        }

        foreach ($data['values']['ref'] as $limitationValue) {
            if (!array_key_exists('_href', $limitationValue)) {
                throw new Exceptions\Parser('Invalid format for data values in Limitation.');
            }

            $limitationObject->limitationValues[] = $this->parseIdFromHref($limitationValue);
        }

        return $limitationObject;
    }
137283
public function setParser($p)
    {
        if ($p === null || $p instanceof ParseInterface || is_callable($p)) {
            $this->_parser = $p;
        }
    }
123059
private function xmlCharacterData($parser, $data)
    {
        $count = $this->xmlCount - 1;
        if (!empty($this->xmlCData[$count])) {
            $this->xmlCData[$count] .= $data;
        } else {
            $this->xmlCData[$count] = $data;
        }
    }
639916
public function setParser(?ParserInterface $parser): void
    {
        if (is_null($parser)) {
            $options = array_merge($this->options, ['classArgs' => [$this->createSchema()]]);

            $parser = ClassFactory::createParser($this->configType, $options);
            if (!empty($this->options) && $parser instanceof ConfigInterface) {
                $parser->setConfig($this->options);
            }
        }

        $this->parser = $parser;
    }
1051074
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $parsedData = array();

        //@todo XSD has a login element, but it's not possible to update login

        if (array_key_exists('email', $data)) {
            $parsedData['email'] = $data['email'];
        }

        if (array_key_exists('password', $data)) {
            $parsedData['password'] = $data['password'];
        }

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

        if (array_key_exists('mainLanguageCode', $data)) {
            $parsedData['mainLanguageCode'] = $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 UserUpdate.");
            }

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

        if (array_key_exists('remoteId', $data)) {
            $parsedData['remoteId'] = $data['remoteId'];
        }

        if (array_key_exists('fields', $data)) {
            $userId = $this->requestParser->parseHref($data['__url'], 'userId');

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

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

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

                $fieldValue = $this->fieldTypeParser->parseFieldValue($userId, $fieldData['fieldDefinitionIdentifier'], $fieldData['fieldValue']);

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

                $parsedData['fields'][$fieldData['fieldDefinitionIdentifier']] = array(
                    'fieldValue' => $fieldValue,
                    'languageCode' => $languageCode,
                );
            }
        }

        $userUpdateStruct = $this->userService->newUserUpdateStruct();

        if (!empty($parsedData)) {
            if (array_key_exists('email', $parsedData)) {
                $userUpdateStruct->email = $parsedData['email'];
            }

            if (array_key_exists('password', $parsedData)) {
                $userUpdateStruct->password = $parsedData['password'];
            }

            if (array_key_exists('enabled', $parsedData)) {
                $userUpdateStruct->enabled = $parsedData['enabled'];
            }

            if (array_key_exists('mainLanguageCode', $parsedData) || array_key_exists('remoteId', $parsedData)) {
                $userUpdateStruct->contentMetadataUpdateStruct = $this->contentService->newContentMetadataUpdateStruct();

                if (array_key_exists('mainLanguageCode', $parsedData)) {
                    $userUpdateStruct->contentMetadataUpdateStruct->mainLanguageCode = $parsedData['mainLanguageCode'];
                }

                if (array_key_exists('remoteId', $parsedData)) {
                    $userUpdateStruct->contentMetadataUpdateStruct->remoteId = $parsedData['remoteId'];
                }
            }

            if (array_key_exists('fields', $parsedData)) {
                $userUpdateStruct->contentUpdateStruct = $this->contentService->newContentUpdateStruct();

                foreach ($parsedData['fields'] as $fieldDefinitionIdentifier => $fieldValue) {
                    $userUpdateStruct->contentUpdateStruct->setField(
                        $fieldDefinitionIdentifier,
                        $fieldValue['fieldValue'],
                        $fieldValue['languageCode']
                    );
                }
            }
        }

        return new RestUserUpdateStruct(
            $userUpdateStruct,
            array_key_exists('sectionId', $parsedData) ? $parsedData['sectionId'] : null
        );
    }
221520
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!isset($data['Field'])) {
            throw new Exceptions\Parser("The <Field> sort clause doesn't exist in the input structure");
        }

        if (!is_array($data['Field'])) {
            throw new Exceptions\Parser('The <Field> sort clause has missing arguments: contentTypeIdentifier, fieldDefinitionIdentifier');
        }

        $data['Field'] = $this->normalizeData($data['Field']);

        $direction = isset($data['Field']['direction']) ? $data['Field']['direction'] : null;

        if (!in_array($direction, [Query::SORT_ASC, Query::SORT_DESC])) {
            throw new Exceptions\Parser('Invalid direction format in <Field> sort clause');
        }

        if (isset($data['Field']['identifier'])) {
            if (false === strpos($data['Field']['identifier'], '/')) {
                throw new Exceptions\Parser('<Field> sort clause parameter "identifier" value has to be in "contentTypeIdentifier/fieldDefinitionIdentifier" format');
            }

            list($contentTypeIdentifier, $fieldDefinitionIdentifier) = explode('/', $data['Field']['identifier'], 2);
        } else {
            if (!isset($data['Field']['contentTypeIdentifier'])) {
                throw new Exceptions\Parser('<Field> sort clause have missing parameter "contentTypeIdentifier"');
            }
            if (!isset($data['Field']['fieldDefinitionIdentifier'])) {
                throw new Exceptions\Parser('<Field> sort clause have missing parameter "fieldDefinitionIdentifier"');
            }

            $contentTypeIdentifier = $data['Field']['contentTypeIdentifier'];
            $fieldDefinitionIdentifier = $data['Field']['fieldDefinitionIdentifier'];
        }

        return new FieldSortClause($contentTypeIdentifier, $fieldDefinitionIdentifier, $direction);
    }
552616
protected function init(DOMElement $element)
    {
        $this->parseType($element);
        $this->parseId($element, false);
        $this->parseName($element, false);

        $this->parseArgs($element);
    }
210682
public function handle(Parser $parser, \DOMNode $node, NodeInterface $target)
    {
        $target->{$this->setterName}($this->getNodeContent($node));
    }
1040917
public function getElement(Parser $parser, ElementInterface $parent = null)
    {
        $parser->getReader()->open($this->src);
        $parsed = $parser->getReader()->parse();

        return $parser->parseElements($parsed['value'], $parent);
    }
471817
public function setParser(Parser $parser)
    {
        if (!empty($this->statics) || !empty($this->dynamics)) {
            throw new \LogicException("You can't define a route parser after registering a route.");
        }

        $this->parser = $parser;
        return $this;
    }
331302
protected function parseChildren(DOMElement $ir, DOMElement $parent)
	{
		foreach ($parent->childNodes as $child)
		{
			switch ($child->nodeType)
			{
				case XML_COMMENT_NODE:
					// Do nothing
					break;

				case XML_TEXT_NODE:
					if (trim($child->textContent) !== '')
					{
						$this->appendLiteralOutput($ir, $child->textContent);
					}
					break;

				case XML_ELEMENT_NODE:
					$this->parseNode($ir, $child);
					break;

				default:
					throw new RuntimeException("Cannot parse node '" . $child->nodeName . "''");
			}
		}
	}
616702
public function handle(Parser $parser, \DOMNode $node, NodeInterface $target)
    {
        /** @var ItemInterface $target */
        $target->setLastModified(\DateTime::createFromFormat(\DateTime::RSS, $node->nodeValue));
    }
1048389
public function parse(Parser $parser)
    {
        $parser->match(Lexer::T_IDENTIFIER);
        $parser->match(Lexer::T_OPEN_PARENTHESIS);

        $this->maskField = $parser->ArithmeticPrimary();
        $this->deleteDeferredPath($parser, $this->maskField);

        $parser->match(Lexer::T_COMMA);
        $this->findValue = $parser->ArithmeticPrimary();

        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
        $this->parserResult = $parser->getParserResult();
    }
1138238
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('identifier', $data)) {
            throw new Exceptions\Parser("Missing 'identifier' attribute for ObjectStateGroupCreate.");
        }

        $objectStateGroupCreateStruct = $this->objectStateService->newObjectStateGroupCreateStruct($data['identifier']);

        if (!array_key_exists('defaultLanguageCode', $data)) {
            throw new Exceptions\Parser("Missing 'defaultLanguageCode' attribute for ObjectStateGroupCreate.");
        }

        $objectStateGroupCreateStruct->defaultLanguageCode = $data['defaultLanguageCode'];

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

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

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

        if (array_key_exists('descriptions', $data) && is_array($data['descriptions'])) {
            $objectStateGroupCreateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
        }

        return $objectStateGroupCreateStruct;
    }