Commit 87a6ae6c authored by Thomas Löffler's avatar Thomas Löffler
Browse files

[TASK] Setup command correctly and refactor for v11

parent b85a2dd4
Pipeline #27081 failed with stages
in 1 minute and 45 seconds
......@@ -46,7 +46,7 @@ class MonthlyCommand extends Command
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$io->title($this->getDescription());
......@@ -67,6 +67,8 @@ class MonthlyCommand extends Command
}
$io->writeln('Finished.');
return self::SUCCESS;
}
/**
......@@ -75,7 +77,7 @@ class MonthlyCommand extends Command
* @param array $banner
* @return bool
*/
protected function sendReport($banner)
protected function sendReport(array $banner): bool
{
if ($banner['email']) {
$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('randombanners');
......@@ -113,7 +115,7 @@ class MonthlyCommand extends Command
*
* @param array $banner
*/
protected function setStatistics($banner)
protected function setStatistics(array $banner)
{
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_randombanners_domain_model_banner')
......
......@@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface;
use T3o\Randombanners\Domain\Repository\BannerRepository;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
......@@ -40,7 +41,7 @@ class BannerController extends ActionController
public function indexAction(): ResponseInterface
{
$this->objectManager->get(PageRenderer::class)
GeneralUtility::makeInstance(PageRenderer::class)
->addJsFooterFile('EXT:randombanners/Resources/Public/Javascript/randombanners.js');
$this->view->assign('banners', $this->bannerRepository->findAll());
$this->view->assign('contentData', $this->configurationManager->getContentObject()->data);
......
......@@ -14,6 +14,7 @@ namespace T3o\Randombanners\Domain\Model;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
......@@ -25,47 +26,47 @@ class Banner extends AbstractEntity
*
* @var string
*/
protected $name;
protected string $name = '';
/**
* link
*
* @var string
*/
protected $link;
protected string $link = '';
/**
* email
*
* @var string
*/
protected $email;
protected string $email = '';
/**
* Logo
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference|null
*/
protected $logo;
protected ?FileReference $logo = null;
/**
* clickedThisMonth
*
* @var int
*/
protected $clickedThisMonth;
protected int $clickedThisMonth = 0;
/**
* clickedLastMonth
*
* @var int
*/
protected $clickedLastMonth;
protected int $clickedLastMonth = 0;
/**
* @param string $name
*/
public function setName($name)
public function setName(string $name): void
{
$this->name = $name;
}
......@@ -73,7 +74,7 @@ class Banner extends AbstractEntity
/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
......@@ -81,7 +82,7 @@ class Banner extends AbstractEntity
/**
* @param string $link
*/
public function setLink($link)
public function setLink(string $link): void
{
$this->link = $link;
}
......@@ -89,15 +90,15 @@ class Banner extends AbstractEntity
/**
* @return string
*/
public function getLink()
public function getLink(): string
{
return $this->link;
}
/**
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $logo
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference|null $logo
*/
public function setLogo(ObjectStorage $logo)
public function setLogo(?FileReference $logo): void
{
$this->logo = $logo;
}
......@@ -105,9 +106,9 @@ class Banner extends AbstractEntity
/**
* Get logo
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference|null
*/
public function getLogo()
public function getLogo(): ?FileReference
{
return $this->logo;
}
......@@ -115,7 +116,7 @@ class Banner extends AbstractEntity
/**
* @param string $email
*/
public function setEmail($email)
public function setEmail(string $email): void
{
$this->email = $email;
}
......@@ -123,7 +124,7 @@ class Banner extends AbstractEntity
/**
* @return string
*/
public function getEmail()
public function getEmail(): string
{
return $this->email;
}
......@@ -131,7 +132,7 @@ class Banner extends AbstractEntity
/**
* @param int $clickedThisMonth
*/
public function setClickedThisMonth($clickedThisMonth)
public function setClickedThisMonth(int $clickedThisMonth): void
{
$this->clickedThisMonth = $clickedThisMonth;
}
......@@ -139,7 +140,7 @@ class Banner extends AbstractEntity
/**
* @return int
*/
public function getClickedThisMonth()
public function getClickedThisMonth(): int
{
return $this->clickedThisMonth;
}
......@@ -147,7 +148,7 @@ class Banner extends AbstractEntity
/**
* @param int $clickedLastMonth
*/
public function setClickedLastMonth($clickedLastMonth)
public function setClickedLastMonth(int $clickedLastMonth): void
{
$this->clickedLastMonth = $clickedLastMonth;
}
......@@ -155,7 +156,7 @@ class Banner extends AbstractEntity
/**
* @return int
*/
public function getClickedLastMonth()
public function getClickedLastMonth(): int
{
return $this->clickedLastMonth;
}
......
......@@ -24,7 +24,7 @@ class ClickCountMiddleware implements MiddlewareInterface
->fetch();
if ($bannerRecord) {
$queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_randombanners_domain_model_banner');
$queryBuilder
->update('tx_randombanners_domain_model_banner')
......
<?php
return [
'randombanners:monthly' => [
'class' => \T3o\Randombanners\Command\MonthlyCommand::class,
'schedulable' => true,
],
];
......@@ -147,7 +147,6 @@ return [
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'logo',
[
'minitems' => 1,
'maxitems' => 1,
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment