Skip to content
Snippets Groups Projects

3023322 - Contextual Links Style Update

7 unresolved threads
5 files
+ 59
3
Compare changes
  • Side-by-side
  • Inline
Files
5
  • 7064c439
    Issue #3173770 by chr.fritsch, phenaproxima, akalam, dejan0: Allow field types... · 7064c439
    Alex Pott authored
    Issue #3173770 by chr.fritsch, phenaproxima, akalam, dejan0: Allow field types extending entity_reference to use field widgets extending media_library
@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Field\EntityReferenceFieldItemList;
/**
* The media library opener for field widgets.
@@ -95,7 +96,9 @@ public function checkAccess(MediaLibraryState $state, AccountInterface $account)
$items = $entity->get($field_name);
$field_definition = $items->getFieldDefinition();
if ($field_definition->getType() !== 'entity_reference') {
// 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') {
Loading