/** * Load each bundles routing.php file * * @param mixed $resource * @param null $type * * @return RouteCollection * @throws \RuntimeException */ public function load($resource, $type = null) { if (true === $this->loaded) { throw new \RuntimeException('Do not add the "mautic" loader twice'); } $dispatcher = $this->factory->getDispatcher(); // Public $event = new RouteEvent($this, 'public'); $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event); $collection = $event->getCollection(); // Force all links to be SSL if the site_url parameter is SSL $siteUrl = $this->factory->getParameter('site_url'); $forceSSL = false; if (!empty($siteUrl)) { $parts = parse_url($siteUrl); $forceSSL = !empty($parts['scheme']) && $parts['scheme'] == 'https'; } if ($forceSSL) { $collection->setSchemes('https'); } // Secured area - Default $event = new RouteEvent($this); $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event); $secureCollection = $event->getCollection(); // OneupUploader (added behind our secure /s) $secureCollection->addCollection($this->import('.', 'uploader')); if ($this->factory->getParameter('api_enabled')) { //API $event = new RouteEvent($this, 'api'); $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event); $apiCollection = $event->getCollection(); $apiCollection->addPrefix('/api'); if ($forceSSL) { $apiCollection->setSchemes('https'); } $collection->addCollection($apiCollection); } $secureCollection->addPrefix('/s'); if ($forceSSL) { $secureCollection->setSchemes('https'); } $collection->addCollection($secureCollection); // Catch all $event = new RouteEvent($this, 'catchall'); $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event); $lastCollection = $event->getCollection(); if ($forceSSL) { $lastCollection->setSchemes('https'); } $collection->addCollection($lastCollection); $this->loaded = true; return $collection; }
/** * {@inheritdoc} * * @param Request $request * * @return Response never null */ public function logout(Request $request, Response $response, TokenInterface $token) { /** @var \Mautic\UserBundle\Model\UserModel $userModel */ $userModel = $this->factory->getModel('user'); $userModel->setOnlineStatus('offline'); $dispatcher = $this->factory->getDispatcher(); if ($dispatcher->hasListeners(UserEvents::USER_LOGOUT)) { $event = new LogoutEvent($this->factory); $dispatcher->dispatch(UserEvents::USER_LOGOUT, $event); } // Clear session $this->factory->getSession()->clear(); }
/** * @param FactoryInterface $knpFactory * @param MatcherInterface $matcher * @param MauticFactory $factory */ public function __construct(FactoryInterface $knpFactory, MatcherInterface $matcher, MauticFactory $factory) { $this->factory = $knpFactory; $this->matcher = $matcher; $this->dispatcher = $factory->getDispatcher(); $this->menuHelper = $factory->getHelper('menu'); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->em = $factory->getEntityManager(); $this->security = $factory->getSecurity(); $this->dispatcher = $factory->getDispatcher(); $this->translator = $factory->getTranslator(); $this->factory = $factory; }
/** * Dispatch send event to generate tokens * * @return array */ public function dispatchSendEvent() { if ($this->dispatcher == null) { $this->dispatcher = $this->factory->getDispatcher(); } $event = new EmailSendEvent($this); $this->dispatcher->dispatch(EmailEvents::EMAIL_ON_SEND, $event); $this->eventTokens = array_merge($this->eventTokens, $event->getTokens()); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { if (function_exists('imap_open')) { $data = $options['data']; $event = new MonitoredEmailEvent($builder, $data); // Default email bundles $event->addFolder('general', '', 'mautic.email.config.monitored_email.general'); $event->addFolder('EmailBundle', 'bounces', 'mautic.email.config.monitored_email.bounce_folder'); $event->addFolder('EmailBundle', 'unsubscribes', 'mautic.email.config.monitored_email.unsubscribe_folder'); if ($this->factory->getDispatcher()->hasListeners(EmailEvents::MONITORED_EMAIL_CONFIG)) { $this->factory->getDispatcher()->dispatch(EmailEvents::MONITORED_EMAIL_CONFIG, $event); } $folderSettings = $event->getFolders(); foreach ($folderSettings as $key => $settings) { $folderData = array_key_exists($key, $data) ? $data[$key] : []; $builder->add($key, 'monitored_mailboxes', ['label' => $settings['label'], 'mailbox' => $key, 'default_folder' => $settings['default'], 'data' => $folderData, 'required' => false, 'general_settings' => array_key_exists('general', $data) ? $data['general'] : []]); } } }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->factory = $factory; $this->templating = $factory->getTemplating(); $this->request = $factory->getRequest(); $this->security = $factory->getSecurity(); $this->serializer = $factory->getSerializer(); $this->params = $factory->getSystemParameters(); $this->dispatcher = $factory->getDispatcher(); $this->translator = $factory->getTranslator(); $this->init(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->translator = $factory->getTranslator(); $this->dispatcher = $factory->getDispatcher(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->factory = $factory; $this->dispatcher = $factory->getDispatcher(); $this->init(); }
/** * @param $eventName * @param array $keys * * @return array */ protected function dispatchIntegrationKeyEvent($eventName, $keys = array()) { /** @var PluginIntegrationKeyEvent $event */ $event = $this->factory->getDispatcher()->dispatch($eventName, new PluginIntegrationKeyEvent($this, $keys)); return $event->getKeys(); }
/** * @param array $config * @param Lead $lead * @param MauticFactory $factory * * @return boolean */ public static function send(array $config, Lead $lead, MauticFactory $factory) { /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $factory->getModel('lead.lead'); if ($leadModel->isContactable($lead, 'sms') !== DoNotContact::IS_CONTACTABLE) { return array('failed' => 1); } $leadPhoneNumber = $lead->getFieldValue('mobile'); if (empty($leadPhoneNumber)) { $leadPhoneNumber = $lead->getFieldValue('phone'); } if (empty($leadPhoneNumber)) { return array('failed' => 1); } /** @var \Mautic\SmsBundle\Api\AbstractSmsApi $sms */ $smsApi = $factory->getKernel()->getContainer()->get('mautic.sms.api'); /** @var \Mautic\SmsBundle\Model\SmsModel $smsModel */ $smsModel = $factory->getModel('sms'); $smsId = (int) $config['sms']; /** @var \Mautic\SmsBundle\Entity\Sms $sms */ $sms = $smsModel->getEntity($smsId); if ($sms->getId() !== $smsId) { return array('failed' => 1); } $dispatcher = $factory->getDispatcher(); $event = new SmsSendEvent($sms->getMessage(), $lead); $event->setSmsId($smsId); $dispatcher->dispatch(SmsEvents::SMS_ON_SEND, $event); $metadata = $smsApi->sendSms($leadPhoneNumber, $event->getContent()); // If there was a problem sending at this point, it's an API problem and should be requeued if ($metadata === false) { return false; } return array('type' => 'mautic.sms.sms', 'status' => 'mautic.sms.timeline.status.delivered', 'id' => $sms->getId(), 'name' => $sms->getName(), 'content' => $event->getContent()); }