You are here

public static function ResourceIdentifier::isDuplicate in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php \Drupal\jsonapi\JsonApiResource\ResourceIdentifier::isDuplicate()

Determines if two ResourceIdentifiers are the same.

This method does not consider parallel relationships with different arity values to be duplicates. For that, use the isParallel() method.

Parameters

\Drupal\jsonapi\JsonApiResource\ResourceIdentifier $a: The first ResourceIdentifier object.

\Drupal\jsonapi\JsonApiResource\ResourceIdentifier $b: The second ResourceIdentifier object.

Return value

bool TRUE if both relationships reference the same resource and do not have two distinct arity's, FALSE otherwise.

For example, if $a and $b both reference the same resource identifier, they can only be distinct if they *both* have an arity and those values are not the same. If $a or $b does not have an arity, they will be considered duplicates.

2 calls to ResourceIdentifier::isDuplicate()
EntityResource::removeFromRelationshipData in core/modules/jsonapi/src/Controller/EntityResource.php
Deletes the relationship of an entity.
ResourceIdentifier::deduplicate in core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php
Deduplicates an array of ResourceIdentifier objects.

File

core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php, line 190

Class

ResourceIdentifier
Represents a JSON:API resource identifier object.

Namespace

Drupal\jsonapi\JsonApiResource

Code

public static function isDuplicate(ResourceIdentifier $a, ResourceIdentifier $b) {
  return static::compare($a, $b) === 0;
}