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
ca4941f3
Commit
ca4941f3
authored
9 years ago
by
Daniel Wehner
Browse files
Options
Downloads
Patches
Plain Diff
address feedback
parent
e2ac92bb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Revision/EnhancedEntityRevisionInterface.php
+2
-2
2 additions, 2 deletions
src/Revision/EnhancedEntityRevisionInterface.php
src/Revision/EnhancedEntityRevisionTrait.php
+86
-0
86 additions, 0 deletions
src/Revision/EnhancedEntityRevisionTrait.php
with
88 additions
and
2 deletions
src/EnhancedEntityRevisionInterface.php
→
src/
Revision/
EnhancedEntityRevisionInterface.php
+
2
−
2
View file @
ca4941f3
...
...
@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\
src
\EnhancedEntityRevisionInterface.
* Contains \Drupal\
entity\Revision
\EnhancedEntityRevisionInterface.
*/
namespace
Drupal\
src
;
namespace
Drupal\
entity\Revision
;
/**
* Defines an entity type with create/author/log information for revisions.
...
...
This diff is collapsed.
Click to expand it.
src/EnhancedEntityRevisionTrait.php
→
src/
Revision/
EnhancedEntityRevisionTrait.php
+
86
−
0
View file @
ca4941f3
...
...
@@ -2,28 +2,44 @@
/**
* @file
* Contains \Drupal\
src
\EnhancedEntityRevisionTrait.
* Contains \Drupal\
entity\Revision
\EnhancedEntityRevisionTrait.
*/
namespace
Drupal\src
;
namespace
Drupal\entity\Revision
;
use
Drupal\user\Entity\User
;
/**
* Provides a trait implementing \Drupal\entity\EnhanceredEntityRevisionInterface.
*/
trait
EnhancedEntityRevisionTrait
{
/**
* Returns whether the entity type has a specific field.
*
* @param string $field_name
* The field name.
*
* @return bool
*/
abstract
function
hasField
(
$field_name
);
/**
* {@inheritdoc}
*/
public
function
getRevisionCreationTime
()
{
return
$this
->
revision_create
->
value
;
if
(
$this
->
hasField
(
'revision_create'
))
{
return
$this
->
revision_create
->
value
;
}
return
0
;
}
/**
* {@inheritdoc}
*/
public
function
setRevisionCreationTime
(
$timestamp
)
{
$this
->
revision_create
->
value
=
$timestamp
;
if
(
$this
->
hasField
(
'revision_create'
))
{
$this
->
revision_create
->
value
=
$timestamp
;
}
return
$this
;
}
...
...
@@ -31,14 +47,19 @@ trait EnhancedEntityRevisionTrait {
* {@inheritdoc}
*/
public
function
getRevisionAuthor
()
{
return
$this
->
revision_author
->
entity
;
if
(
$this
->
hasField
(
'revision_author'
))
{
return
$this
->
revision_author
->
entity
;
}
return
User
::
getAnonymousUser
();
}
/**
* {@inheritdoc}
*/
public
function
setRevisionAuthorId
(
$uid
)
{
$this
->
revision_author
->
target_id
=
$uid
;
if
(
$this
->
hasField
(
'revision_author'
))
{
$this
->
revision_author
->
target_id
=
$uid
;
}
return
$this
;
}
...
...
@@ -46,14 +67,19 @@ trait EnhancedEntityRevisionTrait {
* {@inheritdoc}
*/
public
function
getRevisionLog
()
{
return
$this
->
revision_log
->
value
;
if
(
$this
->
hasField
(
'revision_log'
))
{
return
$this
->
revision_log
->
value
;
}
return
''
;
}
/**
* {@inheritdoc}
*/
public
function
setRevisionLog
(
$revision_log
)
{
$this
->
revision_log
->
value
=
$revision_log
;
if
(
$this
->
hasField
(
'revision_log'
))
{
$this
->
revision_log
->
value
=
$revision_log
;
}
return
$this
;
}
...
...
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