You are here

function plugin_type_example_sandwich_info_alter in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 plugin_type_example/plugin_type_example.module \plugin_type_example_sandwich_info_alter()

Implements hook_sandwich_info_alter().

Any module can implement hook_sandwich_info_alter() and alter the definitions of all plugins discovered by the plugin manager.

Note: Plugin definitions are cached after initially being discovered, and altered. Any changes you make here will require a cache clear to take effect.

See also

\Drupal\plugin_type_example\SandwichPluginManager

Related topics

File

modules/plugin_type_example/plugin_type_example.module, line 65
Demonstrates how to define a new plugin type.

Code

function plugin_type_example_sandwich_info_alter(&$sandwich_plugin_info) {

  // Let's change the 'description' property for all sandwiches.
  foreach ($sandwich_plugin_info as $plugin_id => $plugin_definition) {

    // Always uppercase the word rocket in sandwich descriptions.
    $sandwich_plugin_info[$plugin_id]['description'] = str_replace(t('rocket'), t('ROCKET'), $sandwich_plugin_info[$plugin_id]['description']);
  }
}