You are here

protected function JsonapiHelper::relationshipHandleable in Entity Share 8.2

Same name and namespace in other branches
  1. 8 modules/entity_share_client/src/Service/JsonapiHelper.php \Drupal\entity_share_client\Service\JsonapiHelper::relationshipHandleable()

Check if a relationship is handleable.

Filter on fields not targeting config entities or users.

Parameters

\Drupal\Core\Field\FieldItemListInterface $field: The field item list.

Return value

bool TRUE if the relationship is handleable.

1 call to JsonapiHelper::relationshipHandleable()
JsonapiHelper::updateRelationships in modules/entity_share_client/src/Service/JsonapiHelper.php
Create or update the entity reference field values of an entity.

File

modules/entity_share_client/src/Service/JsonapiHelper.php, line 740

Class

JsonapiHelper
Class JsonapiHelper.

Namespace

Drupal\entity_share_client\Service

Code

protected function relationshipHandleable(FieldItemListInterface $field) {
  $relationship_handleable = FALSE;
  if ($field instanceof EntityReferenceFieldItemListInterface) {
    $settings = $field
      ->getItemDefinition()
      ->getSettings();

    // Entity reference and Entity reference revisions.
    if (isset($settings['target_type'])) {
      $relationship_handleable = !$this
        ->isUserOrConfigEntity($settings['target_type']);
    }
    elseif (isset($settings['entity_type_ids'])) {
      foreach ($settings['entity_type_ids'] as $entity_type_id) {
        $relationship_handleable = !$this
          ->isUserOrConfigEntity($entity_type_id);
        if (!$relationship_handleable) {
          break;
        }
      }
    }
  }
  return $relationship_handleable;
}