A simple example Drupal Controller with an uncached JsonResponse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\example\Controller; | |
use Drupal\Core\Controller\ControllerBase; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
class ExampleController extends ControllerBase { | |
public function getJson(Request $request) { | |
$data = []; | |
// Do some useful stuff to build an array of data. | |
return new JsonResponse($data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment