Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toc_filter
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
toc_filter
Merge requests
!10
Issue 3449678: fix block placement filter format not found
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue 3449678: fix block placement filter format not found
issue/toc_filter-3449678:3449678-fix-block-placement
into
8.x-2.x
Overview
0
Commits
3
Pipelines
2
Changes
1
Merged
James Candan
requested to merge
issue/toc_filter-3449678:3449678-fix-block-placement
into
8.x-2.x
11 months ago
Overview
0
Commits
3
Pipelines
2
Changes
1
Expand
Closes
#3449678
0
0
Merge request reports
Compare
8.x-2.x
version 3
43167b44
11 months ago
version 2
517d93ce
11 months ago
version 1
2053bd00
11 months ago
8.x-2.x (base)
and
latest version
latest version
6141bdce
3 commits,
7 months ago
version 3
43167b44
3 commits,
11 months ago
version 2
517d93ce
2 commits,
11 months ago
version 1
2053bd00
1 commit,
11 months ago
1 file
+
11
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Plugin/Block/TocFilterBlock.php
+
11
−
6
Options
@@ -3,6 +3,7 @@
namespace
Drupal\toc_filter\Plugin\Block
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\filter\Entity\FilterFormat
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\toc_api
\Plugin\Block\TocBlockBase
;
@@ -31,15 +32,19 @@ class TocFilterBlock extends TocBlockBase {
// Node should have [toc] token or filter should have auto enabled.
$format_id
=
$node
->
body
->
format
;
if
(
$format_id
!==
NULL
){
$format
=
FilterFormat
::
load
(
$format_id
);
if
(
$format
&&
$format
->
filters
(
'toc_filter'
))
{
$toc_filter_config
=
$format
->
filters
(
'toc_filter'
)
->
getConfiguration
();
// If auto is disabled, and there is no [toc token, don't display block.
if
(
!
$toc_filter_config
[
'settings'
][
'auto'
]
&&
stripos
(
$node
->
body
->
value
,
'[toc'
)
===
FALSE
)
{
return
AccessResult
::
forbidden
();
if
(
$format
&&
$format
->
filters
(
'toc_filter'
))
{
$toc_filter_config
=
$format
->
filters
(
'toc_filter'
)
->
getConfiguration
();
// If auto is disabled, and there is no [toc token, don't display block.
if
(
!
$toc_filter_config
[
'settings'
][
'auto'
]
&&
stripos
(
$node
->
body
->
value
,
'[toc'
)
===
FALSE
)
{
return
AccessResult
::
forbidden
();
}
}
}
else
{
return
AccessResult
::
forbidden
();
}
// Since entities (ie node) are cached we need to pass the current node's
// body through it's filters and see if a TOC is being generated and
// displayed in this block.
Loading