Created
November 28, 2016 11:08
-
-
Save slivorezka/76e9f5255432ced981f58771bb6cf15e to your computer and use it in GitHub Desktop.
Drupal 8: Allow other modules to alter your data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Allow other modules to alter your data. | |
$data = [ | |
'#type' => 'markup', | |
'#markup' => t('This is the default text.'), | |
]; | |
\Drupal::moduleHandler()->alter('MODULE_some_action', $data); | |
/** | |
* Implements hook_MODULE_some_action_alter(). | |
*/ | |
function MODULE_MODULE_some_action1_alter(&$data) { | |
// Here we have full access to $data array. | |
$data['#markup'] = t('This was altered by MODULE.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment