function DebugCommand::dumpValidatorsForClass
1 call to DebugCommand::dumpValidatorsForClass()
- DebugCommand::execute in vendor/
symfony/ validator/ Command/ DebugCommand.php - Executes the current command.
File
-
vendor/
symfony/ validator/ Command/ DebugCommand.php, line 85
Class
- DebugCommand
- A console command to debug Validators information.
Namespace
Symfony\Component\Validator\CommandCode
private function dumpValidatorsForClass(InputInterface $input, OutputInterface $output, string $class) : void {
$io = new SymfonyStyle($input, $output);
$title = \sprintf('<info>%s</info>', $class);
$rows = [];
$dump = new Dumper($output);
/** @var ClassMetadataInterface $classMetadata */
$classMetadata = $this->validator
->getMetadataFor($class);
foreach ($this->getClassConstraintsData($classMetadata) as $data) {
$rows[] = [
'-',
$data['class'],
implode(', ', $data['groups']),
$dump($data['options']),
];
}
foreach ($this->getConstrainedPropertiesData($classMetadata) as $propertyName => $constraintsData) {
foreach ($constraintsData as $data) {
$rows[] = [
$propertyName,
$data['class'],
implode(', ', $data['groups']),
$dump($data['options']),
];
}
}
if (!$rows) {
if (false === $input->getOption('show-all')) {
return;
}
$io->section($title);
$io->text('No validators were found for this class.');
return;
}
$io->section($title);
$table = new Table($output);
$table->setHeaders([
'Property',
'Name',
'Groups',
'Options',
]);
$table->setRows($rows);
$table->setColumnMaxWidth(3, 80);
$table->render();
}