Skip to content
Snippets Groups Projects
Commit 7891e83e authored by igor mashevskyi's avatar igor mashevskyi Committed by Viktor Holovachek
Browse files

Issue #3502141: Add possibility of using Attributes instead of plugin...

parent 9d174518
No related branches found
No related tags found
1 merge request!43Issue #3502141: Add possibility of using Attributes instead of plugin...
Pipeline #405494 passed with warnings
......@@ -20,11 +20,14 @@ class FapiValidationFilter extends Plugin {
* (optional) The human-readable name of the filter type.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
* (optional) A short description of the filter type.
* @param class-string|null $deriver
* (optional) The deriver class.
*/
public function __construct(
public readonly string $id,
public readonly ?TranslatableMarkup $label = NULL,
public readonly ?TranslatableMarkup $description = NULL,
public readonly ?string $deriver = NULL,
) {}
}
<?php
namespace Drupal\fapi_validation\Attribute;
use Drupal\Component\Plugin\Attribute\Plugin;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Defines a FAPI Validation Validator attribute for plugin discovery.
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class FapiValidationValidator extends Plugin {
/**
* Constructs a FapiValidationValidator attribute.
*
* @param string $id
* The plugin ID.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $label
* (optional) The human-readable name of the validator type.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
* (optional) A short description of the validator type.
* @param string|null $error_message
* (optional) The error message.
* @param string|null $error_callback
* (optional) The callback for error messages.
* @param class-string|null $deriver
* (optional) The deriver class.
*/
public function __construct(
public readonly string $id,
public readonly ?TranslatableMarkup $label = NULL,
public readonly ?TranslatableMarkup $description = NULL,
public readonly ?string $error_message = NULL,
public readonly ?string $error_callback = NULL,
public readonly ?string $deriver = NULL,
) {}
}
......@@ -36,6 +36,7 @@ class FapiValidationValidatorsManager extends DefaultPluginManager {
$namespaces,
$module_handler,
'Drupal\fapi_validation\FapiValidationValidatorsInterface',
'Drupal\fapi_validation\Attribute\FapiValidationValidator',
'Drupal\fapi_validation\Annotation\FapiValidationValidator'
);
}
......
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