diff --git a/CHANGELOG.md b/CHANGELOG.md index 662a455d..839786b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Stanford Media +11.1.0 +-------------------------------------------------------------------------------- +_Release Date: 2024-06-26_ + +- D11 upgrades, requires D10.3 +- Logger syntax bug fix. + 11.0.3 -------------------------------------------------------------------------------- _Release Date: 2024-03-14_ diff --git a/composer.json b/composer.json index 2761b735..225466c0 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=8.1", "davidbarratt/custom-installer": "^1.1", - "drupal/core": "^10.2", + "drupal/core": "^10.3 || ^11", "drupal/dropzonejs": "^2.7", "drupal/entity_usage": "^2.0@beta", "drupal/focal_point": "^2.0@alpha", @@ -30,6 +30,9 @@ "drupal/oembed_providers": "^2.1", "enyo/dropzone": "^5.9" }, + "conflict": { + "drupal/ckeditor": "*" + }, "extra": { "custom-installer": { "docroot/libraries/{$name}/": [ diff --git a/modules/media_duplicate_validation/media_duplicate_validation.info.yml b/modules/media_duplicate_validation/media_duplicate_validation.info.yml index a589a862..5dc48a63 100644 --- a/modules/media_duplicate_validation/media_duplicate_validation.info.yml +++ b/modules/media_duplicate_validation/media_duplicate_validation.info.yml @@ -1,7 +1,7 @@ name: 'Media Duplicate Validation' type: module description: 'Media Validation plugins to help prevent duplication of media items' -core_version_requirement: ^10 +core_version_requirement: ^10 || ^11 version: 10.0.0 package: media dependencies: diff --git a/src/Form/StanfordMediaDialogForm.php b/src/Form/StanfordMediaDialogForm.php deleted file mode 100644 index a774651a..00000000 --- a/src/Form/StanfordMediaDialogForm.php +++ /dev/null @@ -1,136 +0,0 @@ -get('entity.repository'), - $container->get('entity_display.repository'), - $container->get('plugin.manager.media_embed_dialog_manager') - ); - } - - /** - * {@inheritDoc} - */ - public function __construct(EntityRepositoryInterface $entity_repository, EntityDisplayRepositoryInterface $display_repository, MediaEmbedDialogManager $dialog_manager) { - parent::__construct($entity_repository, $display_repository); - $this->dialogPluginManager = $dialog_manager; - } - - /** - * {@inheritDoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, EditorInterface $editor = NULL) { - $form = parent::buildForm($form, $form_state, $editor); - $media = $this->getFormMediaEntity($form_state); - foreach ($this->getDialogAlterPlugins($media) as $plugin) { - $plugin->alterDialogForm($form, $form_state); - } - return $form; - } - - /** - * {@inheritDoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - parent::validateForm($form, $form_state); - $media = $this->getFormMediaEntity($form_state); - foreach ($this->getDialogAlterPlugins($media) as $plugin) { - $plugin->validateDialogForm($form, $form_state); - } - } - - /** - * {@inheritDoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $response = parent::submitForm($form, $form_state); - $commands = $response->getCommands(); - - if ($commands[0]['command'] == 'editorDialogSave') { - $values = $commands[0]['values']; - - $media = $this->getFormMediaEntity($form_state); - - foreach ($this->getDialogAlterPlugins($media) as $plugin) { - $plugin->alterDialogValues($values, $form, $form_state); - } - - $response = new AjaxResponse(); - $response->addCommand(new EditorDialogSave($values)); - $response->addCommand(new CloseModalDialogCommand()); - } - return $response; - } - - /** - * Get the entity UUID and load the media entity associated to it. - * - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Current form state. - * - * @return \Drupal\media\MediaInterface|null - * Media entity in the form. - * - * @throws \Drupal\Core\Entity\EntityStorageException - */ - protected function getFormMediaEntity(FormStateInterface $form_state): ?MediaInterface { - $media_uuid = $form_state->get(['media_embed_element', 'data-entity-uuid']); - return $this->entityRepository->loadEntityByUuid('media', $media_uuid); - } - - /** - * Get an array of all plugins that are supposed to alter the dialog. - * - * @param \Drupal\media\MediaInterface $media - * Media entity. - * - * @return \Drupal\stanford_media\Plugin\MediaEmbedDialogInterface[] - * Array of plugins. - * - * @throws \Drupal\Component\Plugin\Exception\PluginException - */ - protected function getDialogAlterPlugins(MediaInterface $media): array { - $plugins = []; - foreach (array_keys($this->dialogPluginManager->getDefinitions()) as $plugin_id) { - /** @var \Drupal\stanford_media\Plugin\MediaEmbedDialogInterface $plugin */ - $plugin = $this->dialogPluginManager->createInstance($plugin_id, ['entity' => $media]); - - if ($plugin->isApplicable()) { - $plugins[$plugin_id] = $plugin; - } - } - return $plugins; - } - -} diff --git a/src/Plugin/MediaEmbedDialogBase.php b/src/Plugin/MediaEmbedDialogBase.php index f6adb3b9..092c1abc 100644 --- a/src/Plugin/MediaEmbedDialogBase.php +++ b/src/Plugin/MediaEmbedDialogBase.php @@ -34,6 +34,7 @@ abstract class MediaEmbedDialogBase extends PluginBase implements MediaEmbedDial * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( $configuration, $plugin_id, diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index 817cdfa8..40216844 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -19,9 +19,6 @@ protected function alterRoutes(RouteCollection $collection) { if ($route = $collection->get('entity.media.add_page')) { $route->setDefault('_controller', MediaAdd::class . '::addPage'); } - if ($route = $collection->get('editor.media_dialog')) { - $route->setDefault('_form', StanfordMediaDialogForm::class); - } } } diff --git a/stanford_media.info.yml b/stanford_media.info.yml index 776d2ac4..ef9edb37 100644 --- a/stanford_media.info.yml +++ b/stanford_media.info.yml @@ -1,9 +1,9 @@ name: Stanford Media description: Provides media module configuration and plugins. -core_version_requirement: ^10.2 +core_version_requirement: ^10.2 || 11 package: media type: module -version: 11.0.3 +version: 11.1.0 dependencies: - dropzonejs:dropzonejs - drupal:breakpoint diff --git a/stanford_media.install b/stanford_media.install index 8a95869d..de31ba53 100644 --- a/stanford_media.install +++ b/stanford_media.install @@ -42,4 +42,13 @@ function stanford_media_update_11001() { $config->clear('filters.stanford_media_embed_markup')->save(); } } +} + +/** + * Check if ckeditor installed. + */ +function stanford_media_update_11002() { + if (\Drupal::moduleHandler()->moduleExists('ckeditor')) { + throw new \Exception('Stanford Media is not compatible with ckeditor'); + } } \ No newline at end of file diff --git a/tests/src/Kernel/Form/StanfordMediaDialogFormTest.php b/tests/src/Kernel/Form/StanfordMediaDialogFormTest.php deleted file mode 100644 index 9362e75e..00000000 --- a/tests/src/Kernel/Form/StanfordMediaDialogFormTest.php +++ /dev/null @@ -1,74 +0,0 @@ - 'html', 'name' => 'test format'])->save(); - $editor = Editor::create([ - 'format' => 'html', - 'editor' => 'ckeditor5', - ]); - $editor->save(); - $media = Media::create(['bundle' => 'file']); - $media->save(); - $form_state = new FormState(); - $form_state->set('media_embed_element', [ - 'data-entity-uuid' => $media->uuid(), - 'data-view-mode' => NULL, - ]); - $form_state->addBuildInfo('args', [$editor]); - $form = \Drupal::formBuilder()->buildForm($this->formArg, $form_state); - $this->assertArrayHasKey('description', $form); - - $form_state->setValue(['attributes', 'data-view-mode'], NULL); - $form_state->setValue('description', 'foo bar'); - $form_state->getFormObject()->validateForm($form, $form_state); - $this->assertFalse($form_state::hasAnyErrors()); - $response = $form_state->getFormObject()->submitForm($form, $form_state); - $this->assertEquals('foo bar', $response->getCommands()[0]['values']['attributes']['data-display-description']); - } - -} diff --git a/tests/src/Kernel/Plugin/Field/FieldFormatter/EmbeddableFormatterTest.php b/tests/src/Kernel/Plugin/Field/FieldFormatter/EmbeddableFormatterTest.php index da8e84dc..b6f71d97 100644 --- a/tests/src/Kernel/Plugin/Field/FieldFormatter/EmbeddableFormatterTest.php +++ b/tests/src/Kernel/Plugin/Field/FieldFormatter/EmbeddableFormatterTest.php @@ -36,6 +36,7 @@ class EmbeddableFormatterTest extends KernelTestBase { 'field', 'file', 'entity_test', + 'path_alias', ]; /** @@ -82,6 +83,7 @@ public function setup(): void { parent::setUp(); $this->installEntitySchema('user'); $this->installEntitySchema('media'); + $this->installEntitySchema('path_alias'); $this->installConfig('media'); $this->installEntitySchema('field_storage_config'); $this->installEntitySchema('field_config'); @@ -288,7 +290,7 @@ public function testEmbeddableFormatter() { $view_builder = \Drupal::entityTypeManager() ->getViewBuilder('media'); $view_render = $view_builder->view($this->unstructured_media, 'default'); - $rendered_view = \Drupal::service('renderer')->renderPlain($view_render); + $rendered_view = \Drupal::service('renderer')->renderInIsolation($view_render); $this->assertStringContainsString('http://www.test.com', $rendered_view); $view_builder = \Drupal::entityTypeManager() diff --git a/tests/src/Kernel/Plugin/Field/FieldFormatter/GoogleFormFormatterTest.php b/tests/src/Kernel/Plugin/Field/FieldFormatter/GoogleFormFormatterTest.php index d4bff28d..2a68d756 100644 --- a/tests/src/Kernel/Plugin/Field/FieldFormatter/GoogleFormFormatterTest.php +++ b/tests/src/Kernel/Plugin/Field/FieldFormatter/GoogleFormFormatterTest.php @@ -159,7 +159,7 @@ public function testGoogleFormatter() { $view_builder = \Drupal::entityTypeManager()->getViewBuilder('media'); $display = $view_builder->view($this->media, 'default'); - $display = \Drupal::service('renderer')->renderPlain($display); + $display = \Drupal::service('renderer')->renderInIsolation($display); preg_match('/assertCount(1, $matches); diff --git a/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaImageFormatterTest.php b/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaImageFormatterTest.php index 9cf6d234..12ce55a1 100644 --- a/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaImageFormatterTest.php +++ b/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaImageFormatterTest.php @@ -156,7 +156,7 @@ public function testFieldFormatter() { $view_builder = \Drupal::entityTypeManager() ->getViewBuilder('node'); $node_render = $view_builder->view($node, 'default'); - $rendered_node = \Drupal::service('renderer')->renderPlain($node_render); + $rendered_node = \Drupal::service('renderer')->renderInIsolation($node_render); preg_match_all('//s', $rendered_node, $preg_match); $this->assertNotEmpty($preg_match[0]); preg_match_all('/alt="Foo Bar Alt"/', $rendered_node, $preg_match); @@ -175,7 +175,7 @@ public function testFieldFormatter() { $view_builder = \Drupal::entityTypeManager() ->getViewBuilder('node'); $node_render = $view_builder->view($node, 'default'); - $rendered_node = \Drupal::service('renderer')->renderPlain($node_render); + $rendered_node = \Drupal::service('renderer')->renderInIsolation($node_render); preg_match_all('//s', $rendered_node, $preg_match); $this->assertNotEmpty($preg_match[0]); preg_match_all('/alt="Foo Bar Alt"/', $rendered_node, $preg_match); diff --git a/tests/src/Kernel/Plugin/Field/FieldFormatter/MultiMediaFormatterTest.php b/tests/src/Kernel/Plugin/Field/FieldFormatter/MultiMediaFormatterTest.php index ddec04ec..b01fac33 100644 --- a/tests/src/Kernel/Plugin/Field/FieldFormatter/MultiMediaFormatterTest.php +++ b/tests/src/Kernel/Plugin/Field/FieldFormatter/MultiMediaFormatterTest.php @@ -238,7 +238,7 @@ private function getRenderedNode($node, $view_mode = 'default') { $view_builder = \Drupal::entityTypeManager() ->getViewBuilder('node'); $node_render = $view_builder->view($node, $view_mode); - return \Drupal::service('renderer')->renderPlain($node_render); + return \Drupal::service('renderer')->renderInIsolation($node_render); } /** diff --git a/tests/src/Kernel/Plugin/media/Source/EmbeddableTest.php b/tests/src/Kernel/Plugin/media/Source/EmbeddableTest.php index bdfd2238..a81cd228 100644 --- a/tests/src/Kernel/Plugin/media/Source/EmbeddableTest.php +++ b/tests/src/Kernel/Plugin/media/Source/EmbeddableTest.php @@ -29,6 +29,7 @@ class EmbeddableTest extends KernelTestBase { 'field', 'file', 'stanford_media', + 'path_alias', ]; /** @@ -70,6 +71,7 @@ public function setup(): void { $this->installEntitySchema('field_storage_config'); $this->installEntitySchema('field_config'); $this->installEntitySchema('file'); + $this->installEntitySchema('path_alias'); $this->installSchema('file', ['file_usage']); $this->installConfig('system'); diff --git a/tests/src/Kernel/StanfordMediaTestBase.php b/tests/src/Kernel/StanfordMediaTestBase.php index a4583b5f..5f23d5f3 100644 --- a/tests/src/Kernel/StanfordMediaTestBase.php +++ b/tests/src/Kernel/StanfordMediaTestBase.php @@ -21,6 +21,8 @@ abstract class StanfordMediaTestBase extends KernelTestBase { 'media', 'media_library', 'views', + 'filter', + 'path_alias', ]; /** @@ -36,6 +38,7 @@ public function setup(): void { $this->installEntitySchema('file'); $this->installEntitySchema('user'); $this->installEntitySchema('media'); + $this->installEntitySchema('path_alias'); $this->installSchema('file', ['file_usage']); $this->installSchema('system', ['sequences']); $this->installConfig('system');