Initial commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
namespace EP\EpEvents\Hooks;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* 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\DataHandling\DataHandler;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
|
||||
class Tcemain
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
* @param string $table
|
||||
* @param int $id
|
||||
* @param DataHandler $obj
|
||||
*/
|
||||
public function processDatamap_preProcessFieldArray(array &$fields, $table, $id, DataHandler $obj)
|
||||
{
|
||||
if ($table === 'tx_epevents_domain_model_offer') {
|
||||
// Set default value for url segment
|
||||
if (empty($fields['url'])) {
|
||||
$fields['url'] = $fields['name'] . date('dmy');
|
||||
}
|
||||
// Clear realurl cache for detail page
|
||||
$settings = $this->getSettings();
|
||||
$detailPageUid = $settings['plugin']['tx_epevents']['settings']['offerDetailPageUid'];
|
||||
if ((int) $detailPageUid > 0) {
|
||||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_realurl_urldata', 'page_id=' . $detailPageUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getSettings()
|
||||
{
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
|
||||
return GeneralUtility::removeDotsFromTS(
|
||||
$configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user