class CustomMetaDeriverHttpEquiv in Custom Meta 2.0.x
Create a new custom_meta tag plugin for http-equiv custom tags.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\custom_meta\Plugin\Derivative\CustomMetaDeriverHttpEquiv
Expanded class hierarchy of CustomMetaDeriverHttpEquiv
File
- src/
Plugin/ Derivative/ CustomMetaDeriverHttpEquiv.php, line 10
Namespace
Drupal\custom_meta\Plugin\DerivativeView source
class CustomMetaDeriverHttpEquiv extends DeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
// Get a list of all custom defined metas.
$custom_meta_settings = \Drupal::config('custom_meta.settings');
$custom_meta = $custom_meta_settings
->get('tag');
$custom_meta_prefix = $custom_meta_settings
->get('prefix');
// Now we loop over them and declare the derivatives.
foreach ($custom_meta as $id => $meta) {
if ($meta['attribute'] == 'http-equiv') {
// The base definition includes the annotations defined in the plugin,
// i.e. CustomMetaTagHttpEquiv. Each one may be overridden.
$derivative = $base_plugin_definition;
// Here we fill in any missing keys on the layout annotation.
$derivative['weight']++;
$derivative['id'] = $id;
$derivative['name'] = $custom_meta_prefix . $id;
$derivative['label'] = t($meta['label']);
$derivative['description'] = t($meta['description']);
// Reference derivatives based on their UUID instead of the record ID.
$this->derivatives[$derivative['id']] = $derivative;
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CustomMetaDeriverHttpEquiv:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |