Created
May 6, 2017 18:52
-
-
Save acrosman/945d29162d3ba0e0101333638dd88295 to your computer and use it in GitHub Desktop.
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