Initial commit
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
namespace EP\EpEvents\DataProcessing;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* Cedric Ziel <[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 EP\EpEvents\Constants;
|
||||
use EP\EpEvents\Domain\Repository\OfferRepository;
|
||||
use EP\EpEvents\Domain\Repository\TraveltypeRepository;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
|
||||
|
||||
class OfferProcessor implements DataProcessorInterface
|
||||
{
|
||||
/**
|
||||
* @param ContentObjectRenderer $cObj
|
||||
* @param array $contentObjectConfiguration
|
||||
* @param array $processorConfiguration
|
||||
* @param array $processedData
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function process(
|
||||
ContentObjectRenderer $cObj,
|
||||
array $contentObjectConfiguration,
|
||||
array $processorConfiguration,
|
||||
array $processedData
|
||||
) {
|
||||
// Process page data for special page type only
|
||||
if ((int) $cObj->data['doktype'] !== Constants::PAGETYPE_OFFER) {
|
||||
return $processedData;
|
||||
}
|
||||
// Get offer repository instance
|
||||
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
/** @var \EP\EpEvents\Domain\Repository\OfferRepository $repository */
|
||||
$repository = $objectManager->get(OfferRepository::class);
|
||||
$offer = null;
|
||||
// First look for selected offer in page settings and fetch offer
|
||||
// by page uid otherwise
|
||||
$offerUid = (int) $cObj->data['tx_epevents_offer'];
|
||||
if ($offerUid !== 0) {
|
||||
/** @var \EP\EpEvents\Domain\Model\Offer $offer */
|
||||
$offer = $repository->findByIdentifier($offerUid);
|
||||
} else {
|
||||
$pageUid = $GLOBALS['TSFE']->id;
|
||||
$offer = $repository->findOneByDetailPage($pageUid);
|
||||
}
|
||||
/** @var \EP\EpEvents\Domain\Model\Offer $offer */
|
||||
$processedData['offer'] = $offer;
|
||||
$processedData['travelType'] = null;
|
||||
if ($offer->getConfiguratorType()) {
|
||||
$configuratorType = $offer->getConfiguratorType();
|
||||
/** @var \EP\EpEvents\Domain\Repository\TraveltypeRepository $repository */
|
||||
$repository = $objectManager->get(TraveltypeRepository::class);
|
||||
$processedData['travelType'] = $repository->findOneByConfiguratorType($configuratorType);
|
||||
}
|
||||
$processedData['search'] = GeneralUtility::_GET('search');
|
||||
return $processedData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace EP\EpEvents\DataProcessing;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
|
||||
* Cedric Ziel <[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 EP\EpEvents\Constants;
|
||||
use EP\EpEvents\Domain\Repository\TraveltypeRepository;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
|
||||
|
||||
class TraveltypeProcessor implements DataProcessorInterface
|
||||
{
|
||||
/**
|
||||
* @param ContentObjectRenderer $cObj
|
||||
* @param array $contentObjectConfiguration
|
||||
* @param array $processorConfiguration
|
||||
* @param array $processedData
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function process(
|
||||
ContentObjectRenderer $cObj,
|
||||
array $contentObjectConfiguration,
|
||||
array $processorConfiguration,
|
||||
array $processedData
|
||||
) {
|
||||
// Process page data for special page type only
|
||||
if ((int) $cObj->data['doktype'] !== Constants::PAGETYPE_CATEGORY) {
|
||||
return $processedData;
|
||||
}
|
||||
// Get traveltype repository instance
|
||||
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
/** @var \EP\EpEvents\Domain\Repository\TraveltypeRepository $repository */
|
||||
$repository = $objectManager->get(TraveltypeRepository::class);
|
||||
$traveltype = null;
|
||||
$traveltypeUid = (int) $cObj->data['tx_epevents_traveltype'];
|
||||
if ($traveltypeUid !== 0) {
|
||||
/** @var \EP\EpEvents\Domain\Model\Traveltype $traveltype */
|
||||
$traveltype = $repository->findByIdentifier($traveltypeUid);
|
||||
}
|
||||
$processedData['traveltype'] = $traveltype;
|
||||
return $processedData;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user