diff -u b/modules/ctools_inline_block/src/Entity/BlockContent.php b/modules/ctools_inline_block/src/Entity/BlockContent.php --- b/modules/ctools_inline_block/src/Entity/BlockContent.php +++ b/modules/ctools_inline_block/src/Entity/BlockContent.php @@ -5,7 +5,7 @@ use Drupal\block_content\Entity\BlockContent as CoreBlockContent; /** - * Defines the custom block entity class. + * Defines the inline custom block entity class. * * @ContentEntityType( * id = "inline_block_content", @@ -14,24 +14,15 @@ * handlers = { * "storage" = "Drupal\ctools_inline_block\Entity\InlineBlockStorage", * "access" = "Drupal\block_content\BlockContentAccessControlHandler", - * "list_builder" = "Drupal\block_content\BlockContentListBuilder", * "view_builder" = "Drupal\block_content\BlockContentViewBuilder", - * "views_data" = "Drupal\block_content\BlockContentViewsData", * "form" = { * "add" = "Drupal\block_content\BlockContentForm", * "edit" = "Drupal\block_content\BlockContentForm", - * "delete" = "Drupal\block_content\Form\BlockContentDeleteForm", * "default" = "Drupal\block_content\BlockContentForm" * }, * "translation" = "Drupal\block_content\BlockContentTranslationHandler" * }, * admin_permission = "administer blocks", - * links = { - * "canonical" = "/block/{block_content}", - * "delete-form" = "/block/{block_content}/delete", - * "edit-form" = "/block/{block_content}", - * "collection" = "/admin/structure/block/block-content", - * }, * translatable = TRUE, * entity_keys = { * "id" = "id", diff -u b/modules/ctools_inline_block/src/Entity/InlineBlockStorage.php b/modules/ctools_inline_block/src/Entity/InlineBlockStorage.php --- b/modules/ctools_inline_block/src/Entity/InlineBlockStorage.php +++ b/modules/ctools_inline_block/src/Entity/InlineBlockStorage.php @@ -2,22 +2,12 @@ namespace Drupal\ctools_inline_block\Entity; -use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Sql\SqlContentEntityStorage; -use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\ctools_inline_block\InlineStorage; /** * A content entity storage handler that does not save to the database. */ -class InlineBlockStorage extends SqlContentEntityStorage { - - /** - * {@inheritdoc} - */ - protected function getQueryServiceName() { - return 'entity.query.null'; - } +class InlineBlockStorage extends InlineStorage { /** * {@inheritdoc} @@ -25,14 +15,10 @@ public function delete(array $entities) { parent::delete($entities); - $ids = array_keys($entities); - $this->database ->delete('inline_block') - ->condition('uuid', $ids, 'IN') + ->condition('uuid', array_keys($entities), 'IN') ->execute(); - - $this->resetCache($ids); } /** @@ -73,72 +59,8 @@ foreach ($records as $uuid => $record) { + // @TODO: Inject the service as a dependency. $mapped[$uuid] = \Drupal::service($record->loader)->load($uuid, $record->data); } return $mapped; } - /** - * {@inheritdoc} - */ - public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) { - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original) { - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function requiresEntityDataMigration(EntityTypeInterface $entity_type, EntityTypeInterface $original) { - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function requiresFieldDataMigration(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) { - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function onEntityTypeCreate(EntityTypeInterface $entity_type) { - } - - /** - * {@inheritdoc} - */ - public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) { - $this->entityType = $entity_type; - } - - /** - * {@inheritdoc} - */ - public function onEntityTypeDelete(EntityTypeInterface $entity_type) { - } - - /** - * {@inheritdoc} - */ - protected function doSaveFieldItems(ContentEntityInterface $entity, array $names = []) { - } - - /** - * {@inheritdoc} - */ - protected function saveToSharedTables(ContentEntityInterface $entity, $table_name = NULL, $new_revision = NULL) { - } - - /** - * {@inheritdoc} - */ - protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = array()) { - } - } diff -u b/modules/ctools_inline_block/tests/src/FunctionalJavascript/InlineBlockFieldTest.php b/modules/ctools_inline_block/tests/src/FunctionalJavascript/InlineBlockFieldTest.php --- b/modules/ctools_inline_block/tests/src/FunctionalJavascript/InlineBlockFieldTest.php +++ b/modules/ctools_inline_block/tests/src/FunctionalJavascript/InlineBlockFieldTest.php @@ -51,6 +51,7 @@ } $page->fillField('Block description', $this->randomMachineName()); $page->fillField('id', $block_id); + $page->fillField('region', 'content'); $page->pressButton('Save block'); $block = Block::load($block_id); diff -u b/modules/ctools_inline_block/tests/src/Kernel/StorageTest.php b/modules/ctools_inline_block/tests/src/Kernel/StorageTest.php --- b/modules/ctools_inline_block/tests/src/Kernel/StorageTest.php +++ b/modules/ctools_inline_block/tests/src/Kernel/StorageTest.php @@ -26,6 +26,7 @@ 'file', 'filter', 'image', + 'system', 'text', 'user', ]; @@ -105,9 +106,9 @@ 'body' => $body, ]); - // Assert that it's an inline block masquerading as a normal block_content. + // Assert that it's an inline block. $this->assertInstanceOf(InlineBlockContent::class, $block_content); - $this->assertSame('block_content', $block_content->getEntityTypeId()); + $this->assertSame('inline_block_content', $block_content->getEntityTypeId()); // Like any other entity, inline blocks should be new if unsaved. $this->assertTrue($block_content->isNew()); only in patch2: unchanged: --- /dev/null +++ b/modules/ctools_inline_block/src/InlineStorage.php @@ -0,0 +1,119 @@ +entityType = $entity_type; + } + + /** + * {@inheritdoc} + */ + public function onEntityTypeDelete(EntityTypeInterface $entity_type) { + } + + /** + * {@inheritdoc} + */ + public function delete(array $entities) { + parent::delete($entities); + $this->resetCache(array_keys($entities)); + } + + /** + * {@inheritdoc} + */ + protected function doDeleteFieldItems($entities) { + } + + /** + * {@inheritdoc} + */ + protected function doDeleteRevisionFieldItems(ContentEntityInterface $revision) { + } + + /** + * {@inheritdoc} + */ + protected function deleteFromDedicatedTables(ContentEntityInterface $entity) { + } + + /** + * {@inheritdoc} + */ + protected function deleteRevisionFromDedicatedTables(ContentEntityInterface $entity) { + } + + /** + * {@inheritdoc} + */ + protected function doSaveFieldItems(ContentEntityInterface $entity, array $names = []) { + } + + /** + * {@inheritdoc} + */ + protected function saveToSharedTables(ContentEntityInterface $entity, $table_name = NULL, $new_revision = NULL) { + } + + /** + * {@inheritdoc} + */ + protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = []) { + } + +}