本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getParameter方法的具体用法?PHP MauticFactory::getParameter怎么用?PHP MauticFactory::getParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Factory\MauticFactory
的用法示例。
在下文中一共展示了MauticFactory::getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* @author William DURAND <william.durand1@gmail.com>
*
* @param GetResponseEvent $event
*
* @return void
* @throws AuthenticationException
* @throws HttpException
*/
public function handle(GetResponseEvent $event)
{
$apiMode = $this->factory->getParameter('api_mode');
if ($apiMode != 'oauth1') {
return;
}
$request = $event->getRequest();
if (false === $request->attributes->get('oauth_request_parameters', false)) {
return;
}
$token = new OAuthToken();
$token->setRequestParameters($request->attributes->get('oauth_request_parameters'));
$token->setRequestMethod($request->attributes->get('oauth_request_method'));
$token->setRequestUrl($request->attributes->get('oauth_request_url'));
try {
$returnValue = $this->authenticationManager->authenticate($token);
if ($returnValue instanceof TokenInterface) {
return $this->securityContext->setToken($returnValue);
} elseif ($returnValue instanceof Response) {
return $event->setResponse($returnValue);
}
} catch (AuthenticationException $e) {
throw $e;
}
throw new HttpException(401);
}
示例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>');
}
示例3: handle
/**
* {@inheritdoc}
*/
public function handle(GetResponseEvent $event)
{
$apiMode = $this->factory->getParameter('api_mode');
if ($apiMode != 'oauth2') {
return;
}
parent::handle($event);
}
示例4: 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')));
}
示例5: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->path = $factory->getParameter('cookie_path');
$this->domain = $factory->getParameter('cookie_domain');
$this->secure = $factory->getParameter('cookie_secure');
if ($this->secure == '' || $this->secure == null) {
$this->secure = $factory->getRequest()->server->get('HTTPS', false);
}
$this->httponly = $factory->getParameter('cookie_httponly');
}
示例6: load
/**
* Load each bundles routing.php file
*
* @param mixed $resource
* @param null $type
*
* @return RouteCollection
* @throws \RuntimeException
*/
public function load($resource, $type = null)
{
if (true === $this->loaded) {
throw new \RuntimeException('Do not add the "mautic" loader twice');
}
$dispatcher = $this->factory->getDispatcher();
// Public
$event = new RouteEvent($this, 'public');
$dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
$collection = $event->getCollection();
// Force all links to be SSL if the site_url parameter is SSL
$siteUrl = $this->factory->getParameter('site_url');
$forceSSL = false;
if (!empty($siteUrl)) {
$parts = parse_url($siteUrl);
$forceSSL = !empty($parts['scheme']) && $parts['scheme'] == 'https';
}
if ($forceSSL) {
$collection->setSchemes('https');
}
// Secured area - Default
$event = new RouteEvent($this);
$dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
$secureCollection = $event->getCollection();
// OneupUploader (added behind our secure /s)
$secureCollection->addCollection($this->import('.', 'uploader'));
if ($this->factory->getParameter('api_enabled')) {
//API
$event = new RouteEvent($this, 'api');
$dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
$apiCollection = $event->getCollection();
$apiCollection->addPrefix('/api');
if ($forceSSL) {
$apiCollection->setSchemes('https');
}
$collection->addCollection($apiCollection);
}
$secureCollection->addPrefix('/s');
if ($forceSSL) {
$secureCollection->setSchemes('https');
}
$collection->addCollection($secureCollection);
// Catch all
$event = new RouteEvent($this, 'catchall');
$dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
$lastCollection = $event->getCollection();
if ($forceSSL) {
$lastCollection->setSchemes('https');
}
$collection->addCollection($lastCollection);
$this->loaded = true;
return $collection;
}
示例7: fetchData
/**
* Retrieves the update data from our home server
*
* @param bool $overrideCache
*
* @return array
*/
public function fetchData($overrideCache = false)
{
$cacheFile = $this->factory->getSystemPath('cache') . '/lastUpdateCheck.txt';
// Check if we have a cache file and try to return cached data if so
if (!$overrideCache && is_readable($cacheFile)) {
$update = (array) json_decode(file_get_contents($cacheFile));
// Check if the user has changed the update channel, if so the cache is invalidated
if ($update['stability'] == $this->factory->getParameter('update_stability')) {
// If we're within the cache time, return the cached data
if ($update['checkedTime'] > strtotime('-3 hours')) {
return $update;
}
}
}
// Before processing the update data, send up our metrics
try {
// Generate a unique instance ID for the site
$instanceId = hash('sha1', $this->factory->getParameter('secret_key') . 'Mautic' . $this->factory->getParameter('db_driver'));
$data = array('application' => 'Mautic', 'version' => $this->factory->getVersion(), 'phpVersion' => PHP_VERSION, 'dbDriver' => $this->factory->getParameter('db_driver'), 'serverOs' => php_uname('s') . ' ' . php_uname('r'), 'instanceId' => $instanceId, 'installSource' => $this->factory->getParameter('install_source', 'Mautic'));
$this->connector->post('https://updates.mautic.org/stats/send', $data, array(), 10);
} catch (\Exception $exception) {
// Not so concerned about failures here, move along
}
// Get the update data
try {
$appData = array('appVersion' => $this->factory->getVersion(), 'phpVersion' => PHP_VERSION, 'stability' => $this->factory->getParameter('update_stability'));
$data = $this->connector->post('https://updates.mautic.org/index.php?option=com_mauticdownload&task=checkUpdates', $appData, array(), 10);
$update = json_decode($data->body);
} catch (\Exception $exception) {
// Log the error
$logger = $this->factory->getLogger();
$logger->addError('An error occurred while attempting to fetch updates: ' . $exception->getMessage());
return array('error' => true, 'message' => 'mautic.core.updater.error.fetching.updates');
}
if ($data->code != 200) {
// Log the error
$logger = $this->factory->getLogger();
$logger->addError(sprintf('An unexpected %1$s code was returned while attempting to fetch updates. The message received was: %2$s', $data->code, is_string($data->body) ? $data->body : implode('; ', $data->body)));
return array('error' => true, 'message' => 'mautic.core.updater.error.fetching.updates');
}
// If the user's up-to-date, go no further
if ($update->latest_version) {
return array('error' => false, 'message' => 'mautic.core.updater.running.latest.version');
}
// Last sanity check, if the $update->version is older than our current version
if (version_compare($this->factory->getVersion(), $update->version, 'ge')) {
return array('error' => false, 'message' => 'mautic.core.updater.running.latest.version');
}
// The user is able to update to the latest version, cache the data first
$data = array('error' => false, 'message' => 'mautic.core.updater.update.available', 'version' => $update->version, 'announcement' => $update->announcement, 'package' => $update->package, 'checkedTime' => time(), 'stability' => $this->factory->getParameter('update_stability'));
file_put_contents($cacheFile, json_encode($data));
return $data;
}
示例8: setBody
/**
* @param $content
* @param string $contentType
* @param null $charset
* @param bool $ignoreTrackingPixel
* @param bool $ignoreEmbedImageConversion
*/
public function setBody($content, $contentType = 'text/html', $charset = null, $ignoreTrackingPixel = false, $ignoreEmbedImageConversion = false)
{
if (!$ignoreEmbedImageConversion && $this->factory->getParameter('mailer_convert_embed_images')) {
$matches = array();
if (preg_match_all('/<img.+?src=[\\"\'](.+?)[\\"\'].*?>/i', $content, $matches)) {
$replaces = array();
foreach ($matches[1] as $match) {
if (strpos($match, 'cid:') === false) {
$replaces[$match] = $this->message->embed(\Swift_Image::fromPath($match));
}
}
$content = strtr($content, $replaces);
}
}
if (!$ignoreTrackingPixel && $this->factory->getParameter('mailer_append_tracking_pixel')) {
// Append tracking pixel
$trackingImg = '<img style="display: none;" height="1" width="1" src="{tracking_pixel}" alt="Mautic is open source marketing automation" />';
if (strpos($content, '</body>') !== false) {
$content = str_replace('</body>', $trackingImg . '</body>', $content);
} else {
$content .= $trackingImg;
}
}
// Update the identifier for the content
$this->contentHash = md5($content . $this->plainText);
$this->body = array('content' => $content, 'contentType' => $contentType, 'charset' => $charset);
}
示例9: __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();
}
示例10: __construct
/**
* @param MauticFactory $factory
* @param string $theme
*
* @throws BadConfigurationException
* @throws FileNotFoundException
*/
public function __construct(MauticFactory $factory, $theme = 'current')
{
$this->factory = $factory;
$this->theme = $theme == 'current' ? $factory->getParameter('theme') : $theme;
if ($this->theme == null) {
$this->theme = 'Mauve';
}
$this->themeDir = $factory->getSystemPath('themes') . '/' . $this->theme;
$this->themePath = $factory->getSystemPath('themes_root') . '/' . $this->themeDir;
//check to make sure the theme exists
if (!file_exists($this->themePath)) {
throw new FileNotFoundException($this->theme . ' not found!');
}
//get the config
if (file_exists($this->themePath . '/config.json')) {
$this->config = json_decode(file_get_contents($this->themePath . '/config.json'), true);
} elseif (file_exists($this->themePath . '/config.php')) {
$this->config = (include $this->themePath . '/config.php');
} else {
throw new BadConfigurationException($this->theme . ' is missing a required config file');
}
if (!isset($this->config['name'])) {
throw new BadConfigurationException($this->theme . ' does not have a valid config file');
}
}
示例11: isEnabled
/**
* Check if a bundle is enabled
*
* @param string $bundle
* @param bool $forceRefresh
*
* @return bool
*/
public function isEnabled($bundle)
{
$dbName = $this->factory->getParameter('db_name');
if (empty($dbName)) {
//the database hasn't been installed yet
return false;
}
if (!static::$loaded) {
$this->buildAddonCache();
}
// Check if the bundle is registered
if (isset(static::$addons[$bundle])) {
return static::$addons[$bundle];
}
// If we don't know about the bundle, it isn't properly registered and we will always return false
return false;
}
示例12: __construct
/**
* @param MauticFactory $factory
*
* @throws \RuntimeException if the mcrypt extension is not enabled
*/
public function __construct(MauticFactory $factory)
{
// Toss an Exception back if mcrypt is not found
if (!extension_loaded('mcrypt')) {
throw new \RuntimeException($factory->getTranslator()->trans('mautic.core.error.no.mcrypt'));
}
$this->key = $factory->getParameter('secret_key');
}
示例13: 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);
}
示例14: __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');
}
示例15: 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, array('form', $form->getId()));
if ($messengerMode) {
return array('download' => $url);
}
$msg = $message . $factory->getTranslator()->trans('mautic.asset.asset.submitaction.downloadfile.msg', array('%url%' => $url));
$content = $factory->getTemplating()->renderResponse('MauticCoreBundle::message.html.php', array('message' => $msg, 'type' => 'notice', 'template' => $factory->getParameter('theme')))->getContent();
return new Response($content);
}