Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,112 @@
<?php
namespace Drupal\{{ machine_name }}\Plugin\views\argument_default;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Example of argument default plugin.
*
* @ViewsArgumentDefault(
* id = "{{ plugin_id }}",
* title = @Translation("{{ plugin_label }}")
* )
*/
class {{ class }} extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
/**
* The route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs a new {{ class }} instance.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
// @DCG
// The Route match service is used to extract argument from the current
// route.
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_route_match')
);
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['example_option'] = ['default' => ''];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['example_option'] = [
'#type' => 'textfield',
'#title' => t('Some example option'),
'#default_value' => $this->options['example_option'],
];
}
/**
* {@inheritdoc}
*/
public function getArgument() {
// @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 let's use example option as an argument.
$argument = $this->options['example_option'];
return $argument;
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return ['url'];
}
}

View file

@ -0,0 +1,52 @@
<?php
namespace Drupal\{{ machine_name }}\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Provides {{ plugin_label }} field handler.
*
* @ViewsField("{{ plugin_id }}")
*/
class {{ class }} extends FieldPluginBase {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['prefix'] = ['default' => ''];
$options['suffix'] = ['default' => ''];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['prefix'] = [
'#type' => 'textfield',
'#title' => $this->t('Prefix'),
'#default_value' => $this->options['prefix'],
];
$form['suffix'] = [
'#type' => 'textfield',
'#title' => $this->t('Suffix'),
'#default_value' => $this->options['suffix'],
];
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
return $this->options['prefix'] . parent::render($values) . $this->options['suffix'];
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace Drupal\{{ machine_name }}\Plugin\views\style;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\style\StylePluginBase;
/**
* {{ plugin_label }} style plugin.
*
* @ViewsStyle(
* id = "{{ plugin_id }}",
* title = @Translation("{{ plugin_label }}"),
* help = @Translation("Foo style plugin help."),
* theme = "views_style_{{ plugin_id }}",
* display_types = {"normal"}
* )
*/
class {{ class }} extends StylePluginBase {
/**
* {@inheritdoc}
*/
protected $usesRowPlugin = TRUE;
/**
* {@inheritdoc}
*/
protected $usesRowClass = TRUE;
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['wrapper_class'] = ['default' => 'item-list'];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['wrapper_class'] = [
'#title' => $this->t('Wrapper class'),
'#description' => $this->t('The class to provide on the wrapper, outside rows.'),
'#type' => 'textfield',
'#default_value' => $this->options['wrapper_class'],
];
}
}

View file

@ -0,0 +1,14 @@
/**
* Prepares variables for views-style-{{ plugin_id|u2h }}.html.twig template.
*/
function template_preprocess_views_style_{{ plugin_id }}(&$variables) {
$handler = $variables['view']->style_plugin;
// Fetch wrapper classes from handler options.
if ($handler->options['wrapper_class']) {
$wrapper_class = explode(' ', $handler->options['wrapper_class']);
$variables['attributes']['class'] = array_map('\Drupal\Component\Utility\Html::cleanCssIdentifier', $wrapper_class);
}
template_preprocess_views_view_unformatted($variables);
}

View file

@ -0,0 +1,7 @@
views.style.{{ plugin_id }}:
type: views_style
label: '{{ plugin_label }}'
mapping:
wrapper_class:
type: string
label: Wrapper class

View file

@ -0,0 +1,22 @@
{{ '{#' }}
/**
* @file
* Default theme implementation for a view template to display a list of rows.
*
* Available variables:
* - attributes: HTML attributes for the container.
* - rows: A list of rows.
* - attributes: The row's HTML attributes.
* - content: The row's contents.
* - title: The title of this group of rows. May be empty.
*
* @see template_preprocess_views_style_{{ plugin_id }}()
*/
{{ '#}' }}{% verbatim %}
<div{{ attributes }}>
{% for row in rows %}
<div{{ row.attributes }}>{{ row.content }}</div>
{% endfor %}
</div>{% endverbatim %}