final class TestLinkProviderDeriver in JSON:API Hypermedia 8
Derives test plugins.
@internal
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\jsonapi_hypermedia_test_link_providers\Plugin\Derivative\TestLinkProviderDeriver
Expanded class hierarchy of TestLinkProviderDeriver
File
- tests/
modules/ jsonapi_hypermedia_test_link_providers/ src/ Plugin/ Derivative/ TestLinkProviderDeriver.php, line 13
Namespace
Drupal\jsonapi_hypermedia_test_link_providers\Plugin\DerivativeView source
final class TestLinkProviderDeriver extends DeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$plugin_template = \Drupal::state()
->get('jsonapi_hypermedia_test_link_providers.template');
$random = new Random();
$definitions['not_restricted'] = [
'link_key' => $random
->name(8, TRUE),
'link_relation_type' => 'related',
'link_context' => $plugin_template['link_context'],
];
$definitions['access_restricted'] = [
'link_key' => $random
->name(8, TRUE),
'link_relation_type' => 'related',
'link_context' => $plugin_template['link_context'],
'_test_restrict_access' => TRUE,
];
$definitions['no_link_relations'] = [
'link_key' => $random
->name(8, TRUE),
'link_relation_type' => 'related',
'link_context' => $plugin_template['link_context'],
];
$definitions['link_relations'] = [
'link_key' => $random
->name(8, TRUE),
'link_relation_type' => 'test',
'link_context' => $plugin_template['link_context'],
];
$definitions['target_attributes'] = [
'link_key' => $random
->name(8, TRUE),
'link_relation_type' => 'related',
'link_context' => $plugin_template['link_context'],
'_test_target_attributes' => [
'foo' => 'bar',
],
];
$this->derivatives = array_map(function (array $definition) use ($base_plugin_definition) {
return array_merge($definition, $base_plugin_definition);
}, $definitions);
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
TestLinkProviderDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |