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

Merge branch '38-update-for-typo3-v10' into 'master'

Resolve "Update for TYPO3 v10"

Closes #38

See merge request t3o/t3o_membership!9
parents ba3cb149 aaff73d3
<?php
namespace T3o\T3oMembership\Task;
namespace T3o\T3oMembership\Command;
use Dropbox\Dropbox;
use TYPO3\CMS\Core\Database\Connection;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Scheduler\Task;
/**
* This file is part of the TYPO3 CMS project.
......@@ -21,7 +23,7 @@ use TYPO3\CMS\Extbase\Scheduler\Task;
*
* The TYPO3 project - inspiring people to share!
*/
class ImportMembersTask extends Task
class ImportMembersCommand extends \Symfony\Component\Console\Command\Command
{
/**
* @var array
......@@ -49,10 +51,37 @@ class ImportMembersTask extends Task
protected $memberships = array();
/**
* @return boolean
* Configure the command by defining the name, options and arguments
*/
public function execute()
protected function configure()
{
$this->setDescription('Import members');
//$this->setHelp('Meaningful help text');
$this->addArgument(
'importFile',
InputArgument::REQUIRED
);
$this->addArgument(
'membershipStoragePid',
InputArgument::REQUIRED
);
$this->addArgument(
'dropboxToken',
InputArgument::REQUIRED
);
}
/**
* Executes the command
*
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->title($this->getDescription());
/** @var $logger \TYPO3\CMS\Core\Log\Logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
$logger->debug('Execute');
......@@ -136,7 +165,7 @@ class ImportMembersTask extends Task
}
}
return true;
$io->writeln('Finished.');
}
/**
......@@ -238,7 +267,7 @@ class ImportMembersTask extends Task
return;
}
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['t3omembership']['importMemberTaksHooks'] as $classData) {
$hookObject = GeneralUtility::getUserObj($classData);
$hookObject = GeneralUtility::makeInstance($classData);
if (!is_object($hookObject)) {
throw new \UnexpectedValueException( // @TODO Namespace?
'The hook object class ' . $classData . ' could not be instantiated.'
......
......@@ -67,7 +67,7 @@ class MemberController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
*
* @return void
*/
public function listAction()
public function listAction(): void
{
$filterMembership = 0;
$filterString = '';
......@@ -80,6 +80,12 @@ class MemberController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
$this->view->assign('selectedMembership', $filterMembership);
}
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$this->memberRepository->setDefaultQuerySettings($querySettings);
$this->membershipRepository->setDefaultQuerySettings($querySettings);
if ($filterString || $filterMembership) {
$members = $this->memberRepository->findByStringAndMembership($filterString, $filterMembership);
} else {
......
......@@ -2,6 +2,7 @@
namespace T3o\T3oMembership\Domain\Model;
use Typo3Agencies\Domain\Model\Agency;
use TYPO3\CMS\Extbase\Annotation as Extbase;
/**
* This file is part of the TYPO3 CMS project.
......@@ -27,7 +28,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* Member name
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $name;
......@@ -35,7 +36,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* externalId
*
* @var integer
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $externalId;
......@@ -43,7 +44,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* endDate
*
* @var \DateTime
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $endDate;
......@@ -51,7 +52,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* address
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $address;
......@@ -59,7 +60,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* zip
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $zip;
......@@ -67,7 +68,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* city
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $city;
......@@ -75,7 +76,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* country
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $country;
......@@ -83,7 +84,7 @@ class Member extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* email
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $email;
......
<?php
namespace T3o\T3oMembership\Domain\Model;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Extbase\Annotation as Extbase;
/**
* Class \T3oMembership\Domain\Model\Membership
......@@ -25,23 +27,15 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
* name
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $name;
/**
* logo
*
* @var string
* @validate NotEmpty
*/
protected $logo;
/**
* personalMembership
*
* @var bool
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $personalMembership;
......@@ -49,7 +43,7 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
* noFilter
*
* @var bool
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $noFilter;
......@@ -105,27 +99,6 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
$this->name = $name;
}
/**
* Returns the logo
*
* @return string $logo
*/
public function getLogo()
{
return $this->logo;
}
/**
* Sets the logo
*
* @param string $logo
* @return void
*/
public function setLogo($logo)
{
$this->logo = $logo;
}
/**
* Returns the status of a membership (personal or company)
*
......@@ -137,7 +110,7 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
}
/**
* Sets the logo
* Sets the status of a membership (personal or company)
*
* @param bool $personalMembership
* @return void
......
......@@ -23,11 +23,10 @@ use TYPO3\CMS\Extbase\Persistence\QueryInterface;
*/
class MembershipRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* @var array
*/
protected $defaultOrderings = array(
'uid' => QueryInterface::ORDER_ASCENDING
);
}
\ No newline at end of file
}
<?php
namespace T3o\T3oMembership\Task;
use TYPO3\CMS\Scheduler\Task\AbstractTask;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class ImportMembersTaskAdditionalFieldProvider
*
* @author Thomas Löffler <thomas.loeffler@typo3.org>
*/
class ImportMembersTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
{
/**
* Gets additional fields to render in the form to add/edit a task
*
* @param array $taskInfo Reference to the array containing the info used in the add/edit form
* @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
* @return array Array containing all the information pertaining to the additional fields
*/
public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
{
$additionalFields = array();
// adds field for setting file path for CSV file to import
$fieldID = 'task_importFile';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[importFile]" id="' . $fieldID . '" value="' . $task->importFile . '" size="120">';
// adds field for setting storage PID
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang.xlf:importFile',
);
$fieldID = 'task_membershipStoragePid';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[membershipStoragePid]" id="' . $fieldID . '" value="' . (int)$task->membershipStoragePid . '" size="30">';
// adds field for setting storage PID
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang.xlf:storagePid'
);
$fieldID = 'task_dropboxToken';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[dropboxToken]" id="' . $fieldID . '" value="' . $task->dropboxToken . '" size="120">';
// adds field for dropboxToken setting
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang.xlf:dropboxToken'
);
return $additionalFields;
}
/**
* This method checks any additional data that is relevant to the specific task
* If the task class is not relevant, the method is expected to return TRUE
*
* @param array $submittedData Reference to the array containing the data submitted by the user
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module)
* @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
*/
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
{
// only validation for importFile would be a file_exists, but it will be validated in the task itself
return true;
}
/**
* This method is used to save any additional input into the current task object
* if the task class matches
*
* @param array $submittedData Array containing the data submitted by the user
* @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
*/
public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task){
$task->importFile = $submittedData['importFile'];
$task->membershipStoragePid = $submittedData['membershipStoragePid'];
$task->dropboxToken = $submittedData['dropboxToken'];
}
}
<?php
return [
't3omembership:importmembers' => [
'class' => \T3o\T3oMembership\Command\ImportMembersCommand::class,
'schedulable' => true,
],
];
\ No newline at end of file
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
't3o_membership',
'Configuration/TypoScript',
'TYPO3 Membership'
);
\ No newline at end of file
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'T3oMembership',
'List',
'Association member list'
);
\ No newline at end of file
......@@ -3,278 +3,264 @@ if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$tca = array(
'ctrl' => array(
'title' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang_db.xlf:tx_t3omembership_domain_model_member',
'label' => 'name',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_t3omembership_domain_model_member',
'EXT:t3o_membership/Resources/Private/Language/locallang_csh_tx_t3omembership_domain_model_member.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_t3omembership_domain_model_member');
return [
'ctrl' => [
'title' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang_db.xlf:tx_t3omembership_domain_model_member',
'label' => 'name',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'dividers2tabs' => true,
'origUid' => 't3_origuid',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'origUid' => 't3_origuid',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'delete' => 'deleted',
'enablecolumns' => array(
'disabled' => 'hidden',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
),
'searchFields' => 'name,external_id,end_date,address,zip,city,country,email,url,membership,',
'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3o_membership') . 'Configuration/TCA/tx_t3omembership_domain_model_member.php',
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3o_membership') . 'Resources/Public/Icons/tx_t3omembership_domain_model_member.gif'
),
'interface' => array(
'endtime' => 'endtime',
],
'searchFields' => 'name,external_id,end_date,address,zip,city,country,email,url,membership,',
'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3o_membership') . 'Configuration/TCA/tx_t3omembership_domain_model_member.php',
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('t3o_membership') . 'Resources/Public/Icons/tx_t3omembership_domain_model_member.gif'
],
'interface' => [
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, firstname, lastname, external_id, end_date, address, zip, city, country, email, invoice_email, url, membership, logo',
),
'types' => array(
'1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, name, firstname, lastname, external_id, subscription_no, end_date, address, zip, city, country, email, invoice_email, url, membership, logo,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,starttime, endtime'),
),
'palettes' => array(
'1' => array('showitem' => ''),
),
'columns' => array(
'sys_language_uid' => array(
],
'types' => [
'1' => ['showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, name, firstname, lastname, external_id, subscription_no, end_date, address, zip, city, country, email, invoice_email, url, membership, logo,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,starttime, endtime'],
],
'palettes' => [
'1' => ['showitem' => ''],
],
'columns' => [
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => array(
'config' => [
'type' => 'select',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => array(
array('LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1),
array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0)
),
),
),
'l10n_parent' => array(
'items' => [
['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1],
['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0]
],
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
'config' => array(
'config' => [
'type' => 'select',
'items' => array(
array('', 0),
),
'items' => [
['', 0],
],
'foreign_table' => 'tx_t3omembership_domain_model_member',
'foreign_table_where' => 'AND tx_t3omembership_domain_model_member.pid=###CURRENT_PID### AND tx_t3omembership_domain_model_member.sys_language_uid IN (-1,0)',
),
),
'l10n_diffsource' => array(
'config' => array(
],
],
'l10n_diffsource' => [
'config' => [
'type' => 'passthrough',
),
),
'hidden' => array(
],
],
'hidden' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden',
'config' => array(
'config' => [
'type' => 'check',
),
),
'starttime' => array(
],
],
'starttime' => [
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime',
'config' => array(
'config' => [
'type' => 'input',
'size' => 13,
'max' => 20,
'eval' => 'datetime',
'checkbox' => 0,
'default' => 0,
'range' => array(
'range' => [
'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
),
),
),
'endtime' => array(
],
],
],
'endtime' => [
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime',
'config' => array(
'config' => [
'type' => 'input',
'size' => 13,
'max' => 20,
'eval' => 'datetime',
'checkbox' => 0,
'default' => 0,
'range' => array(
'range' => [
'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
),
),
),
'name' => array(
],
],
],
'name' => [