protected function ParagraphCloneForm::prepareEntity in Paragraphs Edit 8.2
Prepares the entity object before the form is built first.
Overrides ContentEntityForm::prepareEntity
File
- src/
Form/ ParagraphCloneForm.php, line 26
Class
- ParagraphCloneForm
- ParagraphCloneForm class.
Namespace
Drupal\paragraphs_edit\FormCode
protected function prepareEntity() {
parent::prepareEntity();
$account = $this
->currentUser();
// Keep track of the original entity.
$this->originalEntity = $this->entity;
// Create a duplicate.
$paragraph = $this->entity = $this->entity
->createDuplicate();
$paragraph
->set('created', \Drupal::time()
->getRequestTime());
$paragraph
->setOwnerId($account
->id());
$paragraph
->setRevisionAuthorId($account
->id());
}