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
3b01b6e3
Commit
3b01b6e3
authored
9 years ago
by
Daniel Wehner
Browse files
Options
Downloads
Patches
Plain Diff
Address feedback from bojanz
parent
8018260c
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/Form/RevisionableContentEntityForm.php
+14
-7
14 additions, 7 deletions
src/Form/RevisionableContentEntityForm.php
tests/modules/entity_module_test/src/Entity/EnhancedEntity.php
+2
-2
2 additions, 2 deletions
.../modules/entity_module_test/src/Entity/EnhancedEntity.php
with
16 additions
and
9 deletions
src/Form/ContentEntityForm
WithRevisions
.php
→
src/Form/
Revisionable
ContentEntityForm.php
+
14
−
7
View file @
3b01b6e3
...
...
@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\entity\Form\ContentEntityForm
WithRevisions
.
* Contains \Drupal\entity\Form\
Revisionable
ContentEntityForm.
*/
namespace
Drupal\entity\Form
;
...
...
@@ -11,7 +11,10 @@ use Drupal\Core\Entity\ContentEntityForm;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\entity\Entity\RevisionableEntityBundleInterface
;
class
ContentEntityFormWithRevisions
extends
ContentEntityForm
{
/**
* Extends the base entity form with revision support in the UI.
*/
class
RevisionableContentEntityForm
extends
ContentEntityForm
{
/**
* The entity being used by this form.
...
...
@@ -39,20 +42,24 @@ class ContentEntityFormWithRevisions extends ContentEntityForm {
}
}
/**
* Returns the bundle entity of the entity, or NULL if there is none.
*
* @return \Drupal\Core\Entity\EntityInterface|null
*/
protected
function
getBundleEntity
()
{
$bundle_entity
=
$this
->
entity
->
{
$this
->
entity
->
getEntityType
()
->
getKey
(
'bundle'
)}
->
referencedEntities
()[
0
];
return
$bundle_entity
;
if
(
$bundle_key
=
$this
->
entity
->
getEntityType
()
->
getKey
(
'bundle'
))
{
return
$this
->
entity
->
{
$bundle_key
}
->
referencedEntities
()[
0
];
}
return
NULL
;
}
/**
* {@inheritdoc}
*/
public
function
form
(
array
$form
,
FormStateInterface
$form_state
)
{
$entity_type
=
$this
->
entity
->
getEntityType
();
$bundle_entity
=
$this
->
getBundleEntity
();
$account
=
$this
->
currentUser
();
if
(
$this
->
operation
==
'edit'
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/modules/entity_module_test/src/Entity/EnhancedEntity.php
+
2
−
2
View file @
3b01b6e3
...
...
@@ -22,8 +22,8 @@ use Drupal\entity\Revision\EntityRevisionLogTrait;
* handlers = {
* "storage" = "\Drupal\Core\Entity\Sql\SqlContentEntityStorage",
* "form" = {
* "add" = "\Drupal\entity\Form\ContentEntityForm
WithRevisions
",
* "edit" = "\Drupal\entity\Form\ContentEntityForm
WithRevisions
",
* "add" = "\Drupal\entity\Form\
Revisionable
ContentEntityForm",
* "edit" = "\Drupal\entity\Form\
Revisionable
ContentEntityForm",
* "delete" = "\Drupal\Core\Entity\EntityDeleteForm",
* },
* "route_provider" = {
...
...
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