Same name and namespace in other branches
  1. 8.x-1.x src/EntityClone/Content/ContentEntityCloneFormBase.php \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneFormBase::getFormDescription()

Get the clone form confirmation page description.

If there are no recursive elements visible, the default description should be shown.

Parameters

array $form: The clone form.

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup Description to be shown

1 call to ContentEntityCloneFormBase::getFormDescription()
ContentEntityCloneFormBase::formElement in src/EntityClone/Content/ContentEntityCloneFormBase.php
Get all specific form element.

File

src/EntityClone/Content/ContentEntityCloneFormBase.php, line 255

Class

ContentEntityCloneFormBase
Class Content Entity Clone Form Base.

Namespace

Drupal\entity_clone\EntityClone\Content

Code

protected function getFormDescription(array $form, EntityInterface $entity) {
    $has_recursive = FALSE;
    $elements_visible = FALSE;
    if (isset($form['recursive'])) {
        $has_recursive = TRUE;
    }
    array_walk_recursive($form['recursive'], function ($item, $key) use (&$elements_visible) {
        if ($key === '#description_should_be_shown') {
            $elements_visible = $elements_visible || $item;
        }
    });
    if ($has_recursive && $elements_visible) {
        return $this->translationManager
            ->translate("\n            <p>Specify the child entities (the entities referenced by this entity) that should also be cloned as part of\n            the cloning process. If they're not included, these fields' referenced entities will be the same as in the\n            original.  In other words, fields in both the original entity and the cloned entity will refer to the same\n            referenced entity. Examples:</p>\n\n            <p>If you have a Paragraph field in your entity, and you choose not to clone it here, deleting the original\n            or cloned entity will also delete the Paragraph field from the other one. So you probably want to clone\n            Paragraph fields.</p>\n\n            <p>However, if you have a User reference field, you probably don't want to clone it here because a new User\n            will be created for referencing by the clone.</p>\n\n            <p>Some options may be disabled here, preventing you from changing them, as set by your administrator. Some\n            options may also be missing, hidden by your administrator, forcing you to clone with the default settings.\n            It's possible that there are no options here for you at all, or none need to be set, in which case you may\n            simply hit the <em>Clone</em> button.</p>\n          ");
    }
    else {
        return $this->translationManager
            ->translate("<p>Do you want to clone the <em>@type</em> entity named <em>@title</em>?</p>", [
            "@type" => $entity->getEntityType()
                ->getLabel(),
            "@title" => $entity->label(),
        ]);
    }
}