fcdb3d666b32523fda1968a3db8ec17109f08abc
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / views-plugin / argument-default.twig
1 <?php
2
3 /**
4  * @file
5  * Contains the {{ plugin_name }} argument default plugin.
6  *
7  * @DCG This file needs to be referenced from {{ machine_name }}.info using files[] directive.
8  */
9
10 /**
11  * Plugin description.
12  */
13 class views_plugin_argument_{{ plugin_machine_name }} extends views_plugin_argument_default {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function option_definition() {
19     $options = parent::option_definition();
20     $options['example_option'] = array('default' => 15);
21     return $options;
22   }
23
24   /**
25    * {@inheritdoc}
26    */
27   public function options_form(&$form, &$form_state) {
28     $form['example_option'] = array(
29       '#type' => 'textfield',
30       '#title' => t('Some example option.'),
31       '#default_value' => $this->options['example_option'],
32     );
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function options_validate(&$form, &$form_state) {
39     if ($form_state['values']['options']['argument_default']['{{ plugin_machine_name }}']['example_option'] == 10) {
40       form_error($form['example_option'], t('The value is not correct.'));
41     }
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function options_submit(&$form, &$form_state, &$options) {
48     $options['example_option'] = $form_state['values']['options']['argument_default']['{{ plugin_machine_name }}']['example_option'];
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function get_argument() {
55
56     // @DCG
57     // Here is the place where you should create a default argument for the
58     // contextual filter. The source of this argument depends on your needs.
59     // For example, you can extract the value from the URL or fetch it from
60     // some fields of the current viewed entity.
61     // For now lets use example option as an argument.
62     $argument = $this->options['example_option'];
63
64     return $argument;
65   }
66
67 }