preprocessors-8.x-1.0-beta8/modules/preprocessors_example/src/Plugin/preprocessors/AnnotationNodePreprocessor.php
modules/preprocessors_example/src/Plugin/preprocessors/AnnotationNodePreprocessor.php
<?php
namespace Drupal\preprocessors_example\Plugin\preprocessors;
use Drupal\preprocessors\PreprocessorPluginBase;
/**
* Provide plugin to preprocess variables for nodes.
*
* @Preprocessor(
* id = "preprocessors_example.preprocessor.annotation_node",
* hooks = {
* "node",
* },
* themes = "*",
* weight = 0,
* )
*/
final class AnnotationNodePreprocessor extends PreprocessorPluginBase {
/**
* Preprocess your variables.
*
* This method works just like a 'hook_preprocess_HOOK()' function.
*
* {@inheritdoc}
*/
public function preprocess(array &$variables, string $hook, array $info) : void {
$variables['foo'] = "bar";
}
}
