$field_definition =
$items->
getFieldDefinition();
// Check that the field is an entity reference, or subclass of it, since we
// need to check the target_type setting.
if (!
$items instanceof EntityReferenceFieldItemList
) { throw new \
LogicException('Expected the media library to be opened by an entity reference field.'
);
} if ($field_definition->
getFieldStorageDefinition()->
getSetting('target_type'
) !== 'media'
) { throw new \
LogicException('Expected the media library to be opened by an entity reference field that target media items.'
);
} $field_access =
$access_handler->
fieldAccess('edit',
$field_definition,
$account,
$items, TRUE
);
$access =
$entity_access->
andIf($field_access);
if ($access instanceof RefinableCacheableDependencyInterface
) { $access->
addCacheableDependency($state);
} return $access;
} /**
* {@inheritdoc}
*/
public function getSelectionResponse(MediaLibraryState
$state, array
$selected_ids) {