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

Commit 071f067

Browse files
committed
Added an interface for EntityEmbedDisplayManager.
1 parent 9ccf455 commit 071f067

4 files changed

Lines changed: 78 additions & 35 deletions

File tree

src/EntityEmbedDisplay/EntityEmbedDisplayManager.php

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @see \Drupal\entity_embed\Annotation\EntityEmbedDisplay
2020
* @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayInterface
2121
*/
22-
class EntityEmbedDisplayManager extends DefaultPluginManager {
22+
class EntityEmbedDisplayManager extends DefaultPluginManager implements EntityEmbedDisplayManagerInterface {
2323

2424
/**
2525
* Constructs a new class instance.
@@ -52,16 +52,7 @@ public function processDefinition(&$definition, $plugin_id) {
5252
}
5353

5454
/**
55-
* Determines plugins whose constraints are satisfied by a set of contexts.
56-
*
57-
* @param array $contexts
58-
* An array of contexts.
59-
*
60-
* @return array
61-
* An array of plugin definitions.
62-
*
63-
* @todo At some point convert this to use ContextAwarePluginManagerTrait
64-
* @see https://drupal.org/node/2277981
55+
* @{inheritdoc}
6556
*/
6657
public function getDefinitionsForContexts(array $contexts = array()) {
6758
$definitions = $this->getDefinitions();
@@ -83,13 +74,7 @@ public function getDefinitionsForContexts(array $contexts = array()) {
8374
}
8475

8576
/**
86-
* Provides a list of plugins that can be used for a certain entity.
87-
*
88-
* @param \Drupal\Core\Entity\EntityInterface $entity
89-
* An entity object.
90-
*
91-
* @return array
92-
* An array of valid plugin labels, keyed by plugin ID.
77+
* @{inheritdoc}
9378
*/
9479
public function getDefinitionOptionsForEntity(EntityInterface $entity) {
9580
$definitions = $this->getDefinitionsForContexts(array('entity' => $entity));
@@ -99,13 +84,7 @@ public function getDefinitionOptionsForEntity(EntityInterface $entity) {
9984
}
10085

10186
/**
102-
* Provides a list of plugins that can be used for a certain entity type.
103-
*
104-
* @param string $entity_type
105-
* The entity type id.
106-
*
107-
* @return array
108-
* An array of valid plugin labels, keyed by plugin ID.
87+
* @{inheritdoc}
10988
*/
11089
public function getDefinitionOptionsForEntityType($entity_type) {
11190
$definitions = $this->getDefinitionsForContexts(array('entity_type' => $entity_type));
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Contains \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface.
6+
*/
7+
8+
namespace Drupal\entity_embed\EntityEmbedDisplay;
9+
10+
use Drupal\Component\Plugin\PluginManagerInterface;
11+
use Drupal\Core\Entity\EntityInterface;
12+
13+
/**
14+
* Provides an Entity embed display plugin manager.
15+
*
16+
* @see \Drupal\entity_embed\Annotation\EntityEmbedDisplay
17+
* @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayInterface
18+
*/
19+
interface EntityEmbedDisplayManagerInterface extends PluginManagerInterface {
20+
21+
/**
22+
* The default display plugin.
23+
*
24+
* @var string
25+
*/
26+
const DEFAULT_PLUGIN_ID = 'entity_reference:entity_reference_entity_view';
27+
28+
/**
29+
* Determines plugins whose constraints are satisfied by a set of contexts.
30+
*
31+
* @param array $contexts
32+
* An array of contexts.
33+
*
34+
* @return array
35+
* An array of plugin definitions.
36+
*
37+
* @todo At some point convert this to use ContextAwarePluginManagerTrait
38+
* @see https://drupal.org/node/2277981
39+
*/
40+
public function getDefinitionsForContexts(array $contexts = array());
41+
42+
/**
43+
* Provides a list of plugins that can be used for a certain entity.
44+
*
45+
* @param \Drupal\Core\Entity\EntityInterface $entity
46+
* An entity object.
47+
*
48+
* @return array
49+
* An array of valid plugin labels, keyed by plugin ID.
50+
*/
51+
public function getDefinitionOptionsForEntity(EntityInterface $entity);
52+
53+
/**
54+
* Provides a list of plugins that can be used for a certain entity type.
55+
*
56+
* @param string $entity_type
57+
* The entity type id.
58+
*
59+
* @return array
60+
* An array of valid plugin labels, keyed by plugin ID.
61+
*/
62+
public function getDefinitionOptionsForEntityType($entity_type);
63+
64+
}

src/EntityHelperTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Drupal\Core\Entity\EntityStorageException;
1313
use Drupal\Core\Extension\ModuleHandlerInterface;
1414
use Drupal\Core\Render\RendererInterface;
15-
use Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager;
15+
use Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface;
1616

1717
/**
1818
* Wrapper methods for entity loading and rendering.
@@ -41,7 +41,7 @@ trait EntityHelperTrait {
4141
/**
4242
* The display plugin manager.
4343
*
44-
* @var \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager.
44+
* @var \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface.
4545
*/
4646
protected $displayPluginManager;
4747

@@ -287,7 +287,7 @@ public function setModuleHandler(ModuleHandlerInterface $module_handler) {
287287
/**
288288
* Returns the display plugin manager.
289289
*
290-
* @return \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager
290+
* @return \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface
291291
* The display plugin manager.
292292
*/
293293
protected function displayPluginManager() {
@@ -300,12 +300,12 @@ protected function displayPluginManager() {
300300
/**
301301
* Sets the display plugin manager service.
302302
*
303-
* @param \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager $display_plugin_manager
303+
* @param \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface $display_plugin_manager
304304
* The display plugin manager service.
305305
*
306306
* @return self
307307
*/
308-
public function setDisplayPluginManager(EntityEmbedDisplayManager $display_plugin_manager) {
308+
public function setDisplayPluginManager(EntityEmbedDisplayManagerInterface $display_plugin_manager) {
309309
$this->displayPluginManager = $display_plugin_manager;
310310
return $this;
311311
}

src/Form/EntityEmbedDialog.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Drupal\editor\Ajax\EditorDialogSave;
1818
use Drupal\editor\EditorInterface;
1919
use Drupal\embed\EmbedButtonInterface;
20-
use Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager;
20+
use Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface;
2121
use Drupal\entity_embed\EntityHelperTrait;
2222
use Drupal\Component\Serialization\Json;
2323
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -38,12 +38,12 @@ class EntityEmbedDialog extends FormBase {
3838
/**
3939
* Constructs a EntityEmbedDialog object.
4040
*
41-
* @param \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager $plugin_manager
42-
* The Module Handler.
41+
* @param \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManagerInterface $plugin_manager
42+
* The display plugin manager.
4343
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
44-
* The Form Builder.
44+
* The form builder.
4545
*/
46-
public function __construct(EntityEmbedDisplayManager $plugin_manager, FormBuilderInterface $form_builder) {
46+
public function __construct(EntityEmbedDisplayManagerInterface $plugin_manager, FormBuilderInterface $form_builder) {
4747
$this->setDisplayPluginManager($plugin_manager);
4848
$this->formBuilder = $form_builder;
4949
}

0 commit comments

Comments
 (0)