Newer
Older
Alex Pott
committed
<?php
namespace Drupal\config_test;
use Drupal\Core\Controller\ControllerBase;
use Drupal\config_test\Entity\ConfigTest;
Alex Pott
committed
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Route controller class for the config_test module.
*/
class ConfigTestController extends ControllerBase {
Alex Pott
committed
/**
Alex Pott
committed
* Route title callback.
Alex Pott
committed
*
* @param \Drupal\config_test\Entity\ConfigTest $config_test
Alex Pott
committed
* The ConfigTest object.
Alex Pott
committed
*
Alex Pott
committed
* @return string
* The title for the ConfigTest edit form.
Alex Pott
committed
*/
Alex Pott
committed
public function editTitle(ConfigTest $config_test) {
return $this->t('Edit %label', ['%label' => $config_test->label()]);
Alex Pott
committed
}
/**
* Enables a ConfigTest object.
*
* @param \Drupal\config_test\ConfigTest $config_test
* The ConfigTest object to enable.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect response to the config_test listing page.
*/
function enable(ConfigTest $config_test) {
$config_test->enable()->save();
return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
Alex Pott
committed
}
/**
* Disables a ConfigTest object.
*
* @param \Drupal\config_test\ConfigTest $config_test
* The ConfigTest object to disable.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect response to the config_test listing page.
*/
function disable(ConfigTest $config_test) {
$config_test->disable()->save();
return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));