示例#1
0
    /**
     * PreProcess page slots for public view.
     *
     * @param array $slots
     * @param Email $entity
     */
    private function processSlots($slots, $entity)
    {
        /** @var \Mautic\CoreBundle\Templating\Helper\SlotsHelper $slotsHelper */
        $slotsHelper = $this->factory->getHelper('template.slots');
        /** @var \Mautic\CoreBundle\Templating\Helper\TranslatorHelper $translatorHelper */
        $translatorHelper = $this->factory->getHelper('template.translator');
        $content = $entity->getContent();
        //Set the slots
        foreach ($slots as $slot => $slotConfig) {
            //support previous format where email slots are not defined with config array
            if (is_numeric($slot)) {
                $slot = $slotConfig;
                $slotConfig = [];
            }
            $value = isset($content[$slot]) ? $content[$slot] : '';
            $placeholder = isset($slotConfig['placeholder']) ? $slotConfig['placeholder'] : 'mautic.page.builder.addcontent';
            $slotsHelper->set($slot, "<div data-slot=\"text\" id=\"slot-{$slot}\">{$value}</div>");
        }
        //add builder toolbar
        $slotsHelper->start('builder');
        ?>
        <input type="hidden" id="builder_entity_id" value="<?php 
        echo $entity->getSessionId();
        ?>
"/>
        <?php 
        $slotsHelper->stop();
    }
 /**
  * {@inheritDoc}
  */
 public function getSessionId()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSessionId', array());
     return parent::getSessionId();
 }