Commit baceb17d authored by oknate's avatar oknate Committed by Wim Leers

Issue #2974668 by deepakkumar14, oknate: Convert module to use short array...

Issue #2974668 by deepakkumar14, oknate: Convert module to use short array syntax (new coding standard)
parent f8806125
......@@ -44,14 +44,14 @@ abstract class EntityEmbedDisplayBase extends PluginBase implements ContainerFac
*
* @var array
*/
public $context = array();
public $context = [];
/**
* The attributes on the embedded entity.
*
* @var array
*/
public $attributes = array();
public $attributes = [];
/**
* {@inheritdoc}
......@@ -131,14 +131,14 @@ abstract class EntityEmbedDisplayBase extends PluginBase implements ContainerFac
* {@inheritdoc}
*/
public function calculateDependencies() {
return array();
return [];
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return array();
return [];
}
/**
......
......@@ -40,12 +40,12 @@ class EntityEmbedDisplayManager extends DefaultPluginManager {
* Overrides DefaultPluginManager::processDefinition().
*/
public function processDefinition(&$definition, $plugin_id) {
$definition += array(
$definition += [
'entity_types' => FALSE,
);
];
if ($definition['entity_types'] !== FALSE && !is_array($definition['entity_types'])) {
$definition['entity_types'] = array($definition['entity_types']);
$definition['entity_types'] = [$definition['entity_types']];
}
}
......@@ -62,7 +62,7 @@ class EntityEmbedDisplayManager extends DefaultPluginManager {
*
* @see https://drupal.org/node/2277981
*/
public function getDefinitionsForContexts(array $contexts = array()) {
public function getDefinitionsForContexts(array $contexts = []) {
$definitions = $this->getDefinitions();
$valid_ids = array_filter(array_keys($definitions), function ($id) use ($contexts) {
try {
......@@ -96,7 +96,7 @@ class EntityEmbedDisplayManager extends DefaultPluginManager {
* An array of valid plugin labels, keyed by plugin ID.
*/
public function getDefinitionOptionsForEntity(EntityInterface $entity) {
$definitions = $this->getDefinitionsForContexts(array('entity' => $entity, 'entity_type' => $entity->getEntityTypeId()));
$definitions = $this->getDefinitionsForContexts(['entity' => $entity, 'entity_type' => $entity->getEntityTypeId()]);
$definitions = $this->filterExposedDefinitions($definitions);
return array_map(function ($definition) {
return (string) $definition['label'];
......@@ -131,7 +131,7 @@ class EntityEmbedDisplayManager extends DefaultPluginManager {
* An array of valid plugin labels, keyed by plugin ID.
*/
public function getDefinitionOptionsForEntityType($entity_type) {
$definitions = $this->getDefinitionsForContexts(array('entity_type' => $entity_type));
$definitions = $this->getDefinitionsForContexts(['entity_type' => $entity_type]);
$definitions = $this->filterExposedDefinitions($definitions);
return array_map(function ($definition) {
return (string) $definition['label'];
......
......@@ -144,7 +144,7 @@ abstract class FieldFormatterEntityEmbedDisplayBase extends EntityEmbedDisplayBa
public function build() {
// Create a temporary node object to which our fake field value can be
// added.
$node = Node::create(array('type' => '_entity_embed'));
$node = Node::create(['type' => '_entity_embed']);
$definition = $this->getFieldDefinition();
......@@ -161,7 +161,7 @@ abstract class FieldFormatterEntityEmbedDisplayBase extends EntityEmbedDisplayBa
// Prepare, expects an array of items, keyed by parent entity ID.
$formatter = $this->getFieldFormatter();
$formatter->prepareView(array($node->id() => $items));
$formatter->prepareView([$node->id() => $items]);
$build = $formatter->viewElements($items, $this->getLangcode());
// For some reason $build[0]['#printed'] is TRUE, which means it will fail
// to render later. So for now we manually fix that.
......@@ -192,20 +192,20 @@ abstract class FieldFormatterEntityEmbedDisplayBase extends EntityEmbedDisplayBa
*/
public function getFieldFormatter() {
if (!isset($this->fieldFormatter)) {
$display = array(
$display = [
'type' => $this->getFieldFormatterId(),
'settings' => $this->getConfiguration(),
'label' => 'hidden',
);
];
// Create the formatter plugin. Will use the default formatter for that
// field type if none is passed.
$this->fieldFormatter = $this->formatterPluginManager->getInstance(
array(
[
'field_definition' => $this->getFieldDefinition(),
'view_mode' => '_entity_embed',
'configuration' => $display,
)
]
);
}
......
This diff is collapsed.
......@@ -37,11 +37,11 @@ class DrupalEntity extends EmbedCKEditorPluginBase {
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
return array(
return [
'DrupalEntity_dialogTitleAdd' => t('Insert entity'),
'DrupalEntity_dialogTitleEdit' => t('Edit entity'),
'DrupalEntity_buttons' => $this->getButtons(),
);
];
}
}
......@@ -116,39 +116,39 @@ class Entity extends EmbedTypeBase implements ContainerFactoryPluginInterface {
$embed_button = $form_state->getTemporaryValue('embed_button');
$entity_type_id = $this->getConfigurationValue('entity_type');
$form['entity_type'] = array(
$form['entity_type'] = [
'#type' => 'select',
'#title' => $this->t('Entity type'),
'#options' => $this->getEntityTypeOptions(),
'#default_value' => $entity_type_id,
'#description' => $this->t("Entity type for which this button is to enabled."),
'#required' => TRUE,
'#ajax' => array(
'callback' => array($form_state->getFormObject(), 'updateTypeSettings'),
'#ajax' => [
'callback' => [$form_state->getFormObject(), 'updateTypeSettings'],
'effect' => 'fade',
),
],
'#disabled' => !$embed_button->isNew(),
);
];
if ($entity_type_id) {
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$form['bundles'] = array(
$form['bundles'] = [
'#type' => 'checkboxes',
'#title' => $entity_type->getBundleLabel() ?: $this->t('Bundles'),
'#options' => $this->getEntityBundleOptions($entity_type),
'#default_value' => $this->getConfigurationValue('bundles'),
'#description' => $this->t('If none are selected, all are allowed.'),
);
];
$form['bundles']['#access'] = !empty($form['bundles']['#options']);
// Allow option to limit Entity Embed Display plugins.
$form['display_plugins'] = array(
$form['display_plugins'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Allowed Entity Embed Display plugins'),
'#options' => $this->displayPluginManager->getDefinitionOptionsForEntityType($entity_type_id),
'#default_value' => $this->getConfigurationValue('display_plugins'),
'#description' => $this->t('If none are selected, all are allowed. Note that these are the plugins which are allowed for this entity type, all of these might not be available for the selected entity.'),
);
];
$form['display_plugins']['#access'] = !empty($form['display_plugins']['#options']);
/** @var \Drupal\entity_browser\EntityBrowserInterface[] $browsers */
......@@ -258,7 +258,7 @@ class Entity extends EmbedTypeBase implements ContainerFactoryPluginInterface {
* An array of bundle labels, keyed by bundle name.
*/
protected function getEntityBundleOptions(EntityTypeInterface $entity_type) {
$bundle_options = array();
$bundle_options = [];
// If the entity has bundles, allow option to restrict to bundle(s).
if ($entity_type->hasKey('bundle')) {
foreach ($this->entityTypeBundleInfo->getBundleInfo($entity_type->id()) as $bundle_id => $bundle_info) {
......
......@@ -139,7 +139,7 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte
}
$context = $this->getNodeAttributesAsArray($node);
$context += array('data-langcode' => $langcode);
$context += ['data-langcode' => $langcode];
$build = $this->builder->buildEntityEmbed($entity, $context);
// We need to render the embedded entity:
// - without replacing placeholders, so that the placeholders are
......
......@@ -33,7 +33,7 @@ class EntityReferenceFieldFormatter extends FieldFormatterEntityEmbedDisplayBase
* {@inheritdoc}
*/
public function getFieldValue() {
return array('target_id' => $this->getContextValue('entity')->id());
return ['target_id' => $this->getContextValue('entity')->id()];
}
}
......@@ -25,7 +25,7 @@ class FileFieldFormatter extends EntityReferenceFieldFormatter {
*/
public function getFieldValue() {
$value = parent::getFieldValue();
$value += array_intersect_key($this->getConfiguration(), array('description' => ''));
$value += array_intersect_key($this->getConfiguration(), ['description' => '']);
return $value;
}
......@@ -47,12 +47,12 @@ class FileFieldFormatter extends EntityReferenceFieldFormatter {
// Description is stored in the configuration since it doesn't map to an
// actual HTML attribute.
$form['description'] = array(
$form['description'] = [
'#type' => 'textfield',
'#title' => $this->t('Description'),
'#default_value' => $this->getConfigurationValue('description'),
'#description' => $this->t('The description may be used as the label of the link to the file.'),
);
];
return $form;
}
......
......@@ -77,7 +77,7 @@ class ImageFieldFormatter extends FileFieldFormatter {
$value = parent::getFieldValue();
// File field support descriptions, but images do not.
unset($value['description']);
$value += array_intersect_key($this->getAttributeValues(), array('alt' => '', 'title' => ''));
$value += array_intersect_key($this->getAttributeValues(), ['alt' => '', 'title' => '']);
return $value;
}
......@@ -158,24 +158,24 @@ class ImageFieldFormatter extends FileFieldFormatter {
}
// Add support for editing the alternate and title text attributes.
$form['alt'] = array(
$form['alt'] = [
'#type' => 'textfield',
'#title' => $this->t('Alternate text'),
'#default_value' => $alt,
'#description' => $this->t('This text will be used by screen readers, search engines, or when the image cannot be loaded.'),
'#parents' => array('attributes', 'alt'),
'#parents' => ['attributes', 'alt'],
'#required' => TRUE,
'#required_error' => $this->t('Alternative text is required.<br />(Only in rare cases should this be left empty. To create empty alternative text, enter <code>""</code> — two double quotes without any content).'),
'#maxlength' => 512,
);
$form['title'] = array(
];
$form['title'] = [
'#type' => 'textfield',
'#title' => $this->t('Title'),
'#default_value' => $this->getAttributeValue('title', ''),
'#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'),
'#parents' => array('attributes', 'title'),
'#parents' => ['attributes', 'title'],
'#maxlength' => 1024,
);
];
return $form;
}
......@@ -186,8 +186,8 @@ class ImageFieldFormatter extends FileFieldFormatter {
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// When the alt attribute is set to two double quotes, transform it to the
// empty string: two double quotes signify "empty alt attribute". See above.
if (trim($form_state->getValue(array('attributes', 'alt'))) === '""') {
$form_state->setValue(array('attributes', 'alt'), '');
if (trim($form_state->getValue(['attributes', 'alt'])) === '""') {
$form_state->setValue(['attributes', 'alt'], '');
}
}
......
......@@ -57,9 +57,9 @@ class EntityEmbedTwigExtension extends \Twig_Extension {
* {@inheritdoc}
*/
public function getFunctions() {
return array(
return [
new \Twig_SimpleFunction('entity_embed', [$this, 'getRenderArray']),
);
];
}
/**
......
......@@ -13,15 +13,15 @@ use Drupal\Core\Session\AccountInterface;
* Implements hook_theme().
*/
function entity_embed_test_theme($existing, $type, $theme, $path) {
$items['entity_embed_twig_test'] = array(
$items['entity_embed_twig_test'] = [
'template' => 'entity_embed_twig_test',
'variables' => array(
'variables' => [
'entity_type' => '',
'id' => '',
'display_plugin' => 'default',
'display_settings' => array(),
),
);
'display_settings' => [],
],
];
return $items;
}
......@@ -35,7 +35,7 @@ function entity_embed_test_entity_embed_display_plugins_alter(&$info) {
}
// Prefix each plugin name with 'testing_hook:'.
$new_info = array();
$new_info = [];
foreach ($info as $key => $value) {
$new_key = "testing_hook:" . $key;
$new_info[$new_key] = $info[$key];
......@@ -55,7 +55,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-display-settings'] = array('link' => 1);
$context['data-entity-embed-display-settings'] = ['link' => 1];
// Set title of the entity.
$entity->setTitle("Title set by hook_entity_embed_context_alter");
......
......@@ -11,36 +11,36 @@ class EntityEmbedTestTwigController {
* Menu callback for testing entity_embed twig extension using entity ID.
*/
public function idRender() {
return array(
return [
'#theme' => 'entity_embed_twig_test',
'#entity_type' => 'node',
'#id' => '1',
);
];
}
/**
* Menu callback for testing entity_embed twig extension using 'label' Entity Embed Display plugin.
*/
public function labelPluginRender() {
return array(
return [
'#theme' => 'entity_embed_twig_test',
'#entity_type' => 'node',
'#id' => '1',
'#display_plugin' => 'entity_reference:entity_reference_label',
);
];
}
/**
* Menu callback for testing entity_embed twig extension using 'label' Entity Embed Display plugin without linking to the node.
*/
public function labelPluginNoLinkRender() {
return array(
return [
'#theme' => 'entity_embed_twig_test',
'#entity_type' => 'node',
'#id' => '1',
'#display_plugin' => 'entity_reference:entity_reference_label',
'#display_settings' => array('link' => 0),
);
'#display_settings' => ['link' => 0],
];
}
}
......@@ -32,10 +32,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
public function testFilter() {
// Tests entity embed using entity ID and view mode.
$content = '<drupal-entity data-entity-type="node" data-entity-id="' . $this->node->id() . '" data-view-mode="teaser">This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with entity-id and view-mode';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertNoRaw('<drupal-entity data-entity-type="node" data-entity');
......@@ -70,10 +70,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
// Tests entity embed using entity UUID and view mode.
$content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-view-mode="teaser">This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with entity-uuid and view-mode';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertNoRaw('<drupal-entity data-entity-type="node" data-entity');
......@@ -84,10 +84,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
// Ensure that placeholder is not replaced when embed is unsuccessful.
$content = '<drupal-entity data-entity-type="node" data-entity-id="InvalidID" data-view-mode="teaser">This placeholder should be rendered since specified entity does not exists.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test that placeholder is retained when specified entity does not exists';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertNoRaw('<drupal-entity data-entity-type="node" data-entity');
......@@ -96,10 +96,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
// Ensure that UUID is preferred over ID when both attributes are present.
$sample_node = $this->drupalCreateNode();
$content = '<drupal-entity data-entity-type="node" data-entity-id="' . $sample_node->id() . '" data-entity-uuid="' . $this->node->uuid() . '" data-view-mode="teaser">This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test that entity-uuid is preferred over entity-id when both attributes are present';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertNoRaw('<drupal-entity data-entity-type="node" data-entity');
......@@ -110,10 +110,10 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
// 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-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-display-settings';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->body->value, 'Embedded node exists in page.');
......@@ -123,10 +123,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-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 = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-display-settings';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->body->value, 'Embedded node exists in page with the view mode specified by entity-embed-settings.');
......@@ -141,19 +141,19 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
// Test that tag of container element is not replaced when it's not
// <drupal-entity>.
$content = '<not-drupal-entity data-entity-type="node" data-entity-id="' . $this->node->id() . '" data-view-mode="teaser">this placeholder should not be rendered.</not-drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'test entity embed with entity-id and view-mode';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalget('node/' . $node->id());
$this->assertNoText($this->node->body->value, 'embedded node exists in page');
$this->assertRaw('</not-drupal-entity>');
$content = '<div data-entity-type="node" data-entity-id="' . $this->node->id() . '" data-view-mode="teaser">this placeholder should not be rendered.</div>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'test entity embed with entity-id and view-mode';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalget('node/' . $node->id());
$this->assertNoText($this->node->body->value, 'embedded node exists in page');
......
......@@ -52,10 +52,10 @@ class EntityEmbedHooksTest extends EntityEmbedTestBase {
// 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-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test hook_entity_embed_alter()';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->body->value, 'Embedded node exists in page.');
......@@ -69,10 +69,10 @@ class EntityEmbedHooksTest extends EntityEmbedTestBase {
// 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-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test hook_entity_embed_context_alter()';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertNoText(strip_tags($content), 'Placeholder does not appears in the output when embed is successful.');
......
......@@ -84,10 +84,10 @@ abstract class EntityEmbedTestBase extends BrowserTestBase {
$this->drupalLogin($this->webUser);
// Create a sample node to be embedded.
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Embed Test Node';
$settings['body'] = array('value' => 'This node is to be used for embedding in other nodes.', 'format' => 'custom_format');
$settings['body'] = ['value' => 'This node is to be used for embedding in other nodes.', 'format' => 'custom_format'];
$this->node = $this->drupalCreateNode($settings);
}
......
......@@ -14,7 +14,7 @@ class EntityEmbedTwigTest extends EntityEmbedTestBase {
*/
protected function setUp() {
parent::setUp();
\Drupal::service('theme_handler')->install(array('test_theme'));
\Drupal::service('theme_handler')->install(['test_theme']);
}
/**
......
......@@ -25,11 +25,11 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
parent::setUp();
// Add a new menu entity which does not has a view controller.
$this->menu = entity_create('menu', array(
$this->menu = entity_create('menu', [
'id' => 'menu_name',
'label' => 'Label',
'description' => 'Description text',
));
]);
$this->menu->save();
}
......@@ -60,18 +60,18 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
// Ensure that correct form attributes are returned for
// 'entity_reference:entity_reference_entity_id' plugin.
$form = array();
$form = [];
$form_state = new FormState();
$display = $this->container->get('plugin.manager.entity_embed.display')->createInstance('entity_reference:entity_reference_entity_id', array());
$display = $this->container->get('plugin.manager.entity_embed.display')->createInstance('entity_reference:entity_reference_entity_id', []);
$display->setContextValue('entity', $this->node);
$conf_form = $display->buildConfigurationForm($form, $form_state);
$this->assertIdentical(array_keys($conf_form), array());
$this->assertIdentical(array_keys($conf_form), []);
// Ensure that correct form attributes are returned for
// 'entity_reference:entity_reference_entity_view' plugin.
$form = array();
$form = [];
$form_state = new FormState();
$display = $this->container->get('plugin.manager.entity_embed.display')->createInstance('entity_reference:entity_reference_entity_view', array());
$display = $this->container->get('plugin.manager.entity_embed.display')->createInstance('entity_reference:entity_reference_entity_view', []);
$display->setContextValue('entity', $this->node);
$conf_form = $display->buildConfigurationForm($form, $form_state);
$this->assertIdentical($conf_form['view_mode']['#type'], 'select');
......@@ -79,12 +79,12 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
// Ensure that correct form attributes are returned for
// 'entity_reference:entity_reference_label' plugin.
$form = array();
$form = [];
$form_state = new FormState();
$display = $this->container->get('plugin.manager.entity_embed.display')->createInstance('entity_reference:entity_reference_label', array());
$display = $this->container->get('plugin.manager.entity_embed.display')->createInstance('entity_reference:entity_reference_label', []);
$display->setContextValue('entity', $this->node);
$conf_form = $display->buildConfigurationForm($form, $form_state);
$this->assertIdentical(array_keys($conf_form), array('link'));
$this->assertIdentical(array_keys($conf_form), ['link']);
$this->assertIdentical($conf_form['link']['#type'], 'checkbox');
$this->assertIdentical((string) $conf_form['link']['#title'], 'Link label to the referenced entity');
......@@ -100,10 +100,10 @@ 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-display-settings=\'{"link":1}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity_reference:entity_reference_label Entity Embed Display plugin';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->title->value, 'Title of the embedded node exists in page.');
......@@ -113,10 +113,10 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
// Test 'Entity ID' 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_id">This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity_reference:entity_reference_entity_id Entity Embed Display plugin';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->id(), 'ID of the embedded node exists in page.');
......@@ -127,10 +127,10 @@ class EntityReferenceFieldFormatterTest extends EntityEmbedTestBase {
// 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-display-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity_reference:entity_reference_label Entity Embed Display plugin';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($this->node->body->value, 'Body of embedded node does not exists in page.');
......
......@@ -49,13 +49,13 @@ class FileFieldFormatterTest extends EntityEmbedTestBase {
// Ensure that correct form attributes are returned for the file field
// formatter plugins.
$form = array();
$form = [];
$form_state = new FormState();
$plugins = array(
$plugins = [
'file:file_table',
'file:file_default',
'file:file_url_plain',
);
];
// Ensure that description field is available for all the 'file' plugins.
foreach ($plugins as $plugin) {
$display = $this->container->get('plugin.manager.entity_embed.display')
......@@ -68,12 +68,14 @@ class FileFieldFormatterTest extends EntityEmbedTestBase {
}
// Test entity embed using 'Generic file' Entity Embed Display plugin.
$embed_settings = array('description' => "This is sample description");
$embed_settings = [
'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-display-settings=\'' . Json::encode($embed_settings) . '\'>This placeholder should not be rendered.</drupal-entity>';
$settings = array();
$settings = [];
$settings['type'] = 'page';
$settings['title'] = 'Test entity embed with file:file_default';
$settings['body'] = array(array('value' => $content, 'format' => 'custom_format'));
$settings['body'] = [['value' => $content, 'format' => 'custom_format']];
$node = $this->drupalCreateNode($settings);
$this->drupalGet('node/' . $node->id());
$this->assertText($embed_settings['description'], 'Description of the embedded file exists in page.');
......
......@@ -58,18 +58,18 @@ class ImageFieldFormatterTest extends EntityEmbedTestBase {
]);
// Ensure that correct form attributes are returned for the image plugin.
$form = array();
$form = [];
$form_state = new FormState();
$display = $this->container->get('plugin.manager.entity_embed.display')
->createInstance('image:image', []);
$display->setContextValue('entity', $this->image);
$conf_form = $display->buildConfigurationForm($form, $form_state);
$this->assertIdentical(array_keys($conf_form), array(
$this->assertIdentical(array_keys($conf_form), [
'image_style',