Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entity
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository 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
drupal.org
entity
Commits
f629e294
"ist-git@git.uwaterloo.ca:b26feng/cs452Trainee.git" did not exist on "e2e45cbfb6063e871c46111c8609ff0584285fae"
Commit
f629e294
authored
9 years ago
by
Daniel Wehner
Browse files
Options
Downloads
Patches
Plain Diff
Use EntityKeysFieldsTrait in the test and actually fix it
parent
9bfeb288
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/EntityKeysFieldsTrait.php
+1
-1
1 addition, 1 deletion
src/EntityKeysFieldsTrait.php
tests/modules/entity_test/src/Entity/EntityWithRevisionLog.php
+3
-26
3 additions, 26 deletions
.../modules/entity_test/src/Entity/EntityWithRevisionLog.php
with
4 additions
and
27 deletions
src/EntityKeysFieldsTrait.php
+
1
−
1
View file @
f629e294
...
...
@@ -23,7 +23,7 @@ trait EntityKeysFieldsTrait {
*
* @return \Drupal\Core\Field\BaseFieldDefinition[]
*/
protected
function
entityKeysBaseFieldDefinitions
(
ContentEntityTypeInterface
$entity_type
)
{
protected
static
function
entityKeysBaseFieldDefinitions
(
ContentEntityTypeInterface
$entity_type
)
{
$fields
=
[];
if
(
$entity_type
->
hasKey
(
'id'
))
{
...
...
This diff is collapsed.
Click to expand it.
tests/modules/entity_test/src/Entity/EntityWithRevisionLog.php
+
3
−
26
View file @
f629e294
...
...
@@ -10,6 +10,7 @@ namespace Drupal\entity_test\Entity;
use
Drupal\Core\Entity\ContentEntityBase
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Core\Field\BaseFieldDefinition
;
use
Drupal\entity\EntityKeysFieldsTrait
;
use
Drupal\entity\Revision\EntityRevisionLogTrait
;
/**
...
...
@@ -31,6 +32,7 @@ use Drupal\entity\Revision\EntityRevisionLogTrait;
class
EntityWithRevisionLog
extends
ContentEntityBase
{
use
EntityRevisionLogTrait
;
use
EntityKeysFieldsTrait
;
/**
* {@inheritdoc}
...
...
@@ -38,32 +40,7 @@ class EntityWithRevisionLog extends ContentEntityBase {
public
static
function
baseFieldDefinitions
(
EntityTypeInterface
$entity_type
)
{
$fields
=
[];
$fields
[
'id'
]
=
BaseFieldDefinition
::
create
(
'integer'
)
->
setLabel
(
t
(
''
))
->
setReadOnly
(
TRUE
)
->
setSetting
(
'unsigned'
,
TRUE
);
$fields
[
'uuid'
]
=
BaseFieldDefinition
::
create
(
'uuid'
)
->
setLabel
(
t
(
'UUID'
))
->
setReadOnly
(
TRUE
);
$fields
[
'vid'
]
=
BaseFieldDefinition
::
create
(
'integer'
)
->
setLabel
(
t
(
'Revision ID'
))
->
setReadOnly
(
TRUE
)
->
setSetting
(
'unsigned'
,
TRUE
);
$fields
[
'langcode'
]
=
BaseFieldDefinition
::
create
(
'language'
)
->
setLabel
(
t
(
'Language'
))
->
setTranslatable
(
TRUE
)
->
setRevisionable
(
TRUE
)
->
setDisplayOptions
(
'view'
,
[
'type'
=>
'hidden'
,
])
->
setDisplayOptions
(
'form'
,
[
'type'
=>
'language_select'
,
'weight'
=>
2
,
]);
$fields
+=
static
::
entityKeysBaseFieldDefinitions
(
$entity_type
);
$fields
+=
static
::
entityRevisionLogBaseFieldDefinitions
();
return
$fields
;
...
...
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