summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenatog2017-07-06 15:36:06 (GMT)
committerRenato Goncalves de Araujo2017-07-06 15:36:06 (GMT)
commitcd54d14ae96d2e874cedf019664054f575f7aec2 (patch)
tree805678318259afbcd08df52543e991c3de44e17c
parent631a8a81508d684193a77f327fcb126abee9746a (diff)
Issue #2892746 by PatrickMichael, RenatoG: Notice: Undefined index: #entity_type in ColorboxFormatter.php
-rw-r--r--colorbox.install2
-rw-r--r--src/Plugin/Field/FieldFormatter/ColorboxFormatter.php18
2 files changed, 16 insertions, 4 deletions
diff --git a/colorbox.install b/colorbox.install
index 7474b11..742667b 100644
--- a/colorbox.install
+++ b/colorbox.install
@@ -5,8 +5,6 @@
* Install, update and uninstall functions for the colorbox module.
*/
-use Drupal\Core\Url;
-
/**
* Implements hook_install().
*/
diff --git a/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php b/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php
index a648d8f..aa05134 100644
--- a/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php
@@ -190,11 +190,18 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl
],
];
if ($this->moduleHandler->moduleExists('token')) {
+
+ $entity_type = '';
+
+ if (!empty($form['#entity_type'])) {
+ $entity_type = $form['#entity_type'];
+ }
+
$element['colorbox_token_gallery'] = [
'#type' => 'fieldset',
'#title' => $this->t('Replacement patterns'),
'#theme' => 'token_tree_link',
- '#token_types' => [$form['#entity_type'], 'file'],
+ '#token_types' => [$entity_type, 'file'],
'#states' => [
'visible' => [
':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => ['value' => 'custom'],
@@ -241,11 +248,18 @@ class ColorboxFormatter extends ImageFormatterBase implements ContainerFactoryPl
],
];
if ($this->moduleHandler->moduleExists('token')) {
+
+ $entity_type = '';
+
+ if (!empty($form['#entity_type'])) {
+ $entity_type = $form['#entity_type'];
+ }
+
$element['colorbox_token_caption'] = [
'#type' => 'fieldset',
'#title' => $this->t('Replacement patterns'),
'#theme' => 'token_tree_link',
- '#token_types' => [$form['#entity_type'], 'file'],
+ '#token_types' => [$entity_type, 'file'],
'#states' => [
'visible' => [
':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => ['value' => 'custom'],