b272dfcf2f95ab73f63f9bdcb2d9127c659f5e6c
[yaffs-website] / web / modules / contrib / ctools / tests / modules / ctools_wizard_test / src / Wizard / EntityEditWizardTest.php
1 <?php
2
3 namespace Drupal\ctools_wizard_test\Wizard;
4
5 use Drupal\ctools\Wizard\EntityFormWizardBase;
6
7 class EntityEditWizardTest extends EntityFormWizardBase {
8
9   /**
10    * {@inheritdoc}
11    */
12   public function getWizardLabel() {
13     return $this->t('Example entity');
14   }
15
16   /**
17    * {@inheritdoc}
18    */
19   public function getMachineLabel() {
20     return $this->t('Label');
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   public function getEntityType() {
27     return 'ctools_wizard_test_config_entity';
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function exists() {
34     return '\Drupal\ctools_wizard_test\Entity\ExampleConfigEntity::load';
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function getOperations($cached_values) {
41     /** @var $page \Drupal\ctools_wizard_test\Entity\ExampleConfigEntity */
42     $config_entity = $cached_values['ctools_wizard_test_config_entity'];
43
44     $steps = [
45       'general' => [
46         'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityGeneralForm',
47         'title' => $this->t('General'),
48       ],
49       'one' => [
50         'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityOneForm',
51         'title' => $this->t('Form One'),
52       ],
53       'two' => [
54         'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityTwoForm',
55         'title' => $this->t('Form Two'),
56       ],
57     ];
58
59     // To test that we can get the config entity and add/remove steps
60     // based on it's values, we'll add a special step only when the entity
61     // is pre-existing.
62     if (!empty($config_entity) && !$config_entity->isNew()) {
63       $steps['existing'] = [
64         'form' => 'Drupal\ctools_wizard_test\Form\ExampleConfigEntityExistingForm',
65         'title' => $this->t('Existing entity'),
66       ];
67     }
68
69     return $steps;
70   }
71 }