예제 #1
0
 /**
  * Add forms to available page tokens.
  *
  * @param Events\PageBuilderEvent $event
  */
 public function onPageBuild(Events\PageBuilderEvent $event)
 {
     $tokenHelper = new BuilderTokenHelper($this->factory, 'page');
     if ($event->tokenSectionsRequested()) {
         //add extra tokens
         $content = $this->templating->render('MauticPageBundle:SubscribedEvents\\PageToken:token.html.php');
         $event->addTokenSection('page.extratokens', 'mautic.page.builder.header.extra', $content, 2);
         //add pagetokens
         $event->addTokenSection('page.pagetokens', 'mautic.page.pages', $tokenHelper->getTokenContent(['filter' => ['force' => [['column' => 'p.variantParent', 'expr' => 'isNull']]]]), -254);
     }
     if ($event->abTestWinnerCriteriaRequested()) {
         //add AB Test Winner Criteria
         $bounceRate = ['group' => 'mautic.page.abtest.criteria', 'label' => 'mautic.page.abtest.criteria.bounce', 'callback' => '\\Mautic\\PageBundle\\Helper\\AbTestHelper::determineBounceTestWinner'];
         $event->addAbTestWinnerCriteria('page.bouncerate', $bounceRate);
         $dwellTime = ['group' => 'mautic.page.abtest.criteria', 'label' => 'mautic.page.abtest.criteria.dwelltime', 'callback' => '\\Mautic\\PageBundle\\Helper\\AbTestHelper::determineDwellTimeTestWinner'];
         $event->addAbTestWinnerCriteria('page.dwelltime', $dwellTime);
     }
     if ($event->tokensRequested([$this->pageTokenRegex])) {
         $event->addTokensFromHelper($tokenHelper, $this->pageTokenRegex, 'title', 'id', false, true);
         $event->addTokens($event->filterTokens([$this->langBarRegex => $this->translator->trans('mautic.page.token.lang'), $this->shareButtonsRegex => $this->translator->trans('mautic.page.token.share'), $this->titleRegex => $this->translator->trans('mautic.core.title'), $this->descriptionRegex => $this->translator->trans('mautic.page.form.metadescription')]));
     }
     if ($event->slotTypesRequested()) {
         $event->addSlotType('text', 'Text', 'font', 'MauticCoreBundle:Slots:text.html.php', 'slot', 1000);
         $event->addSlotType('image', 'Image', 'image', 'MauticCoreBundle:Slots:image.html.php', 'slot', 900);
         $event->addSlotType('button', 'Button', 'external-link', 'MauticCoreBundle:Slots:button.html.php', 'slot_button', 800);
         $event->addSlotType('separator', 'Separator', 'minus', 'MauticCoreBundle:Slots:separator.html.php', 'slot', 700);
     }
 }