Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / workspaces / src / Form / WorkspaceDeleteForm.php
1 <?php
2
3 namespace Drupal\workspaces\Form;
4
5 use Drupal\Core\Entity\ContentEntityDeleteForm;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Provides a form for deleting a workspace.
10  *
11  * @internal
12  */
13 class WorkspaceDeleteForm extends ContentEntityDeleteForm implements WorkspaceFormInterface {
14
15   /**
16    * The workspace entity.
17    *
18    * @var \Drupal\workspaces\WorkspaceInterface
19    */
20   protected $entity;
21
22   /**
23    * {@inheritdoc}
24    */
25   public function buildForm(array $form, FormStateInterface $form_state) {
26     $form = parent::buildForm($form, $form_state);
27     $source_rev_diff = $this->entityTypeManager->getStorage('workspace_association')->getTrackedEntities($this->entity->id());
28     $items = [];
29     foreach ($source_rev_diff as $entity_type_id => $revision_ids) {
30       $label = $this->entityTypeManager->getDefinition($entity_type_id)->getLabel();
31       $items[] = $this->formatPlural(count($revision_ids), '1 @label revision.', '@count @label revisions.', ['@label' => $label]);
32     }
33     $form['revisions'] = [
34       '#theme' => 'item_list',
35       '#title' => $this->t('The following will also be deleted:'),
36       '#items' => $items,
37     ];
38
39     return $form;
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function getDescription() {
46     return $this->t('This action cannot be undone, and will also delete all content created in this workspace.');
47   }
48
49 }