diff -u b/modules/ctools_inline_block/config/schema/ctools_inline_block.schema.yml b/modules/ctools_inline_block/config/schema/ctools_inline_block.schema.yml --- b/modules/ctools_inline_block/config/schema/ctools_inline_block.schema.yml +++ b/modules/ctools_inline_block/config/schema/ctools_inline_block.schema.yml @@ -2,6 +2,9 @@ type: block_settings label: 'Inline block content' mapping: + langcode: + type: string + label: 'Language code' entity: type: string label: 'Serialized block_content entity' diff -u b/modules/ctools_inline_block/src/Plugin/Block/InlineBlock.php b/modules/ctools_inline_block/src/Plugin/Block/InlineBlock.php --- b/modules/ctools_inline_block/src/Plugin/Block/InlineBlock.php +++ b/modules/ctools_inline_block/src/Plugin/Block/InlineBlock.php @@ -55,7 +55,6 @@ // If the #default_value is NULL, a new entity will be created. '#default_value' => $this->getEntity(), ]; - $form['#process'][] = [static::class, 'enableInlineEntityForm']; return $form; } diff -u b/modules/ctools_inline_block/tests/modules/ctools_inline_block_test/config/install/field.field.block_content.basic.field_puppies.yml b/modules/ctools_inline_block/tests/modules/ctools_inline_block_test/config/install/field.field.block_content.basic.field_puppies.yml --- b/modules/ctools_inline_block/tests/modules/ctools_inline_block_test/config/install/field.field.block_content.basic.field_puppies.yml +++ b/modules/ctools_inline_block/tests/modules/ctools_inline_block_test/config/install/field.field.block_content.basic.field_puppies.yml @@ -22,8 +22,8 @@ max_filesize: '' max_resolution: '' min_resolution: '' - alt_field: true - alt_field_required: true + alt_field: false + alt_field_required: false title_field: false title_field_required: false default_image: diff -u b/modules/ctools_inline_block/tests/src/Functional/RenderTest.php b/modules/ctools_inline_block/tests/src/Functional/RenderTest.php --- b/modules/ctools_inline_block/tests/src/Functional/RenderTest.php +++ b/modules/ctools_inline_block/tests/src/Functional/RenderTest.php @@ -39,6 +39,8 @@ ]); $block_content->save(); + // Place the block using the normal block_content plugin and render + // it out. Nothing special here. $block = $this->placeBlock('block_content:' . $block_content->uuid(), [ 'region' => 'content', ]); @@ -48,6 +50,8 @@ $concrete_output = $assert->elementExists('css', $selector)->getOuterHtml(); + // Use the inline_content plugin to display the same block_content entity, + // serialized and stored in the plugin configuration. $settings = $block->get('settings'); $settings['entity'] = serialize($block_content); $block only in patch2: unchanged: --- /dev/null +++ b/modules/ctools_inline_block/tests/modules/ctools_inline_block_test/config/install/core.entity_form_display.block_content.basic.default.yml @@ -0,0 +1,39 @@ +langcode: en +status: true +dependencies: + config: + - block_content.type.basic + - field.field.block_content.basic.body + - field.field.block_content.basic.field_puppies + - image.style.thumbnail + module: + - image + - text +id: block_content.basic.default +targetEntityType: block_content +bundle: basic +mode: default +content: + body: + type: text_textarea_with_summary + weight: 1 + settings: + rows: 9 + summary_rows: 3 + placeholder: '' + third_party_settings: { } + field_puppies: + type: image_image + weight: 2 + settings: + progress_indicator: throbber + preview_image_style: thumbnail + third_party_settings: { } + info: + type: string_textfield + weight: 0 + settings: + size: 60 + placeholder: '' + third_party_settings: { } +hidden: { } only in patch2: unchanged: --- /dev/null +++ b/modules/ctools_inline_block/tests/src/FunctionalJavascript/InlineBlockFieldTest.php @@ -0,0 +1,76 @@ +createUser(['administer blocks']); + $this->drupalLogin($account); + $this->drupalGet('/admin/structure/block/add/inline_content:basic/classy'); + + $page = $this->getSession()->getPage(); + + $image = \Drupal::moduleHandler()->getModule('image')->getPath() . '/sample.png'; + $page->attachFileToField('Puppies', \Drupal::root() . '/' . $image); + + $block_id = strtolower($this->randomMachineName(16)); + + // Wait for the file element to do its AJAX business. + $result = $this->getSession()->wait(10000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))'); + if (!$result) { + $this->fail('Timed out waiting for AJAX upload to complete.'); + } + $page->fillField('Block description', $this->randomMachineName()); + $page->fillField('id', $block_id); + $page->pressButton('Save block'); + + $block = Block::load($block_id); + $block_content = $block->getPlugin()->getEntity(); + $this->assertInstanceOf(InlineBlockContent::class, $block_content); + $this->assertFalse($block_content->field_puppies->isEmpty()); + + /** @var \Drupal\file\FileInterface $image */ + $image = $block_content->field_puppies->entity; + /** @var \Drupal\file\FileUsage\FileUsageInterface $file_usage */ + $file_usage = \Drupal::service('file.usage'); + $this->assertTrue($image->isPermanent()); + $this->assertNotEmpty($file_usage->listUsage($image)); + + // Deleting the block should delete the inline block, which in turn should + // cause the image to be marked as temporary since nothing will be using it. + $block->delete(); + $this->assertEmpty($file_usage->listUsage($image)); + $image = \Drupal::entityTypeManager()->getStorage('file')->loadUnchanged($image->id()); + $this->assertTrue($image->isTemporary()); + } + +}