Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rest_views
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
rest_views
Merge requests
!22
Issue
#3472326
Unable to remove item at non-existing index.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3472326
Unable to remove item at non-existing index.
issue/rest_views-3472326:3472326-unable-remove-item
into
3.0.x
Overview
1
Commits
2
Pipelines
2
Changes
1
All threads resolved!
Hide all comments
Merged
Volodymyr Selyvanov
requested to merge
issue/rest_views-3472326:3472326-unable-remove-item
into
3.0.x
8 months ago
Overview
1
Commits
2
Pipelines
2
Changes
1
All threads resolved!
Hide all comments
Expand
Related to
#3472326
0
0
Merge request reports
Compare
3.0.x
version 1
54c7b8a3
8 months ago
3.0.x (base)
and
latest version
latest version
015d8fc2
2 commits,
1 month ago
version 1
54c7b8a3
1 commit,
8 months ago
1 file
+
10
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Plugin/Field/FieldFormatter/EntityReferenceExportFormatter.php
+
10
−
2
Options
@@ -31,11 +31,19 @@ class EntityReferenceExportFormatter extends EntityReferenceEntityFormatter {
public
function
view
(
FieldItemListInterface
$items
,
$langcode
=
NULL
):
array
{
$elements
=
$this
->
viewElements
(
$items
,
$langcode
);
$deltasToRemove
=
[];
foreach
(
$items
as
$k
=>
$item
)
{
if
(
empty
(
$elements
[
$k
])
&&
$item
->
entity
)
{
$
items
->
removeItem
(
$k
)
;
if
(
!
empty
(
$elements
)
&&
!
isset
(
$elements
[
$k
])
&&
$item
->
entity
)
{
$
deltasToRemove
[]
=
$k
;
}
}
// Field item deltas are reset when an item is removed. This removes
// items in descending order so that the deltas yet to be removed will
// continue to exist and can be removed in a future loop.
rsort
(
$deltasToRemove
);
foreach
(
$deltasToRemove
as
$delta
)
{
$items
->
removeItem
(
$delta
);
}
$elements
=
array_values
(
$elements
);
$output
=
[
'#items'
=>
$items
];
Loading