public function ResourceController::get in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/tests/modules/media_test_oembed/src/Controller/ResourceController.php \Drupal\media_test_oembed\Controller\ResourceController::get()
- 9 core/modules/media/tests/modules/media_test_oembed/src/Controller/ResourceController.php \Drupal\media_test_oembed\Controller\ResourceController::get()
Creates an oEmbed resource response.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
\Symfony\Component\HttpFoundation\Response The oEmbed resource response.
1 string reference to 'ResourceController::get'
- media_test_oembed.routing.yml in core/
modules/ media/ tests/ modules/ media_test_oembed/ media_test_oembed.routing.yml - core/modules/media/tests/modules/media_test_oembed/media_test_oembed.routing.yml
File
- core/
modules/ media/ tests/ modules/ media_test_oembed/ src/ Controller/ ResourceController.php, line 23
Class
- ResourceController
- Test controller returning oEmbed resources from Media's test fixtures.
Namespace
Drupal\media_test_oembed\ControllerCode
public function get(Request $request) {
$asset_url = $request->query
->get('url');
$resources = \Drupal::state()
->get(static::class, []);
if ($resources[$asset_url] === 404) {
$response = new Response('Not Found', 404);
}
else {
$content = file_get_contents($resources[$asset_url]);
$response = new Response($content);
$response->headers
->set('Content-Type', 'application/' . pathinfo($resources[$asset_url], PATHINFO_EXTENSION));
}
return $response;
}