Spaces:
No application file
No application file
File size: 2,838 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
<?php
namespace Mautic\CoreBundle\Controller;
use Mautic\CoreBundle\CoreEvents;
use Mautic\CoreBundle\Event\GlobalSearchEvent;
use Symfony\Component\HttpFoundation\Request;
/**
* Almost all other Mautic Bundle controllers extend this default controller.
*/
class DefaultController extends CommonController
{
/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function indexAction(Request $request)
{
$root = $this->coreParametersHelper->get('webroot');
if (empty($root)) {
return $this->redirectToRoute('mautic_dashboard_index');
} else {
/** @var \Mautic\PageBundle\Model\PageModel $pageModel */
$pageModel = $this->getModel('page');
$page = $pageModel->getEntity($root);
if (empty($page)) {
return $this->notFound();
}
$slug = $pageModel->generateSlug($page);
$request->attributes->set('ignore_mismatch', true);
return $this->forward('Mautic\PageBundle\Controller\PublicController::indexAction', ['slug' => $slug]);
}
}
public function globalSearchAction(Request $request): \Symfony\Component\HttpFoundation\Response
{
$searchStr = $request->get('global_search', $request->getSession()->get('mautic.global_search', ''));
$request->getSession()->set('mautic.global_search', $searchStr);
if (!empty($searchStr)) {
$event = new GlobalSearchEvent($searchStr, $this->translator);
$this->dispatcher->dispatch($event, CoreEvents::GLOBAL_SEARCH);
$results = $event->getResults();
} else {
$results = [];
}
return $this->render('@MauticCore/GlobalSearch/globalsearch.html.twig',
[
'results' => $results,
'searchString' => $searchStr,
]
);
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function notificationsAction(): \Symfony\Component\HttpFoundation\Response
{
/** @var \Mautic\CoreBundle\Model\NotificationModel $model */
$model = $this->getModel('core.notification');
[$notifications, $showNewIndicator, $updateMessage] = $model->getNotificationContent(null, false, 200);
return $this->delegateView(
[
'contentTemplate' => '@MauticCore/Notification/notifications.html.twig',
'viewParameters' => [
'showNewIndicator' => $showNewIndicator,
'notifications' => $notifications,
'updateMessage' => $updateMessage,
],
]
);
}
}
|