本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getDispatcher方法的具体用法?PHP MauticFactory::getDispatcher怎么用?PHP MauticFactory::getDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Factory\MauticFactory
的用法示例。
在下文中一共展示了MauticFactory::getDispatcher方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* 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;
}
示例2: logout
/**
* {@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();
}
示例3: __construct
/**
* @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');
}
示例4: __construct
/**
* @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;
}
示例5: dispatchSendEvent
/**
* 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());
}
示例6: buildForm
/**
* @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'] : []]);
}
}
}
示例7: __construct
/**
* @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();
}
示例8: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->translator = $factory->getTranslator();
$this->dispatcher = $factory->getDispatcher();
}
示例9: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->factory = $factory;
$this->dispatcher = $factory->getDispatcher();
$this->init();
}
示例10: dispatchIntegrationKeyEvent
/**
* @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();
}
示例11: send
/**
* @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());
}