Commit e6ec7a54 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Removed db stuff

parent 3a2f2144
......@@ -26,7 +26,7 @@ namespace SGalinski\SgMail\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SGalinski\SgMail\Domain\Model\RegisteredTemplate;
use SGalinski\SgMail\Service\MailTemplateService;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
......@@ -34,37 +34,21 @@ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
*/
class MailController extends ActionController {
/**
* TemplateRepository
*
* @var \SGalinski\SgMail\Domain\Repository\RegisteredTemplateRepository
* @inject
*/
protected $registeredTemplateRepository;
/**
*
*/
public function indexAction() {
// @TODO auslagern in function, da jede action dies brauchen wird
/** @var RegisteredTemplate $registeredTemplates */
$registeredTemplates = $this->registeredTemplateRepository->findAll();
$this->view->assign('extensions', $this->getDistinctExtensionKeys($registeredTemplates));
$this->view->assign('extensions', array_keys(MailTemplateService::$registerArray));
}
/**
* @param array $templates
* @return array
* @return void
*/
protected function getDistinctExtensionKeys($templates) {
$extensionKeys = [];
/** @var RegisteredTemplate $template */
foreach ($templates as $template) {
!in_array($template->getExtKey(), $extensionKeys) ? $extensionKeys[] = $template->getExtKey() : NULL;
}
public function showAction() {
print_r($_REQUEST);
return $extensionKeys;
$this->view->assign('extensions', array_keys(MailTemplateService::$registerArray));
$this->view->assign('templates', array_keys(MailTemplateService::$registerArray));
}
}
......@@ -26,6 +26,7 @@ namespace SGalinski\SgMail\Domain\Repository;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\Repository;
......@@ -47,4 +48,17 @@ class RegisteredTemplateRepository extends Repository {
$this->setDefaultQuerySettings($querySettings);
}
/**
* @param $registeredTemplate
*/
public static function addTemplate($extensionKey, $template) {
/** @var $databaseConnection DatabaseConnection */
$databaseConnection = $GLOBALS['TYPO3_DB'];
$fieldsValues = [
'ext_key' => $extensionKey, 'template' => $template, 'mail_key' => uniqid()
];
$databaseConnection->exec_INSERTquery($table, $fieldsValues);
}
}
......@@ -26,20 +26,12 @@ namespace SGalinski\SgMail\Service;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* MailTemplateService
*/
class MailTemplateService {
/**
* TemplateRepository
*
* @var \SGalinski\SgMail\Domain\Repository\RegisteredTemplateRepository
* @inject
*/
protected static $registeredTemplateRepository;
public static $registerArray = [];
/**
* @param $extensionKey
......@@ -47,15 +39,10 @@ class MailTemplateService {
* @return string
*/
public static function registerTemplate($extensionKey, $template) {
$registeredTemplate = new RegisteredTemplate();
$registeredTemplate->setExtKey($extensionKey);
$registeredTemplate->setTemplate($template);
$mailKey = uniqid();
$registeredTemplate->setMailKey($mailKey);
MailTemplateService::$registeredTemplateRepository->add($registeredTemplate);
return $mailKey;
if (!array_key_exists($extensionKey, MailTemplateService::$registerArray)) {
MailTemplateService::$registerArray[$extensionKey] = [$template];
} elseif (!in_array(MailTemplateService::$registerArray[$extensionKey], $template)) {
MailTemplateService::$registerArray[$extensionKey][] = $template;
}
}
}
......@@ -4,13 +4,13 @@
<div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation">
<div class="module-docheader-bar-column-left">
<div class="btn-toolbar" role="toolbar">
<f:for each="{extensions}" as="extension">
<f:be.menus.actionMenu>
<f:be.menus.actionMenu>
<f:for each="{extensions}" as="extension">
<f:be.menus.actionMenuItem label="{extension}"
controller="Mail"
action="index" />
</f:be.menus.actionMenu>
</f:for>
action="show" />
</f:for>
</f:be.menus.actionMenu>
</div>
</div>
<div class="module-docheader-bar-column-right">
......
<f:layout name="Default" />
<f:section name="iconButtons">
&nbsp;
</f:section>
<f:section name="main">
<f:flashMessages renderMode="div" />
<f:for each="{templates}" as="template">
<h3>{template}</h3>
</f:for>
</f:section>
......@@ -4,17 +4,13 @@ if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages(
'tx_sgmail_domain_model_registeredtemplate'
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'SGalinski.sg_mail',
'web',
'Mail',
'',
[
'Mail' => 'index',
'Mail' => 'index', 'show',
],
[
'access' => 'admin,user,group',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment