From 0d1ed6e36037343d62e34ae65c970a2e0fc9b696 Mon Sep 17 00:00:00 2001 From: domjos1994 Date: Thu, 29 Aug 2019 18:11:56 +0200 Subject: [PATCH] solve bug 0000074 --- Classes/Controller/TimelineController.php | 44 +++++++++++++++++++++++ ext_emconf.php | 4 +-- ext_localconf.php | 4 +++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Classes/Controller/TimelineController.php b/Classes/Controller/TimelineController.php index 80bb049..0f6ae07 100644 --- a/Classes/Controller/TimelineController.php +++ b/Classes/Controller/TimelineController.php @@ -2,10 +2,17 @@ namespace DominicJoas\Timeline\Controller; +use DominicJoas\Timeline\Domain\Model\TimelineEvent; use DominicJoas\Timeline\Domain\Repository\TimelineEventRepository; + +use Exception; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; +use GeorgRinger\News\Domain\Model\Dto\NewsDemand; +use GeorgRinger\News\Domain\Repository\NewsRepository; + class TimelineController extends ActionController { private $timelineEventRepository; protected $configurationManager; @@ -59,6 +66,38 @@ public function injectConfigurationManager(ConfigurationManagerInterface $config } } + public function createTimeLineEventsFromNews() { + $events = []; + try { + $pages = $this->configurationManager->getContentObject()->data['pages']; + $objManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); + $newsRepository = $objManager->get(NewsRepository::class); + $demand = $objManager->get(NewsDemand::class); + $demand->setStoragePage($pages); + $demand->setPid($pages); + $entries = $newsRepository->findDemanded($demand); + + $counter = 0; + foreach ($entries as $entry) { + if($entry->getPid()==$pages) { + $event = new TimelineEvent(); + $event->setTitle($entry->getTitle()); + $event->setDescription($entry->getDescription()); + $event->setStartDate($entry->getStarttime()); + $event->setEndDate($entry->getEndtime()); + if($entry->getRelatedLinks()!=null) { + if($entry->getRelatedLinks()->count()!=0) { + $event->setEventLink($entry->getRelatedLinks()[0]->getUri()); + } + } + $events[$counter] = $event; + $counter++; + } + } + } catch (Exception $ex) {} + return $events; + } + public function listAction() { $uid = $this->configurationManager->getContentObject()->data['_LOCALIZED_UID']; if($uid==null) { @@ -76,6 +115,11 @@ public function listAction() { $timelineEvents = $query->toArray(); } + $newsEvents = $this->createTimeLineEventsFromNews(); + if(count($newsEvents)!=0) { + $timelineEvents = $newsEvents; + } + $uniqueIDs = null; for($i = 0;$i<=count($timelineEvents)-1; $i++) { $uniqueIDs[$i] = uniqid(rand(), true); diff --git a/ext_emconf.php b/ext_emconf.php index 4405594..e50cb56 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -19,12 +19,12 @@ 'author_email' => 'developing@domjos.de', 'state' => 'beta', 'clearCacheOnLoad' => true, - 'version' => '0.0.4', + 'version' => '0.0.5', 'constraints' => array ( 'depends' => array ( - 'typo3' => '7.6.0-9.5.99', + 'typo3' => '8.7.0-9.5.99', ), 'conflicts' => array ( diff --git a/ext_localconf.php b/ext_localconf.php index c9ccf43..8dcb95e 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,5 +1,7 @@ registerImplementation(NewsRepository::class, NewsRepository::class);