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


PHP MauticFactory::getModel方法代码示例

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


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

示例1: getTokenContent

 /**
  * @param int $page
  *
  * @return string
  */
 public function getTokenContent($page = 1)
 {
     if (!$this->factory->getSecurity()->isGranted('lead:fields:full')) {
         return;
     }
     $session = $this->factory->getSession();
     //set limits
     $limit = 5;
     $start = $page === 1 ? 0 : ($page - 1) * $limit;
     if ($start < 0) {
         $start = 0;
     }
     $request = $this->factory->getRequest();
     $search = $request->get('search', $session->get('mautic.lead.emailtoken.filter', ''));
     $session->set('mautic.lead.emailtoken.filter', $search);
     $filter = array('string' => $search, 'force' => array(array('column' => 'f.isPublished', 'expr' => 'eq', 'value' => true)));
     $fields = $this->factory->getModel('lead.field')->getEntities(array('start' => $start, 'limit' => $limit, 'filter' => $filter, 'orderBy' => 'f.label', 'orderByDir' => 'ASC', 'hydration_mode' => 'HYDRATE_ARRAY'));
     $count = count($fields);
     if ($count && $count < $start + 1) {
         //the number of entities are now less then the current page so redirect to the last page
         if ($count === 1) {
             $page = 1;
         } else {
             $page = ceil($count / $limit) ?: 1;
         }
         $session->set('mautic.lead.emailtoken.page', $page);
     }
     return $this->factory->getTemplating()->render('MauticLeadBundle:SubscribedEvents\\EmailToken:list.html.php', array('items' => $fields, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search));
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:34,代码来源:EmailTokenHelper.php

示例2: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->factory = $this->getContainer()->get('mautic.factory');
     $queueMode = $this->factory->getParameter('queue_mode');
     // check to make sure we are in queue mode
     if ($queueMode != 'command_process') {
         $output->writeLn('Webhook Bundle is in immediate process mode. To use the command function change to command mode.');
         return 0;
     }
     $id = $input->getOption('webhook-id');
     /** @var \Mautic\WebhookBundle\Model\WebhookModel $model */
     $model = $this->factory->getModel('webhook');
     if ($id) {
         $webhook = $model->getEntity($id);
         $webhooks = $webhook !== null && $webhook->isPublished() ? array($id => $webhook) : array();
     } else {
         // make sure we only get published webhook entities
         $webhooks = $model->getEntities(array('filter' => array('force' => array(array('column' => 'e.isPublished', 'expr' => 'eq', 'value' => 1)))));
     }
     if (!count($webhooks)) {
         $output->writeln('<error>No published webhooks found. Try again later.</error>');
         return;
     }
     $output->writeLn('<info>Processing Webhooks</info>');
     try {
         $model->processWebhooks($webhooks);
     } catch (\Exception $e) {
         $output->writeLn('<error>' . $e->getMessage() . '</error>');
     }
     $output->writeLn('<info>Webhook Processing Complete</info>');
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:34,代码来源:ProcessWebhookQueuesCommand.php

示例3: sendEmailAction

 /**
  * @param MauticFactory $factory
  * @param               $lead
  * @param               $event
  *
  * @return bool|mixed
  */
 public static function sendEmailAction(MauticFactory $factory, $lead, $event)
 {
     $emailSent = false;
     if ($lead instanceof Lead) {
         $fields = $lead->getFields();
         /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
         $leadModel = $factory->getModel('lead');
         $leadCredentials = $leadModel->flattenFields($fields);
         $leadCredentials['id'] = $lead->getId();
     } else {
         $leadCredentials = $lead;
     }
     if (!empty($leadCredentials['email'])) {
         /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
         $emailModel = $factory->getModel('email');
         $emailId = (int) $event['properties']['email'];
         $email = $emailModel->getEntity($emailId);
         if ($email != null && $email->isPublished()) {
             $options = array('source' => array('campaign', $event['campaign']['id']));
             $emailSent = $emailModel->sendEmail($email, $leadCredentials, $options);
         }
     }
     unset($lead, $leadCredentials, $email, $emailModel, $factory);
     return $emailSent;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:32,代码来源:CampaignEventHelper.php

示例4: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     /** @var \Mautic\LeadBundle\Model\ListModel $listModel */
     $listModel = $factory->getModel('lead.list');
     $this->fieldChoices = $listModel->getChoiceFields();
     // Locales
     $this->timezoneChoices = FormFieldHelper::getTimezonesChoices();
     $this->countryChoices = FormFieldHelper::getCountryChoices();
     $this->regionChoices = FormFieldHelper::getRegionChoices();
     // Segments
     $lists = $listModel->getUserLists();
     foreach ($lists as $list) {
         $this->listChoices[$list['id']] = $list['name'];
     }
     // Emails
     /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
     $emailModel = $factory->getModel('email');
     $viewOther = $factory->getSecurity()->isGranted('email:emails:viewother');
     $emails = $emailModel->getRepository()->getEmailList('', 0, 0, $viewOther, true);
     foreach ($emails as $email) {
         $this->emailChoices[$email['language']][$email['id']] = $email['name'];
     }
     ksort($this->emailChoices);
     // Tags
     $leadModel = $factory->getModel('lead');
     $tags = $leadModel->getTagList();
     foreach ($tags as $tag) {
         $this->tagChoices[$tag['value']] = $tag['label'];
     }
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:34,代码来源:ListType.php

示例5: 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

示例6: convertToTrackedUrl

 /**
  * Convert a non-tracked url to a tracked url.
  *
  * @param string $url
  * @param array  $clickthrough
  *
  * @return string
  */
 public function convertToTrackedUrl($url, array $clickthrough = [])
 {
     /** @var \Mautic\PageBundle\Model\TrackableModel $trackableModel */
     $trackableModel = $this->factory->getModel('page.trackable');
     /* @var \Mautic\PageBundle\Entity\Redirect $redirect */
     $trackable = $trackableModel->getTrackableByUrl($url, 'notification', $clickthrough['notification']);
     return $trackableModel->generateTrackableUrl($trackable, $clickthrough);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:16,代码来源:AbstractNotificationApi.php

示例7: unsubscribe

 /**
  * @param string $email
  *
  * @return bool
  */
 public function unsubscribe($email)
 {
     /** @var \Mautic\LeadBundle\Entity\LeadRepository $repo */
     $repo = $this->factory->getEntityManager()->getRepository('MauticLeadBundle:Lead');
     $lead = $repo->getLeadByEmail($email);
     /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
     $leadModel = $this->factory->getModel('lead.lead');
     return $leadModel->addDncForLead($lead, 'notification', null, DoNotContact::UNSUBSCRIBED);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:14,代码来源:NotificationHelper.php

示例8: buildForm

 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $model = $this->factory->getModel('lead.list');
     $lists = $model->getUserLists();
     $segments = [];
     $segments[0] = $this->factory->getTranslator()->trans('mautic.lead.all.leads');
     foreach ($lists as $list) {
         $segments[$list['id']] = $list['name'];
     }
     $builder->add('flag', 'choice', ['label' => 'mautic.lead.list.filter', 'multiple' => true, 'choices' => $segments, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control'], 'required' => false]);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:15,代码来源:DashboardLeadsLifetimeWidgetType.php

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

示例10: buildAddonCache

 public function buildAddonCache()
 {
     // Populate our addon cache if not present
     /** @var \Mautic\AddonBundle\Entity\IntegrationRepository $repo */
     try {
         $repo = $this->factory->getModel('addon')->getRepository();
         static::$addons = $repo->getBundleStatus();
     } catch (\Exception $exception) {
         //database is probably not installed or there was an issue connecting
         return false;
     }
     static::$loaded = true;
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:13,代码来源:AddonHelper.php

示例11: validateFormValue

 /**
  * Determine if this campaign applies
  *
  * @param $eventDetails
  * @param $event
  *
  * @return bool
  */
 public static function validateFormValue(MauticFactory $factory, $event, Lead $lead)
 {
     if (!$lead || !$lead->getId()) {
         return false;
     }
     $model = $factory->getModel('form');
     $operators = $model->getFilterExpressionFunctions();
     $form = $model->getRepository()->findOneById($event['properties']['form']);
     if (!$form || !$form->getId()) {
         return false;
     }
     return $factory->getModel('form.submission')->getRepository()->compareValue($lead->getId(), $form->getId(), $form->getAlias(), $event['properties']['field'], $event['properties']['value'], $operators[$event['properties']['operator']]['expr']);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:21,代码来源:CampaignEventHelper.php

示例12: createOpportunity

 public static function createOpportunity(MauticFactory $factory, $lead, $event)
 {
     $model = $factory->getModel('customCrm.opportunity');
     $opportunity = new Opportunity();
     $opportunity->setStatus($event['properties']['status']);
     $opportunity->setConfidence($event['properties']['confidence']);
     $opportunity->setValue($event['properties']['value']);
     $opportunity->setValueType($event['properties']['valueType']);
     $opportunity->setEstimatedClose(self::generateDueDate($event));
     $opportunity->setComments($event['properties']['comments']);
     $opportunity->setOwnerUser($factory->getModel('user')->getEntity($event['properties']['ownerUser']));
     $opportunity->setLead($lead);
     $model->saveEntity($opportunity);
 }
开发者ID:redmantech,项目名称:Mautic_CRM,代码行数:14,代码来源:CampaignEventHelper.php

示例13: validate

 /**
  * @param mixed      $value
  * @param Constraint $constraint
  */
 public function validate($value, Constraint $constraint)
 {
     $listModel = $this->factory->getModel('lead.list');
     $lists = $listModel->getUserLists();
     if (!count($value)) {
         $this->context->addViolation($constraint->message, array('%string%' => ''));
     }
     foreach ($value as $l) {
         if (!isset($lists[$l->getId()])) {
             $this->context->addViolation($constraint->message, array('%string%' => $l->getName()));
             break;
         }
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:18,代码来源:LeadListAccessValidator.php

示例14: addRemoveLead

 /**
  * @param MauticFactory $factory
  * @param               $lead
  * @param               $event
  *
  * @throws \Doctrine\ORM\ORMException
  */
 public static function addRemoveLead(MauticFactory $factory, $lead, $event)
 {
     /** @var \Mautic\CampaignBundle\Model\CampaignModel $campaignModel */
     $campaignModel = $factory->getModel('campaign');
     $properties = $event['properties'];
     $addToCampaigns = $properties['addTo'];
     $removeFromCampaigns = $properties['removeFrom'];
     $em = $factory->getEntityManager();
     $leadsModified = false;
     if (!empty($addToCampaigns)) {
         foreach ($addToCampaigns as $c) {
             $campaignModel->addLead($em->getReference('MauticCampaignBundle:Campaign', $c), $lead, true);
         }
         $leadsModified = true;
     }
     if (!empty($removeFromCampaigns)) {
         foreach ($removeFromCampaigns as $c) {
             if ($c == 'this') {
                 $c = $event['campaign']['id'];
             }
             $campaignModel->removeLead($em->getReference('MauticCampaignBundle:Campaign', $c), $lead, true);
         }
         $leadsModified = true;
     }
     return $leadsModified;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:33,代码来源:CampaignEventHelper.php

示例15: getTokens

 /**
  * @param string              $tokenRegex     Token regex without wrapping regex escape characters.  Use (value) or (.*?) where the ID of the
  *                                            entity should go. i.e. {pagelink=(value)}
  * @param string              $filter         String to filter results by
  * @param string              $labelColumn    The column that houses the label
  * @param string              $valueColumn    The column that houses the value
  * @param CompositeExpression $expr           Use $factory->getDatabase()->getExpressionBuilder()->andX()
  *
  * @return array|void
  */
 public function getTokens($tokenRegex, $filter = '', $labelColumn = 'name', $valueColumn = 'id', CompositeExpression $expr = null)
 {
     //set some permissions
     $permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY");
     if (in_array(false, $permissions)) {
         return;
     }
     $repo = $this->factory->getModel($this->modelName)->getRepository();
     $prefix = $repo->getTableAlias();
     if (!empty($prefix)) {
         $prefix .= '.';
     }
     $exprBuilder = $this->factory->getDatabase()->getExpressionBuilder();
     if ($expr == null) {
         $expr = $exprBuilder->andX();
     }
     if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) {
         $expr->add($exprBuilder->eq($prefix . 'createdBy', $this->factory->getUser()->getId()));
     }
     if (!empty($filter)) {
         $expr->add($exprBuilder->like('LOWER(' . $labelColumn . ')', ':label'));
         $parameters = array('label' => strtolower($filter) . '%');
     } else {
         $parameters = array();
     }
     $items = $repo->getSimpleList($expr, $parameters, $labelColumn, $valueColumn);
     $tokens = array();
     foreach ($items as $item) {
         $token = str_replace(array('(value)', '(.*?)'), $item['value'], $tokenRegex);
         $tokens[$token] = $item['label'];
     }
     return $tokens;
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:43,代码来源:BuilderTokenHelper.php


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