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


PHP MauticFactory::getEntityManager方法代码示例

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


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

示例1: unsubscribe

 public function unsubscribe($number)
 {
     $phoneUtil = PhoneNumberUtil::getInstance();
     $phoneNumber = $phoneUtil->parse($number, 'US');
     $number = $phoneUtil->format($phoneNumber, PhoneNumberFormat::E164);
     /** @var \Mautic\LeadBundle\Entity\LeadRepository $repo */
     $repo = $this->factory->getEntityManager()->getRepository('MauticLeadBundle:Lead');
     $args = array('filter' => array('force' => array(array('column' => 'mobile', 'expr' => 'eq', 'value' => $number))));
     $leads = $repo->getEntities($args);
     if (!empty($leads)) {
         $lead = array_shift($leads);
     } else {
         // Try to find the lead based on the given phone number
         $args['filter']['force'][0]['column'] = 'phone';
         $leads = $repo->getEntities($args);
         if (!empty($leads)) {
             $lead = array_shift($leads);
         } else {
             return false;
         }
     }
     /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
     $leadModel = $this->factory->getModel('lead.lead');
     return $leadModel->addDncForLead($lead, 'sms', null, DoNotContact::UNSUBSCRIBED);
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:25,代码来源:SmsHelper.php

示例2: 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:HomeRefill,项目名称:mautic,代码行数:14,代码来源:NotificationHelper.php

示例3: extractAuthKeys

 /**
  * Extacts the auth keys from response and saves entity
  *
  * @param $data
  *
  * @return bool|string false if no error; otherwise the error string
  */
 public function extractAuthKeys($data, $tokenOverride = null)
 {
     //check to see if an entity exists
     $entity = $this->getIntegrationSettings();
     if ($entity == null) {
         $entity = new Integration();
         $entity->setName($this->getName());
     }
     // Prepare the keys for extraction such as renaming, setting expiry, etc
     $data = $this->prepareResponseForExtraction($data);
     //parse the response
     $authTokenKey = $tokenOverride ? $tokenOverride : $this->getAuthTokenKey();
     if (is_array($data) && isset($data[$authTokenKey])) {
         $keys = $this->mergeApiKeys($data, null, true);
         $encrypted = $this->encryptApiKeys($keys);
         $entity->setApiKeys($encrypted);
         $error = false;
     } else {
         $error = $this->getErrorsFromResponse($data);
         if (empty($error)) {
             $error = $this->factory->getTranslator()->trans("mautic.integration.error.genericerror", array(), "flashes");
         }
     }
     //save the data
     $em = $this->factory->getEntityManager();
     $em->persist($entity);
     $em->flush();
     $this->setIntegrationSettings($entity);
     return $error;
 }
开发者ID:smotalima,项目名称:mautic,代码行数:37,代码来源:AbstractIntegration.php

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

示例5: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->em = $factory->getEntityManager();
     $this->translator = $factory->getTranslator();
     $this->model = $factory->getModel('category');
     $this->router = $factory->getRouter();
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:10,代码来源:CategoryListType.php

示例6: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->defaultTheme = $factory->getParameter('theme');
     $this->em = $factory->getEntityManager();
     $this->request = $factory->getRequest();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:10,代码来源:EmailType.php

示例7: determineDwellTimeTestWinner

 /**
  * Determines the winner of A/B test based on dwell time rates
  *
  * @param MauticFactory $factory
  * @param Page          $parent
  * @param               $children
  *
  * @return array
  */
 public static function determineDwellTimeTestWinner($factory, $parent, $children)
 {
     //find the hits that did not go any further
     $repo = $factory->getEntityManager()->getRepository('MauticPageBundle:Hit');
     $pageIds = array($parent->getId());
     foreach ($children as $c) {
         $pageIds[] = $c->getId();
     }
     $startDate = $parent->getVariantStartDate();
     if ($startDate != null && !empty($pageIds)) {
         //get their bounce rates
         $counts = $repo->getDwellTimes(array('pageIds' => $pageIds, 'startDate' => $startDate));
         $translator = $factory->getTranslator();
         $support = array();
         if ($counts) {
             //in order to get a fair grade, we have to compare the averages here since a page that is only shown
             //25% of the time will have a significantly lower sum than a page shown 75% of the time
             $avgs = array();
             $support['data'] = array();
             $support['labels'] = array();
             foreach ($counts as $pid => $stats) {
                 $avgs[$pid] = $stats['average'];
                 $support['data'][$translator->trans('mautic.page.abtest.label.dewlltime.average')][] = $stats['average'];
                 $support['labels'][] = $pid . ':' . $stats['title'];
             }
             //set max for scales
             $max = max($avgs);
             $support['step_width'] = ceil($max / 10) * 10;
             //get the page ids with the greatest average dwell time
             $winners = $max > 0 ? array_keys($avgs, $max) : array();
             return array('winners' => $winners, 'support' => $support, 'basedOn' => 'page.dwelltime', 'supportTemplate' => 'MauticPageBundle:SubscribedEvents\\AbTest:bargraph.html.php');
         }
     }
     return array('winners' => array(), 'support' => array(), 'basedOn' => 'page.dwelltime');
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:44,代码来源:AbTestHelper.php

示例8: createEmailStat

 /**
  * Create an email stat.
  *
  * @param bool|true   $persist
  * @param string|null $emailAddress
  * @param null        $listId
  *
  * @return Stat|void
  *
  * @throws \Doctrine\ORM\ORMException
  */
 public function createEmailStat($persist = true, $emailAddress = null, $listId = null)
 {
     static $copies = [];
     //create a stat
     $stat = new Stat();
     $stat->setDateSent(new \DateTime());
     $stat->setEmail($this->email);
     // Note if a lead
     if (null !== $this->lead) {
         $stat->setLead($this->factory->getEntityManager()->getReference('MauticLeadBundle:Lead', $this->lead['id']));
         $emailAddress = $this->lead['email'];
     }
     // Find email if applicable
     if (null === $emailAddress) {
         // Use the last address set
         $emailAddresses = $this->message->getTo();
         if (count($emailAddresses)) {
             end($emailAddresses);
             $emailAddress = key($emailAddresses);
         }
     }
     $stat->setEmailAddress($emailAddress);
     // Note if sent from a lead list
     if (null !== $listId) {
         $stat->setList($this->factory->getEntityManager()->getReference('MauticLeadBundle:LeadList', $listId));
     }
     $stat->setTrackingHash($this->idHash);
     if (!empty($this->source)) {
         $stat->setSource($this->source[0]);
         $stat->setSourceId($this->source[1]);
     }
     $stat->setTokens($this->getTokens());
     /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
     $emailModel = $this->factory->getModel('email');
     // Save a copy of the email - use email ID if available simply to prevent from having to rehash over and over
     $id = null !== $this->email ? $this->email->getId() : md5($this->subject . $this->body['content']);
     if (!isset($copies[$id])) {
         $hash = strlen($id) !== 32 ? md5($this->subject . $this->body['content']) : $id;
         $copy = $emailModel->getCopyRepository()->findByHash($hash);
         $copyCreated = false;
         if (null === $copy) {
             if (!$emailModel->getCopyRepository()->saveCopy($hash, $this->subject, $this->body['content'])) {
                 // Try one more time to find the ID in case there was overlap when creating
                 $copy = $emailModel->getCopyRepository()->findByHash($hash);
             } else {
                 $copyCreated = true;
             }
         }
         if ($copy || $copyCreated) {
             $copies[$id] = $hash;
         }
     }
     if (isset($copies[$id])) {
         $stat->setStoredCopy($this->factory->getEntityManager()->getReference('MauticEmailBundle:Copy', $copies[$id]));
     }
     if ($persist) {
         $emailModel->getStatRepository()->saveEntity($stat);
     }
     return $stat;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:71,代码来源:MailHelper.php

示例9: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->em = $factory->getEntityManager();
     $this->model = $factory->getModel('page');
     $this->canViewOther = $factory->getSecurity()->isGranted('page:pages:viewother');
     $this->user = $factory->getUser();
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:11,代码来源:PageType.php

示例10: __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;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:11,代码来源:CommonModel.php

示例11: getMauticLead

 /**
  * Create or update existing Mautic lead from the integration's profile data
  *
  * @param mixed       $data    Profile data from integration
  * @param bool|true   $persist Set to false to not persist lead to the database in this method
  * @param array|null  $socialCache
  * @param mixed||null $identifiers
  * @return Lead
  */
 public function getMauticLead($data, $persist = true, $socialCache = null, $identifiers = null)
 {
     if (is_object($data)) {
         // Convert to array in all levels
         $data = json_encode(json_decode($data), true);
     } elseif (is_string($data)) {
         // Assume JSON
         $data = json_decode($data, true);
     }
     // Match that data with mapped lead fields
     $matchedFields = $this->populateMauticLeadData($data);
     if (empty($matchedFields)) {
         return;
     }
     // Find unique identifier fields used by the integration
     /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
     $leadModel = $this->factory->getModel('lead');
     $uniqueLeadFields = $this->factory->getModel('lead.field')->getUniqueIdentiferFields();
     $uniqueLeadFieldData = array();
     foreach ($matchedFields as $leadField => $value) {
         if (array_key_exists($leadField, $uniqueLeadFields) && !empty($value)) {
             $uniqueLeadFieldData[$leadField] = $value;
         }
     }
     // Default to new lead
     $lead = new Lead();
     $lead->setNewlyCreated(true);
     if (count($uniqueLeadFieldData)) {
         $existingLeads = $this->factory->getEntityManager()->getRepository('MauticLeadBundle:Lead')->getLeadsByUniqueFields($uniqueLeadFieldData);
         if (!empty($existingLeads)) {
             $lead = array_shift($existingLeads);
             // Update remaining leads
             if (count($existingLeads)) {
                 foreach ($existingLeads as $existingLead) {
                     $existingLead->setLastActive(new \DateTime());
                 }
             }
         }
     }
     $leadModel->setFieldValues($lead, $matchedFields, false, false);
     // Update the social cache
     $leadSocialCache = $lead->getSocialCache();
     if (!isset($leadSocialCache[$this->getName()])) {
         $leadSocialCache[$this->getName()] = array();
     }
     $leadSocialCache[$this->getName()] = array_merge($leadSocialCache[$this->getName()], $socialCache);
     // Check for activity while here
     if (null !== $identifiers && in_array('public_activity', $this->getSupportedFeatures())) {
         $this->getPublicActivity($identifiers, $leadSocialCache[$this->getName()]);
     }
     $lead->setSocialCache($leadSocialCache);
     $lead->setLastActive(new \DateTime());
     if ($persist) {
         // Only persist if instructed to do so as it could be that calling code needs to manipulate the lead prior to executing event listeners
         $leadModel->saveEntity($lead, false);
     }
     return $lead;
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:67,代码来源:AbstractIntegration.php

示例12: clearIntegrationCache

 /**
  * @param      $lead
  * @param bool $integration
  *
  * @return array
  */
 public function clearIntegrationCache($lead, $integration = false)
 {
     $socialCache = $lead->getSocialCache();
     if (!empty($integration)) {
         unset($socialCache[$integration]);
     } else {
         $socialCache = array();
     }
     $lead->setSocialCache($socialCache);
     $this->factory->getEntityManager()->getRepository('MauticLeadBundle:Lead')->saveEntity($lead);
     return $socialCache;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:18,代码来源:IntegrationHelper.php

示例13: __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->em = $factory->getEntityManager();
     $this->router = $factory->getRouter();
     $this->init();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:17,代码来源:CommonSubscriber.php

示例14: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->defaultTheme = $factory->getParameter('theme');
     $this->em = $factory->getEntityManager();
     $this->request = $factory->getRequest();
     $this->countryChoices = FormFieldHelper::getCountryChoices();
     $this->regionChoices = FormFieldHelper::getRegionChoices();
     $this->timezoneChoices = FormFieldHelper::getTimezonesChoices();
     $this->localeChoices = FormFieldHelper::getLocaleChoices();
     $stages = $factory->getModel('stage')->getRepository()->getSimpleList();
     foreach ($stages as $stage) {
         $this->stageChoices[$stage['value']] = $stage['label'];
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:18,代码来源:EmailType.php

示例15: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->em = $factory->getEntityManager();
     $this->model = $factory->getModel('user');
     // Get the list of available languages
     /** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
     $languageHelper = $factory->getHelper('language');
     $languages = $languageHelper->fetchLanguages(false, false);
     $langChoices = array();
     foreach ($languages as $code => $langData) {
         $langChoices[$code] = $langData['name'];
     }
     $langChoices = array_merge($langChoices, $factory->getParameter('supported_languages'));
     // Alpha sort the languages by name
     asort($langChoices);
     $this->supportedLanguages = $langChoices;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:21,代码来源:UserType.php


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