Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
digit-joinup-reference
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ec-europa
digit-joinup-reference
Merge requests
!168
Patch release v1.104.1
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Patch release v1.104.1
digit/digit-joinup-dev:patch/v1.104.1
into
master
Overview
0
Commits
41
Pipelines
0
Changes
7
Merged
Claudiu Cristea
requested to merge
digit/digit-joinup-dev:patch/v1.104.1
into
master
10 months ago
Overview
0
Commits
41
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
version 2
version 6
05a62743
10 months ago
version 5
05848194
10 months ago
version 4
a1f4e301
10 months ago
version 3
02e3aab1
10 months ago
version 2
e563f8ff
10 months ago
version 1
0da81042
10 months ago
master (base)
and
version 3
latest version
2edaee85
41 commits,
10 months ago
version 6
05a62743
38 commits,
10 months ago
version 5
05848194
15 commits,
10 months ago
version 4
a1f4e301
10 commits,
10 months ago
version 3
02e3aab1
8 commits,
10 months ago
version 2
e563f8ff
6 commits,
10 months ago
version 1
0da81042
2 commits,
10 months ago
Show latest version
1 file
+
19
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
web/modules/custom/search_api_field/src/Plugin/Field/FieldFormatter/SearchFormatter.php
+
19
−
10
Options
@@ -23,6 +23,7 @@
use
Drupal\search_api_field
\Plugin\Field\FieldType\SearchItemInterface
;
use
Drupal\search_api_field
\Plugin\FilterPluginManagerInterface
;
use
Drupal\topic\Entity\Topic
;
use
Drupal\topic\Entity\TopicInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\Request
;
@@ -428,33 +429,41 @@ protected function applyPresets(QueryInterface $query, string $presets): void {
// comma-separated list.
if
(
$operator
===
'IN'
)
{
$value
=
explode
(
','
,
$value
);
$value
=
array_map
(
'trim'
,
$value
);
array_walk
(
$value
,
[
$this
,
'uriToId'
],
$field
);
$value
=
array_map
(
function
(
$item
)
use
(
$field
)
{
return
$this
->
convertValuePreset
(
trim
(
$item
),
$field
);
},
$value
);
$value
=
array_filter
(
$value
);
}
else
{
$
this
->
uriToId
(
$value
,
0
,
$field
);
$
value
=
$this
->
convertValuePreset
(
$value
,
$field
);
}
$query
->
addCondition
(
$field
,
$value
,
$operator
);
if
(
$value
)
{
$query
->
addCondition
(
$field
,
$value
,
$operator
);
}
}
}
}
/**
*
Provides a callback converting a topic URI to term ID
.
*
Converts the given field value preset
.
*
* @param mixed $value
* A potential topic URI passed by reference.
* @param int $delta
* The value's delta (not used).
* The preset value.
* @param string $field
* The Search API field name.
*
* @return mixed
* The converted value.
*/
protected
function
uriToId
(
mixed
&
$value
,
int
$delta
,
string
$field
):
voi
d
{
protected
function
convertValuePreset
(
mixed
$value
,
string
$field
):
mixe
d
{
if
(
$field
===
'topic'
)
{
$value
=
Topic
::
loadByUri
(
$value
)
->
id
();
// Try to convert the topic URI to term ID, fallback to NULL.
$entity
=
Topic
::
loadByUri
(
$value
);
$value
=
$entity
instanceof
TopicInterface
?
$entity
->
id
()
:
NULL
;
}
return
$value
;
}
/**
Loading