RelationLinkManager.php in Default Content 8
File
src/LinkManager/RelationLinkManager.php
View source
<?php
namespace Drupal\defaultcontent\LinkManager;
use Drupal\rest\LinkManager\RelationLinkManager as RestRelationLinkManager;
class RelationLinkManager extends RestRelationLinkManager {
public function getRelationUri($entity_type, $bundle, $field_name) {
return "http://drupal.org/rest/relation/{$entity_type}/{$bundle}/{$field_name}";
}
protected function writeCache() {
$data = array();
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
$reflection = new \ReflectionClass($entity_type
->getClass());
if ($reflection
->implementsInterface('\\Drupal\\Core\\Config\\Entity\\ConfigEntityInterface') || !$reflection
->hasMethod('baseFieldDefinitions')) {
continue;
}
foreach (array_keys($this->entityManager
->getBundleInfo($entity_type_id)) as $bundle) {
foreach ($this->entityManager
->getFieldDefinitions($entity_type_id, $bundle) as $field_name => $field_details) {
$relation_uri = $this
->getRelationUri($entity_type_id, $bundle, $field_name);
$data[$relation_uri] = array(
'entity_type' => $entity_type_id,
'bundle' => $bundle,
'field_name' => $field_name,
);
}
}
}
}
}