/** * Executes the command * * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $sourcefile = $input->getOption('source'); try { $output->writeln("Validating: {$sourcefile}"); $check = OData\Helper::validate($sourcefile, $errors); if ($check) { $output->writeln("Document is a valid ODATA source. "); } else { $output->writeln("Document '" . $sourcefile . "' isn`t valid ODATA source "); foreach ($errors as $error) { $output->writeln(OData\Helper::LibXMLErrorToString($error)); } throw new \Exception("Source is not valid."); } $output->writeln("Done."); } catch (\eZ\Publish\API\Repository\Exceptions\NotFoundException $e) { $output->writeln($e->getMessage()); } catch (\eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e) { $output->writeln($e->getMessage()); } catch (\eZ\Publish\API\Repository\Exceptions\ContentValidationException $e) { $output->writeln($e->getMessage()); } /* $source = new OData\Source( $url); $import = new Import\Process( $location, $contentType, $source ); if($import->validate()){ $import->import(); } */ }
public function validateImport() { try { $check = OData\Helper::validateDom($this->feed, $errors, $this->_contenttypeidentifier); if ($check) { echo "Document is a valid ODATA source. \n"; return true; } else { echo "Document isn`t valid ODATA source\n"; foreach ($errors as $error) { echo OData\Helper::LibXMLErrorToString($error) . "\n"; } throw new \Exception("Source is not valid."); } } catch (\eZ\Publish\API\Repository\Exceptions\NotFoundException $e) { $output->writeln($e->getMessage()); } catch (\eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e) { $output->writeln($e->getMessage()); } catch (\eZ\Publish\API\Repository\Exceptions\ContentValidationException $e) { $output->writeln($e->getMessage()); } }