getInlineBlockRevisionIdsInSections example


  protected function getRemovedBlockIds(EntityInterface $entity) {
    $original_sections = $this->getEntitySections($entity->original);
    $current_sections = $this->getEntitySections($entity);
    // Avoid un-needed conversion from revision IDs to block content IDs by     // first determining if there are any revisions in the original that are not     // also in the current sections.     $current_block_content_revision_ids = $this->getInlineBlockRevisionIdsInSections($current_sections);
    $original_block_content_revision_ids = $this->getInlineBlockRevisionIdsInSections($original_sections);
    if ($unused_original_revision_ids = array_diff($original_block_content_revision_ids$current_block_content_revision_ids)) {
      // If there are any revisions in the original that aren't in the current       // there may some blocks that need to be removed.       $current_block_content_ids = $this->getBlockIdsForRevisionIds($current_block_content_revision_ids);
      $unused_original_block_content_ids = $this->getBlockIdsForRevisionIds($unused_original_revision_ids);
      return array_diff($unused_original_block_content_ids$current_block_content_ids);
    }
    return [];
  }

  
$test_class = new TestClass();
    $this->assertSame($expected_components$test_class->getInlineBlockComponents($sections));
  }

  /** * @covers ::getInlineBlockRevisionIdsInSections * * @dataProvider providerSectionsWithInlineComponents */
  public function testGetInlineBlockRevisionIdsInSections($sections$components$expected_revision_ids) {
    $test_class = new TestClass();
    $this->assertSame($expected_revision_ids$test_class->getInlineBlockRevisionIdsInSections($sections));
  }

}

/** * Test class using the trait. */
class TestClass {
  use LayoutEntityHelperTrait {
    getInlineBlockComponents as public;
    getInlineBlockRevisionIdsInSections as public;
  }

  protected function isBlockRevisionUsedInEntity(EntityInterface $layout_entity, BlockContentInterface $block_content) {
    $sections_blocks_revision_ids = $this->getInlineBlockRevisionIdsInSections($this->getEntitySections($layout_entity));
    return in_array($block_content->getRevisionId()$sections_blocks_revision_ids);
  }

}
Home | Imprint | This part of the site doesn't use cookies.