Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edit_uuid
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
edit_uuid
Commits
d77eacc1
Commit
d77eacc1
authored
5 years ago
by
Karthikeyan Manivasagam
Browse files
Options
Downloads
Patches
Plain Diff
Added UUID display formatter
parent
279b2dfc
Branches
Branches containing commit
Tags
8.x-1.1-alpha2
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
edit_uuid.module
+12
-0
12 additions, 0 deletions
edit_uuid.module
src/Plugin/Field/FieldFormatter/EditUuidFieldFormatter.php
+38
-0
38 additions, 0 deletions
src/Plugin/Field/FieldFormatter/EditUuidFieldFormatter.php
with
50 additions
and
0 deletions
edit_uuid.module
+
12
−
0
View file @
d77eacc1
...
...
@@ -10,6 +10,8 @@ use Drupal\Core\Form\FormStateInterface;
use
Drupal\Core\Entity\EntityForm
;
use
Drupal\Component\Uuid\Uuid
;
use
Drupal\Component\Uuid\Php
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Core\Field\BaseFieldDefinition
;
/**
* Implements hook_help().
...
...
@@ -92,3 +94,13 @@ function edit_uuid_form_validate(array $form, FormStateInterface $form_state) {
}
}
}
/**
* Implements hook_entity_base_field_info_alter().
*/
function
edit_uuid_entity_base_field_info_alter
(
&
$fields
,
EntityTypeInterface
$entity_type
)
{
if
((
$field_name
=
$entity_type
->
getKey
(
'uuid'
))
&&
$field
=
$fields
[
$field_name
])
{
assert
(
$field
instanceof
BaseFieldDefinition
);
$field
->
setDisplayConfigurable
(
'view'
,
TRUE
);
}
}
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldFormatter/EditUuidFieldFormatter.php
0 → 100644
+
38
−
0
View file @
d77eacc1
<?php
namespace
Drupal\edit_uuid\Plugin\Field\FieldFormatter
;
use
Drupal\Core\Field\FieldItemListInterface
;
use
Drupal\Core\Field\FormatterBase
;
/**
* Plugin implementation of the 'uuid' formatter.
*
* @FieldFormatter(
* id = "uuid",
* label = @Translation("UUID"),
* field_types = {
* "uuid",
* },
* )
*/
class
EditUuidFieldFormatter
extends
FormatterBase
{
/**
* {@inheritdoc}
*/
public
function
viewElements
(
FieldItemListInterface
$items
,
$langcode
)
{
$elements
=
[];
$user
=
\Drupal
::
currentUser
();
if
(
$user
->
hasPermission
(
'show edit_uuid'
))
{
foreach
(
$items
as
$delta
=>
$item
)
{
$elements
[
$delta
]
=
[
'#markup'
=>
$item
->
value
,
];
}
}
return
$elements
;
}
}
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