public function validateCommand($type = null, $path = null, $verbose = false)
{
if ($type === null) {
$this->outputLine('Validating <b>all</b> configuration');
} else {
$this->outputLine('Validating <b>' . $type . '</b> configuration' . ($path !== null ? ' on path <b>' . $path . '</b>' : ''));
}
$this->outputLine();
$validatedSchemaFiles = [];
try {
$result = $this->configurationSchemaValidator->validate($type, $path, $validatedSchemaFiles);
} catch (SchemaValidationException $exception) {
$this->outputLine('<b>Exception:</b>');
$this->outputFormatted($exception->getMessage(), [], 4);
$this->quit(2);
return;
}
if ($verbose) {
$this->outputLine('<b>Loaded Schema Files:</b>');
foreach ($validatedSchemaFiles as $validatedSchemaFile) {
$this->outputLine('- ' . substr($validatedSchemaFile, strlen(FLOW_PATH_ROOT)));
}
$this->outputLine();
if ($result->hasNotices()) {
$notices = $result->getFlattenedNotices();
$this->outputLine('<b>%d notices:</b>', [count($notices)]);
/** @var Notice $notice */
foreach ($notices as $path => $pathNotices) {
foreach ($pathNotices as $notice) {
$this->outputLine(' - %s -> %s', [$path, $notice->render()]);
}
}
$this->outputLine();
}
}
if ($result->hasErrors()) {
$errors = $result->getFlattenedErrors();
$this->outputLine('<b>%d errors were found:</b>', [count($errors)]);
/** @var Error $error */
foreach ($errors as $path => $pathErrors) {
foreach ($pathErrors as $error) {
$this->outputLine(' - %s -> %s', [$path, $error->render()]);
}
}
$this->quit(1);
} else {
$this->outputLine('<b>All Valid!</b>');
}
}