Skip to content

Commit

Permalink
Make compatible with TYPO3 10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
garbast committed Aug 24, 2019
1 parent b314caa commit 91c72cd
Show file tree
Hide file tree
Showing 46 changed files with 478 additions and 547 deletions.
16 changes: 12 additions & 4 deletions Classes/Controller/AjaxController.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Controller;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,9 +13,10 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Controller;

use Evoweb\Sessionplaner\Domain\Model\Day;
use Evoweb\Sessionplaner\Domain\Model\Room;
use Evoweb\Sessionplaner\Domain\Model\Session;
use Evoweb\Sessionplaner\Domain\Model\Slot;
use Evoweb\Sessionplaner\Domain\Repository\DayRepository;
use Evoweb\Sessionplaner\Domain\Repository\RoomRepository;
use Evoweb\Sessionplaner\Domain\Repository\SessionRepository;
Expand Down Expand Up @@ -110,12 +113,14 @@ protected function initializeAction(ServerRequestInterface $request)
{
$this->parameter = $request->getParsedBody()['tx_sessionplaner'];

if (!($this->backendUser->isAdmin() || $this->backendUser->modAccess($this->moduleConfiguration, 0))) {
if (!($this->backendUser->isAdmin() || $this->backendUser->modAccess($this->moduleConfiguration))) {
$this->errorAction();
return false;
}

$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$configuration = $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
);
if (empty($configuration['persistence']['storagePid'])) {
$currentPid['persistence']['storagePid'] = $request->getParsedBody()['id'];
$this->configurationManager->setConfiguration(array_merge($configuration, $currentPid));
Expand Down Expand Up @@ -220,14 +225,17 @@ protected function updateSessionFromRequest(Session $session)
foreach ($sessionData as $field => $value) {
switch ($field) {
case 'room':
/** @var Room $room */
$room = $this->roomRepository->findByUid((int) $value);
$session->setRoom($room);
break;
case 'slot':
/** @var Slot $slot */
$slot = $this->slotRepository->findByUid((int) $value);
$session->setSlot($slot);
break;
case 'day':
/** @var Day $day */
$day = $this->dayRepository->findByUid((int) $value);
$session->setDay($day);
break;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/BackendModuleController.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Controller;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,8 +13,6 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Controller;

use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down
18 changes: 12 additions & 6 deletions Classes/Controller/SessionController.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Controller;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,8 +13,7 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Controller;

use Evoweb\Sessionplaner\Domain\Model\Session;
use Evoweb\Sessionplaner\TitleTagProvider\EventTitleTagProvider;
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -39,33 +40,38 @@ public function injectSessionRepository(\Evoweb\Sessionplaner\Domain\Repository\
$this->sessionRepository = $repository;
}

public function listAction(\Evoweb\Sessionplaner\Domain\Model\Session $session = null)
public function listAction(Session $session = null)
{
if ($session) {
$this->forward('show');
}

if ($this->settings['suggestions']) {
$sessions = $this->sessionRepository->findSuggested();
} else {
$sessions = $this->sessionRepository->findByDayAndHasSlotHasRoom($this->settings['days']);
$days = $this->dayRepository->findByUidsRaw($this->settings['days']);
$this->view->assign('days', $days);
}

$this->view->assign('sessions', $sessions);
}

public function showAction(\Evoweb\Sessionplaner\Domain\Model\Session $session = null)
public function showAction(Session $session = null)
{
if ($session === null) {
$this->forward('list');
}

$provider = GeneralUtility::makeInstance(EventTitleTagProvider::class);
$provider->setTitle($session->getTopic());

$ogMetaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('og:title');
$ogMetaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)
->getManagerForProperty('og:title');
$ogMetaTagManager->addProperty('og:title', $session->getTopic());

$twitterMetaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('twitter:title');
$twitterMetaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)
->getManagerForProperty('twitter:title');
$twitterMetaTagManager->addProperty('twitter:title', $session->getTopic());

$this->view->assign('session', $session);
Expand Down
7 changes: 3 additions & 4 deletions Classes/Controller/SessionplanController.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Controller;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,12 +13,9 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Controller;

use Evoweb\Sessionplaner\Domain\Repository\DayRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class SessionplanController extends ActionController
class SessionplanController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* @var DayRepository
Expand Down
24 changes: 10 additions & 14 deletions Classes/Controller/SpeakerController.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Controller;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,15 +13,12 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Controller;

use Evoweb\Sessionplaner\Domain\Model\Speaker;
use Evoweb\Sessionplaner\TitleTagProvider\SpeakerTitleTagProvider;
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class SpeakerController extends ActionController
class SpeakerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* @var \Evoweb\Sessionplaner\Domain\Repository\SpeakerRepository
Expand All @@ -29,33 +28,30 @@ class SpeakerController extends ActionController
/**
* @param \Evoweb\Sessionplaner\Domain\Repository\SpeakerRepository $speakerRepository
*/
public function injectSpeakerRepository(\Evoweb\Sessionplaner\Domain\Repository\SpeakerRepository $speakerRepository)
{
public function injectSpeakerRepository(
\Evoweb\Sessionplaner\Domain\Repository\SpeakerRepository $speakerRepository
) {
$this->speakerRepository = $speakerRepository;
}

/**
* @return void
*/
public function listAction()
{
$speakers = $this->speakerRepository->findAll();

$this->view->assign('speakers', $speakers);
}

/**
* @param Speaker $speaker
*/
public function showAction(Speaker $speaker)
{
$provider = GeneralUtility::makeInstance(SpeakerTitleTagProvider::class);
$provider->setTitle($speaker->getName());

$ogMetaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('og:title');
$metaTagRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);

$ogMetaTagManager = $metaTagRegistry->getManagerForProperty('og:title');
$ogMetaTagManager->addProperty('og:title', $speaker->getName());

$twitterMetaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('twitter:title');
$twitterMetaTagManager = $metaTagRegistry->getManagerForProperty('twitter:title');
$twitterMetaTagManager->addProperty('twitter:title', $speaker->getName());

$this->view->assign('speaker', $speaker);
Expand Down
21 changes: 10 additions & 11 deletions Classes/Controller/SuggestController.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Controller;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,12 +13,10 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Controller;

use Evoweb\Sessionplaner\Domain\Model\Session;
use Evoweb\Sessionplaner\Domain\Repository\DayRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class SuggestController extends ActionController
class SuggestController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* @var \Evoweb\Sessionplaner\Domain\Repository\SessionRepository
Expand All @@ -28,17 +28,17 @@ public function injectSessionRepository(\Evoweb\Sessionplaner\Domain\Repository\
$this->sessionRepository = $repository;
}

public function newAction(\Evoweb\Sessionplaner\Domain\Model\Session $session = null)
public function newAction(Session $session = null)
{
// Has a session been submitted?
if ($session === null) {
// Get a blank one
$session = $this->objectManager->get(\Evoweb\Sessionplaner\Domain\Model\Session::class);
$session = $this->objectManager->get(Session::class);
}
$this->view->assign('session', $session);
}

public function createAction(\Evoweb\Sessionplaner\Domain\Model\Session $session = null)
public function createAction(Session $session = null)
{
if ($session === null) {
// redirect to drop unwanted parameters
Expand All @@ -56,9 +56,8 @@ public function createAction(\Evoweb\Sessionplaner\Domain\Model\Session $session
$this->redirect('new');
}

protected function setDefaultValues(
\Evoweb\Sessionplaner\Domain\Model\Session $session
): \Evoweb\Sessionplaner\Domain\Model\Session {
protected function setDefaultValues(Session $session): Session
{
if (isset($this->settings['default'])
&& is_array($this->settings['default'])
&& !empty($this->settings['default'])) {
Expand All @@ -81,7 +80,7 @@ protected function setDefaultValues(
*
* @return mixed
*/
protected function getDefaultValues($field, $value)
protected function getDefaultValues(string $field, $value)
{
switch ($field) {
case 'day':
Expand Down
4 changes: 2 additions & 2 deletions Classes/DataProcessing/SpeakerProcessor.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\DataProcessing;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,8 +13,6 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\DataProcessing;

use Evoweb\Sessionplaner\Domain\Model\Speaker;
use Evoweb\Sessionplaner\Domain\Repository\SpeakerRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down
26 changes: 12 additions & 14 deletions Classes/Domain/Model/AbstractSlugEntity.php
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);
namespace Evoweb\Sessionplaner\Domain\Model;

/*
* This file is part of the package evoweb\sessionplaner.
Expand All @@ -11,11 +13,8 @@
* LICENSE file that was distributed with this source code.
*/

namespace Evoweb\Sessionplaner\Domain\Model;

use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory;
use TYPO3\CMS\Core\DataHandling\SlugHelper;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
Expand All @@ -34,19 +33,22 @@ abstract class AbstractSlugEntity extends AbstractEntity

/**
* @throws NoSuchArgumentException
* @throws SiteNotFoundException
*
* @return bool
*/
public function _isNew()
public function _isNew(): bool
{
$isnew = parent::_isNew();
if ($isnew) {
$isNew = parent::_isNew();
if ($isNew) {
if (empty($this->slugField)) {
throw new NoSuchArgumentException('The property "slugField" can not be empty', 1559731500);
}
$slugSetter = 'set' . GeneralUtility::underscoredToUpperCamelCase($this->slugField);
if (!method_exists($this, $slugSetter)) {
throw new NoSuchArgumentException('The method "' . $slugSetter . '" must exist in your entity', 1559731501);
throw new NoSuchArgumentException(
'The method "' . $slugSetter . '" must exist in your entity',
1559731501
);
}
if (empty($this->tablename)) {
throw new NoSuchArgumentException('The property "tablename" can not be empty', 1559731502);
Expand All @@ -57,14 +59,9 @@ public function _isNew()
$this->{$slugSetter}($this->generateSlug());
}

return $isnew;
return $isNew;
}

/**
* @throws NoSuchArgumentException
* @throws SiteNotFoundException
* @return string
*/
public function generateSlug(): string
{
$properties = $this->_getProperties();
Expand All @@ -82,6 +79,7 @@ public function generateSlug(): string
$record[$field] = $v;
}

$pid = (int)$record['pid'];
$slug = $slugHelper->generate($record, $this->getPid());
$state = RecordStateFactory::forName($this->tablename)->fromArray($record, $pid, 'NEW');
if ($hasToBeUniqueInSite && !$slugHelper->isUniqueInSite($slug, $state)) {
Expand Down

0 comments on commit 91c72cd

Please sign in to comment.