You are here

protected function ViewsFieldTemplate::setDerivative in Calendar 8

2 calls to ViewsFieldTemplate::setDerivative()
ViewsFieldTemplate::getDerivativeDefinitions in src/Plugin/Derivative/ViewsFieldTemplate.php
Gets the definition of all derivatives of a base plugin.
ViewsFieldTemplate::setConfigurableFieldsDerivatives in src/Plugin/Derivative/ViewsFieldTemplate.php
Set all derivatives for an entity type.

File

src/Plugin/Derivative/ViewsFieldTemplate.php, line 221

Class

ViewsFieldTemplate
Derivative class to find all field and properties for calendar View Builders.

Namespace

Drupal\calendar\Plugin\Derivative

Code

protected function setDerivative(array $derivative, array $base_plugin_definition) {
  $info = $derivative['replacements'];
  $derivative_id = $info['entity_type'] . '__' . $info['field_id'];

  // Move some replacements values to root of derivative also.
  $derivative['entity_type'] = $info['entity_type'];
  $derivative['field_id'] = $info['field_id'];

  // Create base path.
  if ($derivative['entity_type'] == 'node') {
    $base_path = 'calendar-' . $derivative['field_id'];
  }
  else {
    $base_path = "calendar-{$derivative['entity_type']}-{$derivative['field_id']}";
  }
  $derivative['replacements']['base_path'] = $base_path;
  $derivative['id'] = $base_plugin_definition['id'] . ':' . $derivative_id;
  $derivative += $base_plugin_definition;
  $this->derivatives[$derivative_id] = $derivative;
}