Commit 64b0b1eb authored by Thomas Löffler's avatar Thomas Löffler

Fixes review form

parent e015be42
Pipeline #1970 passed with stages
in 1 minute and 26 seconds
...@@ -35,7 +35,8 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = [ ...@@ -35,7 +35,8 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = [
[ [
'GETvar' => 'tx_terfe2_pi1[controller]', 'GETvar' => 'tx_terfe2_pi1[controller]',
'valueMap' => [ 'valueMap' => [
'Extension' => '' 'Extension' => '',
'Review' => 'security-review'
], ],
'noMatch' => 'bypass' 'noMatch' => 'bypass'
], ],
...@@ -43,7 +44,8 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = [ ...@@ -43,7 +44,8 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = [
'GETvar' => 'tx_terfe2_pi1[action]', 'GETvar' => 'tx_terfe2_pi1[action]',
'valueMap' => [ 'valueMap' => [
'detail' => '', 'detail' => '',
'download' => 'download' 'download' => 'download',
'update' => 'update'
], ],
'noMatch' => 'bypass' 'noMatch' => 'bypass'
], ],
......
...@@ -31,41 +31,22 @@ namespace T3o\TerFe2\Controller; ...@@ -31,41 +31,22 @@ namespace T3o\TerFe2\Controller;
class ReviewController extends \T3o\TerFe2\Controller\AbstractTerBasedController class ReviewController extends \T3o\TerFe2\Controller\AbstractTerBasedController
{ {
/**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
*/
protected $persistenceManager;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController()
{
$this->persistenceManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
}
/** /**
* Set unsecure flag of all given versions * Set unsecure flag of all given versions
* *
* @param \T3o\TerFe2\Domain\Model\Extension $extension The extension to update * @param \T3o\TerFe2\Domain\Model\Extension $extension The extension to update
* @param mixed $insecureVersions Version UIDs or empty string of no version was selected * @param array $insecureVersions Version UIDs or empty string of no version was selected
* @return void * @return void
*/ */
public function updateAction(\T3o\TerFe2\Domain\Model\Extension $extension, $insecureVersions) public function updateAction(\T3o\TerFe2\Domain\Model\Extension $extension, array $insecureVersions)
{ {
$insecureVersions = (is_array($insecureVersions) ? $insecureVersions : array()); $actionParameters = ['extension' => $extension];
$extensionKey = $extension->getExtKey();
$versions = $extension->getVersions(); $versions = $extension->getVersions();
$persist = FALSE; $versionChanged = false;
$versionRepository = $this->objectManager->get(\T3o\TerFe2\Domain\Repository\VersionRepository::class);
foreach ($versions as $version) { foreach ($versions as $version) {
$versionString = $version->getVersionString(); /** @var \T3o\TerFe2\Domain\Model\Version $version */
$actionParameters = array('extension' => $extension);
$reviewState = 0; $reviewState = 0;
if (in_array($version->getUid(), $insecureVersions)) { if (in_array($version->getUid(), $insecureVersions)) {
$reviewState = -1; $reviewState = -1;
...@@ -76,17 +57,17 @@ class ReviewController extends \T3o\TerFe2\Controller\AbstractTerBasedController ...@@ -76,17 +57,17 @@ class ReviewController extends \T3o\TerFe2\Controller\AbstractTerBasedController
} }
$error = ''; $error = '';
if ($this->terConnection->setReviewState($extensionKey, $versionString, $reviewState, $error)) { if ($this->terConnection->setReviewState($extension->getExtKey(), $version->getVersionString(), $reviewState, $error)) {
$version->setReviewState($reviewState); $version->setReviewState($reviewState);
$persist = TRUE; $versionChanged = true;
$versionRepository->update($version);
} else { } else {
$message = $this->translate('msg.reviewstate_not_enabled', array($versionString, $error)); $message = $this->translate('msg.reviewstate_not_enabled', [$version->getVersionString(), $error]);
$this->redirectWithMessage($message, 'show', '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, 'Extension', NULL, $actionParameters); $this->redirectWithMessage($message, 'show', '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, 'Extension', NULL, $actionParameters);
} }
} }
if ($persist) { if ($versionChanged) {
$this->persistenceManager->persistAll();
$this->redirectWithMessage($this->translate('msg.reviewstate_enabled'), 'show', '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, 'Extension', NULL, $actionParameters); $this->redirectWithMessage($this->translate('msg.reviewstate_enabled'), 'show', '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, 'Extension', NULL, $actionParameters);
} }
......
Markdown is supported
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