Created
November 19, 2017 20:50
-
-
Save cburschka/b214a52bdb1fdf7349ef3b0afe56b950 to your computer and use it in GitHub Desktop.
replace node with media in link widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -74,7 +74,7 @@ protected static function getUriAsDisplayableString($uri) { | |
// Show the 'entity:' URI as the entity autocomplete would. | |
// @todo Support entity types other than 'node'. Will be fixed in | |
// https://www.drupal.org/node/2423093. | |
- if ($entity_type == 'node' && $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id)) { | |
+ if ($entity_type == 'media' && $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id)) { | |
$displayable_string = EntityAutocomplete::getEntityLabels([$entity]); | |
} | |
} | |
@@ -108,7 +108,7 @@ protected static function getUserEnteredStringAsUri($string) { | |
if ($entity_id !== NULL) { | |
// @todo Support entity types other than 'node'. Will be fixed in | |
// https://www.drupal.org/node/2423093. | |
- $uri = 'entity:node/' . $entity_id; | |
+ $uri = 'entity:media/' . $entity_id; | |
} | |
// Detect a schemeless string, map to 'internal:' URI. | |
elseif (!empty($string) && parse_url($string, PHP_URL_SCHEME) === NULL) { | |
@@ -185,7 +185,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen | |
$element['uri']['#type'] = 'entity_autocomplete'; | |
// @todo The user should be able to select an entity type. Will be fixed | |
// in https://www.drupal.org/node/2423093. | |
- $element['uri']['#target_type'] = 'node'; | |
+ $element['uri']['#target_type'] = 'media'; | |
// Disable autocompletion when the first character is '/', '#' or '?'. | |
$element['uri']['#attributes']['data-autocomplete-first-character-blacklist'] = '/#?'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment