Steps
-
define a new class in a custom module in folder $CUSTOM_MODULE/src/Plugin/views/field/$OVERRIDE_CLASS.php
-
add the proper annotation for the plugin type you want to override
This is how you mark the class as a views field plugin:
/** * @ViewsField("view_override") */
-
-
replace the original plugin class
In the hook_views_plugins_field_alter, replace the class by the index you want to override.
For example, this overrides the 'view' views field plugin and replaces it's class:
function api_adapter_views_plugins_field_alter(array &$plugins) { $plugins['view']['class'] = 'Drupal\\api_adapter\\Plugin\\views\\field\\ViewOverride'; }