default services conflit ?
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide views data and handlers for {{ name }} module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_plugins().
|
||||
*/
|
||||
function {{ machine_name }}_views_plugins() {
|
||||
return array(
|
||||
'module' => '{{ machine_name }}',
|
||||
'argument default' => array(
|
||||
'{{ plugin_machine_name }}' => array(
|
||||
'title' => t('{{ plugin_name }}'),
|
||||
'handler' => 'views_plugin_argument_{{ plugin_machine_name }}',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary module hooks for {{ name }} module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function {{ machine_name }}_views_api() {
|
||||
return array(
|
||||
'api' => '3.0',
|
||||
'path' => drupal_get_path('module', '{{ machine_name }}') . '/views',
|
||||
);
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user