9638b57ab516b340c76a6fca0c8f7902f07a6a2e
[yaffs-website] / web / core / modules / path / src / Form / EditForm.php
1 <?php
2
3 namespace Drupal\path\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Url;
7
8 /**
9  * Provides the path edit form.
10  *
11  * @internal
12  */
13 class EditForm extends PathFormBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getFormId() {
19     return 'path_admin_edit';
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function buildPath($pid) {
26     return $this->aliasStorage->load(['pid' => $pid]);
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
33     $form = parent::buildForm($form, $form_state, $pid);
34
35     $form['#title'] = $this->path['alias'];
36     $form['pid'] = [
37       '#type' => 'hidden',
38       '#value' => $this->path['pid'],
39     ];
40
41     $url = new Url('path.delete', [
42       'pid' => $this->path['pid'],
43     ]);
44
45     if ($this->getRequest()->query->has('destination')) {
46       $url->setOption('query', $this->getDestinationArray());
47     }
48
49     $form['actions']['delete'] = [
50       '#type' => 'link',
51       '#title' => $this->t('Delete'),
52       '#url' => $url,
53       '#attributes' => [
54         'class' => ['button', 'button--danger'],
55       ],
56     ];
57
58     return $form;
59   }
60
61 }