Skip to content

Commit

Permalink
Merge pull request #41 from thucke/renSetup
Browse files Browse the repository at this point in the history
v1.7.1 changes
  • Loading branch information
thucke committed Feb 7, 2019
2 parents 8edd33c + 9cb0ec2 commit ceacf54
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 194 deletions.
94 changes: 94 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# CSS-Files
[*.css]
indent_style = tab
indent_size = 4

# HTML-Files
[*.html]
indent_style = tab
indent_size = 2

# TMPL-Files
[*.tmpl]
indent_style = tab
indent_size = 4

# SCSS-Files
[*.scss]
indent_style = space
indent_size = 4

# TS/JS-Files
[*.ts]
indent_style = space
indent_size = 2
[*.js]
indent_style = space
indent_size = 2

# JSON-Files
[*.json]
indent_style = tab
indent_size = 4

# PHP-Files
[*.php]
indent_style = space
indent_size = 4

# ReST-Files
[*.rst]
indent_style = space
indent_size = 3

# MD-Files
[*.md]
indent_style = space
indent_size = 4

# YAML-Files
[{*.yaml,*.yml}]
indent_style = space
indent_size = 2

# package.json
# .travis.yml
# bower.json
[{package.json,.travis.yml,bower.json}]
indent_style = space
indent_size = 2

# TypoScript
[*.typoscript]
indent_style = space
indent_size = 2
[*.tsconfig]
indent_style = space
indent_size = 2

# XLF-Files
[*.xlf]
indent_style = tab
indent_size = 4

# SQL-Files
[*.sql]
indent_style = tab
indent_size = 2

