-
-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[generate:entity:content] Start using show_revision_ui Entity Annotation Key #4000
Comments
While I'm on the subject of improving revisioning, currently with Drupal Console generated Content Entities, if you edit a Entity and choose not to create a new revision, but the Entity already has a revision with a log message, the log message will be erased. To solve this we should add this override method to the generated Entity class (taken directly from the Node module with slight modification): /**
* {@inheritdoc}
*/
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
parent::preSaveRevision($storage, $record);
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log_message) || $record->revision_log_message === '')) {
// If we are updating an existing entity without adding a new revision, we
// need to make sure $entity->revision_log_message is reset whenever it is
// empty. Therefore, this code allows us to avoid clobbering an existing
// log entry with an empty one.
$record->revision_log_message = $this->original->revision_log_message->value;
}
} |
Regarding my previous comment, came across this core issue which will probably address that at a higher level https://www.drupal.org/project/drupal/issues/1863258 I suppose it comes down to, add the override of preSaveRevision now and remove later, or just don't bother and assume it'll be fixed eventually in that core issue. |
@AaronMcHale Could you tell us if this issue was resolved in the latest release of Drupal 8.7.x? |
Problem/Motivation
Drupal 8.3 introduced a new key in the Content Entity Annotation
show_revision_ui
(see https://www.drupal.org/node/2835025) eliminating the need for Drupal Console to add some custom code and logic to the Entity Form.Solution
When Drupal Console generates Content Entities this key should be added and set to
TRUE
if the user specifies that they would like revision.The result is that the whole
buildForm
method in the generatedContentEntityForm
class can be removed, or if not all of it just the field which adds theCreate new revision
checkbox, assuming the later this would leave:In the
save
method of the generatedContentEntityForm
class will need to be modified slightly, the checkbox which allows the user to choose if they want to create a new revision is now named simplyrevision
, notnew_revision
:Should be changed to:
There may be additional code which can also be removed, or some code which may need to change, but I haven't found anything else yet..
The text was updated successfully, but these errors were encountered: