Mercurial > hg > cmmr2012-drupal-site
comparison vendor/chi-teck/drupal-code-generator/templates/d7/ctools-plugin/access.twig @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * {{ plugin_name }} access plugin. | |
6 */ | |
7 | |
8 /** | |
9 * Plugin definition. | |
10 */ | |
11 $plugin = array( | |
12 'single' => TRUE, | |
13 'title' => t('{{ plugin_name }}'), | |
14 'description' => t('{{ description }}'), | |
15 {% if context == 'Node' or context == 'User' %} | |
16 'required context' => new ctools_context_required(t('{{ context }}'), '{{ context | lower }}'), | |
17 {% elseif context == 'Term' %} | |
18 'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')), | |
19 {% endif %} | |
20 'category' => t('{{ category }}'), | |
21 'callback' => '{{ machine_name }}_{{ plugin_machine_name }}_access_check', | |
22 'summary' => '{{ machine_name }}_{{ plugin_machine_name }}_access_summary', | |
23 ); | |
24 | |
25 /** | |
26 * Access callback. | |
27 */ | |
28 function {{ machine_name }}_{{ plugin_machine_name }}_access_check($conf, $context) { | |
29 {% if context != '-' %} | |
30 | |
31 if (empty($context->data)) { | |
32 return; | |
33 } | |
34 {% endif %} | |
35 | |
36 {% if context == 'Node' or context == 'Term' %} | |
37 ${{ context | lower }} = clone $context->data; | |
38 | |
39 {% elseif context == 'User' %} | |
40 {# Use $account variable avoid confusion with the global $user object #} | |
41 $account = clone $context->data; | |
42 | |
43 {% endif %} | |
44 // @TODO: Check access here. | |
45 return TRUE; | |
46 } | |
47 | |
48 /** | |
49 * Summary callback. | |
50 */ | |
51 function {{ machine_name }}_{{ plugin_machine_name }}_access_summary($conf, $context) { | |
52 return t('Summary placeholder'); | |
53 } |