# .htaccess
[{_.htaccess,.htaccess}]
indent_style = tab
indent_size = 4
62 changes: 31 additions & 31 deletions Classes/Controller/VoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class VoteController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
/**
* @param \Thucke\ThRating\Service\AccessControlService $accessControllService
*/
public function injectAccessControlService(\Thucke\ThRating\Service\AccessControlService $accessControllService)
public function injectAccessControlService(\Thucke\ThRating\Service\AccessControlService $accessControllService): void
{
$this->accessControllService = $accessControllService;
}
Expand All @@ -101,7 +101,7 @@ public function injectAccessControlService(\Thucke\ThRating\Service\AccessContro
/**
* @param \Thucke\ThRating\Service\RichSnippetService $richSnippetService
*/
public function injectRichSnippetService(\Thucke\ThRating\Service\RichSnippetService $richSnippetService)
public function injectRichSnippetService(\Thucke\ThRating\Service\RichSnippetService $richSnippetService): void
{
$this->richSnippetService = $richSnippetService;
}
Expand All @@ -114,7 +114,7 @@ public function injectRichSnippetService(\Thucke\ThRating\Service\RichSnippetSer
/**
* @param \Thucke\ThRating\Service\CookieService $cookieService
*/
public function injectCookieService(\Thucke\ThRating\Service\CookieService $cookieService)
public function injectCookieService(\Thucke\ThRating\Service\CookieService $cookieService): void
{
$this->cookieService = $cookieService;
}
Expand All @@ -127,7 +127,7 @@ public function injectCookieService(\Thucke\ThRating\Service\CookieService $cook
/**
* @param \Thucke\ThRating\Domain\Repository\VoteRepository $voteRepository
*/
public function injectVoteRepository(\Thucke\ThRating\Domain\Repository\VoteRepository $voteRepository)
public function injectVoteRepository(\Thucke\ThRating\Domain\Repository\VoteRepository $voteRepository): void
{
$this->voteRepository = $voteRepository;
}
Expand All @@ -141,7 +141,7 @@ public function injectVoteRepository(\Thucke\ThRating\Domain\Repository\VoteRepo
* @param \Thucke\ThRating\Domain\Validator\VoteValidator $voteValidator
* @return void
*/
public function injectVoteValidator(\Thucke\ThRating\Domain\Validator\VoteValidator $voteValidator)
public function injectVoteValidator(\Thucke\ThRating\Domain\Validator\VoteValidator $voteValidator): void
{
$this->voteValidator = $voteValidator;
}
Expand All @@ -155,7 +155,7 @@ public function injectVoteValidator(\Thucke\ThRating\Domain\Validator\VoteValida
* @param \Thucke\ThRating\Domain\Validator\RatingValidator $ratingValidator
* @return void
*/
public function injectRatingValidator(\Thucke\ThRating\Domain\Validator\RatingValidator $ratingValidator)
public function injectRatingValidator(\Thucke\ThRating\Domain\Validator\RatingValidator $ratingValidator): void
{
$this->ratingValidator = $ratingValidator;
}
Expand All @@ -169,7 +169,7 @@ public function injectRatingValidator(\Thucke\ThRating\Domain\Validator\RatingVa
* @param \Thucke\ThRating\Domain\Repository\RatingobjectRepository $ratingobjectRepository
* @return void
*/
public function injectRatingobjectRepository(\Thucke\ThRating\Domain\Repository\RatingobjectRepository $ratingobjectRepository)
public function injectRatingobjectRepository(\Thucke\ThRating\Domain\Repository\RatingobjectRepository $ratingobjectRepository): void
{
$this->ratingobjectRepository = $ratingobjectRepository;
}
Expand All @@ -183,7 +183,7 @@ public function injectRatingobjectRepository(\Thucke\ThRating\Domain\Repository\
* @param \Thucke\ThRating\Domain\Repository\StepconfRepository $stepconfRepository
* @return void
*/
public function injectStepconfRepository(\Thucke\ThRating\Domain\Repository\StepconfRepository $stepconfRepository)
public function injectStepconfRepository(\Thucke\ThRating\Domain\Repository\StepconfRepository $stepconfRepository): void
{
$this->stepconfRepository = $stepconfRepository;
}
Expand All @@ -197,7 +197,7 @@ public function injectStepconfRepository(\Thucke\ThRating\Domain\Repository\Step
* @param \Thucke\ThRating\Domain\Validator\StepconfValidator $stepconfValidator
* @return void
*/
public function injectStepconfValidator(\Thucke\ThRating\Domain\Validator\StepconfValidator $stepconfValidator)
public function injectStepconfValidator(\Thucke\ThRating\Domain\Validator\StepconfValidator $stepconfValidator): void
{
$this->stepconfValidator = $stepconfValidator;
}
Expand All @@ -211,17 +211,18 @@ public function injectStepconfValidator(\Thucke\ThRating\Domain\Validator\Stepco
* @param \Thucke\ThRating\Service\ExtensionHelperService $extensionHelperService
* @return void
*/
public function injectExtensionHelperService(\Thucke\ThRating\Service\ExtensionHelperService $extensionHelperService)
public function injectExtensionHelperService(\Thucke\ThRating\Service\ExtensionHelperService $extensionHelperService): void
{
$this->extensionHelperService = $extensionHelperService;
}

/**
* Lifecycle-Event
* wird nach der Initialisierung des Objekts und nach dem Aufl�sen der Dependencies aufgerufen.
* wird nach der Initialisierung des Objekts und nach dem Auflösen der Dependencies aufgerufen.
*
*/
public function initializeObject() {
public function initializeObject(): void
{
}

/**
Expand All @@ -233,7 +234,7 @@ public function initializeObject() {
* @throws \Thucke\ThRating\Exception\InvalidStoragePageException
*/
/** @noinspection PhpMissingParentCallCommonInspection */
protected function initializeAction()
protected function initializeAction(): void
{
//instantiate the logger
$this->logger = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class)
Expand All @@ -248,6 +249,7 @@ protected function initializeAction()

/** @var array $frameworkConfiguration */
$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);

if ($this->request->hasArgument(self::AJAX_REFERENCE_ID)) {
//switch to JSON respone on AJAX request
$this->request->setFormat('json');
Expand Down Expand Up @@ -366,11 +368,11 @@ public function createAction(\Thucke\ThRating\Domain\Model\Vote $vote)
if (!$this->voteValidator->isObjSet($matchVote) || $this->voteValidator->validate($matchVote)->hasErrors() || $vote->isAnonymous()) {
$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'New vote could be added', ['errorCode' => 1404934012]);
$vote->getRating()->addVote($vote);
if ($vote->isAnonymous() && !$vote->hasAnonymousVote($this->prefixId) && $this->cookieProtection) {
if ($this->cookieProtection && $vote->isAnonymous() && !$vote->hasAnonymousVote($this->prefixId)) {
$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'Anonymous rating; preparing cookie potection', ['errorCode' => 1404934021]);
$anonymousRating['ratingtime'] = time();
$anonymousRating['voteUid'] = $vote->getUid();
$lifeTime = time() + 60 * 60 * 24 * $this->cookieLifetime;
$lifeTime = (new \DateTime('NOW'))->add(DateInterval::createFromDateString($this->cookieLifetime.' days'));
//set cookie to prevent multiple anonymous ratings
$this->cookieService->setVoteCookie($this->prefixId . '_AnonymousRating_' . $vote->getRating()->getUid(), json_encode($anonymousRating), $lifeTime);
}
Expand Down Expand Up @@ -466,13 +468,6 @@ public function ratinglinksAction(\Thucke\ThRating\Domain\Model\Vote $vote = NUL
$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'Entry ratinglinksAction', []);
$this->settings['ratingConfigurations']['default'] = $this->settings['defaultRatingConfiguration']['ratinglinks'];
$this->graphicActionHelper($vote);
/*if ( $this->settings['fluid']['templates']['ratinglinks']['likesMode'] ) {
\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
get_class($this).': Setting "fluid.templates.ratinglinks.likesMode" is deprecated' .
' Use the specific action "mark" as a replacement. Will be removed two versions after 0.10.2 - at least in version 1.0.'
);
$this->view->assign('actionMethodName','markAction');
}*/
$this->initSignalSlotDispatcher('afterRatinglinkAction');
$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'Exit ratinglinksAction', []);
}
Expand Down Expand Up @@ -606,7 +601,7 @@ public function graphicActionHelper(\Thucke\ThRating\Domain\Model\Vote $vote = N
* @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
* @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException
*/
protected function initSignalSlotDispatcher($slotName)
protected function initSignalSlotDispatcher($slotName): void
{
$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'Entry initSignalSlotDispatcher', ['slotName' => $slotName]);
if ($this->request->hasArgument('signalSlotHandlerContent')) {
Expand Down Expand Up @@ -691,7 +686,7 @@ protected function initVoting(\Thucke\ThRating\Domain\Model\Vote $vote = NULL)
*
* @return void
*/
protected function initSettings()
protected function initSettings():void
{
$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'Entry initSettings', []);

Expand Down Expand Up @@ -753,6 +748,8 @@ protected function initSettings()

$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$frameworkConfiguration['settings'] = $this->settings;
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($frameworkConfiguration,' initSettings.settings ');

$this->setFrameworkConfiguration($frameworkConfiguration);

$this->logger->log(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, 'Exit initSettings', []);
Expand All @@ -765,7 +762,7 @@ protected function initSettings()
*
* @return void
*/
protected function setAjaxSelections(\Thucke\ThRating\Domain\Model\Vote $vote)
protected function setAjaxSelections(\Thucke\ThRating\Domain\Model\Vote $vote): void
{
if ($vote->getVoter() instanceof \Thucke\ThRating\Domain\Model\Voter && empty($this->settings['displayOnly'])) {
//cleanup settings to reduce data size in POST form
Expand Down Expand Up @@ -794,7 +791,7 @@ protected function setAjaxSelections(\Thucke\ThRating\Domain\Model\Vote $vote)
* @return void
* @throws \Thucke\ThRating\Exception\InvalidAggregateRatingSchemaTypeException
*/
protected function fillSummaryView()
protected function fillSummaryView(): void
{
$this->view->assign('settings', $this->settings);
$this->view->assign('ajaxRef', $this->ajaxSelections['ajaxRef']);
Expand Down Expand Up @@ -855,24 +852,26 @@ protected function getErrorFlashMessage()
* @throws \Thucke\ThRating\Exception\FeUserStoragePageException if plugin.tx_felogin_pi1.storagePid has not been set
* @return void
*/
protected function setStoragePids()
protected function setStoragePids(): void
{
/** @var array $frameworkConfiguration */
$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$feUserStoragePid = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $frameworkConfiguration['plugin.']['tx_felogin_pi1.']['storagePid'], true);
$frameworkConfiguration = $frameworkConfiguration['plugin.']['tx_thrating.'];

$storagePids = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $frameworkConfiguration['storagePid'], true);

if (empty($storagePids[0])) {
throw new \Thucke\ThRating\Exception\InvalidStoragePageException(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('flash.vote.general.invalidStoragePid', 'ThRating'), 1403203519);
}

if (empty($feUserStoragePid[0])) {
throw new \Thucke\ThRating\Exception\FeUserStoragePageException(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('flash.pluginConfiguration.missing.feUserStoragePid', 'ThRating'), 1403190539);
}
array_push($storagePids, $feUserStoragePid[0]);
$storagePids[] = $feUserStoragePid[0];
$frameworkConfiguration['persistence.']['storagePid'] = implode(',', $storagePids);
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($frameworkConfiguration,' setStoragePids.$frameworkConfiguration');
$this->setFrameworkConfiguration($frameworkConfiguration);
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK),' setStoragePids Final');
}

/**
Expand All @@ -891,7 +890,7 @@ protected function getRandomId()
* @param array $frameworkConfiguration
* @return void
*/
protected function setFrameworkConfiguration(array $frameworkConfiguration)
protected function setFrameworkConfiguration(array $frameworkConfiguration): void
{
$this->configurationManager->setConfiguration($frameworkConfiguration);
$this->cookieLifetime = abs((int)$this->settings['cookieLifetime']);
Expand All @@ -901,6 +900,7 @@ protected function setFrameworkConfiguration(array $frameworkConfiguration)
} else {
$this->cookieProtection = true;
}
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK),' setFrameworkConfiguration ');
}


Expand All @@ -913,7 +913,7 @@ protected function setFrameworkConfiguration(array $frameworkConfiguration)
* @param array $additionalInfo
* @return void
*/
private function logFlashMessage(string $messageText, string $messageTitle, string $severity, array $additionalInfo)
private function logFlashMessage(string $messageText, string $messageTitle, string $severity, array $additionalInfo): void
{
$additionalInfo = ['messageTitle' => $messageTitle] + $additionalInfo;
$severity = strtoupper($severity);
Expand Down
26 changes: 17 additions & 9 deletions Classes/Service/LoggingService.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Thucke\ThRating\Service;

/***************************************************************
* Copyright notice
*
Expand Down Expand Up @@ -60,25 +61,32 @@ public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $ob
* @param string $name the class name which this logger is for
* @return \TYPO3\CMS\Core\Log\Logger
*/
public function getLogger( $name ) {
$writerConfiguration = $GLOBALS['TYPO3_CONF_VARS']['LOG']['Thucke']['ThRating']['writerConfiguration'];
public function getLogger( $name ): \TYPO3\CMS\Core\Log\Logger
{
/** @var array $writerConfiguration */
$writerConfiguration = $GLOBALS['TYPO3_CONF_VARS']['LOG']['Thucke']['ThRating']['writerConfiguration'];
$settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,'thRating','pi1');
If ( is_array($settings['logging']) ){
foreach ($settings['logging'] as $logLevel => $logConfig) {
$levelUppercase = strtoupper($logLevel);
If ( !empty($logConfig['file']) ) {
$writerConfiguration[constant('\TYPO3\CMS\Core\Log\LogLevel::'.$levelUppercase)]['TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter'] =

/** @var string $levelUppercase */
$levelUppercase = strtoupper($logLevel);

If ( !empty($logConfig['file']) ) {
$writerConfiguration[constant('\TYPO3\CMS\Core\Log\LogLevel::'.$levelUppercase)][\TYPO3\CMS\Core\Log\Writer\FileWriter::class] =
['logFile' => $logConfig['file']];
}
If ( !empty($logConfig['database']) ) {
$writerConfiguration[constant('\TYPO3\CMS\Core\Log\LogLevel::'.$levelUppercase)]['TYPO3\\CMS\\Core\\Log\\Writer\\Database'] =
$writerConfiguration[constant('\TYPO3\CMS\Core\Log\LogLevel::'.$levelUppercase)][\TYPO3\CMS\Core\Log\Writer\DatabaseWriter::class] =
['table' => $logConfig['table']];
}
}
}
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Thucke']['ThRating']['writerConfiguration'] = $writerConfiguration;
$logger = $this->objectManager->get('TYPO3\\CMS\\Core\\Log\\LogManager')->getLogger( $name );
return $logger;
if (!empty($writerConfiguration)) {
/** @noinspection UnsupportedStringOffsetOperationsInspection */
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Thucke']['ThRating']['writerConfiguration'] = $writerConfiguration;
}
return $this->objectManager->get(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger( $name );
}

}
Loading

0 comments on commit ceacf54

Please sign in to comment.