Skip to content

Commit

Permalink
Merge pull request #171 from openeuropa/EWPP-1288
Browse files Browse the repository at this point in the history
EWPP-1288: Code style fixes.
  • Loading branch information
upchuk committed Jul 20, 2021
2 parents a40efdb + 0840a1b commit ccb7109
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"guzzlehttp/guzzle": "~6.3",
"instaclick/php-webdriver": "^1.4.7",
"openeuropa/behat-transformation-context": "~0.1",
"openeuropa/code-review": "~1.6",
"openeuropa/code-review": "^1.7",
"openeuropa/drupal-core-require-dev": "^8.9 || ^9",
"openeuropa/task-runner-drupal-project-symlink": "^1.0",
"openeuropa/oe_link_lists": "dev-master",
Expand Down
15 changes: 12 additions & 3 deletions modules/oe_media_embed/src/Form/MediaEmbedDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ public function buildSelectStep(array &$form, FormStateInterface $form_state): a
$form['#title'] = $this->t('Select Media to embed');

if ($this->entityBrowser) {
$this->eventDispatcher->addListener(Events::REGISTER_JS_CALLBACKS, [$this, 'registerJsCallback']);
$this->eventDispatcher->addListener(Events::REGISTER_JS_CALLBACKS, [
$this,
'registerJsCallback',
]);
$form['entity_browser'] = [
'#type' => 'entity_browser',
'#entity_browser' => $this->entityBrowser->id(),
Expand Down Expand Up @@ -402,7 +405,13 @@ public function validateForm(array &$form, FormStateInterface $form_state): void
* The current state of the form.
*/
public function validateSelectStep(array $form, FormStateInterface $form_state): void {
if (($form_state->hasValue(['entity_browser', 'entities'])) && (count($form_state->getValue(['entity_browser', 'entities'])) > 0)) {
if (($form_state->hasValue([
'entity_browser',
'entities',
])) && (count($form_state->getValue([
'entity_browser',
'entities',
])) > 0)) {
$id = $form_state->getValue(['entity_browser', 'entities', 0])->id();
$element = $form['entity_browser'];
}
Expand Down Expand Up @@ -700,7 +709,7 @@ protected function getMediaViewModeFormElement(array $entity_element, EntityInte
'media_type' => $entity->bundle(),
]),
'#attributes' => ['target' => '_blank'],
];;
];
}

return $form_element;
Expand Down
5 changes: 4 additions & 1 deletion modules/oe_media_embed/src/Plugin/EmbedType/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ function ($item) {
},
// Filter out both modal and standalone forms as they don't work.
array_filter($browsers, function (EntityBrowserInterface $browser) {
return !in_array($browser->getDisplay()->getPluginId(), ['modal', 'standalone'], TRUE);
return !in_array($browser->getDisplay()->getPluginId(), [
'modal',
'standalone',
], TRUE);
})
);
$options = ['_none' => $this->t('None (autocomplete)')] + $browsers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,16 @@ public function testIntegration(): void {
->getStorage('media')
->loadMultiple();

$element = new FormattableMarkup('<p data-oembed="https://oembed.ec.europa.eu?url=https%3A//data.ec.europa.eu/ewp/media/@uuid%3Fview_mode%3Dimage_teaser"><a href="https://data.ec.europa.eu/ewp/media/@uuid">@title</a></p>', ['@uuid' => $media[1]->uuid(), '@title' => $media[1]->label()]);
$element = new FormattableMarkup('<p data-oembed="https://oembed.ec.europa.eu?url=https%3A//data.ec.europa.eu/ewp/media/@uuid%3Fview_mode%3Dimage_teaser"><a href="https://data.ec.europa.eu/ewp/media/@uuid">@title</a></p>', [
'@uuid' => $media[1]->uuid(),
'@title' => $media[1]->label(),
]);
$this->assertContains($element->__toString(), $this->getSession()->getPage()->getHtml());

$element = new FormattableMarkup('<p data-oembed="https://oembed.ec.europa.eu?url=https%3A//data.ec.europa.eu/ewp/media/@uuid%3Fview_mode%3Dembed"><a href="https://data.ec.europa.eu/ewp/media/@uuid">@title</a></p>', ['@uuid' => $media[2]->uuid(), '@title' => $media[2]->label()]);
$element = new FormattableMarkup('<p data-oembed="https://oembed.ec.europa.eu?url=https%3A//data.ec.europa.eu/ewp/media/@uuid%3Fview_mode%3Dembed"><a href="https://data.ec.europa.eu/ewp/media/@uuid">@title</a></p>', [
'@uuid' => $media[2]->uuid(),
'@title' => $media[2]->label(),
]);
$this->assertContains($element->__toString(), $this->getSession()->getPage()->getHtml());
}

Expand Down
4 changes: 3 additions & 1 deletion src/Plugin/EntityBrowser/Widget/MediaCreationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public function getForm(array &$original_form, FormStateInterface $form_state, a
$bundle = $form_state->get('media_bundle');
if ($bundle && isset($options[$bundle])) {
// Pretend to be IEFs submit button.
$form['#submit'] = [['Drupal\inline_entity_form\ElementSubmit', 'trigger']];
$form['#submit'] = [
['Drupal\inline_entity_form\ElementSubmit', 'trigger'],
];
$form['actions']['submit']['#ief_submit_trigger'] = TRUE;
$form['actions']['submit']['#ief_submit_trigger_all'] = TRUE;

Expand Down
10 changes: 8 additions & 2 deletions tests/src/Behat/AvPortalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class AvPortalContext extends RawDrupalContext {
* @beforeScenario @av_portal
*/
public function enableTestModule(BeforeScenarioScope $scope): void {
\Drupal::service('module_installer')->install(['media_avportal_mock', 'oe_media_avportal_test']);
\Drupal::service('module_installer')->install([
'media_avportal_mock',
'oe_media_avportal_test',
]);
}

/**
Expand All @@ -34,7 +37,10 @@ public function enableTestModule(BeforeScenarioScope $scope): void {
* @afterScenario @av_portal
*/
public function disableTestModule(AfterScenarioScope $scope): void {
\Drupal::service('module_installer')->uninstall(['media_avportal_mock', 'oe_media_avportal_test']);
\Drupal::service('module_installer')->uninstall([
'media_avportal_mock',
'oe_media_avportal_test',
]);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/src/Kernel/MediaAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ protected function setUp($import_test_views = TRUE) {

$this->installConfig(['oe_media']);

$this->currentUser = $this->setUpCurrentUser(['username' => 'test'], ['access media overview', 'view media']);
$this->currentUser = $this->setUpCurrentUser(
['username' => 'test'],
['access media overview', 'view media']
);
}

/**
Expand Down

0 comments on commit ccb7109

Please sign in to comment.