Loading modules/inline_formatter_display/inline_formatter_display.module +12 −1 Changes for modules/inline_formatter_display/inline_formatter_display.module: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\field_ui\Form\EntityViewDisplayEditForm; use Drupal\Component\Render\MarkupInterface; /** * Implements hook_help(). Loading Loading @@ -143,7 +144,17 @@ function inline_formatter_display_entity_view_alter(array &$build, EntityInterfa $token_data = [ $entity->getEntityTypeId() => $entity, ]; $display_value = Drupal::service('token')->replace($display_value, $token_data, ['clear' => $clear_tokens]); $options = [ 'clear' => $clear_tokens, 'callback' => function (array &$replacements, array $data, array $options) { foreach ($replacements as $token => $value) { if (is_string($value) || $value instanceof MarkupInterface) { $replacements[$token] = str_replace(['{', '}'], ['{', '}'], (string) $value); } } }, ]; $display_value = Drupal::service('token')->replace($display_value, $token_data, $options); // Remove all properties that are not entity attributes or the label key. $allowed_keys = ['title', 'links', 'created', 'uid']; $entity_type_keys = $entity->getEntityType()->getKeys(); Loading src/Plugin/Field/FieldFormatter/InlineFormatterFieldFormatter.php +16 −1 Changes for src/Plugin/Field/FieldFormatter/InlineFormatterFieldFormatter.php: 16 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ use Drupal\Core\Render\Renderer; use Drupal\Core\Session\AccountProxy; use Drupal\Core\Utility\Token; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Render\MarkupInterface; /** * Plugin implementation of the 'html_inject_formatter' formatter. Loading Loading @@ -241,7 +242,21 @@ class InlineFormatterFieldFormatter extends FormatterBase implements ContainerFa $entity->getEntityTypeId() => $entity, ]; $clear_tokens = $editor->getSettings()['clear_tokens'] ?? FALSE; $formatted_field = $this->token->replace($formatted_field, $token_data, ['clear' => $clear_tokens]); $options = [ 'clear' => $clear_tokens, 'callback' => function (array &$replacements, array $data, array $options) { foreach ($replacements as $token => $value) { if (is_string($value) || $value instanceof MarkupInterface) { $replacements[$token] = str_replace( ['{', '}'], ['{', '}'], (string) $value ); } } }, ]; $formatted_field = $this->token->replace($formatted_field, $token_data, $options); $context = [ $entity->getEntityTypeId() => $entity, Loading Loading
modules/inline_formatter_display/inline_formatter_display.module +12 −1 Changes for modules/inline_formatter_display/inline_formatter_display.module: 12 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\field_ui\Form\EntityViewDisplayEditForm; use Drupal\Component\Render\MarkupInterface; /** * Implements hook_help(). Loading Loading @@ -143,7 +144,17 @@ function inline_formatter_display_entity_view_alter(array &$build, EntityInterfa $token_data = [ $entity->getEntityTypeId() => $entity, ]; $display_value = Drupal::service('token')->replace($display_value, $token_data, ['clear' => $clear_tokens]); $options = [ 'clear' => $clear_tokens, 'callback' => function (array &$replacements, array $data, array $options) { foreach ($replacements as $token => $value) { if (is_string($value) || $value instanceof MarkupInterface) { $replacements[$token] = str_replace(['{', '}'], ['{', '}'], (string) $value); } } }, ]; $display_value = Drupal::service('token')->replace($display_value, $token_data, $options); // Remove all properties that are not entity attributes or the label key. $allowed_keys = ['title', 'links', 'created', 'uid']; $entity_type_keys = $entity->getEntityType()->getKeys(); Loading
src/Plugin/Field/FieldFormatter/InlineFormatterFieldFormatter.php +16 −1 Changes for src/Plugin/Field/FieldFormatter/InlineFormatterFieldFormatter.php: 16 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ use Drupal\Core\Render\Renderer; use Drupal\Core\Session\AccountProxy; use Drupal\Core\Utility\Token; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Render\MarkupInterface; /** * Plugin implementation of the 'html_inject_formatter' formatter. Loading Loading @@ -241,7 +242,21 @@ class InlineFormatterFieldFormatter extends FormatterBase implements ContainerFa $entity->getEntityTypeId() => $entity, ]; $clear_tokens = $editor->getSettings()['clear_tokens'] ?? FALSE; $formatted_field = $this->token->replace($formatted_field, $token_data, ['clear' => $clear_tokens]); $options = [ 'clear' => $clear_tokens, 'callback' => function (array &$replacements, array $data, array $options) { foreach ($replacements as $token => $value) { if (is_string($value) || $value instanceof MarkupInterface) { $replacements[$token] = str_replace( ['{', '}'], ['{', '}'], (string) $value ); } } }, ]; $formatted_field = $this->token->replace($formatted_field, $token_data, $options); $context = [ $entity->getEntityTypeId() => $entity, Loading