You are here

protected function ParagraphCloneForm::prepareEntity in Paragraphs table 8

Prepares the entity object before the form is built first.

Overrides ContentEntityForm::prepareEntity

File

src/Form/ParagraphCloneForm.php, line 23

Class

ParagraphCloneForm
Paragraph Clone Form class.

Namespace

Drupal\paragraphs_table\Form

Code

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());
}