X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fembed%2Fsrc%2FController%2FEmbedController.php;fp=web%2Fmodules%2Fcontrib%2Fembed%2Fsrc%2FController%2FEmbedController.php;h=65df04fc9b5071fb44d6f68afc5b602578c96235;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/embed/src/Controller/EmbedController.php b/web/modules/contrib/embed/src/Controller/EmbedController.php new file mode 100644 index 000000000..65df04fc9 --- /dev/null +++ b/web/modules/contrib/embed/src/Controller/EmbedController.php @@ -0,0 +1,74 @@ +get('value'); + if ($text == '') { + throw new NotFoundHttpException(); + } + + $build = [ + '#type' => 'processed_text', + '#text' => $text, + '#format' => $filter_format->id(), + ]; + + $response = new AjaxResponse(); + $response->addCommand(new EmbedInsertCommand($build)); + return $response; + } + + /** + * Returns an Ajax response to generate preview of an entity. + * + * Expects the the HTML element as GET parameter. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * The request object. + * @param \Drupal\editor\EditorInterface $editor + * The editor. + * @param \Drupal\embed\EmbedButtonInterface $embed_button + * The embed button. + * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * Throws an exception if 'value' parameter is not found in the request. + * + * @return \Symfony\Component\HttpFoundation\Response + * The preview of the embedded item specified by the data attributes. + */ + public function previewEditor(Request $request, EditorInterface $editor, EmbedButtonInterface $embed_button) { + return $this->preview($request, $editor->getFilterFormat()); + } + +}