class ValidateNode in Node Accessibility 8
Perform accessibility validation on a node.
Plugin annotation
@Action(
id = "node_accessibility_validate_action",
label = @Translation("Perform Accessibility Validation on Node"),
type = "node"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Action\ActionBase implements ActionInterface
- class \Drupal\node_accessibility\Plugin\Action\ValidateNode
- class \Drupal\Core\Action\ActionBase implements ActionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ValidateNode
File
- src/
Plugin/ Action/ ValidateNode.php, line 21
Namespace
Drupal\node_accessibility\Plugin\ActionView source
class ValidateNode extends ActionBase {
/**
* {@inheritdoc}
*/
public function execute($entity = NULL) {
if (is_null($entity)) {
return;
}
$id_node = $entity
->id();
$id_revision = $entity
->id();
$settings = TypeSettingsStorage::loadByNodeAsArray($id_node);
if (is_null($id_revision)) {
$results = PerformValidation::nodes([
$id_node,
], NULL, NULL, $settings['standards']);
}
else {
$results = PerformValidation::node_revisions([
$id_revision => $id_node,
], NULL, NULL, $settings['standards']);
}
if (empty($settings['node_type'])) {
return;
}
if (empty($settings['enabled']) || $settings['enabled'] == 'disabled') {
return;
}
if (array_key_exists($id_node, $results) && !empty($results[$id_node])) {
$severitys = QuailApiSettings::get_severity();
$methods = QuailApiSettings::get_validation_methods();
if ($settings['method'] == 'quail_api_method_manual' || $settings['method'] == 'quail_api_method_immediate') {
// do not process validation action if not saving to the database.
return;
}
$revision = reset($results[$id_node]);
unset($results);
if (empty($revision['report'])) {
unset($revision);
$markup = $this
->t('No accessibility violations have been detected.');
}
else {
$reports = $revision['report'];
$total = $revision['total'];
unset($revision);
if (empty($settings['format_results'])) {
$format_results = \Drupal::config('quail_api.settings')
->get('filter_format');
}
else {
$format_results = $settings['format_results'];
}
if (empty($settings['title_block'])) {
$title_block = \Drupal::config('quail_api.settings')
->get('title_block');
}
else {
$title_block = $settings['title_block'];
}
if (empty($title_block)) {
$title_block = 'h3';
}
// the reason this is converted to markup is because the generated
// markup is intended to be saved to the database. This is not a
// cache, but a renderred copy of the data for archival and
// validation purposes.
$markup = '';
foreach ($reports as $severity => $severity_results) {
$theme_array = [
'#theme' => 'quail_api_results',
'#quail_severity_id' => $severity,
'#quail_severity_array' => $severitys[$severity],
'#quail_severity_results' => $severity_results,
'#quail_markup_format' => $format_results,
'#quail_title_block' => $title_block,
'#quail_display_title' => TRUE,
'#attached' => [
'library' => [
'node_accessibility/results-theme',
],
],
];
$markup .= \Drupal::service('renderer')
->render($theme_array, FALSE);
}
}
}
}
/**
* {@inheritdoc}
*/
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
return $object
->access('perform node accessibility validation', $account, $return_as_object);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActionBase:: |
public | function |
Executes the plugin for an array of objects. Overrides ActionInterface:: |
3 |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ValidateNode:: |
public | function |
Checks object access. Overrides ActionInterface:: |
|
ValidateNode:: |
public | function |
Executes the plugin. Overrides ExecutableInterface:: |