Skip to content
Snippets Groups Projects
Commit ef0fba96 authored by Viktor Holovachek's avatar Viktor Holovachek
Browse files

Issue #3500177 - Add new page

parent 837f1964
No related branches found
No related tags found
1 merge request!40Issue #3500177 - Add new page
Pipeline #405466 passed with warnings
......@@ -3,3 +3,7 @@ fapi_validation.settings:
description: 'Displays Form API Validation settings.'
route_name: fapi_validation.settings
parent: system.admin_config_system
fapi_validation.validations:
title: Validation plugins
route_name: fapi_validation.validations
parent: fapi_validation.settings
......@@ -4,6 +4,9 @@ manage fapi validation settings:
bypass fapi validations:
title: 'Allow users to bypass all validations'
description: 'Allows a user to bypass all fapi validation plugins.'
view fapi validation plugins:
title: 'Allow users to view all validations'
description: 'Allows a user to view all fapi validation plugins.'
permission_callbacks:
- Drupal\fapi_validation\FapiValidationPermissions::permissions
......@@ -5,3 +5,10 @@ fapi_validation.settings:
_title: 'Form API Validation settings'
requirements:
_permission: 'manage fapi validation settings'
fapi_validation.validations:
path: '/admin/config/system/fapi/validations'
defaults:
_controller: '\Drupal\fapi_validation\Controller\FapiValidationController::validations'
_title: 'Form API Validation plugins'
requirements:
_permission: 'view fapi validation plugins'
<?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,
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment