first commit
This commit is contained in:
commit
e81864e683
2984 files changed
+267797
No files matched your search
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service\AutoAdminConfirmation;
|
||||
|
||||
use In2code\Femanager\Domain\Model\User;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Class AbstractConfirmation
|
||||
*/
|
||||
abstract class AbstractConfirmation implements ConfirmationInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
|
||||
/**
|
||||
* @var ContentObjectRenderer
|
||||
*/
|
||||
protected $contentObject;
|
||||
|
||||
/**
|
||||
* AbstractConfirmation constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param User $user
|
||||
* @param array $settings
|
||||
* @param ContentObjectRenderer $contentObject
|
||||
*/
|
||||
public function __construct(array $config, User $user, array $settings, ContentObjectRenderer $contentObject)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
$this->contentObject = $contentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip manual confirmation from admin?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutoConfirmed(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig(): array
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSettings(): array
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContentObjectRenderer
|
||||
*/
|
||||
public function getContentObject(): ContentObjectRenderer
|
||||
{
|
||||
return $this->contentObject;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service\AutoAdminConfirmation;
|
||||
|
||||
/**
|
||||
* Interface ConfirmationInterface
|
||||
*/
|
||||
interface ConfirmationInterface
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutoConfirmed(): bool;
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service\AutoAdminConfirmation;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Class EmailDomainConfirmation
|
||||
*/
|
||||
class EmailDomainConfirmation extends AbstractConfirmation
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutoConfirmed(): bool
|
||||
{
|
||||
if (!$this->isException() && $this->isGivenDomainsPartOfEmail()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isGivenDomainsPartOfEmail(): bool
|
||||
{
|
||||
$domains = GeneralUtility::trimExplode(',', $this->getConfig()['confirmByEmailDomains'], true);
|
||||
foreach ($domains as $domain) {
|
||||
if (stristr($this->getEmailDomain(), $domain)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function isException(): bool
|
||||
{
|
||||
$exceptionDomains =
|
||||
GeneralUtility::trimExplode(',', $this->getConfig()['confirmByEmailDomainsExceptions'], true);
|
||||
return in_array($this->getEmailDomain(), $exceptionDomains);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get domain of an email address: "alex@in2code.de" => "in2code.de"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEmailDomain(): string
|
||||
{
|
||||
$email = $this->getUser()->getEmail();
|
||||
$parts = explode('@', $email);
|
||||
return $parts[1];
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use In2code\Femanager\Domain\Model\User;
|
||||
use In2code\Femanager\Domain\Service\AutoAdminConfirmation\ConfirmationInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Class AutoAdminConfirmationService
|
||||
*/
|
||||
class AutoAdminConfirmationService
|
||||
{
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
|
||||
/**
|
||||
* @var ContentObjectRenderer
|
||||
*/
|
||||
protected $contentObject;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $confirmInterface = ConfirmationInterface::class;
|
||||
|
||||
/**
|
||||
* AutoAdminConfirmationService constructor.
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $settings
|
||||
* @param ContentObjectRenderer $contentObject
|
||||
*/
|
||||
public function __construct(User $user, array $settings, ContentObjectRenderer $contentObject)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->settings = $settings;
|
||||
$this->contentObject = $contentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop through all AutoAdminConfirmation classes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutoAdminConfirmationFullfilled(): bool
|
||||
{
|
||||
$autoConfirmation = false;
|
||||
foreach ($this->getConfirmationClasses() as $classConfiguration) {
|
||||
/** @var ConfirmationInterface $confirmation */
|
||||
$confirmation = GeneralUtility::makeInstance(
|
||||
$classConfiguration['class'],
|
||||
$classConfiguration['config'],
|
||||
$this->user,
|
||||
$this->settings,
|
||||
$this->contentObject
|
||||
);
|
||||
if ($confirmation->isAutoConfirmed() === true) {
|
||||
$autoConfirmation = true;
|
||||
}
|
||||
}
|
||||
return $autoConfirmation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getConfirmationClasses(): array
|
||||
{
|
||||
$classes = [];
|
||||
if (!empty($this->settings['autoAdminConfirmation'])) {
|
||||
foreach ($this->settings['autoAdminConfirmation'] as $configuration) {
|
||||
$className = $configuration['class'];
|
||||
if (!class_exists($className)) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Class ' . $className . ' does not exists - check if file was loaded with autoloader',
|
||||
1516373867533
|
||||
);
|
||||
}
|
||||
if (!is_subclass_of($className, $this->confirmInterface)) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Class ' . $className . ' does not implement interface ' . $this->confirmInterface,
|
||||
1516373878882
|
||||
);
|
||||
}
|
||||
$classes[] = $configuration;
|
||||
}
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use In2code\Femanager\Utility\ConfigurationUtility;
|
||||
use TYPO3\CMS\Core\Resource\ResourceFactory;
|
||||
use TYPO3\CMS\Core\Resource\Security\FileNameValidator;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\PathUtility;
|
||||
|
||||
/**
|
||||
* Class FileService
|
||||
*/
|
||||
class FileService
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fileName = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fileArray = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fallbackExtensions = 'jpg,jpeg,png,gif,bmp,tif,tiff';
|
||||
|
||||
/**
|
||||
* FileService constructor.
|
||||
*
|
||||
* @param string $filename Filename like (upload.png)
|
||||
* @param array $fileArray From PHP with tmp_name, etc...
|
||||
*/
|
||||
public function __construct(string $filename, array $fileArray)
|
||||
{
|
||||
$this->fileName = $filename;
|
||||
$this->fileArray = $fileArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @todo add filesize check
|
||||
*/
|
||||
public function isEverythingValid(): bool
|
||||
{
|
||||
return $this->validFileExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check extension of given filename
|
||||
*
|
||||
* @return bool If Extension is allowed
|
||||
*/
|
||||
protected function validFileExtension(): bool
|
||||
{
|
||||
$extensionList = ConfigurationUtility::getConfiguration('misc.uploadFileExtension');
|
||||
if (!empty($extensionList)) {
|
||||
$extensionList = str_replace(' ', '', $extensionList);
|
||||
} else {
|
||||
$extensionList = $this->fallbackExtensions;
|
||||
}
|
||||
$fileInfo = pathinfo($this->fileName);
|
||||
|
||||
return !empty($fileInfo['extension']) &&
|
||||
GeneralUtility::inList($extensionList, strtolower($fileInfo['extension'])) &&
|
||||
GeneralUtility::makeInstance(FileNameValidator::class)->isValid($this->fileName) &&
|
||||
GeneralUtility::validPathStr($this->fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create sys_file entry for given filename and return uid
|
||||
*
|
||||
* @param string $file absolute path and filename
|
||||
* @return int
|
||||
*/
|
||||
public function indexFile(string $file): int
|
||||
{
|
||||
$fileIdentifier = 0;
|
||||
if (file_exists($file)) {
|
||||
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
|
||||
$file = $resourceFactory->getFileObjectFromCombinedIdentifier($this->getCombinedIdentifier($file));
|
||||
$fileIdentifier = (int)$file->getProperty('uid');
|
||||
}
|
||||
return $fileIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* build combined identifier from absolute filename:
|
||||
* "/var/www/fileadmin/folder/test.pdf" => "1:folder/test.pdf"
|
||||
*
|
||||
* @param string $file relative path and filename
|
||||
* @return string
|
||||
*/
|
||||
protected function getCombinedIdentifier(string $file): string
|
||||
{
|
||||
// @Todo Make it a bit less ugly
|
||||
$file = PathUtility::getRelativePathTo($file);
|
||||
$identifier = $this->substituteFileadminFromPathAndName($file);
|
||||
return '1:' . $identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* "fileadmin/downloads/test.pdf" => "/downloads/test.pdf"
|
||||
*
|
||||
* @param string $pathAndName
|
||||
* @return string
|
||||
*/
|
||||
protected function substituteFileadminFromPathAndName(string $pathAndName): string
|
||||
{
|
||||
$substituteString = 'fileadmin/';
|
||||
if (substr($pathAndName, 0, strlen($substituteString)) === $substituteString) {
|
||||
$pathAndName = str_replace($substituteString, '', $pathAndName);
|
||||
}
|
||||
if (substr($pathAndName, 0, 1) !== '/') {
|
||||
$pathAndName = '/' . $pathAndName;
|
||||
}
|
||||
return $pathAndName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use In2code\Femanager\Domain\Model\User;
|
||||
use In2code\Femanager\Finisher\AbstractFinisher;
|
||||
use In2code\Femanager\Utility\StringUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Class FinisherService
|
||||
*/
|
||||
class FinisherService
|
||||
{
|
||||
/**
|
||||
* @var ContentObjectRenderer
|
||||
*/
|
||||
protected $contentObject;
|
||||
|
||||
/**
|
||||
* Classname
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $class = '';
|
||||
|
||||
/**
|
||||
* Path that should be required
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $requirePath;
|
||||
|
||||
/**
|
||||
* Finisher Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $configuration = [];
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* Controller actionName - usually "createAction" or "confirmationAction"
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
protected $actionMethodName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $finisherInterface = 'In2code\Femanager\Finisher\FinisherInterface';
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
public function injectObjectManager(ObjectManagerInterface $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @return FinisherService
|
||||
*/
|
||||
public function setClass($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRequirePath()
|
||||
{
|
||||
return $this->requirePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set require path and do a require_once
|
||||
*
|
||||
* @param string|null $requirePath
|
||||
* @return FinisherService
|
||||
*/
|
||||
public function setRequirePath($requirePath)
|
||||
{
|
||||
$this->requirePath = $requirePath;
|
||||
if ($this->getRequirePath() && file_exists($this->getRequirePath())) {
|
||||
require_once($this->getRequirePath());
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfiguration()
|
||||
{
|
||||
return $this->configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $configuration
|
||||
* @return FinisherService
|
||||
*/
|
||||
public function setConfiguration($configuration)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return FinisherService
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $settings
|
||||
* @return FinisherService
|
||||
*/
|
||||
public function setSettings($settings)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActionMethodName()
|
||||
{
|
||||
return $this->actionMethodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $actionMethodName
|
||||
* @return FinisherService
|
||||
*/
|
||||
public function setActionMethodName($actionMethodName)
|
||||
{
|
||||
$this->actionMethodName = $actionMethodName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start implementation
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
if (!class_exists($this->getClass())) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Class ' . $this->getClass() . ' does not exists - check if file was loaded with autoloader',
|
||||
1516373888508
|
||||
);
|
||||
}
|
||||
if (is_subclass_of($this->getClass(), $this->finisherInterface)) {
|
||||
/** @var AbstractFinisher $finisher */
|
||||
$finisher = $this->objectManager->get(
|
||||
$this->getClass(),
|
||||
$this->getUser(),
|
||||
$this->getConfiguration(),
|
||||
$this->getSettings(),
|
||||
$this->getActionMethodName(),
|
||||
$this->contentObject
|
||||
);
|
||||
$finisher->initializeFinisher();
|
||||
$this->callFinisherMethods($finisher);
|
||||
} else {
|
||||
throw new \UnexpectedValueException(
|
||||
'Finisher does not implement ' . $this->finisherInterface,
|
||||
1516373899775
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call methods in finisher class
|
||||
*
|
||||
* @param AbstractFinisher $finisher
|
||||
*/
|
||||
protected function callFinisherMethods(AbstractFinisher $finisher)
|
||||
{
|
||||
foreach (get_class_methods($finisher) as $method) {
|
||||
if (!StringUtility::endsWith($method, 'Finisher') || strpos($method, 'initialize') === 0) {
|
||||
continue;
|
||||
}
|
||||
$this->callInitializeFinisherMethod($finisher, $method);
|
||||
$finisher->{$method}();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call initializeFinisherMethods like "initializeSaveFinisher()"
|
||||
*
|
||||
* @param AbstractFinisher $finisher
|
||||
* @param string $finisherMethod
|
||||
*/
|
||||
protected function callInitializeFinisherMethod(AbstractFinisher $finisher, $finisherMethod)
|
||||
{
|
||||
if (method_exists($finisher, 'initialize' . ucfirst($finisherMethod))) {
|
||||
$finisher->{'initialize' . ucfirst($finisherMethod)}();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param array $settings
|
||||
* @param ContentObjectRenderer $contentObject
|
||||
*/
|
||||
public function __construct(User $user, array $settings, ContentObjectRenderer $contentObject)
|
||||
{
|
||||
$this->setUser($user);
|
||||
$this->setSettings($settings);
|
||||
$this->contentObject = $contentObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use TYPO3\CMS\Core\Cache\CacheManager;
|
||||
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
|
||||
use TYPO3\CMS\Core\Context\Context;
|
||||
use TYPO3\CMS\Core\Crypto\Random;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||
|
||||
class RatelimiterService implements SingletonInterface
|
||||
{
|
||||
const CACHE_IDENTIFIER = 'femanager_ratelimiter';
|
||||
const DEFAULT_CONFIG = ['timeframe' => 60, 'limit' => 3];
|
||||
const LIMIT_IP = 'limit_ip_';
|
||||
const SESSION_KEY = 'tx_femanager_ratelimiter';
|
||||
|
||||
/** @var FrontendInterface */
|
||||
protected $cache;
|
||||
|
||||
/** @var int */
|
||||
protected $limit;
|
||||
|
||||
/** @var int */
|
||||
protected $timeframe;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache = GeneralUtility::makeInstance(CacheManager::class)->getCache(self::CACHE_IDENTIFIER);
|
||||
$setup = $this->getTSFE()->tmpl->setup;
|
||||
$config = $setup['plugin.']['tx_femanager.']['settings.']['ratelimiter.'] ?? self::DEFAULT_CONFIG;
|
||||
$this->timeframe = (int)$config['timeframe'];
|
||||
$this->limit = (int)$config['limit'];
|
||||
}
|
||||
|
||||
protected function getTSFE(): TypoScriptFrontendController
|
||||
{
|
||||
return $GLOBALS['TSFE'];
|
||||
}
|
||||
|
||||
public function isLimited(): bool
|
||||
{
|
||||
if ($this->limit > 0) {
|
||||
$userIp = GeneralUtility::getIndpEnv('REMOTE_ADDR');
|
||||
$userIpAccess = $this->getToken(self::LIMIT_IP, $userIp);
|
||||
|
||||
return count($userIpAccess) >= $this->limit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function consumeSlot()
|
||||
{
|
||||
if ($this->limit > 0) {
|
||||
$userIp = GeneralUtility::getIndpEnv('REMOTE_ADDR');
|
||||
$this->consumeToken(self::LIMIT_IP, $userIp);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCookie()
|
||||
{
|
||||
$this->touchCookie();
|
||||
|
||||
return $this->getTSFE()->fe_user->getSessionData(self::SESSION_KEY);
|
||||
}
|
||||
|
||||
public function touchCookie()
|
||||
{
|
||||
$feUser = $this->getTSFE()->fe_user;
|
||||
$identifier = $feUser->getSessionData(self::SESSION_KEY);
|
||||
|
||||
if (null === $identifier) {
|
||||
$unique = GeneralUtility::makeInstance(Random::class)->generateRandomHexString(16);
|
||||
$feUser->setAndSaveSessionData(self::SESSION_KEY, $unique);
|
||||
}
|
||||
}
|
||||
|
||||
protected function consumeToken(string $tokenName, string $value): array
|
||||
{
|
||||
$cacheID = $this->getCacheID($tokenName, $value);
|
||||
|
||||
$token = $this->retrieveToken($cacheID);
|
||||
$token[] = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp');
|
||||
$this->cache->set($cacheID, $token, [], $this->timeframe);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
protected function getCacheID(string $tokenName, string $value): string
|
||||
{
|
||||
return $tokenName . hash('sha1', $value);
|
||||
}
|
||||
|
||||
protected function retrieveToken(string $cacheID): array
|
||||
{
|
||||
$token = [];
|
||||
if ($this->cache->has($cacheID)) {
|
||||
$token = $this->cache->get($cacheID);
|
||||
$token = $this->filterExpiredToken($token);
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
protected function filterExpiredToken(array $token): array
|
||||
{
|
||||
$slidingWindowStartTime = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp') - $this->timeframe;
|
||||
foreach ($token as $idx => $accessTime) {
|
||||
if ($accessTime < $slidingWindowStartTime) {
|
||||
unset($token[$idx]);
|
||||
}
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
protected function getToken(string $tokenName, string $value): array
|
||||
{
|
||||
$cacheID = $this->getCacheID($tokenName, $value);
|
||||
|
||||
return $this->retrieveToken($cacheID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use In2code\Femanager\Event\AfterMailSendEvent;
|
||||
use In2code\Femanager\Event\BeforeMailBodyRenderEvent;
|
||||
use In2code\Femanager\Event\BeforeMailSendEvent;
|
||||
use In2code\Femanager\Utility\ConfigurationUtility;
|
||||
use In2code\Femanager\Utility\ObjectUtility;
|
||||
use In2code\Femanager\Utility\TemplateUtility;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Mime\Part\DataPart;
|
||||
use TYPO3\CMS\Core\Mail\Mailer;
|
||||
use TYPO3\CMS\Core\Mail\MailMessage;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Class SendMailService
|
||||
*/
|
||||
class SendMailService
|
||||
{
|
||||
/**
|
||||
* Content Object
|
||||
*
|
||||
* @var object|null
|
||||
*/
|
||||
public ?object $contentObject = null;
|
||||
|
||||
/**
|
||||
* @var Mailer|null
|
||||
*/
|
||||
private ?Mailer $mailer = null;
|
||||
/**
|
||||
* @var EventDispatcherInterface|null
|
||||
*/
|
||||
private ?EventDispatcherInterface $dispatcher = null;
|
||||
|
||||
/**
|
||||
* SendMailService constructor.
|
||||
*/
|
||||
public function __construct(Mailer $mailer, EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$this->contentObject = ObjectUtility::getContentObject();
|
||||
$this->mailer = $mailer;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $variables
|
||||
*/
|
||||
protected function contentObjectStart(array $variables): void
|
||||
{
|
||||
if (
|
||||
empty($variables['user'] ?? []) === false &&
|
||||
method_exists(($variables['user'] ?? null), '_getProperties') === true
|
||||
) {
|
||||
$this->contentObject->start($variables['user']->_getProperties());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and send Email
|
||||
*
|
||||
* @param string $template Template file in Templates/Email/
|
||||
* @param array $receiver Combination of Email => Name
|
||||
* @param array $sender Combination of Email => Name
|
||||
* @param string $subject Mail subject
|
||||
* @param array $variables Variables for assignMultiple
|
||||
* @param array $typoScript Add TypoScript to overwrite values
|
||||
* @return bool mail was sent?
|
||||
*/
|
||||
public function send(
|
||||
string $template,
|
||||
array $receiver,
|
||||
array $sender,
|
||||
string $subject,
|
||||
array $variables = [],
|
||||
array $typoScript = []
|
||||
): bool {
|
||||
if (false === $this->isMailEnabled($typoScript, $receiver)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->contentObjectStart($variables);
|
||||
$email = GeneralUtility::makeInstance(MailMessage::class);
|
||||
$variables = $this->embedImages($variables, $typoScript, $email);
|
||||
$this->prepareMailObject($template, $receiver, $sender, $subject, $variables, $email);
|
||||
$this->overwriteEmailReceiver($typoScript, $email);
|
||||
$this->overwriteEmailSender($typoScript, $email);
|
||||
$this->setSubject($typoScript, $email);
|
||||
$this->setCc($typoScript, $email);
|
||||
$this->setPriority($typoScript, $email);
|
||||
$this->setAttachments($typoScript, $email);
|
||||
|
||||
$this->dispatcher->dispatch(new BeforeMailSendEvent($email, $variables, $this));
|
||||
$email->send();
|
||||
$this->dispatcher->dispatch(new AfterMailSendEvent($email, $variables, $this));
|
||||
|
||||
return $email->isSent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Email Body
|
||||
*
|
||||
* @param string $template Template file in Templates/Email/
|
||||
* @param array $variables Variables for assignMultiple
|
||||
* @return string
|
||||
*/
|
||||
protected function getMailBody(string $template, array $variables): string
|
||||
{
|
||||
$standAloneView = TemplateUtility::getDefaultStandAloneView();
|
||||
$standAloneView->setTemplatePathAndFilename($this->getRelativeEmailPathAndFilename($template));
|
||||
$standAloneView->assignMultiple($variables);
|
||||
$this->dispatcher->dispatch(new BeforeMailBodyRenderEvent($standAloneView, $variables, $this));
|
||||
return $standAloneView->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $variables
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
* @return array
|
||||
*/
|
||||
protected function embedImages(array $variables, array $typoScript, MailMessage $email): array
|
||||
{
|
||||
$images = $this->contentObject->cObjGetSingle(
|
||||
$typoScript['embedImage'] ?? 'TEXT',
|
||||
$typoScript['embedImage.'] ?? []
|
||||
);
|
||||
|
||||
if (!$images) {
|
||||
return $variables;
|
||||
}
|
||||
|
||||
$images = GeneralUtility::trimExplode(',', $images, true);
|
||||
$imageVariables = [];
|
||||
|
||||
foreach ($images as $path) {
|
||||
$name = basename($path);
|
||||
$imagePart = DataPart::fromPath($path);
|
||||
$contentType = $imagePart->getMediaType() . '/' . $imagePart->getMediaSubtype();
|
||||
$email->embedFromPath($path, $name, $contentType);
|
||||
$imageVariables[] = 'cid:' . $name;
|
||||
}
|
||||
|
||||
return array_merge($variables, ['embedImages' => $imageVariables]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $template
|
||||
* @param array $receiver
|
||||
* @param array $sender
|
||||
* @param string $subject
|
||||
* @param array $variables
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function prepareMailObject(
|
||||
string $template,
|
||||
array $receiver,
|
||||
array $sender,
|
||||
string $subject,
|
||||
array $variables,
|
||||
MailMessage $email
|
||||
): void {
|
||||
$html = $this->getMailBody($template, $variables);
|
||||
$email->setTo($receiver)
|
||||
->setFrom($sender)
|
||||
->setSubject($subject)
|
||||
->html($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function overwriteEmailReceiver(array $typoScript, MailMessage $email): void
|
||||
{
|
||||
$emailAddress = $this->contentObject->cObjGetSingle(
|
||||
(string)ConfigurationUtility::getValue('receiver./email', $typoScript),
|
||||
(array)ConfigurationUtility::getValue('receiver./email.', $typoScript)
|
||||
);
|
||||
$name = $this->contentObject->cObjGetSingle(
|
||||
(string)ConfigurationUtility::getValue('receiver./name', $typoScript),
|
||||
(array)ConfigurationUtility::getValue('receiver./name.', $typoScript)
|
||||
);
|
||||
if ($emailAddress && $name) {
|
||||
$email->setTo([$emailAddress => $name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function overwriteEmailSender(array $typoScript, MailMessage $email): void
|
||||
{
|
||||
$emailAddress = $this->contentObject->cObjGetSingle(
|
||||
(string)ConfigurationUtility::getValue('sender./email', $typoScript),
|
||||
(array)ConfigurationUtility::getValue('sender./email.', $typoScript)
|
||||
);
|
||||
$name = $this->contentObject->cObjGetSingle(
|
||||
(string)ConfigurationUtility::getValue('sender./name', $typoScript),
|
||||
(array)ConfigurationUtility::getValue('sender./name.', $typoScript)
|
||||
);
|
||||
|
||||
if ($emailAddress && $name) {
|
||||
$email->setFrom([$emailAddress => $name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function setSubject(array $typoScript, MailMessage $email): void
|
||||
{
|
||||
if ($this->contentObject->cObjGetSingle((string)$typoScript['subject'], (array)$typoScript['subject.'])) {
|
||||
$email->setSubject($this->contentObject->cObjGetSingle((string)$typoScript['subject'], (array)$typoScript['subject.']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function setCc(array $typoScript, MailMessage $email): void
|
||||
{
|
||||
if ($this->contentObject->cObjGetSingle((string)$typoScript['cc'], (array)$typoScript['cc.'])) {
|
||||
$email->setCc($this->contentObject->cObjGetSingle((string)$typoScript['cc'], (array)$typoScript['cc.']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function setPriority(array $typoScript, MailMessage $email): void
|
||||
{
|
||||
$priority = (int)$this->contentObject->cObjGetSingle(
|
||||
(string)ConfigurationUtility::getValue('priority', $typoScript),
|
||||
(array)ConfigurationUtility::getValue('priority.', $typoScript)
|
||||
);
|
||||
if ($priority) {
|
||||
$email->priority($priority);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param MailMessage $email
|
||||
*/
|
||||
protected function setAttachments(array $typoScript, MailMessage $email): void
|
||||
{
|
||||
if ($this->contentObject->cObjGetSingle($typoScript['attachments'] ?? '', $typoScript['attachments.'] ?? [])) {
|
||||
$files = GeneralUtility::trimExplode(
|
||||
',',
|
||||
$this->contentObject->cObjGetSingle(
|
||||
$typoScript['attachments'] ?? '',
|
||||
$typoScript['attachments.'] ?? []
|
||||
),
|
||||
true
|
||||
);
|
||||
foreach ($files as $file) {
|
||||
$email->attachFromPath($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path and filename for mail template
|
||||
*
|
||||
* @param string $fileName
|
||||
* @return string
|
||||
*/
|
||||
protected function getRelativeEmailPathAndFilename(string $fileName): string
|
||||
{
|
||||
return TemplateUtility::getTemplatePath('Email/' . ucfirst($fileName) . '.html');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $typoScript
|
||||
* @param array $receiver
|
||||
* @return bool
|
||||
*/
|
||||
protected function isMailEnabled(array $typoScript, array $receiver): bool
|
||||
{
|
||||
$cObjectName = (string)ConfigurationUtility::getValue('_enable', $typoScript);
|
||||
$cObjectConf = (array)ConfigurationUtility::getValue('_enable.', $typoScript);
|
||||
|
||||
return $this->contentObject->cObjGetSingle($cObjectName, $cObjectConf) && count($receiver) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use In2code\Femanager\Domain\Model\User;
|
||||
use TYPO3\CMS\Core\Log\LogLevel;
|
||||
use TYPO3\CMS\Core\Log\LogManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Class SendParametersService
|
||||
*/
|
||||
class SendParametersService
|
||||
{
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
|
||||
/**
|
||||
* @var ContentObjectRenderer
|
||||
*/
|
||||
protected $contentObject;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $configuration = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($configuration)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $configurationManager
|
||||
*/
|
||||
public function injectConfigurationManagerInterface(ConfigurationManagerInterface $configurationManager)
|
||||
{
|
||||
$this->configurationManager = $configurationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* SendPost - Send values via curl to target
|
||||
*
|
||||
* @param User $user User properties
|
||||
*/
|
||||
public function send(User $user)
|
||||
{
|
||||
$this->initialize($user);
|
||||
$this->contentObject->start($this->properties);
|
||||
if ($this->isTurnedOn()) {
|
||||
$curlObject = curl_init();
|
||||
curl_setopt($curlObject, CURLOPT_URL, $this->getUri());
|
||||
curl_setopt($curlObject, CURLOPT_POST, 1);
|
||||
curl_setopt($curlObject, CURLOPT_POSTFIELDS, $this->getData());
|
||||
curl_setopt($curlObject, CURLOPT_RETURNTRANSFER, true);
|
||||
if ($GLOBALS['FE']['debug'] === 1) {
|
||||
curl_setopt($curlObject, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curlObject, CURLOPT_SSL_VERIFYPEER, false);
|
||||
}
|
||||
curl_exec($curlObject);
|
||||
curl_close($curlObject);
|
||||
$this->log();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URI for curl request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUri()
|
||||
{
|
||||
return $this->configuration['targetUrl'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data array
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getData()
|
||||
{
|
||||
return $this->contentObject->cObjGetSingle((string)$this->configuration['data'], (array)$this->configuration['data.']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to devlog
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function log()
|
||||
{
|
||||
if (!empty($this->configuration['debug'])) {
|
||||
GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)->log(LogLevel::INFO, 'femanager sendpost values', [
|
||||
'url' => $this->getUri(),
|
||||
'data' => $this->getData(),
|
||||
'properties' => $this->properties
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isTurnedOn()
|
||||
{
|
||||
return $this->contentObject->cObjGetSingle((string)$this->configuration['_enable'], (array)$this->configuration['_enable.'])
|
||||
=== '1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
protected function initialize(User $user)
|
||||
{
|
||||
$this->properties = $user->_getCleanProperties();
|
||||
$this->contentObject = $this->configurationManager->getContentObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Class StoreInDatabaseService
|
||||
*/
|
||||
class StoreInDatabaseService
|
||||
{
|
||||
/**
|
||||
* Database Table to store
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = '';
|
||||
|
||||
/**
|
||||
* Array with fieldname=>value
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = [];
|
||||
|
||||
/**
|
||||
* @var \TYPO3\CMS\CORE\Database\ConnectionPool
|
||||
*/
|
||||
protected $databaseConnection;
|
||||
|
||||
/**
|
||||
* Executes the storage
|
||||
*
|
||||
* @return int uid of inserted record
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$insertTable = $this->databaseConnection->getConnectionForTable($this->getTable());
|
||||
$insertTable->insert(
|
||||
$this->getTable(),
|
||||
$this->getProperties()
|
||||
);
|
||||
|
||||
return (int)$insertTable->lastInsertId($this->getTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TableName
|
||||
*
|
||||
* @param string $table
|
||||
*/
|
||||
public function setTable($table)
|
||||
{
|
||||
$table = preg_replace('/[^a-zA-Z0-9_-]/', '', $table);
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TableName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add property/value pair to array
|
||||
*
|
||||
* @param $propertyName
|
||||
* @param $value
|
||||
*/
|
||||
public function addProperty($propertyName, $value)
|
||||
{
|
||||
$propertyName = preg_replace('/[^a-zA-Z0-9_-]/', '', $propertyName);
|
||||
$this->properties[$propertyName] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove property/value pair form array by its key
|
||||
*
|
||||
* @param $propertyName
|
||||
*/
|
||||
public function removeProperty($propertyName)
|
||||
{
|
||||
unset($this->properties[$propertyName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->databaseConnection = GeneralUtility::makeInstance(ConnectionPool::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Domain\Service;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
|
||||
/**
|
||||
* Class ValidationSettingsService
|
||||
*/
|
||||
class ValidationSettingsService
|
||||
{
|
||||
/**
|
||||
* Needed for validation settings. Should be "new", "edit" or "invitation"
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $controllerName = '';
|
||||
|
||||
/**
|
||||
* Needed for validation settings. Should be "validation" or "validationEdit"
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $validationName = '';
|
||||
|
||||
/**
|
||||
* Validation names with simple configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $simpleValidations = [
|
||||
'date',
|
||||
'email',
|
||||
'intOnly',
|
||||
'lettersOnly',
|
||||
'unicodeLettersOnly',
|
||||
'required',
|
||||
'uniqueInDb',
|
||||
'uniqueInPage'
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $controllerName
|
||||
* @param string $validationName
|
||||
*/
|
||||
public function __construct(string $controllerName, string $validationName)
|
||||
{
|
||||
$this->controllerName = $controllerName;
|
||||
$this->validationName = $validationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get validation string like
|
||||
* required, email, min(10), max(10), intOnly,
|
||||
* lettersOnly, unicodeLettersOnly, uniqueInPage, uniqueInDb, date,
|
||||
* mustInclude(number|letter|special), inList(1|2|3)
|
||||
*
|
||||
* @param string $fieldName Fieldname
|
||||
* @return string
|
||||
*/
|
||||
public function getValidationStringForField(string $fieldName): string
|
||||
{
|
||||
$string = '';
|
||||
$validationSettings = $this->getSettings()[$this->controllerName][$this->validationName][$fieldName] ?? [];
|
||||
|
||||
if (is_array($validationSettings)) {
|
||||
foreach ($validationSettings as $validation => $configuration) {
|
||||
if ($string !== '') {
|
||||
$string .= ',';
|
||||
}
|
||||
$string .= $this->getSingleValidationString($validation, $configuration);
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidationEnabled(string $type = 'client'): bool
|
||||
{
|
||||
$validationSetting = $this->getSettings()[$this->controllerName]['validation']['_enable'][$type] ?? '0';
|
||||
return $validationSetting === '1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $validation
|
||||
* @param string $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function getSingleValidationString($validation, $configuration)
|
||||
{
|
||||
$string = '';
|
||||
if ($this->isSimpleValidation($validation) && $configuration === '1') {
|
||||
$string = $validation;
|
||||
}
|
||||
if (!$this->isSimpleValidation($validation)) {
|
||||
$string = $validation;
|
||||
$string .= '(' . str_replace(',', '|', $configuration) . ')';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if validation is simple or extended
|
||||
*
|
||||
* @param string $validation
|
||||
* @return bool
|
||||
*/
|
||||
protected function isSimpleValidation($validation): bool
|
||||
{
|
||||
if (in_array($validation, $this->simpleValidations)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getSettings(): array
|
||||
{
|
||||
$configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
|
||||
return (array)$configurationManager->getConfiguration(
|
||||
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
|
||||
'femanager',
|
||||
'femanager_pi1'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user