Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Adding weight to display plugins. #175

Open
wants to merge 1 commit into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Annotation/EntityEmbedDisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ class EntityEmbedDisplay extends Plugin {
*/
public $entity_types = FALSE;

/**
* @var int
*/
public $weight = 0;

}
1 change: 1 addition & 0 deletions src/EntityEmbedDisplay/EntityEmbedDisplayManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function getDefinitionsForContexts(array $contexts = array()) {
});
$definitions_for_context = array_intersect_key($definitions, array_flip($valid_ids));
$this->moduleHandler->alter('entity_embed_display_plugins_for_context', $definitions_for_context, $contexts);
uasort($definitions_for_context, 'Drupal\Component\Utility\SortArray::sortByWeightElement');
return $definitions_for_context;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/EntityEmbedDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public function getDisplayPluginOptions(EmbedButtonInterface $embed_button, Enti
$plugins = array_intersect_key($plugins, array_flip($allowed_plugins));
}

natsort($plugins);
//natsort($plugins);
return $plugins;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* entity_types = {"file"},
* deriver = "Drupal\entity_embed\Plugin\Derivative\FieldFormatterDeriver",
* field_type = "file",
* provider = "file"
* provider = "file",
* weight = -10
* )
*/
class FileFieldFormatter extends EntityReferenceFieldFormatter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
* entity_types = {"file"},
* deriver = "Drupal\entity_embed\Plugin\Derivative\FieldFormatterDeriver",
* field_type = "image",
* provider = "image"
* provider = "image",
* weight = -20
* )
*/
class ImageFieldFormatter extends FileFieldFormatter {
Expand Down