252e68c7bd43cb9f5bac53c140a17d897060d98c
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / ctools-plugin / relationship.twig
1 <?php
2
3 /**
4  * @file
5  * {{ plugin_name }} relationship plugin.
6  */
7
8 /**
9  * Plugin definition.
10  */
11 $plugin = array(
12   'title' => t('{{ plugin_name }}'),
13   'description' => t('{{ description }}'),
14 {% if context == 'Node' or context == 'User' %}
15   'required context' => new ctools_context_required(t('{{ context }}'), '{{ context | lower }}'),
16 {% elseif  context == 'Term' %}
17   'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')),
18 {% endif %}
19   'context' => '{{ machine_name }}_{{ plugin_machine_name }}_context',
20 );
21
22 /**
23 * Returns a new context based on an existing context.
24  */
25 function {{ machine_name }}_{{ plugin_machine_name }}_context($context, $conf) {
26
27   // @TODO: Replace "node" with identifier of the context
28   // this plugin is meant to provide.
29   if (empty($context->data)) {
30     return ctools_context_create_empty('node', NULL);
31   }
32
33 {% if context == 'Node' or context == 'Term' %}
34   ${{ context | lower }} = clone $context->data;
35
36 {% elseif  context == 'User' %}
37 {# Use $account variable avoid confusion with the global $user object #}
38   $account = clone $context->data;
39
40 {% endif %}
41   // @TODO: Replace this code with your own.
42   $related_node = node_load(1);
43   return ctools_context_create('node', $related_node);
44 }