-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathworkbench.api.php
More file actions
70 lines (66 loc) · 2.18 KB
/
workbench.api.php
File metadata and controls
70 lines (66 loc) · 2.18 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @file
* API documentation file for Workbench.
*/
/**
* Allows modules to alter the default Workbench landing page.
*
* This hook is a convenience function to be used instead of
* hook_page_alter(). In addition to the normal Render API elements,
* you may also specify a #view and #view_display attribute, both
* of which are strings that indicate which View to render on the page.
*
* The left and right columns in this output are given widths of 35% and 65%
* respectively by workbench.my-workbench.css.
*
* @param array $output
* A Render API array of content items, passed by reference.
*
* @see workbench_content()
*/
function hook_workbench_content_alter(&$output) {
// Replace the default "Recent Content" view with our custom View.
$output['workbench_recent_content']['#view_id'] = 'custom_view';
$output['workbench_recent_content']['#view_display'] = 'block_2';
}
/**
* Allows modules to alter the default content creation page.
*
* Worekbench supplies a Create Content tab which emulates core's
* node/add page. The render array for this page may be modified
* by other modules.
*
* @param array $output
* A Render API array of content items, passed by reference.
*
* @see workbench_create()
*/
function hook_workbench_create_alter(&$output) {
if (\Drupal::currentUser()->hasPermission('use workbench_media add form')) {
$output['#content']['article']->set('description', 'hello world');
}
}
/**
* Return Workbench status information in a block.
*
* To reduce clutter, modules are encouraged to use this hook
* to provide debugging and other relevant information.
*
* @return array
* An array of message strings to print. The preferred format
* is a one line string in the format Title: <em>Message</em>.
*
* @see workbench_block_view()
*/
function hook_workbench_block() {
// Add editing information to this page (if it's a node).
if ($node = \Drupal::routeMatch()->getParameter('node')) {
if ($node->entityTypeId == 'node' && $node->access('update')) {
return array(t('My Module: <em>You may edit this content.</em>'));
}
else {
return array(t('My Module: <em>You may not edit this content.</em>'));
}
}
}