Version 1
[yaffs-website] / web / core / modules / config / tests / config_test / src / ConfigTestController.php
1 <?php
2
3 namespace Drupal\config_test;
4
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\config_test\Entity\ConfigTest;
7 use Symfony\Component\HttpFoundation\RedirectResponse;
8
9 /**
10  * Route controller class for the config_test module.
11  */
12 class ConfigTestController extends ControllerBase {
13
14   /**
15    * Route title callback.
16    *
17    * @param \Drupal\config_test\Entity\ConfigTest $config_test
18    *   The ConfigTest object.
19    *
20    * @return string
21    *   The title for the ConfigTest edit form.
22    */
23   public function editTitle(ConfigTest $config_test) {
24     return $this->t('Edit %label', ['%label' => $config_test->label()]);
25   }
26
27   /**
28    * Enables a ConfigTest object.
29    *
30    * @param \Drupal\config_test\ConfigTest $config_test
31    *   The ConfigTest object to enable.
32    *
33    * @return \Symfony\Component\HttpFoundation\RedirectResponse
34    *   A redirect response to the config_test listing page.
35    */
36   public function enable(ConfigTest $config_test) {
37     $config_test->enable()->save();
38     return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
39   }
40
41   /**
42    * Disables a ConfigTest object.
43    *
44    * @param \Drupal\config_test\ConfigTest $config_test
45    *   The ConfigTest object to disable.
46    *
47    * @return \Symfony\Component\HttpFoundation\RedirectResponse
48    *   A redirect response to the config_test listing page.
49    */
50   public function disable(ConfigTest $config_test) {
51     $config_test->disable()->save();
52     return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
53   }
54
55 }