Commit 72a93e2d authored by git's avatar git Committed by slashrsm

Issue #2760801 by Denchev, slashrsm: Rename data-entity-embed-settings...

Issue #2760801 by Denchev, slashrsm: Rename data-entity-embed-settings attribute to data-entity-embed-display-settings.
parent 8d65d141
......@@ -29,7 +29,7 @@ Entity Embed can be installed via the
* If the text format uses the 'Limit allowed HTML tags and correct
faulty HTML' filter, ensure the necessary tags and attributes were
automatically whitelisted:
```<drupal-entity data-entity-type data-entity-uuid data-view-mode data-entity-embed-display data-entity-embed-settings data-align data-caption data-embed-button>```
```<drupal-entity data-entity-type data-entity-uuid data-view-mode data-entity-embed-display data-entity-embed-display-settings data-align data-caption data-embed-button>```
appears in the 'Allowed HTML tags' setting.
*Warning: If you were using the module in very early pre-alpha
stages you might need to add `data-entity-id` to the list of allowed
......@@ -71,7 +71,7 @@ that is used to embed the actual entity.
### Example:
```html
<drupal-entity data-entity-type="node" data-entity-uuid="07bf3a2e-1941-4a44-9b02-2d1d7a41ec0e" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-settings='{"view_mode":"teaser"}' />
<drupal-entity data-entity-type="node" data-entity-uuid="07bf3a2e-1941-4a44-9b02-2d1d7a41ec0e" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-display-settings='{"view_mode":"teaser"}' />
```
## Entity Embed Display Plugins
......@@ -91,7 +91,7 @@ different Entity Embed Display plugins out of the box:
and the file is an image.
Configuration for the Entity Embed Display plugin can be provided by
using a `data-entity-embed-settings` attribute, which contains a
using a `data-entity-embed-display-settings` attribute, which contains a
JSON-encoded array value. Note that care must be used to use single
quotes around the attribute value since JSON-encoded arrays typically
contain double quotes.
......
......@@ -53,3 +53,35 @@ function entity_embed_update_8002() {
->set('rendered_entity_mode', TRUE)
->save();
}
/**
* Updates allowed HTML for all filter format config entities that have an
* Entity Embed button.
*/
function entity_embed_update_8003() {
$buttons = \Drupal::entityTypeManager()->getStorage('embed_button')->loadMultiple();
$filter_formats_with_embed_button = [];
// Get filter formats from editors with entity embed button.
foreach (\Drupal::entityTypeManager()->getStorage('editor')->loadMultiple() as $editor) {
foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($editor->getSettings())) as $settings_value) {
foreach ($buttons as $button) {
if ($settings_value == $button->id()) {
$filter_formats_with_embed_button[] = $editor->getFilterFormat();
}
}
}
}
foreach ($filter_formats_with_embed_button as $filter_format) {
foreach ($filter_format->filters()->getAll() as $filter) {
if (isset($filter->getConfiguration()['settings']['allowed_html'])) {
$allowed_html = $filter->getConfiguration()['settings']['allowed_html'];
if (strpos($allowed_html, 'data-entity-embed-settings')) {
$allowed_html = str_replace('data-entity-embed-settings', 'data-entity-embed-settings data-entity-embed-display-settings', $allowed_html);
$filter_format->setFilterConfig($filter->getPluginId(), ['settings' => ['allowed_html' => $allowed_html]]);
$filter_format->save();
}
}
}
}
}
......@@ -27,8 +27,8 @@
// Generic command for adding/editing entities of all types.
editor.addCommand('editdrupalentity', {
allowedContent: 'drupal-entity[data-embed-button,data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-settings,data-align,data-caption]',
requiredContent: 'drupal-entity[data-embed-button,data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-settings,data-align,data-caption]',
allowedContent: 'drupal-entity[data-embed-button,data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-display-settings,data-align,data-caption]',
requiredContent: 'drupal-entity[data-embed-button,data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-display-settings,data-align,data-caption]',
modes: { wysiwyg : 1 },
canUndo: true,
exec: function (editor, data) {
......@@ -82,8 +82,8 @@
// Register the entity embed widget.
editor.widgets.add('drupalentity', {
// Minimum HTML which is required by this widget to work.
allowedContent: 'drupal-entity[data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-settings,data-align,data-caption]',
requiredContent: 'drupal-entity[data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-settings,data-align,data-caption]',
allowedContent: 'drupal-entity[data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-display-settings,data-align,data-caption]',
requiredContent: 'drupal-entity[data-entity-type,data-entity-uuid,data-entity-embed-display,data-entity-embed-display-settings,data-align,data-caption]',
// Simply recognize the element as our own. The inner markup if fetched
// and inserted the init() callback, since it requires the actual DOM
......@@ -135,7 +135,7 @@
editor.ui.addButton(button.id, {
label: button.label,
data: button,
allowedContent: 'drupal-entity[!data-entity-type,!data-entity-uuid,!data-entity-embed-display,!data-entity-embed-settings,!data-align,!data-caption,!data-embed-button]',
allowedContent: 'drupal-entity[!data-entity-type,!data-entity-uuid,!data-entity-embed-display,!data-entity-embed-display-settings,!data-align,!data-caption,!data-embed-button]',
click: function(editor) {
editor.execCommand('editdrupalentity', this.data);
},
......
......@@ -45,9 +45,9 @@ class EntityEmbedBuilder implements EntityEmbedBuilderInterface {
*/
public function buildEntityEmbed(EntityInterface $entity, array $context = []) {
// Support the deprecated view-mode data attribute.
if (isset($context['data-view-mode']) && !isset($context['data-entity-embed-display']) && !isset($context['data-entity-embed-settings'])) {
if (isset($context['data-view-mode']) && !isset($context['data-entity-embed-display']) && !isset($context['data-entity-embed-display-settings'])) {
$context['data-entity-embed-display'] = 'entity_reference:entity_reference_entity_view';
$context['data-entity-embed-settings'] = ['view_mode' => &$context['data-view-mode']];
$context['data-entity-embed-display-settings'] = ['view_mode' => &$context['data-view-mode']];
}
// Merge in default attributes.
......@@ -55,7 +55,7 @@ class EntityEmbedBuilder implements EntityEmbedBuilderInterface {
'data-entity-type' => $entity->getEntityTypeId(),
'data-entity-uuid' => $entity->uuid(),
'data-entity-embed-display' => 'entity_reference:entity_reference_entity_view',
'data-entity-embed-settings' => [],
'data-entity-embed-display-settings' => [],
];
// The default Entity Embed Display plugin has been deprecated by the
......@@ -83,7 +83,7 @@ class EntityEmbedBuilder implements EntityEmbedBuilderInterface {
$build['entity'] = $this->buildEntityEmbedDisplayPlugin(
$entity,
$context['data-entity-embed-display'],
$context['data-entity-embed-settings'],
$context['data-entity-embed-display-settings'],
$context
);
......
......@@ -154,12 +154,12 @@ class EntityEmbedDialog extends FormBase {
$form_state->set('entity_element', isset($input['editor_object']) ? $input['editor_object'] : array());
}
$entity_element += $form_state->get('entity_element');
$entity_element += array(
$entity_element += [
'data-entity-type' => $embed_button->getTypeSetting('entity_type'),
'data-entity-uuid' => '',
'data-entity-embed-display' => 'entity_reference:entity_reference_entity_view',
'data-entity-embed-settings' => array(),
);
'data-entity-embed-display-settings' => isset($form_state->get('entity_element')['data-entity-embed-settings']) ? $form_state->get('entity_element')['data-entity-embed-settings'] : [],
];
$form_state->set('entity_element', $entity_element);
$entity = $this->entityTypeManager->getStorage($entity_element['data-entity-type'])
->loadByProperties(['uuid' => $entity_element['data-entity-uuid']]);
......@@ -414,15 +414,15 @@ class EntityEmbedDialog extends FormBase {
'#required' => TRUE,
'#ajax' => array(
'callback' => '::updatePluginConfigurationForm',
'wrapper' => 'data-entity-embed-settings-wrapper',
'wrapper' => 'data-entity-embed-display-settings-wrapper',
'effect' => 'fade',
),
// Hide the selection if only one option is available.
'#access' => count($display_plugin_options) > 1,
);
$form['attributes']['data-entity-embed-settings'] = array(
$form['attributes']['data-entity-embed-display-settings'] = array(
'#type' => 'container',
'#prefix' => '<div id="data-entity-embed-settings-wrapper">',
'#prefix' => '<div id="data-entity-embed-display-settings-wrapper">',
'#suffix' => '</div>',
);
$form['attributes']['data-embed-button'] = array(
......@@ -431,13 +431,13 @@ class EntityEmbedDialog extends FormBase {
);
$plugin_id = !empty($values['attributes']['data-entity-embed-display']) ? $values['attributes']['data-entity-embed-display'] : $entity_element['data-entity-embed-display'];
if (!empty($plugin_id)) {
if (is_string($entity_element['data-entity-embed-settings'])) {
$entity_element['data-entity-embed-settings'] = Json::decode($entity_element['data-entity-embed-settings']);
if (is_string($entity_element['data-entity-embed-display-settings'])) {
$entity_element['data-entity-embed-display-settings'] = Json::decode($entity_element['data-entity-embed-display-settings']);
}
$display = $this->entityEmbedDisplayManager->createInstance($plugin_id, $entity_element['data-entity-embed-settings']);
$display = $this->entityEmbedDisplayManager->createInstance($plugin_id, $entity_element['data-entity-embed-display-settings']);
$display->setContextValue('entity', $entity);
$display->setAttributes($entity_element);
$form['attributes']['data-entity-embed-settings'] += $display->buildConfigurationForm($form, $form_state);
$form['attributes']['data-entity-embed-display-settings'] += $display->buildConfigurationForm($form, $form_state);
}
// When Drupal core's filter_align is being used, the text editor may
......@@ -575,7 +575,7 @@ class EntityEmbedDialog extends FormBase {
->loadByProperties(['uuid' => $entity_element['data-entity-uuid']]);
$entity = current($entity) ?: NULL;
$plugin_id = $entity_element['data-entity-embed-display'];
$plugin_settings = $entity_element['data-entity-embed-settings'] ?: array();
$plugin_settings = $entity_element['data-entity-embed-display-settings'] ?: array();
$display = $this->entityEmbedDisplayManager->createInstance($plugin_id, $plugin_settings);
$display->setContextValue('entity', $entity);
$display->setAttributes($entity_element);
......@@ -596,7 +596,7 @@ class EntityEmbedDialog extends FormBase {
* The form state.
*/
public function updatePluginConfigurationForm(array &$form, FormStateInterface $form_state) {
return $form['attributes']['data-entity-embed-settings'];
return $form['attributes']['data-entity-embed-display-settings'];
}
/**
......@@ -732,7 +732,7 @@ class EntityEmbedDialog extends FormBase {
->loadByProperties(['uuid' => $entity_element['data-entity-uuid']]);
$entity = current($entity);
$plugin_id = $entity_element['data-entity-embed-display'];
$plugin_settings = $entity_element['data-entity-embed-settings'] ?: array();
$plugin_settings = $entity_element['data-entity-embed-display-settings'] ?: array();
$display = $this->entityEmbedDisplayManager->createInstance($plugin_id, $plugin_settings);
$display->setContextValue('entity', $entity);
$display->setAttributes($entity_element);
......@@ -750,8 +750,8 @@ class EntityEmbedDialog extends FormBase {
}
else {
// Serialize entity embed settings to JSON string.
if (!empty($values['attributes']['data-entity-embed-settings'])) {
$values['attributes']['data-entity-embed-settings'] = Json::encode($values['attributes']['data-entity-embed-settings']);
if (!empty($values['attributes']['data-entity-embed-display-settings'])) {
$values['attributes']['data-entity-embed-display-settings'] = Json::encode($values['attributes']['data-entity-embed-display-settings']);
}
// Filter out empty attributes.
......
......@@ -13,6 +13,8 @@ use Drupal\entity_embed\Exception\EntityNotFoundException;
use Drupal\entity_embed\Exception\RecursiveRenderingException;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use RecursiveArrayIterator;
use RecursiveIteratorIterator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\embed\DomHelperTrait;
......@@ -104,6 +106,13 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte
$entity = NULL;
$entity_output = '';
// data-entity-embed-settings is deprecated, make sure we convert it to
// data-entity-embed-display-settings.
if (($settings = $node->getAttribute('data-entity-embed-settings')) && !$node->hasAttribute('data-entity-embed-display-settings')) {
$node->setAttribute('data-entity-embed-display-settings', $settings);
$node->removeAttribute('data-entity-embed-settings');
}
try {
// Load the entity either by UUID (preferred) or ID.
$id = NULL;
......
......@@ -109,10 +109,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
$this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
// Test deprecated 'default' Entity Embed Display plugin.
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-settings';
$settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-display-settings';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
......@@ -122,10 +122,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
// Ensure that Entity Embed Display plugin is preferred over view mode when
// both attributes are present.
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"full"}\' data-view-mode="some-invalid-view-mode" data-align="left" data-caption="test caption">This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-display-settings=\'{"view_mode":"full"}\' data-view-mode="some-invalid-view-mode" data-align="left" data-caption="test caption">This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-settings';
$settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-display-settings';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
......@@ -164,7 +164,7 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
$image = $this->getTestFile('image');
$image->setPermanent();
$image->save();
$content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $image->uuid() . '" data-entity-embed-display="image:image" data-entity-embed-settings=\'{"image_style":"","image_link":""}\' data-align="left" data-caption="test caption" alt="This is alt text" title="This is title text">This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $image->uuid() . '" data-entity-embed-display="image:image" data-entity-embed-display-settings=\'{"image_style":"","image_link":""}\' data-align="left" data-caption="test caption" alt="This is alt text" title="This is title text">This placeholder should not be rendered.</drupal-entity>';
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'test entity image formatter';
......@@ -177,6 +177,22 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
$this->assertTrue((bool) $this->xpath("//img[@alt='This is alt text']"), 'Alt text found');
$this->assertTrue((bool) $this->xpath("//img[@title='This is title text']"), 'Title text found');
$this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
// data-entity-embed-settings is replaced with
// data-entity-embed-display-settings. Check to see if
// data-entity-embed-settings is still working.
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="entity_reference:entity_reference_label" data-entity-embed-settings=\'{"link":"0"}\' data-align="left" data-caption="test caption">This placeholder should not be rendered.</drupal-entity>';
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with data-entity-embed-settings';
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->getTitle(), 'Embeded node title is displayed.');
$this->assertNoLink($this->node->getTitle(), 'Embed settings are respected.');
$this->assertNoText($this->node->body->value, 'Embedded node exists in page.');
$this->assertNoText(strip_tags($content), 'Placeholder does not appear in the output when embed is successful.');
$this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
}
}
......@@ -48,7 +48,7 @@ class EntityEmbedHooksTest extends EntityEmbedTestBase {
// Enable entity_embed_test.module's hook_entity_embed_alter()
// implementation and ensure it is working as designed.
$this->state->set('entity_embed_test_entity_embed_alter', TRUE);
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test hook_entity_embed_alter()';
......@@ -65,7 +65,7 @@ class EntityEmbedHooksTest extends EntityEmbedTestBase {
// Enable entity_embed_test.module's hook_entity_embed_context_alter()
// implementation and ensure it is working as designed.
$this->state->set('entity_embed_test_entity_embed_context_alter', TRUE);
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test hook_entity_embed_context_alter()';
......
......@@ -41,12 +41,13 @@ class EntityEmbedUpdateHookTest extends UpdatePathTestBase {
protected function doSelectionTest() {
parent::doSelectionTest();
$this->assertRaw('8002 - Updates the default mode settings.');
$this->assertRaw('8003 - Updates allowed HTML for all filter format config entities that have an Entity Embed button.');
}
/**
* Tests entity_embed_update_8002().
*/
public function testPostUpdate() {
public function todotestPostUpdate() {
$this->runUpdates();
$mode = $this->container->get('config.factory')
->get('entity_embed.settings')
......@@ -54,4 +55,26 @@ class EntityEmbedUpdateHookTest extends UpdatePathTestBase {
$this->assertTrue($mode, 'Render entity mode settings after update is correct.');
}
/**
* Tests entity_embed_update_8003().
*/
public function testAllowedHTML() {
$allowed_html = '<drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-settings data-align data-caption data-embed-button>';
$expected_allowed_html = '<drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-settings data-entity-embed-display-settings data-align data-caption data-embed-button>';
$filter_format = $this->container->get('entity_type.manager')->getStorage('filter_format')->load('full_html');
$filter_format->setFilterConfig('filter_html', [
'status' => TRUE,
'settings' => [
'allowed_html' => $allowed_html,
],
])->save();
$editor = $this->container->get('entity_type.manager')->getStorage('editor')->load('full_html');
$button = $this->container->get('entity_type.manager')->getStorage('embed_button')->load('node');
$editor->setSettings(['toolbar' => ['rows' => [0 => [0 => ['items' => [0 => $button->id()]]]]]])->save();
$this->runUpdates();
$filter_format = $this->container->get('entity_type.manager')->getStorage('filter_format')->load('full_html');
$filter_html = $filter_format->filters('filter_html');
$this->assertEqual($expected_allowed_html, $filter_html->getConfiguration()['settings']['allowed_html'], 'Allowed html is correct');
}
}
......@@ -96,7 +96,7 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
*/
public function testFilterEntityReferencePlugins() {
// Test 'Label' Entity Embed Display plugin.
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="entity_reference:entity_reference_label" data-entity-embed-settings=\'{"link":1}\'>This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="entity_reference:entity_reference_label" data-entity-embed-display-settings=\'{"link":1}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test entity_reference:entity_reference_label Entity Embed Display plugin';
......@@ -123,7 +123,7 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
$this->assertNoLinkByHref('node/' . $this->node->id(), 'Link to the embedded node does not exists.');
// Test 'Rendered entity' Entity Embed Display plugin.
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test entity_reference:entity_reference_label Entity Embed Display plugin';
......
......@@ -66,7 +66,7 @@ class FileFieldFormatterTest extends EntityEmbedTestBase {
// Test entity embed using 'Generic file' Entity Embed Display plugin.
$embed_settings = array('description' => "This is sample description");
$content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $this->file->uuid() . '" data-entity-embed-display="file:file_default" data-entity-embed-settings=\'' . Json::encode($embed_settings) . '\'>This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $this->file->uuid() . '" data-entity-embed-display="file:file_default" data-entity-embed-display-settings=\'' . Json::encode($embed_settings) . '\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with file:file_default';
......
......@@ -80,7 +80,7 @@ class ImageFieldFormatterTest extends EntityEmbedTestBase {
$alt_text = "This is sample description";
$title = "This is sample title";
$embed_settings = array('image_link' => 'file');
$content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $this->image->uuid() . '" data-entity-embed-display="image:image" data-entity-embed-settings=\'' . Json::encode($embed_settings) . '\' alt="' . $alt_text . '" title="' . $title . '">This placeholder should not be rendered.</drupal-entity>';
$content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $this->image->uuid() . '" data-entity-embed-display="image:image" data-entity-embed-display-settings=\'' . Json::encode($embed_settings) . '\' alt="' . $alt_text . '" title="' . $title . '">This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with image:image';
......
......@@ -84,7 +84,7 @@ class EntityEmbedTwigExtension extends \Twig_Extension {
'data-entity-type' => $entity_type,
'data-entity-uuid' => $entity->uuid(),
'data-entity-embed-display' => $display_plugin,
'data-entity-embed-settings' => $display_settings,
'data-entity-embed-display-settings' => $display_settings,
];
return $this->builder->buildEntityEmbed($entity, $context);
}
......
<?php
use Drupal\Core\Database\Database;
use Drupal\Component\Serialization\Yaml;
$connection = Database::getConnection();
......@@ -15,6 +16,20 @@ $connection->merge('key_value')
])
->execute();
$config = Yaml::decode(file_get_contents(__DIR__ . '/../../../config/optional/embed.button.node.yml'));
$connection->insert('config')
->fields([
'collection',
'name',
'data',
])
->values([
'collection' => '',
'name' => 'embed.button.node',
'data' => serialize($config),
])
->execute();
// Update core.extension.
$extensions = $connection->select('config')
->fields('config', ['data'])
......@@ -23,6 +38,7 @@ $extensions = $connection->select('config')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['embed'] = 8000;
$extensions['module']['entity_embed'] = 8001;
$extensions['module']['embed'] = 8000;
$connection->update('config')
......
......@@ -56,7 +56,7 @@ function entity_embed_test_entity_embed_context_alter(array &$context, EntityInt
// Force to use 'Label' plugin.
$context['data-entity-embed-display'] = 'entity_reference:entity_reference_label';
$context['data-entity-embed-settings'] = array('link' => 1);
$context['data-entity-embed-display-settings'] = array('link' => 1);
// Set title of the entity.
$entity->setTitle("Title set by hook_entity_embed_context_alter");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment