Documentation

ScannableBlockable extends AbstractBlockable
in package

Describe a blockable item.

Table of Contents

Constants

DATA_KEY_LEGAL_BASIS  = 'legalBasis'
Key of blockable data to store the legal basis (multiple legal basis are possible) as string array. If one of the legal basis is `legitimate-interest`, the blockable has higher priority.
DEFAULT_GROUP  = '__default__'
Every rule is within this group.

Properties

$currentlyAddingRules  : mixed
$data  : mixed
$expressionToStrposCache  : mixed
$extended  : mixed
$headlessContentBlocker  : mixed
$identifier  : mixed
$originalExpressions  : array<string|int, string>
Original rules from string rules.
$regexp  : mixed
$ruleGroups  : array<string|int, RuleGroup>
Each rule group gets an own instance of `RuleGroup`.
$rules  : array<string|int, Rule>
Each expression gets an own instance of `Rule`.
$selectorSyntaxFinder  : array<string|int, SelectorSyntaxFinder>
See `SelectorSyntaxFinder`.
$variables  : array<string|int, string>
Variables can be passed as rule in format `:$myVar=...` and can be reused in selector syntax function arguments.

Methods

__construct()  : mixed
C'tor.
addRules()  : mixed
Allows to add rules and rule groups dynamically.
appendFromStringArray()  : mixed
Generate the custom element blockers and regular expressions and append it to this blockable instance.
checkFoundRulesMatchesGroups()  : mixed
Check if a set of found rules matches our group configuration.
findSelectorSyntaxFinderForMatch()  : mixed
Find a `SyntaxSelectorFinder` for a given `AbstractMatch`.
getBlockerId()  : int|string|null
Get the blocker ID. This is added as a custom HTML attribute to the blocked element so your frontend can e.g. add a visual content blocker.
getContainsRegularExpressions()  : array<string|int, string>
Getter.
getCriteria()  : string
The criteria type. This is added as a custom HTML attribute to the blocked element so your frontend can determine the origin for the `getRequiredIds`.
getData()  : mixed
Get additional data.
getExtended()  : mixed
Getter.
getGroupsWithRulesMap()  : mixed
Get a map of `Record<string (group), Rule[] (rules)>`.
getIdentifier()  : mixed
Getter.
getOriginalExpressions()  : array<string|int, string>
Getter.
getPriority()  : int
Get the priority of the blockable. It gets reused in `BlockablesSorter` to sort the blockables.
getRegularExpressions()  : array<string|int, string>
Getter.
getRequiredIds()  : array<string|int, int|string>
Get required IDs. This is added as a custom HTML attribute to the blocked element so your frontend can determine which items by ID are needed so the item can be unblocked.
getRuleGroups()  : mixed
Getter.
getRules()  : mixed
Getter.
getRulesByExpression()  : array<string|int, Rule>
Getter.
getSelectorSyntaxFinder()  : mixed
Getter.
getVariable()  : mixed
getVariables()  : mixed
hasBlockerId()  : mixed
Determine if this blockable should be blocked.
matchesExpressionLoose()  : mixed
It is a performance-boost to extract the searchable strings for this expression, so we can first check for simple `contains` pattern with `strpos` instead of expensive `preg_match`.
matchesLoose()  : mixed
Check if the blockable matches the expression loosely.
setData()  : mixed
Allows to set additional data for this blockable.

Constants

Key of blockable data to store the legal basis (multiple legal basis are possible) as string array. If one of the legal basis is `legitimate-interest`, the blockable has higher priority.

public mixed DATA_KEY_LEGAL_BASIS = 'legalBasis'

DEFAULT_GROUP

Every rule is within this group.

public mixed DEFAULT_GROUP = '__default__'

Properties

$originalExpressions

Original rules from string rules.

private array<string|int, string> $originalExpressions = []

$selectorSyntaxFinder

See `SelectorSyntaxFinder`.

private array<string|int, SelectorSyntaxFinder> $selectorSyntaxFinder = []

$variables

Variables can be passed as rule in format `:$myVar=...` and can be reused in selector syntax function arguments.

private array<string|int, string> $variables = []

Methods

__construct()

C'tor.

public __construct(HeadlessContentBlocker $headlessContentBlocker, string $identifier[, string $extended = null ][, array<string|int, Rule>|array<string|int, array<string|int, mixed>> $rules = [] ][, array<string|int, RuleGroup>|array<string|int, array<string|int, mixed>> $ruleGroups = [] ]) : mixed

Example array for $rules:

[
    [
         'expression' => "*google.com/recaptcha*",
         'assignedToGroups' => 'script', // can be string[]
         'queryArgs' => [
              [
                  'queryArg' => 'id',
                  'isOptional' => true,
                  'regExp' => '/^UA-/'
              ]
         ],
         'needsRequiredSiblingRule' => false,
         'roles' => ['blocker', 'scanner']
]
Parameters
$headlessContentBlocker : HeadlessContentBlocker
$identifier : string
$extended : string = null

The parent extended template identifier

$rules : array<string|int, Rule>|array<string|int, array<string|int, mixed>> = []

A list of expressions which hold different scan options; you can also pass an array which gets automatically converted to Rule.

$ruleGroups : array<string|int, RuleGroup>|array<string|int, array<string|int, mixed>> = []

You can also pass an array which gets automatically converted to RuleGroup.

addRules()

Allows to add rules and rule groups dynamically.

public addRules(array<string|int, Rule>|array<string|int, array<string|int, mixed>>|array<string|int, string> $rules[, array<string|int, RuleGroup>|array<string|int, array<string|int, mixed>> $ruleGroups = [] ][, bool $appendFromStringArray = true ]) : mixed
Parameters
$rules : array<string|int, Rule>|array<string|int, array<string|int, mixed>>|array<string|int, string>

A list of expressions which hold different scan options; you can also pass an array which gets automatically converted to Rule.

$ruleGroups : array<string|int, RuleGroup>|array<string|int, array<string|int, mixed>> = []

You can also pass an array which gets automatically converted to RuleGroup.

$appendFromStringArray : bool = true

Run $this->appendFromStringArray() for the added rules

appendFromStringArray()

Generate the custom element blockers and regular expressions and append it to this blockable instance.

public appendFromStringArray(mixed $blockers) : mixed
Parameters
$blockers : mixed

checkFoundRulesMatchesGroups()

Check if a set of found rules matches our group configuration.

public checkFoundRulesMatchesGroups(array<string|int, array<string|int, Rule>> $foundRules) : mixed
Parameters
$foundRules : array<string|int, array<string|int, Rule>>

findSelectorSyntaxFinderForMatch()

Find a `SyntaxSelectorFinder` for a given `AbstractMatch`.

public findSelectorSyntaxFinderForMatch(AbstractMatch $match) : mixed
Parameters
$match : AbstractMatch

getBlockerId()

Get the blocker ID. This is added as a custom HTML attribute to the blocked element so your frontend can e.g. add a visual content blocker.

public getBlockerId() : int|string|null
Return values
int|string|null

getContainsRegularExpressions()

Getter.

public getContainsRegularExpressions() : array<string|int, string>
Return values
array<string|int, string>

getCriteria()

The criteria type. This is added as a custom HTML attribute to the blocked element so your frontend can determine the origin for the `getRequiredIds`.

public getCriteria() : string

E.g. differ between TCF vendors and another custom criteria.

Return values
string

getData()

Get additional data.

public getData(string $key) : mixed
Parameters
$key : string

getGroupsWithRulesMap()

Get a map of `Record<string (group), Rule[] (rules)>`.

public getGroupsWithRulesMap() : mixed

getOriginalExpressions()

Getter.

public getOriginalExpressions() : array<string|int, string>
Return values
array<string|int, string>

getPriority()

Get the priority of the blockable. It gets reused in `BlockablesSorter` to sort the blockables.

public getPriority() : int

If lower, the blockable gets sorted to the top.

Return values
int

getRegularExpressions()

Getter.

public getRegularExpressions() : array<string|int, string>
Return values
array<string|int, string>

getRequiredIds()

Get required IDs. This is added as a custom HTML attribute to the blocked element so your frontend can determine which items by ID are needed so the item can be unblocked.

public getRequiredIds() : array<string|int, int|string>
Return values
array<string|int, int|string>

getRulesByExpression()

Getter.

public getRulesByExpression(string $expression) : array<string|int, Rule>
Parameters
$expression : string
Return values
array<string|int, Rule>

getSelectorSyntaxFinder()

Getter.

public getSelectorSyntaxFinder() : mixed
Tags
codeCoverageIgnore

getVariable()

public getVariable(mixed $variableName[, mixed $default = '' ]) : mixed
Parameters
$variableName : mixed
$default : mixed = ''

hasBlockerId()

Determine if this blockable should be blocked.

public hasBlockerId() : mixed

matchesExpressionLoose()

It is a performance-boost to extract the searchable strings for this expression, so we can first check for simple `contains` pattern with `strpos` instead of expensive `preg_match`.

public matchesExpressionLoose(string $expression, string $str) : mixed
Parameters
$expression : string
$str : string

matchesLoose()

Check if the blockable matches the expression loosely.

public matchesLoose(string $str) : mixed
Parameters
$str : string

setData()

Allows to set additional data for this blockable.

public setData(string $key, mixed $data) : mixed
Parameters
$key : string
$data : mixed

        
On this page

Search results