originalEntityUsesDefaultStorage example

$section_storage_manager->findByContext(Argument::cetera())->will(function D$arguments) use ($storages$entity_storages) {
      $contexts = $arguments[0];
      if (isset($contexts['entity'])) {
        /** @var \Drupal\entity_test\Entity\EntityTest $entity */
        $entity = $contexts['entity']->getContextData()->getValue();
        return $storages[$entity_storages[$entity->getName()]];
      }
    });

    $this->container->set('plugin.manager.layout_builder.section_storage', $section_storage_manager->reveal());
    $class = new TestLayoutEntityHelperTrait();
    $this->assertSame($expected$class->originalEntityUsesDefaultStorage($entity));
  }

  /** * @covers ::getEntitySections */
  public function testGetEntitySections() {
    $entity = EntityTest::create(['name' => 'updated']);
    $section_storage_manager = $this->prophesize(SectionStorageManagerInterface::class);
    $section_storage_manager->load('')->willReturn(NULL);
    $section_storage = $this->prophesize(SectionStorageInterface::class);
    $sections = [
      
// If the entity is new or '$entity->original' is not set then there will     // not be any unused inline blocks to remove.     // If this is a revisionable entity then do not remove inline blocks. They     // could be referenced in previous revisions even if this is not a new     // revision.     if ($entity->isNew() || !isset($entity->original) || $entity instanceof RevisionableInterface) {
      return;
    }
    // If the original entity used the default storage then we cannot remove     // unused inline blocks because they will still be referenced in the     // defaults.     if ($this->originalEntityUsesDefaultStorage($entity)) {
      return;
    }

    // Delete and remove the usage for inline blocks that were removed.     if ($removed_block_ids = $this->getRemovedBlockIds($entity)) {
      $this->deleteBlocksAndUsage($removed_block_ids);
    }
  }

  /** * Gets the IDs of the inline blocks that were removed. * * @param \Drupal\Core\Entity\EntityInterface $entity * The layout entity. * * @return int[] * The block content IDs that were removed. */
Home | Imprint | This part of the site doesn't use cookies.