Spaces:
No application file
No application file
File size: 1,249 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 |
<?php
namespace Mautic\CoreBundle\Controller;
use Mautic\CoreBundle\CoreEvents;
use Mautic\CoreBundle\Event\BuildJsEvent;
use Symfony\Component\HttpFoundation\Response;
class JsController extends CommonController
{
public function indexAction(): Response
{
// Don't store a visitor with this request
defined('MAUTIC_NON_TRACKABLE_REQUEST') || define('MAUTIC_NON_TRACKABLE_REQUEST', 1);
$dispatcher = $this->dispatcher;
$debug = $this->factory->getKernel()->isDebug();
$event = new BuildJsEvent($this->getJsHeader(), $debug);
if ($dispatcher->hasListeners(CoreEvents::BUILD_MAUTIC_JS)) {
$dispatcher->dispatch($event, CoreEvents::BUILD_MAUTIC_JS);
}
return new Response($event->getJs(), 200, ['Content-Type' => 'application/javascript']);
}
/**
* Build a JS header for the Mautic embedded JS.
*/
protected function getJsHeader(): string
{
$year = date('Y');
return <<<JS
/**
* @package MauticJS
* @copyright {$year} Mautic Contributors. All rights reserved.
* @author Mautic
* @link http://mautic.org
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
JS;
}
}
|