Skip to content
Snippets Groups Projects

Issue #3500177 - Add new page

Files
4
+ 68
0
<?php
namespace Drupal\fapi_validation\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\fapi_validation\FapiValidationValidatorsManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Returns a table with all fapi validation plugins.
*/
class FapiValidationController extends ControllerBase {
/**
* Returns the plugin.manager.fapi_validation_validators service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $validationManager;
/**
* Constructs a FapiValidationController object.
*
* @param \Drupal\fapi_validation\FapiValidationValidatorsManager $validation_manager
* * A plugin manager for Fapi Validation Validators Plugin.
*/
public function __construct(FapiValidationValidatorsManager $validation_manager) {
$this->validationManager = $validation_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('plugin.manager.fapi_validation_validators')
);
}
/**
* Show all validation plugins.
*/
public function validations() {
$header = [
['data' => $this->t('ID')],
['data' => $this->t('Label')],
['data' => $this->t('Description')],
['data' => $this->t('Provider')],
];
$rows = [];
foreach ($this->validationManager->getDefinitions() as $validation) {
$rows[] = [
$validation['id'],
$validation['label'] ?? '',
$validation['description'] ?? '',
$validation['provider'],
];
}
return [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
];
}
}
Loading