Skip to content
Snippets Groups Projects
Commit 836af9dc authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] WIP new registering

parent 21de9c5b
No related branches found
No related tags found
1 merge request!11Feature security update
<?php
namespace SGalinski\SgMail\Service;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* 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 TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class RegisterService
*
* @package SGalinski\SgMail\Service
*/
class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
const CACHE_NAME = 'sg_mail_registerArrayCache';
const CACHE_LIFETIME_IN_SECONDS = 86400;
/**
* @var array
*/
public $registerArray = [];
/**
* @var array
*/
private $registrationFiles = [];
/**
* Enables extensions to add their registration files
*
* @param string $pathToRegisterFile
*/
public function register($pathToRegisterFile) {
if (file_exists($pathToRegisterFile)) {
$this->registerArray[] = [
'path' => $pathToRegisterFile
];
}
}
/**
* Get all registered templates from the cache
*
* @return array
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \BadFunctionCallException
* @throws \InvalidArgumentException
*/
public function getRegisterArray(): array {
/** @var CacheManager $cacheManager */
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
/** @var FrontendInterface $cache */
$cache = $cacheManager->getCache(self::CACHE_NAME);
$cacheId = md5('sg_mail');
/** @var array entry */
if (($entry = $cache->get($cacheId)) === FALSE) {
$entry = $this->registerExtensions();
if ($entry === NULL) {
$entry = [];
}
$cache->set($cacheId, $entry, [], self::CACHE_LIFETIME_IN_SECONDS);
}
return $entry;
}
/**
*
*/
private function registerExtensions() {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment