<?php

/**
 * @file
 * Contains the {{ plugin_name }} argument default plugin.
 *
 * @DCG This file needs to be referenced from {{ machine_name }}.info using files[] directive.
 */

/**
 * Plugin description.
 */
class views_plugin_argument_{{ plugin_machine_name }} extends views_plugin_argument_default {

  /**
   * {@inheritdoc}
   */
  public function option_definition() {
    $options = parent::option_definition();
    $options['example_option'] = array('default' => 15);
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function options_form(&$form, &$form_state) {
    $form['example_option'] = array(
      '#type' => 'textfield',
      '#title' => t('Some example option.'),
      '#default_value' => $this->options['example_option'],
    );
  }

  /**
   * {@inheritdoc}
   */
  public function options_validate(&$form, &$form_state) {
    if ($form_state['values']['options']['argument_default']['{{ plugin_machine_name }}']['example_option'] == 10) {
      form_error($form['example_option'], t('The value is not correct.'));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function options_submit(&$form, &$form_state, &$options) {
    $options['example_option'] = $form_state['values']['options']['argument_default']['{{ plugin_machine_name }}']['example_option'];
  }

  /**
   * {@inheritdoc}
   */
  public function get_argument() {

    // @DCG
    // Here is the place where you should create a default argument for the
    // contextual filter. The source of this argument depends on your needs.
    // For example, you can extract the value from the URL or fetch it from
    // some fields of the current viewed entity.
    // For now lets use example option as an argument.
    $argument = $this->options['example_option'];

    return $argument;
  }

}
