Rename public directory
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpEvents\Service;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
|
||||
|
||||
class ConfigurationService
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $configurationManager
|
||||
*/
|
||||
public function __construct(ConfigurationManagerInterface $configurationManager)
|
||||
{
|
||||
$this->configurationManager = $configurationManager;
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
);
|
||||
$this->settings = $settings['plugin']['tx_epevents'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfiguratorConfig()
|
||||
{
|
||||
$extensionConfig = $this->settings['settings']['configurator']['options'];
|
||||
|
||||
return [
|
||||
'budgetOptions' => $this->parseConfigItem($extensionConfig, 'budget'),
|
||||
'paxOptions' => $this->parseConfigItem($extensionConfig, 'pax'),
|
||||
'periodOptions' => $this->parseConfigItem($extensionConfig, 'period'),
|
||||
'travelTypeOptions' => $this->parseConfigItem($extensionConfig, 'travelType'),
|
||||
'locationTypeOptions' => $this->parseConfigItem($extensionConfig, 'locationType'),
|
||||
'accommodationTypeOptions' => $this->parseConfigItem($extensionConfig, 'accommodationType'),
|
||||
'programmeTypeOptions' => $this->parseConfigItem($extensionConfig, 'programmeType'),
|
||||
'distanceOptions' => $this->parseConfigItem($extensionConfig, 'distance'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $configArray
|
||||
* @param string $itemName
|
||||
* @return array
|
||||
*/
|
||||
protected function parseConfigItem($configArray, $itemName)
|
||||
{
|
||||
$config = [];
|
||||
foreach (explode(';', $configArray[$itemName]) as $item)
|
||||
{
|
||||
[ $value, $label ] = explode(':', $item);
|
||||
$config[$value] = $label;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
namespace EP\EpEvents\Service;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* Cedric Ziel <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpEvents\Domain\Model\Inquiry;
|
||||
use TYPO3\CMS\Core\Mail\MailMessage;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
|
||||
class EmailService implements SingletonInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $configurationManager
|
||||
*/
|
||||
public function __construct(ConfigurationManagerInterface $configurationManager)
|
||||
{
|
||||
$this->configurationManager = $configurationManager;
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
);
|
||||
$this->settings = $settings['plugin']['tx_epevents'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
* @param array $variables
|
||||
* @return bool
|
||||
*/
|
||||
public function send(array $options)
|
||||
{
|
||||
$fromEmail = $this->settings['settings']['inquiryToEmail'];
|
||||
$fromName = $this->settings['settings']['inquiryToName'];
|
||||
$enableAutoreply = $this->settings['settings']['enableContactFormAutoreply'];
|
||||
$autoreplySubject = $this->settings['settings']['contactFormAutoreplySubject'];
|
||||
|
||||
$toEmail = $options['toEmail'];
|
||||
$toName = $options['toName'];
|
||||
$subject = $options['subject'];
|
||||
$templateName = $options['templateName'];
|
||||
$variables = $options['variables'];
|
||||
|
||||
/** @var MailMessage $message */
|
||||
$message = GeneralUtility::makeInstance(MailMessage::class);
|
||||
$message
|
||||
->setTo([$toEmail => $toName])
|
||||
->setFrom([$fromEmail => $fromName])
|
||||
->setSubject($subject)
|
||||
;
|
||||
|
||||
$view = $this->getView($templateName);
|
||||
$view->assignMultiple($variables);
|
||||
$message->setBody($view->render(), 'text/html');
|
||||
|
||||
$messageSent = $message->send();
|
||||
$autoreplySent = false;
|
||||
|
||||
if ($enableAutoreply) {
|
||||
/** @var Inquiry $inquiry */
|
||||
$inquiry = $variables['inquiry'];
|
||||
$toEmail = $inquiry->getEmail();
|
||||
$toName = $inquiry->getName();
|
||||
$templateName = 'Email/Autoreply';
|
||||
|
||||
/** @var MailMessage $message */
|
||||
$message = GeneralUtility::makeInstance(MailMessage::class);
|
||||
$message
|
||||
->setTo([$toEmail => $toName])
|
||||
->setFrom([$fromEmail => $fromName])
|
||||
->setSubject($autoreplySubject)
|
||||
;
|
||||
|
||||
$view = $this->getView($templateName);
|
||||
$view->assignMultiple($variables);
|
||||
$message->setBody($view->render(), 'text/html');
|
||||
|
||||
$autoreplySent = $message->send();
|
||||
}
|
||||
|
||||
return $messageSent && $autoreplySent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $templateName
|
||||
* @param string $format
|
||||
* @return StandaloneView
|
||||
*/
|
||||
protected function getView($templateName, $format = 'html')
|
||||
{
|
||||
/** @var StandaloneView $view */
|
||||
$view = GeneralUtility::makeInstance(StandaloneView::class);
|
||||
$view->setFormat($format);
|
||||
$view->getRequest()->setControllerExtensionName('ep_events');
|
||||
|
||||
$view->setTemplateRootPaths($this->settings['view']['templateRootPaths']);
|
||||
$view->setLayoutRootPaths($this->settings['view']['layoutRootPaths']);
|
||||
$view->setPartialRootPaths($this->settings['view']['partialRootPaths']);
|
||||
$view->setTemplate($templateName);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user