Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
state_machine
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
state_machine
Commits
69010ec9
Commit
69010ec9
authored
1 year ago
by
Guillaume Duveau
Browse files
Options
Downloads
Plain Diff
Merge branch '3281556-diff-plugin' into '8.x-1.x'
Issue
#3281556
: Plugin for Diff See merge request
!8
parents
6299c024
02b15f19
No related branches found
No related tags found
No related merge requests found
Pipeline
#119674
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/diff/Field/StateFieldBuilder.php
+38
-0
38 additions, 0 deletions
src/Plugin/diff/Field/StateFieldBuilder.php
with
38 additions
and
0 deletions
src/Plugin/diff/Field/StateFieldBuilder.php
0 → 100644
+
38
−
0
View file @
69010ec9
<?php
namespace
Drupal\state_machine\Plugin\diff\Field
;
use
Drupal\Core\Field\FieldItemListInterface
;
use
Drupal\diff\Plugin\diff\Field\CoreFieldBuilder
;
/**
* Plugin to compare state fields.
*
* @FieldDiffBuilder(
* id = "state_diff_builder",
* label = @Translation("State Field Diff"),
* field_types = {
* "state"
* },
* )
*/
class
StateFieldBuilder
extends
CoreFieldBuilder
{
/**
* {@inheritdoc}
*/
public
function
build
(
FieldItemListInterface
$field_items
)
{
$result
=
[];
foreach
(
$field_items
as
$field_key
=>
$field_item
)
{
if
(
!
$field_item
->
isEmpty
())
{
$value
=
$field_item
->
view
([
'label'
=>
'hidden'
,
'type'
=>
'default'
]);
$rendered_value
=
$this
->
renderer
->
renderPlain
(
$value
);
$result
[
$field_key
][]
=
$rendered_value
;
}
}
return
$result
;
}
}
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