public function EntityDeriver::getDerivativeDefinitions in Zircon Profile 8
Same name in this branch
- 8 core/modules/rest/src/Plugin/Deriver/EntityDeriver.php \Drupal\rest\Plugin\Deriver\EntityDeriver::getDerivativeDefinitions()
- 8 core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver::getDerivativeDefinitions()
Same name and namespace in other branches
- 8.0 core/modules/rest/src/Plugin/Deriver/EntityDeriver.php \Drupal\rest\Plugin\Deriver\EntityDeriver::getDerivativeDefinitions()
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverInterface::getDerivativeDefinitions
See also
getDerivativeDefinition()
1 call to EntityDeriver::getDerivativeDefinitions()
- EntityDeriver::getDerivativeDefinition in core/
modules/ rest/ src/ Plugin/ Deriver/ EntityDeriver.php - Gets the definition of a derivative plugin.
File
- core/
modules/ rest/ src/ Plugin/ Deriver/ EntityDeriver.php, line 69 - Contains \Drupal\rest\Plugin\Deriver\EntityDeriver.
Class
- EntityDeriver
- Provides a resource plugin definition for every entity type.
Namespace
Drupal\rest\Plugin\DeriverCode
public function getDerivativeDefinitions($base_plugin_definition) {
if (!isset($this->derivatives)) {
// Add in the default plugin configuration and the resource type.
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
$this->derivatives[$entity_type_id] = array(
'id' => 'entity:' . $entity_type_id,
'entity_type' => $entity_type_id,
'serialization_class' => $entity_type
->getClass(),
'label' => $entity_type
->getLabel(),
);
$default_uris = array(
'canonical' => "/entity/{$entity_type_id}/" . '{' . $entity_type_id . '}',
'https://www.drupal.org/link-relations/create' => "/entity/{$entity_type_id}",
);
foreach ($default_uris as $link_relation => $default_uri) {
// Check if there are link templates defined for the entity type and
// use the path from the route instead of the default.
if ($link_template = $entity_type
->getLinkTemplate($link_relation)) {
$this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = '/' . $link_template;
}
else {
$this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = $default_uri;
}
}
$this->derivatives[$entity_type_id] += $base_plugin_definition;
}
}
return $this->derivatives;
}