JsCookieTestController.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/modules/js_cookie_test/src/Controller/JsCookieTestController.php

Namespace

Drupal\js_cookie_test\Controller

File

core/modules/system/tests/modules/js_cookie_test/src/Controller/JsCookieTestController.php

View source
<?php

namespace Drupal\js_cookie_test\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * Test controller to assert js-cookie library integration.
 */
class JsCookieTestController extends ControllerBase {
    
    /**
     * Provides buttons to add and remove cookies using JavaScript.
     *
     * @return array
     *   The render array.
     */
    public function jqueryCookieShimTest() {
        return [
            'add' => [
                '#type' => 'button',
                '#value' => $this->t('Add cookie'),
                '#attributes' => [
                    'class' => [
                        'js_cookie_test_add_button',
                    ],
                ],
            ],
            'add-raw' => [
                '#type' => 'button',
                '#value' => $this->t('Add raw cookie'),
                '#attributes' => [
                    'class' => [
                        'js_cookie_test_add_raw_button',
                    ],
                ],
            ],
            'add-json' => [
                '#type' => 'button',
                '#value' => $this->t('Add JSON cookie'),
                '#attributes' => [
                    'class' => [
                        'js_cookie_test_add_json_button',
                    ],
                ],
            ],
            'add-json-string' => [
                '#type' => 'button',
                '#value' => $this->t('Add JSON cookie without json option'),
                '#attributes' => [
                    'class' => [
                        'js_cookie_test_add_json_string_button',
                    ],
                ],
            ],
            'remove' => [
                '#type' => 'button',
                '#value' => $this->t('Remove cookie'),
                '#attributes' => [
                    'class' => [
                        'js_cookie_test_remove_button',
                    ],
                ],
            ],
            '#attached' => [
                'library' => [
                    'js_cookie_test/with_shim_test',
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
JsCookieTestController Test controller to assert js-cookie library integration.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.