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

[TASK] Fix indendations and use use statements

parent b492499a
......@@ -14,6 +14,7 @@ namespace T3o\Randombanners\Command;
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
......@@ -21,13 +22,15 @@ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Handle click statistics and send monthly mails
*/
class MonthlyCommand extends \Symfony\Component\Console\Command\Command {
class MonthlyCommand extends Command
{
/**
* Configure the command by defining the name, options and arguments
......@@ -35,7 +38,6 @@ class MonthlyCommand extends \Symfony\Component\Console\Command\Command {
protected function configure()
{
$this->setDescription('Handle click statistics and send monthly mails');
//$this->setHelp('Meaningful help text');
}
/**
......@@ -51,14 +53,15 @@ class MonthlyCommand extends \Symfony\Component\Console\Command\Command {
// Get a query builder for a query on table "tt_content"
/** @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_randombanners_domain_model_banner');
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_randombanners_domain_model_banner');
$rows = $queryBuilder
->select('*')
->from('tx_randombanners_domain_model_banner')
->execute()
->fetchAll();
foreach($rows as $banner) {
foreach ($rows as $banner) {
$this->sendReport($banner);
$this->setStatistics($banner);
}
......@@ -72,12 +75,13 @@ class MonthlyCommand extends \Symfony\Component\Console\Command\Command {
* @param array $banner
* @return boolean
*/
protected function sendReport($banner) {
if($banner['email']) {
protected function sendReport($banner)
{
if ($banner['email']) {
$settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('randombanners');
/* @var \TYPO3\CMS\Core\Mail\MailMessage $mailObject */
$mailObject = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
$mailObject = GeneralUtility::makeInstance(MailMessage::class);
// Get email template
/** @var StandaloneView $renderer */
......@@ -94,11 +98,12 @@ class MonthlyCommand extends \Symfony\Component\Console\Command\Command {
$mailObject->text($message);
$mailObject->setFrom([$settings['senderEmail'] => $settings['senderEmail']]);
if(Environment::getContext()->isDevelopment()) {
if (Environment::getContext()->isDevelopment()) {
$mailObject->setTo($settings['developmentEmail'], $banner['name']);
} else {
$mailObject->setTo($banner['email'], $banner['name']);
}
return $mailObject->send();
}
}
......@@ -108,16 +113,20 @@ class MonthlyCommand extends \Symfony\Component\Console\Command\Command {
*
* @param array $banner
*/
protected function setStatistics($banner) {
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_randombanners_domain_model_banner')
protected function setStatistics($banner)
{
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_randombanners_domain_model_banner')
->update(
'tx_randombanners_domain_model_banner',
[
'clicked_last_month' => $banner['clicked_this_month'],
'clicked_this_month' => 0
], // set
[ 'uid' => $banner['uid'] ] // where
'clicked_this_month' => 0,
],
[
'uid' => $banner['uid']
]
);
}
}
\ No newline at end of file
}
......@@ -15,11 +15,13 @@ namespace T3o\Randombanners\Controller;
*/
use T3o\Randombanners\Domain\Repository\BannerRepository;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* Class BannerController
*/
class BannerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
class BannerController extends ActionController
{
/**
* @var BannerRepository
......@@ -36,7 +38,7 @@ class BannerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
public function indexAction()
{
$this->objectManager->get(\TYPO3\CMS\Core\Page\PageRenderer::class)
$this->objectManager->get(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);
......
......@@ -15,162 +15,164 @@ namespace T3o\Randombanners\Domain\Model;
*/
use T3o\T3oMembership\Domain\Model\Member;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Banner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
class Banner extends AbstractEntity
{
/**
* name
*
* @var string
*/
protected $name;
/**
* link
*
* @var string
*/
protected $link;
/**
* email
*
* @var string
*/
protected $email;
/**
* Logo
*
/**
* name
*
* @var string
*/
protected $name;
/**
* link
*
* @var string
*/
protected $link;
/**
* email
*
* @var string
*/
protected $email;
/**
* Logo
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
*/
protected $logo;
*/
protected $logo;
/**
* clickedThisMonth
*
* @var integer
*/
protected $clickedThisMonth;
/**
* clickedThisMonth
*
* @var int
*/
protected $clickedThisMonth;
/**
* clickedLastMonth
*
* @var string
*/
protected $clickedLastMonth;
/**
* clickedLastMonth
*
* @var int
*/
protected $clickedLastMonth;
/**
* $member
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3oMembership\Domain\Model\Member>
*/
protected $member = 0;
/**
* @param string $name
* @return void
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $link
* @return void
*/
public function setLink($link)
{
$this->link = $link;
}
/**
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* @param ObjectStorage $logo
protected $member = null;
/**
* @param string $name
* @return void
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $link
* @return void
*/
public function setLogo(ObjectStorage $logo)
{
$this->logo = $logo;
}
/**
* Get logo
*/
public function setLink($link)
{
$this->link = $link;
}
/**
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* @param ObjectStorage $logo
* @return void
*/
public function setLogo(ObjectStorage $logo)
{
$this->logo = $logo;
}
/**
* Get logo
*
* @return ObjectStorage
*/
public function getLogo() {
return $this->logo;
}
/**
* @param string $email
* @return void
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param integer $clickedThisMonth
* @return void
*/
public function setClickedThisMonth($clickedThisMonth)
{
$this->clickedThisMonth = $clickedThisMonth;
}
/**
* @return integer
*/
public function getClickedThisMonth()
{
return $this->clickedThisMonth;
}
/**
* @param string $clickedLastMonth
* @return void
*/
public function setClickedLastMonth($clickedLastMonth)
{
$this->clickedLastMonth = $clickedLastMonth;
}
/**
* @return string
*/
public function getClickedLastMonth()
{
return $this->clickedLastMonth;
}
* @return ObjectStorage
*/
public function getLogo()
{
return $this->logo;
}
/**
* @param string $email
* @return void
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param int $clickedThisMonth
* @return void
*/
public function setClickedThisMonth($clickedThisMonth)
{
$this->clickedThisMonth = $clickedThisMonth;
}
/**
* @return int
*/
public function getClickedThisMonth()
{
return $this->clickedThisMonth;
}
/**
* @param int $clickedLastMonth
* @return void
*/
public function setClickedLastMonth($clickedLastMonth)
{
$this->clickedLastMonth = $clickedLastMonth;
}
/**
* @return int
*/
public function getClickedLastMonth()
{
return $this->clickedLastMonth;
}
/**
* Adds a Member
......@@ -214,5 +216,4 @@ class Banner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
$this->member = $member;
}
}
......@@ -14,5 +14,8 @@ namespace T3o\Randombanners\Domain\Repository;
* The TYPO3 project - inspiring people to share!
*/
class BannerRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
}
\ No newline at end of file
use TYPO3\CMS\Extbase\Persistence\Repository;
class BannerRepository extends Repository
{
}
<?php
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Randombanners',
'Pi1',
'LLL:EXT:randombanners/Resources/Private/Language/locallang_be.xlf:plugin.title'
);
\ No newline at end of file
);
......@@ -12,7 +12,7 @@ return [
'cruser_id' => 'cruser_id',
'dividers2tabs' => true,
'versioningWS' => 2,
'versioning_followPages' => TRUE,
'versioning_followPages' => true,
'origUid' => 't3_origuid',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
......@@ -23,14 +23,15 @@ return [
'starttime' => 'starttime',
'endtime' => 'endtime',
],
'iconfile' => 'EXT:randombanners/Resources/Public/Icons/tx_randombanners_domain_model_banner.gif'
'iconfile' => 'EXT:randombanners/Resources/Public/Icons/tx_randombanners_domain_model_banner.gif',
],
'interface' => [
'showRecordFieldList' => 'cruser_id, pid, sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, link, email, logo, clicked_this_month, clicked_last_month, member',
],
'types' => [
'1' => [
'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, name, link, email, logo, clicked_this_month, clicked_last_month, member,--div--;LLL:EXT:cms/locallang_ttc.xml:tabs.access,starttime, endtime'],
'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, name, link, email, logo, clicked_this_month, clicked_last_month, member,--div--;LLL:EXT:cms/locallang_ttc.xml:tabs.access,starttime, endtime',
],
],
'palettes' => [
'1' => ['showitem' => ''],
......@@ -46,7 +47,7 @@ return [
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => [
['LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', '-1'],
['LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.default_value', '0']
['LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.default_value', '0'],
],
'default' => 0,
'fieldWizard' => [
......@@ -54,7 +55,7 @@ return [
'disabled' => false,
],
],
]
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
......@@ -68,14 +69,14 @@ return [
],
'foreign_table' => 'tx_randombanners_domain_model_banner',
'foreign_table_where' => 'AND tx_randombanners_domain_model_banner.pid=###CURRENT_PID### AND tx_randombanners_domain_model_banner.sys_language_uid IN (-1,0)',
'showIconTable' => false
]
'showIconTable' => false,
],
],
'l10n_diffsource' => [
'config' => [
'type' => 'passthrough',
'default' => ''
]
'default' => '',
],
],
't3ver_label' => [
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel',
......@@ -83,15 +84,15 @@ return [
'type' => 'input',
'size' => 30,
'max' => 30,
]
],
],
'hidden' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
'config' => [
'type' => 'check',
'default' => 0
]
'default' => 0,
],
],
'starttime' => [
'exclude' => true,
......@@ -103,7 +104,7 @@ return [
'max' => 20,
'eval' => 'datetime',
'default' => 0,
]
],
],
'endtime' => [
'exclude' => true,
......@@ -115,7 +116,7 @@ return [
'max' => 20,
'eval' => 'datetime',
'default' => 0,
]
],
],
'name' => [
'exclude' => false,
......@@ -125,7 +126,7 @@ return [
'size' => 20,
'max' => 255,
'eval' => 'trim,required',
]
],
],
'link' => [
'exclude' => false,
......@@ -135,7 +136,7 @@ return [
'size' => 20,
'max' => 255,
'eval' => 'trim,required',
]
],
],
'email' => [
'exclude' => true,
......@@ -145,7 +146,7 @@ return [
'size' => 20,
'max' => 255,
'eval' => 'trim',
]
],
],
'logo' => [
'exclude' => true,
......@@ -194,4 +195,4 @@ return [
],
],
],
];
\ No newline at end of file
];
plugin.tx_randombanners {
view {
# cat=plugin.tx_randombanners/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:randombanners/Resources/Private/Templates/
# cat=plugin.tx_randombanners/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:randombanners/Resources/Private/Partials/
# cat=plugin.tx_randombanners/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:randombanners/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_randombanners//a; type=int+; label=Default storage PID
storagePid =
}
}
\ No newline at end of file
view {
# cat=plugin.tx_randombanners/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:randombanners/Resources/Private/Templates/
# cat=plugin.tx_randombanners/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:randombanners/Resources/Private/Partials/
# cat=plugin.tx_randombanners/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:randombanners/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_randombanners//a; type=int+; label=Default storage PID
storagePid =
}
}