Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
taxonomy_enum
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
taxonomy_enum
Commits
0202080d
Commit
0202080d
authored
6 months ago
by
Dieter Holvoet
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3465478
by dieterholvoet: 'Undefined array key "vid"' when adding views filter
parent
7bb6d0ba
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
Check if the vid array key is set
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/views/filter/TaxonomyEnumReference.php
+6
-7
6 additions, 7 deletions
src/Plugin/views/filter/TaxonomyEnumReference.php
with
6 additions
and
7 deletions
src/Plugin/views/filter/TaxonomyEnumReference.php
+
6
−
7
View file @
0202080d
...
...
@@ -60,17 +60,16 @@ class TaxonomyEnumReference extends ManyToOne {
return
$this
->
valueOptions
;
}
if
(
!
$vid
=
$this
->
options
[
'vid'
])
{
$this
->
valueOptions
=
[];
return
;
if
(
empty
(
$this
->
options
[
'vid'
]))
{
return
$this
->
valueOptions
=
[];
}
$vid
=
$this
->
options
[
'vid'
];
$vocabulary
=
$this
->
entityTypeManager
->
getStorage
(
'taxonomy_vocabulary'
)
->
load
(
$vid
);
$enumName
=
$vocabulary
->
getThirdPartySetting
(
'taxonomy_enum'
,
'enum_name'
);
if
(
!
enum_exists
(
$enumName
)
||
!
method_exists
(
$enumName
,
'from'
))
{
$this
->
valueOptions
=
[];
return
;
return
$this
->
valueOptions
=
[];
}
$termStorage
=
$this
->
entityTypeManager
...
...
@@ -81,7 +80,7 @@ class TaxonomyEnumReference extends ManyToOne {
->
execute
();
$terms
=
$termStorage
->
loadMultiple
(
$termIds
);
$this
->
valueOptions
=
array_reduce
(
return
$this
->
valueOptions
=
array_reduce
(
$terms
,
function
(
?array
$options
,
TermInterface
$term
)
{
$options
[
$term
->
get
(
'machine_name'
)
->
value
]
=
$term
->
label
();
...
...
@@ -110,7 +109,7 @@ class TaxonomyEnumReference extends ManyToOne {
},
Vocabulary
::
loadMultiple
(),
),
'#default_value'
=>
$this
->
options
[
'vid'
],
'#default_value'
=>
$this
->
options
[
'vid'
]
??
NULL
,
];
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment