Skip to content
Snippets Groups Projects
Commit 17df878e authored by Kristof De Jaeger's avatar Kristof De Jaeger Committed by Kristof De Jaeger
Browse files

Issue #3137198 by swentel, Berdir: Token prevents layout builder to add new ds layout

parent ea5b7299
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
namespace Drupal\ds\Plugin;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
......@@ -124,7 +125,9 @@ class DsLayout extends LayoutDefault implements PluginFormInterface {
];
$token_types = 'all';
if ($entity = $form_state->getFormObject()->getEntity()) {
// The entity is not always available.
// See https://www.drupal.org/project/ds/issues/3137198.
if (($form_object = $form_state->getFormObject()) && $form_object instanceof EntityFormInterface && ($entity = $form_object->getEntity())) {
$token_types = [$entity->getTargetEntityTypeId()];
}
......
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