Version 1
[yaffs-website] / web / core / modules / node / src / Form / NodeDeleteForm.php
1 <?php
2
3 namespace Drupal\node\Form;
4
5 use Drupal\Core\Entity\ContentEntityDeleteForm;
6
7 /**
8  * Provides a form for deleting a node.
9  */
10 class NodeDeleteForm extends ContentEntityDeleteForm {
11
12   /**
13    * {@inheritdoc}
14    */
15   protected function getDeletionMessage() {
16     /** @var \Drupal\node\NodeInterface $entity */
17     $entity = $this->getEntity();
18
19     $node_type_storage = $this->entityManager->getStorage('node_type');
20     $node_type = $node_type_storage->load($entity->bundle())->label();
21
22     if (!$entity->isDefaultTranslation()) {
23       return $this->t('@language translation of the @type %label has been deleted.', [
24         '@language' => $entity->language()->getName(),
25         '@type' => $node_type,
26         '%label' => $entity->label(),
27       ]);
28     }
29
30     return $this->t('The @type %title has been deleted.', [
31       '@type' => $node_type,
32       '%title' => $this->getEntity()->label(),
33     ]);
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   protected function logDeletionMessage() {
40     /** @var \Drupal\node\NodeInterface $entity */
41     $entity = $this->getEntity();
42     $this->logger('content')->notice('@type: deleted %title.', ['@type' => $entity->getType(), '%title' => $entity->label()]);
43   }
44
45 }