Writing Custom Schemata
=======================
The schemas are searched in the path "Resources/Private/Schema" of all
active packages. The schema-filenames must match the pattern
[type].[path].schema.yaml. The type and/or the path can also be
expressed as subdirectories of Resources/Private/Schema. So
Settings/Neos/Flow.persistence.schema.yaml will match the same paths
like Settings.Neos.Flow.persistence.schema.yaml or
Settings/Neos.Flow/persistence.schema.yaml
/** * @param string $type * @return void */ public function indexAction($type = 'Settings') { $availableConfigurationTypes = $this->configurationManager->getAvailableConfigurationTypes(); $this->view->assignMultiple(array('type' => $type, 'availableConfigurationTypes' => $availableConfigurationTypes)); if (in_array($type, $availableConfigurationTypes)) { $this->view->assign('configuration', $this->configurationManager->getConfiguration($type)); try { $this->view->assign('validationResult', $this->configurationSchemaValidator->validate($type)); } catch (SchemaValidationException $exception) { $this->addFlashMessage(htmlspecialchars($exception->getMessage()), 'An error occurred during validation of the configuration.', Message::SEVERITY_ERROR, array(), 1412373972); } } else { $this->addFlashMessage('Configuration type not found.', '', Message::SEVERITY_ERROR, array(), 1412373998); } }
/** * @param string $contextName * @param string $configurationType * @test * @dataProvider configurationValidationDataProvider */ public function configurationValidationTests($contextName, $configurationType) { $this->injectApplicationContextIntoConfigurationManager(new ApplicationContext($contextName)); $schemaFiles = []; $validationResult = $this->configurationSchemaValidator->validate($configurationType, null, $schemaFiles); $this->assertValidationResultContainsNoErrors($validationResult); }
/** * Validate the given configuration * * <b>Validate all configuration</b> * ./flow configuration:validate * * <b>Validate configuration at a certain subtype</b> * ./flow configuration:validate --type Settings --path Neos.Flow.persistence * * You can retrieve the available configuration types with: * ./flow configuration:listtypes * * @param string $type Configuration type to validate * @param string $path path to the subconfiguration separated by "." like "Neos.Flow" * @param boolean $verbose if TRUE, output more verbose information on the schema files which were used * @return void */ 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>'); } }