当前位置: 首页>>代码示例>>PHP>>正文


PHP MauticFactory::getKernel方法代码示例

本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getKernel方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getKernel方法的具体用法?PHP MauticFactory::getKernel怎么用?PHP MauticFactory::getKernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mautic\CoreBundle\Factory\MauticFactory的用法示例。


在下文中一共展示了MauticFactory::getKernel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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());
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:42,代码来源:SmsHelper.php

示例2: send

 /**
  * @param array $config
  * @param Lead $lead
  * @param MauticFactory $factory
  *
  * @return array
  */
 public static function send(array $config, Lead $lead, MauticFactory $factory)
 {
     /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
     $leadModel = $factory->getModel('lead.lead');
     $logger = $factory->getLogger();
     if ($leadModel->isContactable($lead, 'notification') !== DoNotContact::IS_CONTACTABLE) {
         $logger->error('Error: Lead ' . $lead->getId() . ' is not contactable on the web push channel.');
         return array('failed' => 1);
     }
     // If lead has subscribed on multiple devices, get all of them.
     /** @var \Mautic\NotificationBundle\Entity\PushID[] $pushIDs */
     $pushIDs = $lead->getPushIDs();
     $playerID = array();
     foreach ($pushIDs as $pushID) {
         $playerID[] = $pushID->getPushID();
     }
     if (empty($playerID)) {
         $logger->error('Error: Lead ' . $lead->getId() . ' has not subscribed to web push channel.');
         return array('failed' => 1);
     }
     /** @var \Mautic\NotificationBundle\Api\AbstractNotificationApi $notification */
     $notificationApi = $factory->getKernel()->getContainer()->get('mautic.notification.api');
     /** @var \Mautic\NotificationBundle\Model\NotificationModel $notificationModel */
     $notificationModel = $factory->getModel('notification');
     $notificationId = (int) $config['notification'];
     /** @var \Mautic\NotificationBundle\Entity\Notification $notification */
     $notification = $notificationModel->getEntity($notificationId);
     if ($notification->getId() !== $notificationId) {
         $logger->error('Error: The requested notification cannot be found.');
         return array('failed' => 1);
     }
     $url = $notificationApi->convertToTrackedUrl($notification->getUrl(), array('notification' => $notification->getId(), 'lead' => $lead->getId()));
     $response = $notificationApi->sendNotification($playerID, $notification->getMessage(), $notification->getHeading(), $url);
     // If for some reason the call failed, tell mautic to try again by return false
     if ($response->code !== 200) {
         $logger->error('Error: The notification failed to send and returned a ' . $response->code . ' HTTP response with a body of: ' . $response->body);
         return false;
     }
     return array('status' => 'mautic.notification.timeline.status.delivered', 'type' => 'mautic.notification.notification', 'id' => $notification->getId(), 'name' => $notification->getName(), 'heading' => $notification->getHeading(), 'content' => $notification->getMessage());
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:47,代码来源:NotificationHelper.php


注:本文中的Mautic\CoreBundle\Factory\MauticFactory::getKernel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。