Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1.x
  • 2.x
  • 1.0.0
  • 1.0.0-alpha1
  • 1.0.0-alpha2
  • 1.0.0-alpha3
  • 1.0.0-beta1
  • 1.0.0-beta2
8 results

Target

Select target project
  • Issue forks / sector_toc-3281000
  • project / sector_toc
  • Issue forks / sector_toc-3278306
  • Issue forks / sector_toc-3434426
  • Issue forks / sector_toc-3468455
  • Issue forks / sector_toc-3473449
  • Issue forks / sector_toc-3473472
7 results
Select Git revision
Loading items
Show changes

Commits on Source 1

5 files
+ 11
13
Compare changes
  • Side-by-side
  • Inline

Files

+2 −5
Original line number Diff line number Diff line
@@ -30,8 +30,5 @@ include:

variables:
  _CSPELL_WORDS: 'Chunker, chunker, tocs'
  _TARGET_CORE: "$CORE_STABLE"

composer (next major):
  variables:
    _LENIENT_ALLOW_LIST: "toc_api"
  OPT_IN_TEST_CURRENT: 1
  OPT_IN_TEST_PREVIOUS_MAJOR: 1
Original line number Diff line number Diff line
name: 'Sector Table of Contents'
description: 'Table of contents generation and sidebar block'
type: module
core_version_requirement: ^9 || ^10
core_version_requirement: ^10.3 || ^11.0
dependencies:
  - 'chunker:chunker'
  - 'drupal:block'
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\sector_toc\Plugin\Block;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\sector_toc\Util\SectorTocHelper;
use Drupal\toc_api\Entity\TocType;
@@ -22,21 +23,19 @@ class SectorTocBlock extends TocBlockBase {
  /**
   * {@inheritdoc}
   */
  public function blockAccess(AccountInterface $account) {
  public function blockAccess(AccountInterface $account): AccessResultInterface {
    return AccessResult::allowed();
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
  public function build(): array {
    // Load ToC definition, see also toc_api.toc_type.sector_toc.yml.
    $toc_type = TocType::load('sector_toc');
    $options = ($toc_type) ? $toc_type->getOptions() : [];

    // Create a TOC instance using the TOC manager.
    /** @var \Drupal\toc_api\TocManagerInterface $toc_manager */
    $toc_manager = \Drupal::service('toc_api.manager');
    /** @var \Drupal\toc_api\TocInterface $toc */
    $node = $this->getCurrentNode();
    if (is_object($node)) {
@@ -44,7 +43,7 @@ class SectorTocBlock extends TocBlockBase {
      if (!empty($body)) {

        $id = SectorTocHelper::generateTocId($toc_type->id(), $node, 'body', 0);
        $toc = $toc_manager->getToc($id) ?: $toc_manager->create($id, $body, $options);
        $toc = $this->tocManager->getToc($id) ?: $this->tocManager->create($id, $body, $options);

        $toc_builder = \Drupal::service('toc_api.builder');
        $output = $toc_builder->buildToc($toc);
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ class SharedTocInstanceTest extends EntityKernelTestBase {
      'sector_toc_block',
      ['provider' => 'sector_toc'],
      $currentRoute,
      $this->container->get('entity_type.manager'),
      $this->container->get('toc_api.manager'),
    );

    $renderer = \Drupal::service('renderer');