class RelationLinkManager extends LinkManagerBase implements RelationLinkManagerInterface (View source)

Properties

protected string $linkDomain

Link domain used for type links URIs.

from  LinkManagerBase
protected ConfigFactoryInterface $configFactory

Config factory service.

from  LinkManagerBase
protected RequestStack $requestStack

The request stack.

from  LinkManagerBase
protected CacheBackendInterface $cache
protected EntityFieldManagerInterface $entityFieldManager

The entity field manager.

protected EntityTypeBundleInfoInterface $entityTypeBundleInfo

The entity bundle info.

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

protected ModuleHandlerInterface $moduleHandler

Module handler service.

Methods

setLinkDomain($domain)

{@inheritdoc}

string
getLinkDomain(array $context = [])

Gets the link domain.

__construct(CacheBackendInterface $cache, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, RequestStack $request_stack, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityFieldManagerInterface $entity_field_manager)

Constructor.

string
getRelationUri(string $entity_type, string $bundle, string $field_name, array $context = [])

Gets the URI that corresponds to a field.

array
getRelationInternalIds(string $relation_uri, $context = [])

Translates a REST URI into internal IDs.

array
getRelations(array $context = [])

Get the array of relation links.

array
writeCache(array $context = [])

Writes the cache of relation links.

Details

setLinkDomain($domain)

{@inheritdoc}

Parameters

$domain

protected string getLinkDomain(array $context = [])

Gets the link domain.

Parameters

array $context

Normalization/serialization context.

Return Value

string

The link domain.

See also

\Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize()
\Symfony\Component\Serializer\SerializerInterface::serialize()
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY

__construct(CacheBackendInterface $cache, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, RequestStack $request_stack, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityFieldManagerInterface $entity_field_manager)

Constructor.

Parameters

CacheBackendInterface $cache

The cache of relation URIs and their associated Typed Data IDs.

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

ModuleHandlerInterface $module_handler

The module handler service.

ConfigFactoryInterface $config_factory

The config factory service.

RequestStack $request_stack

The request stack.

EntityTypeBundleInfoInterface $entity_type_bundle_info

The entity type bundle info.

EntityFieldManagerInterface $entity_field_manager

The entity field manager.

string getRelationUri(string $entity_type, string $bundle, string $field_name, array $context = [])

Gets the URI that corresponds to a field.

When using hypermedia formats, this URI can be used to indicate which field the data represents. Documentation about this field can also be provided at this URI.

Parameters

string $entity_type

The bundle's entity type.

string $bundle

The bundle name.

string $field_name

The field name.

array $context

(optional) Optional serializer/normalizer context.

Return Value

string

The corresponding URI (or IANA link relation type) for the field.

array getRelationInternalIds(string $relation_uri, $context = [])

Translates a REST URI into internal IDs.

Parameters

string $relation_uri

Relation URI (or IANA link relation type) to transform into internal IDs.

$context

Return Value

array

Array with keys 'entity_type_id', 'bundle' and 'field_name'.

protected array getRelations(array $context = [])

Get the array of relation links.

Any field can be handled as a relation simply by changing how it is normalized. Therefore, there is no prior knowledge that can be used here to determine which fields to assign relation URIs. Instead, each field, even primitives, are given a relation URI. It is up to the caller to determine which URIs to use.

Parameters

array $context

Context from the normalizer/serializer operation.

Return Value

array

An array of typed data IDs keyed by corresponding relation URI. The keys are:

  • 'entity_type_id'
  • 'bundle'
  • 'field_name' The values for 'entity_type_id', 'bundle' and 'field_name' are strings.

See also

https://www.drupal.org/node/2877608

protected array writeCache(array $context = [])

Writes the cache of relation links.

Parameters

array $context

Context from the normalizer/serializer operation.

Return Value

array

An array of typed data IDs keyed by corresponding relation URI. The keys are:

  • 'entity_type_id'
  • 'bundle'
  • 'field_name' The values for 'entity_type_id', 'bundle' and 'field_name' are strings.