forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drush.api.php
46 lines (43 loc) · 1.46 KB
/
drush.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @file
* Drupal hooks provided by the Drush package.
*/
/**
* Executes a deploy function which is intended to update data, like entities,
* after config is imported during a deployment.
*
* These are a higher level alternative to hook_update_n and hook_deploy_NAME
* functions and have to be placed in a MODULE.deploy.php file.
*
* NAME can be arbitrary machine names. In contrast to hook_update_N() the
* alphanumeric naming of functions in the file is the only thing which ensures
* the execution order of those functions. If update order is mandatory,
* you should add numerical prefix to NAME or make it completely numerical.
*
* Drupal also ensures to not execute the same hook_deploy_NAME() function
* twice.
*
* @param array $sandbox
* Stores information for batch updates.
*
* @return string|null
* Optionally, hook_deploy_NAME() hooks may return a translated string
* that will be displayed to the user after the update has completed. If no
* message is returned, no message will be presented to the user.
*
* @throws \Exception
* In case of error, update hooks should throw an instance of
* \Exception with a meaningful message for the user.
*
* @ingroup update_api
*
* @see hook_update_N()
* @see hook_post_update_NAME()
*/
function hook_deploy_NAME(array &$sandbox): string {
$node = \Drupal\node\Entity\Node::load(123);
$node->setTitle('foo');
$node->save();
return t('Node %nid saved', ['%nid' => $node->id()]);
}