本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getHelper方法的具体用法?PHP MauticFactory::getHelper怎么用?PHP MauticFactory::getHelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Factory\MauticFactory
的用法示例。
在下文中一共展示了MauticFactory::getHelper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
/** @var \Mautic\PluginBundle\Helper\IntegrationHelper $integrationHelper */
$integrationHelper = $this->factory->getHelper('integration');
$integrationObjects = $integrationHelper->getIntegrationObjects(null, $options['supported_features'], true);
$integrations = ['' => ''];
foreach ($integrationObjects as $name => $object) {
$settings = $object->getIntegrationSettings();
if ($settings->isPublished()) {
if (!isset($integrations[$settings->getPlugin()->getName()])) {
$integrations[$settings->getPlugin()->getName()] = [];
}
$integrations[$settings->getPlugin()->getName()][$object->getName()] = $object->getDisplayName();
}
}
$builder->add('integration', 'choice', ['choices' => $integrations, 'expanded' => false, 'label_attr' => ['class' => 'control-label'], 'multiple' => false, 'label' => 'mautic.integration.integration', 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.integration.integration.tooltip', 'onchange' => 'Mautic.getIntegrationConfig(this);'], 'required' => true, 'constraints' => [new NotBlank(['message' => 'mautic.core.value.required'])]]);
$formModifier = function (FormInterface $form, $data) use($integrationObjects) {
$form->add('config', 'integration_config', ['label' => false, 'attr' => ['class' => 'integration-config-container'], 'integration' => isset($integrationObjects[$data['integration']]) ? $integrationObjects[$data['integration']] : null, 'data' => isset($data['config']) ? $data['config'] : []]);
};
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier) {
$data = $event->getData();
$formModifier($event->getForm(), $data);
});
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($formModifier) {
$data = $event->getData();
$formModifier($event->getForm(), $data);
});
}
示例2: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$monitoredShowOn = $options['mailbox'] == 'general' ? '{}' : '{"config_emailconfig_monitored_email_' . $options['mailbox'] . '_override_settings_1": "checked"}';
$builder->add('address', 'text', array('label' => 'mautic.email.config.monitored_email_address', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_address.tooltip', 'data-show-on' => $monitoredShowOn), 'constraints' => array(new Email(array('message' => 'mautic.core.email.required'))), 'required' => false));
$builder->add('host', 'text', array('label' => 'mautic.email.config.monitored_email_host', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_host.tooltip', 'data-show-on' => $monitoredShowOn), 'required' => false));
$builder->add('port', 'text', array('label' => 'mautic.email.config.monitored_email_port', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_port.tooltip', 'data-show-on' => $monitoredShowOn), 'required' => false, 'data' => array_key_exists('port', $options['data']) ? $options['data']['port'] : 993));
if (extension_loaded('openssl')) {
$builder->add('encryption', 'choice', array('choices' => array('/ssl' => 'mautic.email.config.mailer_encryption.ssl', '/ssl/novalidate-cert' => 'mautic.email.config.monitored_email_encryption.ssl_novalidate', '/tls' => 'mautic.email.config.mailer_encryption.tls', '/tls/novalidate-cert' => 'mautic.email.config.monitored_email_encryption.tls_novalidate'), 'label' => 'mautic.email.config.monitored_email_encryption', 'required' => false, 'attr' => array('class' => 'form-control', 'data-show-on' => $monitoredShowOn, 'tooltip' => 'mautic.email.config.monitored_email_encryption.tooltip'), 'empty_value' => 'mautic.email.config.mailer_encryption.none', 'data' => isset($options['data']['encryption']) ? $options['data']['encryption'] : '/ssl'));
}
$builder->add('user', 'text', array('label' => 'mautic.email.config.monitored_email_user', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_user.tooltip', 'autocomplete' => 'off', 'data-show-on' => $monitoredShowOn), 'required' => false));
$builder->add('password', 'password', array('label' => 'mautic.email.config.monitored_email_password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => 'mautic.user.user.form.passwordplaceholder', 'preaddon' => 'fa fa-lock', 'tooltip' => 'mautic.email.config.monitored_email_password.tooltip', 'autocomplete' => 'off', 'data-show-on' => $monitoredShowOn), 'required' => false));
if ($options['mailbox'] != 'general') {
$builder->add('override_settings', 'yesno_button_group', array('label' => 'mautic.email.config.monitored_email_override_settings', 'label_attr' => array('class' => 'control-label'), 'data' => array_key_exists('override_settings', $options['data']) && !empty($options['data']['override_settings']) ? true : false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_override_settings.tooltip'), 'required' => false));
/** @var \Mautic\EmailBundle\MonitoredEmail\Mailbox $mailbox */
$mailbox = $this->factory->getHelper('mailbox');
$settings = empty($options['data']['override_settings']) ? $options['general_settings'] : $options['data'];
$mailbox->setMailboxSettings($settings);
// Check for IMAP connection and get a folder list
$choices = array('INBOX' => 'INBOX', 'Trash' => 'Trash');
if ($mailbox->isConfigured()) {
try {
$folders = $mailbox->getListingFolders();
$choices = array_combine($folders, $folders);
} catch (\Exception $e) {
// If the connection failed - add back the selected folder just in case it's a temporary connection issue
if (!empty($options['data']['folder'])) {
$choices[$options['data']['folder']] = $options['data']['folder'];
}
}
}
$builder->add('folder', 'choice', array('choices' => $choices, 'label' => 'mautic.email.config.monitored_email_folder', 'label_attr' => array('class' => 'control-label'), 'attr' => array_merge(array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_folder.tooltip', 'data-imap-folders' => $options['mailbox'])), 'data' => array_key_exists('folder', $options['data']) ? $options['data']['folder'] : $options['default_folder'], 'required' => false));
}
$builder->add('test_connection_button', 'standalone_button', array('label' => 'mautic.email.config.monitored_email.test_connection', 'required' => false, 'attr' => array('class' => 'btn btn-success', 'onclick' => 'Mautic.testMonitoredEmailServerConnection(\'' . $options['mailbox'] . '\')')));
}
示例3: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->devMode = $factory->getEnvironment() == 'dev';
$this->imageDir = $factory->getSystemPath('images');
$this->assetHelper = $factory->getHelper('template.assets');
$this->avatarHelper = $factory->getHelper('template.avatar');
}
示例4: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->devMode = $factory->getEnvironment() == 'dev';
$this->imageDir = $factory->getSystemPath('images');
$this->assetHelper = $factory->getHelper('template.assets');
$this->avatarHelper = $factory->getHelper('template.avatar');
$this->request = $factory->getRequest();
$this->devHosts = (array) $factory->getParameter('dev_hosts');
}
示例5: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('site_url', 'text', array('label' => 'mautic.core.config.form.site.url', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.site.url.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('webroot', 'page_list', array('label' => 'mautic.core.config.form.webroot', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.webroot.tooltip', 'data-placeholder' => $this->factory->getTranslator()->trans('mautic.core.config.form.webroot.dashboard')), 'multiple' => false, 'empty_value' => '', 'required' => false));
$builder->add('cache_path', 'text', array('label' => 'mautic.core.config.form.cache.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cache.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('log_path', 'text', array('label' => 'mautic.core.config.form.log.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.log.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('image_path', 'text', array('label' => 'mautic.core.config.form.image.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.image.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('theme', 'theme_list', array('label' => 'mautic.core.config.form.theme', 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.page.form.template.help')));
// Get the list of available languages
/** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
$languageHelper = $this->factory->getHelper('language');
$languages = $languageHelper->fetchLanguages(false, false);
$langChoices = array();
foreach ($languages as $code => $langData) {
$langChoices[$code] = $langData['name'];
}
$langChoices = array_merge($langChoices, $this->factory->getParameter('supported_languages'));
// Alpha sort the languages by name
asort($langChoices);
$builder->add('locale', 'choice', array('choices' => $langChoices, 'label' => 'mautic.core.config.form.locale', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.locale.tooltip'), 'empty_value' => false));
$arrayStringTransformer = new ArrayStringTransformer();
$builder->add($builder->create('trusted_hosts', 'text', array('label' => 'mautic.core.config.form.trusted.hosts', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.trusted.hosts.tooltip'), 'required' => false))->addViewTransformer($arrayStringTransformer));
$builder->add($builder->create('trusted_proxies', 'text', array('label' => 'mautic.core.config.form.trusted.proxies', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.trusted.proxies.tooltip'), 'required' => false))->addViewTransformer($arrayStringTransformer));
$arrayLinebreakTransformer = new ArrayLinebreakTransformer();
$builder->add($builder->create('do_not_track_ips', 'textarea', array('label' => 'mautic.core.config.form.do_not_track_ips', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.do_not_track_ips.tooltip'), 'required' => false))->addViewTransformer($arrayLinebreakTransformer));
$builder->add('rememberme_key', 'text', array('label' => 'mautic.core.config.form.rememberme.key', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.key.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('rememberme_lifetime', 'text', array('label' => 'mautic.core.config.form.rememberme.lifetime', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.lifetime.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('rememberme_path', 'text', array('label' => 'mautic.core.config.form.rememberme.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('rememberme_domain', 'text', array('label' => 'mautic.core.config.form.rememberme.domain', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.domain.tooltip'), 'required' => false));
$builder->add('default_pagelimit', 'choice', array('choices' => array(5 => 'mautic.core.pagination.5', 10 => 'mautic.core.pagination.10', 15 => 'mautic.core.pagination.15', 20 => 'mautic.core.pagination.20', 25 => 'mautic.core.pagination.25', 30 => 'mautic.core.pagination.30', 50 => 'mautic.core.pagination.50', 100 => 'mautic.core.pagination.100'), 'expanded' => false, 'multiple' => false, 'label' => 'mautic.core.config.form.default.pagelimit', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.default.pagelimit.tooltip'), 'required' => false, 'empty_value' => false));
$builder->add('default_timezone', 'timezone', array('label' => 'mautic.core.config.form.default.timezone', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.default.timezone.tooltip'), 'multiple' => false, 'empty_value' => 'mautic.user.user.form.defaulttimezone', 'required' => false));
$builder->add('date_format_full', 'text', array('label' => 'mautic.core.config.form.date.format.full', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.full.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('date_format_short', 'text', array('label' => 'mautic.core.config.form.date.format.short', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.short.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('date_format_dateonly', 'text', array('label' => 'mautic.core.config.form.date.format.dateonly', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.dateonly.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('date_format_timeonly', 'text', array('label' => 'mautic.core.config.form.date.format.timeonly', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.timeonly.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
// Search for IP Services
$bundles = $this->factory->getMauticBundles(true);
$choices = array();
foreach ($bundles as $bundle) {
if (isset($bundle['config']['ip_lookup_services'])) {
foreach ($bundle['config']['ip_lookup_services'] as $service => $details) {
$choices[$service] = $details['display_name'];
}
}
}
natcasesort($choices);
$builder->add('ip_lookup_service', 'choice', array('choices' => $choices, 'label' => 'mautic.core.config.form.ip.lookup.service', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.ip.lookup.service.tooltip')));
$builder->add('ip_lookup_auth', 'text', array('label' => 'mautic.core.config.form.ip.lookup.auth', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.ip.lookup.auth.tooltip'), 'required' => false));
$builder->add('transifex_username', 'text', array('label' => 'mautic.core.config.form.transifex.username', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.transifex.username.tooltip', 'autocomplete' => 'off'), 'required' => false));
$builder->add('transifex_password', 'password', array('label' => 'mautic.core.config.form.transifex.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => 'mautic.user.user.form.passwordplaceholder', 'preaddon' => 'fa fa-lock', 'tooltip' => 'mautic.core.config.form.transifex.password.tooltip', 'autocomplete' => 'off'), 'required' => false));
$builder->add('update_stability', 'choice', array('choices' => array('alpha' => 'mautic.core.config.update_stability.alpha', 'beta' => 'mautic.core.config.update_stability.beta', 'rc' => 'mautic.core.config.update_stability.rc', 'stable' => 'mautic.core.config.update_stability.stable'), 'label' => 'mautic.core.config.form.update.stability', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.update.stability.tooltip'), 'empty_value' => false));
$builder->add('cookie_path', 'text', array('label' => 'mautic.core.config.form.cookie.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cookie.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
$builder->add('cookie_domain', 'text', array('label' => 'mautic.core.config.form.cookie.domain', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cookie.domain.tooltip'), 'required' => false));
$builder->add('cookie_secure', 'yesno_button_group', array('label' => 'mautic.core.config.form.cookie.secure', 'empty_value' => 'mautic.core.form.default', 'data' => array_key_exists('cookie_secure', $options['data']) && !empty($options['data']['cookie_secure']) ? true : false, 'attr' => array('tooltip' => 'mautic.core.config.form.cookie.secure.tooltip')));
$builder->add('cookie_httponly', 'yesno_button_group', array('label' => 'mautic.core.config.form.cookie.httponly', 'data' => array_key_exists('cookie_httponly', $options['data']) && !empty($options['data']['cookie_httponly']) ? true : false, 'attr' => array('tooltip' => 'mautic.core.config.form.cookie.httponly.tooltip')));
}
示例6: __construct
/**
* @param FactoryInterface $knpFactory
* @param MatcherInterface $matcher
* @param MauticFactory $factory
*/
public function __construct(FactoryInterface $knpFactory, MatcherInterface $matcher, MauticFactory $factory)
{
$this->factory = $knpFactory;
$this->matcher = $matcher;
$this->dispatcher = $factory->getDispatcher();
$this->menuHelper = $factory->getHelper('menu');
}
示例7: buildIcons
/**
* Find and add menu items
*
* @param MauticEvents\IconEvent $event
*
* @return void
*/
protected function buildIcons(MauticEvents\IconEvent $event)
{
$session = $this->factory->getSession();
$icons = $session->get('mautic.menu.icons', array());
if (empty($icons)) {
$bundles = $this->factory->getMauticBundles(true);
$menuHelper = $this->factory->getHelper('menu');
foreach ($bundles as $bundle) {
if (!empty($bundle['config']['menu']['main'])) {
$items = !isset($bundle['config']['menu']['main']['items']) ? $bundle['config']['menu']['main'] : $bundle['config']['menu']['main']['items'];
}
if (!empty($items)) {
$menuHelper->createMenuStructure($items);
foreach ($items as $item) {
if (isset($item['iconClass']) && isset($item['id'])) {
$id = explode('_', $item['id']);
if (isset($id[1])) {
// some bundle names are in plural, create also singular item
if (substr($id[1], -1) == 's') {
$event->addIcon(rtrim($id[1], 's'), $item['iconClass']);
}
$event->addIcon($id[1], $item['iconClass']);
}
}
}
}
}
unset($bundles, $menuHelper);
$icons = $event->getIcons();
$session->set('mautic.menu.icons', $icons);
} else {
$event->setIcons($icons);
}
}
示例8: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
/** @var \Mautic\PluginBundle\Helper\IntegrationHelper $integrationHelper */
$integrationHelper = $this->factory->getHelper('integration');
$integrations = '';
$integrationObjects = $integrationHelper->getIntegrationObjects(null, 'login_button');
foreach ($integrationObjects as $integrationObject) {
if ($integrationObject->getIntegrationSettings()->isPublished()) {
/** @var \Mautic\AssetBundle\Model\AssetModel $model */
$model = $this->factory->getModel('form');
$integrations .= $integrationObject->getName() . ",";
$integration = array('integration' => $integrationObject->getName());
$builder->add('authUrl_' . $integrationObject->getName(), 'hidden', array('data' => $model->buildUrl('mautic_integration_auth_user', $integration, true, array())));
}
}
$builder->add('integrations', 'hidden', array('data' => $integrations));
}
示例9: downloadFile
/**
* @param Form $form
* @param Asset $asset
* @param MauticFactory $factory
* @param $message
* @param $messageMode
*
* @return RedirectResponse|Response
*/
public static function downloadFile(Form $form, Asset $asset, MauticFactory $factory, $message, $messengerMode)
{
/** @var \Mautic\AssetBundle\Model\AssetModel $model */
$model = $factory->getModel('asset');
$url = $model->generateUrl($asset, true, ['form', $form->getId()]);
if ($messengerMode) {
return ['download' => $url];
}
$msg = $message . $factory->getTranslator()->trans('mautic.asset.asset.submitaction.downloadfile.msg', ['%url%' => $url]);
$analytics = $factory->getHelper('template.analytics')->getCode();
if (!empty($analytics)) {
$factory->getHelper('template.assets')->addCustomDeclaration($analytics);
}
$logicalName = $factory->getHelper('theme')->checkForTwigTemplate(':' . $factory->getParameter('theme') . ':message.html.php');
$content = $factory->getTemplating()->renderResponse($logicalName, ['message' => $msg, 'type' => 'notice', 'template' => $factory->getParameter('theme')])->getContent();
return new Response($content);
}
示例10: isMontoringEnabled
/**
* Check to see if a monitored email box is enabled and configured
*
* @param $bundleKey
* @param $folderKey
*
* @return bool|array
*/
public function isMontoringEnabled($bundleKey, $folderKey)
{
/** @var \Mautic\EmailBundle\MonitoredEmail\Mailbox $mailboxHelper */
$mailboxHelper = $this->factory->getHelper('mailbox');
if ($mailboxHelper->isConfigured($bundleKey, $folderKey)) {
return $mailboxHelper->getMailboxSettings();
}
return false;
}
示例11: buildUrl
/**
* @param $route
* @param array $routeParams
* @param bool $absolute
* @param array $clickthrough
* @param bool $shortenUrl
*
* @return string
*/
public function buildUrl($route, $routeParams = array(), $absolute = true, $clickthrough = array(), $shortenUrl = false)
{
$url = $this->factory->getRouter()->generate($route, $routeParams, $absolute);
$url .= !empty($clickthrough) ? '?ct=' . $this->encodeArrayForUrl($clickthrough) : '';
if ($shortenUrl) {
/** @var UrlHelper $urlHelper */
$urlHelper = $this->factory->getHelper('url');
return $urlHelper->buildShortUrl($url);
}
return $url;
}
示例12: decryptApiKeys
/**
* Decrypts API keys
*
* @param array $keys
*
* @return array
*/
public function decryptApiKeys(array $keys)
{
/** @var \Mautic\CoreBundle\Helper\EncryptionHelper $helper */
$helper = $this->factory->getHelper('encryption');
$decrypted = array();
foreach ($keys as $name => $key) {
$key = $helper->decrypt($key);
$decrypted[$name] = $key;
}
return $decrypted;
}
示例13: addBrowserNotification
/**
* @param $message
* @param array $messageVars
* @param string $domain
* @param null $title
* @param null $icon
* @param bool $addNotification
* @param string $type
*/
public function addBrowserNotification($message, $messageVars = array(), $domain = 'flashes', $title = null, $icon = null, $addNotification = true, $type = 'notice')
{
if ($domain == null) {
$domain = 'flashes';
}
$translator = $this->factory->getTranslator();
if ($domain === false) {
//message is already translated
$translatedMessage = $message;
} else {
if (isset($messageVars['pluralCount'])) {
$translatedMessage = $translator->transChoice($message, $messageVars['pluralCount'], $messageVars, $domain);
} else {
$translatedMessage = $translator->trans($message, $messageVars, $domain);
}
}
if ($title !== null) {
$title = $translator->trans($title);
} else {
$title = 'Mautic';
}
if ($icon == null) {
$icon = 'media/images/favicon.ico';
}
if (strpos($icon, 'http') !== 0) {
$assetHelper = $this->factory->getHelper('template.assets');
$icon = $assetHelper->getUrl($icon, null, null, true);
}
$session = $this->factory->getSession();
$browserNotifications = $session->get('mautic.browser.notifications', array());
$browserNotifications[] = array('message' => $translatedMessage, 'title' => $title, 'icon' => $icon);
$session->set('mautic.browser.notifications', $browserNotifications);
if (!defined('MAUTIC_INSTALLER') && $addNotification) {
switch ($type) {
case 'warning':
$iconClass = "text-warning fa-exclamation-triangle";
break;
case 'error':
$iconClass = "text-danger fa-exclamation-circle";
break;
case 'notice':
$iconClass = "fa-info-circle";
default:
break;
}
//If the user has not interacted with the browser for the last 30 seconds, consider the message unread
$lastActive = $this->request->get('mauticUserLastActive', 0);
$isRead = $lastActive > 30 ? 0 : 1;
$this->addNotification($translatedMessage, null, $isRead, null, $iconClass);
}
}
示例14: processSlots
/**
* @param $slots
* @param Email $entity
*/
public function processSlots($slots, $entity)
{
/** @var \Mautic\CoreBundle\Templating\Helper\SlotsHelper $slotsHelper */
$slotsHelper = $this->factory->getHelper('template.slots');
$content = $entity->getContent();
foreach ($slots as $slot => $slotConfig) {
if (is_numeric($slot)) {
$slot = $slotConfig;
$slotConfig = [];
}
$value = isset($content[$slot]) ? $content[$slot] : '';
$slotsHelper->set($slot, $value);
}
}
示例15: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
/** @var \Mautic\PluginBundle\Helper\IntegrationHelper $helper */
$helper = $this->factory->getHelper('integration');
/** @var \MauticPlugin\MauticEmailMarketingBundle\Integration\ConstantContactIntegration $object */
$object = $helper->getIntegrationObject('ConstantContact');
$api = $object->getApiHelper();
try {
$lists = $api->getLists();
$choices = [];
if (!empty($lists)) {
foreach ($lists as $list) {
$choices[$list['id']] = $list['name'];
}
asort($choices);
}
} catch (\Exception $e) {
$choices = [];
$error = $e->getMessage();
}
$builder->add('list', 'choice', ['choices' => $choices, 'label' => 'mautic.emailmarketing.list', 'required' => false, 'attr' => ['tooltip' => 'mautic.emailmarketing.list.tooltip']]);
$builder->add('sendWelcome', 'yesno_button_group', ['label' => 'mautic.emailmarketing.send_welcome', 'data' => !isset($options['data']['sendWelcome']) ? true : $options['data']['sendWelcome']]);
if (!empty($error)) {
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($error) {
$form = $event->getForm();
if ($error) {
$form['list']->addError(new FormError($error));
}
});
}
if (isset($options['form_area']) && $options['form_area'] == 'integration') {
$leadFields = $this->factory->getModel('plugin')->getLeadFields();
$fields = $object->getFormLeadFields();
list($specialInstructions, $alertType) = $object->getFormNotes('leadfield_match');
$builder->add('leadFields', 'integration_fields', ['label' => 'mautic.integration.leadfield_matches', 'required' => true, 'lead_fields' => $leadFields, 'data' => isset($options['data']['leadFields']) ? $options['data']['leadFields'] : [], 'integration_fields' => $fields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType]);
}
}