Skip to content

Commit

Permalink
solve bug 0000074
Browse files Browse the repository at this point in the history
  • Loading branch information
domjos1994 committed Aug 29, 2019
1 parent 0d8cbf8 commit 0d1ed6e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
44 changes: 44 additions & 0 deletions Classes/Controller/TimelineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
'author_email' => '[email protected]',
'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 (
Expand Down
4 changes: 4 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use GeorgRinger\News\Domain\Repository\NewsRepository;

defined('TYPO3_MODE') || die('Access denied.');

call_user_func(function($extKey) {
Expand Down Expand Up @@ -27,3 +29,5 @@
}'
);
}, $_EXTKEY);

\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)->registerImplementation(NewsRepository::class, NewsRepository::class);

0 comments on commit 0d1ed6e

Please sign in to comment.