Clear page cache on product import

This commit is contained in:
Björn Fromme
2018-06-27 12:55:14 +02:00
parent 264d14f5f3
commit 177b8ae70e
3 changed files with 49 additions and 7 deletions
@@ -27,18 +27,42 @@ namespace EP\EpProducts\Command;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use EP\EpProducts\Service\ImportService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
use TYPO3\CMS\Extbase\Service\CacheService;
class ProductCommandController extends CommandController class ProductCommandController extends CommandController
{ {
/** /**
* @var \EP\EpProducts\Service\ImportService * @var \EP\EpProducts\Service\ImportService
* @inject
*/ */
protected $importService; protected $importService;
/**
* @var CacheService
*/
protected $cacheService;
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @param ImportService $importService
* @param CacheService $cacheService
* @param ConfigurationManagerInterface $configurationManager
*/
public function __construct(ImportService $importService, CacheService $cacheService, ConfigurationManagerInterface $configurationManager)
{
$this->importService = $importService;
$this->cacheService = $cacheService;
$this->configurationManager = $configurationManager;
}
public function importCommand() public function importCommand()
{ {
$path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport'); $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport');
@@ -47,7 +71,22 @@ class ProductCommandController extends CommandController
} else { } else {
$count = $this->importService->import($path); $count = $this->importService->import($path);
$this->outputLine('%d rows imported.', [ $count ]); $this->outputLine('%d rows imported.', [ $count ]);
$settings = $this->getSettings();
$resellerPageUid = $settings['resellerExportPageUid'];
$this->cacheService->clearPageCache($resellerPageUid);
} }
} }
/**
* @return array
*/
protected function getSettings()
{
$settings = $this
->configurationManager
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
return $settings['plugin.']['tx_epproducts.']['settings.'];
}
} }
@@ -83,6 +83,8 @@ class BackendController extends ActionController
} else { } else {
$dateCount = $this->importService->import($path); $dateCount = $this->importService->import($path);
$this->addFlashMessage($dateCount . ' Termine importiert', 'Import abgechlossen', AbstractMessage::OK); $this->addFlashMessage($dateCount . ' Termine importiert', 'Import abgechlossen', AbstractMessage::OK);
$resellerPageUid = $this->settings['resellerExportPageUid'];
$this->cacheService->clearPageCache($resellerPageUid);
} }
$this->redirect('index'); $this->redirect('index');
} }
@@ -74,6 +74,7 @@ class ResellerController extends ActionController
/** /**
* @param Reseller $reseller * @param Reseller $reseller
* @param Product $product * @param Product $product
* @return bool
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/ */
@@ -84,13 +85,14 @@ class ResellerController extends ActionController
} }
$data = $this->resellerService->preprocessSingle($product); $data = $this->resellerService->preprocessSingle($product);
var_dump($data);exit; var_dump($data);
//TODO: Implement Excel sheet generation
return false;
} }
/** /**
* @param Reseller $reseller * @param Reseller $reseller
* @return mixed * @return bool
*/ */
public function xmlAction(Reseller $reseller) public function xmlAction(Reseller $reseller)
{ {
@@ -103,10 +105,9 @@ class ResellerController extends ActionController
$serializer = new Serializer($normalizers, $encoders); $serializer = new Serializer($normalizers, $encoders);
header('Content-type: text/xml;charset=utf-8');
echo $serializer->serialize($data, 'xml', [ 'xml_encoding' => 'utf-8', 'xml_format_output' => true ]); echo $serializer->serialize($data, 'xml', [ 'xml_encoding' => 'utf-8', 'xml_format_output' => true ]);
exit;
return false;
} }
} }