/**
  * Parses a XML file.
  *
  * @param string $file Path to a file
  *
  * @return SimpleXMLElement
  *
  * @throws InvalidArgumentException When loading of XML file returns error
  */
 private function parseFile($file)
 {
     static $mappingSchema;
     if (!$mappingSchema) {
         $mappingSchema = realpath(__DIR__ . '/schema/dic/metadata/metadata-1.0.xsd');
     }
     try {
         $dom = XmlUtil::loadFile($file, $mappingSchema);
     } catch (\InvalidArgumentException $e) {
         throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
     }
     return simplexml_import_dom($dom, 'Rollerworks\\Component\\Search\\Metadata\\SimpleXMLElement');
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function process(ProcessorConfig $config, $input)
 {
     if (!is_string($input)) {
         throw new UnexpectedTypeException($input, 'string');
     }
     $input = trim($input);
     if (empty($input)) {
         return;
     }
     $document = simplexml_import_dom(XmlUtil::parseXml($input, __DIR__ . '/schema/dic/input/xml-input-1.0.xsd'));
     $this->config = $config;
     $valuesGroup = new ValuesGroup(isset($document['logical']) ? (string) $document['logical'] : ValuesGroup::GROUP_LOGICAL_AND);
     $this->processGroup($document, $valuesGroup, 0, 0);
     $condition = new SearchCondition($config->getFieldSet(), $valuesGroup);
     if ($condition->getValuesGroup()->hasErrors(true)) {
         throw new InvalidSearchConditionException($condition);
     }
     return $condition;
 }
 /**
  * Converts an xml value to a php type.
  *
  * @param mixed $value
  *
  * @return mixed
  */
 public static function phpize($value)
 {
     return XmlUtil::phpize($value);
 }