public function Controller::cookieSetter in Style Switcher 8.2
Same name and namespace in other branches
- 3.0.x tests/modules/styleswitcher_test_legacy_cookies/src/Controller/Controller.php \Drupal\styleswitcher_test_legacy_cookies\Controller\Controller::cookieSetter()
Sets cookies.
Parameters
int $version: Version of a Style Switcher cookie to set.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse Response object.
1 string reference to 'Controller::cookieSetter'
- styleswitcher_test_legacy_cookies.routing.yml in tests/
modules/ styleswitcher_test_legacy_cookies/ styleswitcher_test_legacy_cookies.routing.yml - tests/modules/styleswitcher_test_legacy_cookies/styleswitcher_test_legacy_cookies.routing.yml
File
- tests/
modules/ styleswitcher_test_legacy_cookies/ src/ Controller/ Controller.php, line 61
Class
- Controller
- Returns responses for Style Switcher Test Legacy Cookies routes.
Namespace
Drupal\styleswitcher_test_legacy_cookies\ControllerCode
public function cookieSetter($version) {
$theme = $this->themeHandler
->getDefault();
$expires = $this->time
->getRequestTime() + 60;
$path = base_path();
switch ($version) {
case 1:
setcookie('styleSwitcher', 'Active', $expires, $path);
break;
case 2:
setcookie('styleswitcher', 'active', $expires, $path);
break;
case 3:
setcookie('styleswitcher', 'theme/active', $expires, $path);
break;
case 4:
setcookie('styleswitcher[' . $theme . ']', 'theme/active', $expires, $path);
break;
}
return $this
->redirect('<front>');
}