Skip to content
Snippets Groups Projects
Commit cb011cb1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2181511 by amateescu, xjm, Berdir | yched: Throw an exception when...

Issue #2181511 by amateescu, xjm, Berdir | yched: Throw an exception when creating an EntityDisplay for a non-ContentEntity.
parent c9b722d0
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -108,13 +108,13 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl ...@@ -108,13 +108,13 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $values, $entity_type) { public function __construct(array $values, $entity_type) {
// @todo See http://drupal.org/node/1825044#comment-6847792: contact.module if (!isset($values['targetEntityType']) || !isset($values['bundle']) || !isset($values['mode'])) {
// currently produces invalid entities with a NULL bundle in some cases. throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.');
// Add the validity checks back when http://drupal.org/node/1856556 is }
// fixed.
// if (!isset($values['targetEntityType']) || !isset($values['bundle']) || !isset($values['mode'])) { if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) {
// throw new \InvalidArgumentException('Missing required properties for an EntityDisplayBase entity.'); throw new \InvalidArgumentException('EntityDisplay entities can only handle content entity types.');
// } }
// A plugin manager and a context type needs to be set by extending classes. // A plugin manager and a context type needs to be set by extending classes.
if (!isset($this->pluginManager)) { if (!isset($this->pluginManager)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment