X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Flinkit%2Fsrc%2FResultManager.php;fp=web%2Fmodules%2Fcontrib%2Flinkit%2Fsrc%2FResultManager.php;h=bd4274454bb7561ed794e29798990600953f4497;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/linkit/src/ResultManager.php b/web/modules/contrib/linkit/src/ResultManager.php new file mode 100644 index 000000000..bd4274454 --- /dev/null +++ b/web/modules/contrib/linkit/src/ResultManager.php @@ -0,0 +1,74 @@ + t('No results'), + ]]; + } + + // Special for link to front page. + if (strpos($search_string, 'front') !== FALSE) { + $matches[] = [ + 'title' => t('Front page'), + 'description' => 'The front page for this site.', + 'path' => Url::fromRoute('')->toString(), + 'group' => t('System'), + ]; + } + + foreach ($linkitProfile->getMatchers() as $plugin) { + $matches = array_merge($matches, $plugin->getMatches($search_string)); + } + + // Check for an e-mail address then return an e-mail match and create a + // mail-to link if appropriate. + if (filter_var($search_string, FILTER_VALIDATE_EMAIL)) { + $matches[] = [ + 'title' => t('E-mail @email', ['@email' => $search_string]), + 'description' => t('Opens your mail client ready to e-mail @email', ['@email' => $search_string]), + 'path' => 'mailto:' . Html::escape($search_string), + 'group' => t('E-mail'), + ]; + } + + // If there is still no matches, return a "no results" array. + if (empty($matches)) { + return [[ + 'title' => t('No results'), + ]]; + } + + return $matches; + } + +}