Commit 330cf9fe authored by Marco Huber's avatar Marco Huber

[TASK] Update for TYPO3 10

parent ba3cb149
<?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.'
......
......@@ -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;
......
......@@ -25,7 +25,7 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
* name
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $name;
......@@ -33,7 +33,7 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
* logo
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $logo;
......@@ -41,7 +41,7 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
* personalMembership
*
* @var bool
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $personalMembership;
......@@ -49,7 +49,7 @@ class Membership extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
* noFilter
*
* @var bool
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $noFilter;
......
<?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
{
"name": "t3o/t3o_membership",
"name": "t3o/t3o-membership",
"description": "Renders the membership listing",
"authors": [
{
......@@ -23,7 +23,7 @@
"issues": "https://git-t3o.typo3.org/t3o/t3o_membership/issues"
},
"require": {
"typo3/cms-core": "8.5.0 - 9.9.99",
"typo3/cms-core": "10.3.0 - 10.9.99",
"lukebaird/dropbox-v2-php-sdk": "^1.1"
},
"autoload": {
......@@ -33,6 +33,6 @@
},
"replace": {
"t3o_membership": "self.version",
"typo3-ter/t3o_membership": "self.version"
"typo3-ter/t3o-membership": "self.version"
}
}
......@@ -10,7 +10,7 @@
# "version" and "dependencies" must not be touched!
########################################################################
$EM_CONF[$_EXTKEY] = array(
$EM_CONF['t3o_membership'] = array(
'title' => 'TYPO3 Membership',
'description' => 'Provides the TYPO3 association members and an import/export possibility',
'category' => 'plugin',
......@@ -27,7 +27,7 @@ $EM_CONF[$_EXTKEY] = array(
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '2.1.0',
'version' => '2.1.1',
'constraints' => array(
'depends' => array(),
'conflicts' => array(),
......
......@@ -4,23 +4,15 @@ if (!defined('TYPO3_MODE')) {
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'T3o.'.$_EXTKEY,
'T3oMembership',
'List',
array(
'Member' => 'list',
\T3o\T3oMembership\Domain\Model\Member::class => 'list',
),
// non-cacheable actions
array(
'Member' => 'list',
\T3o\T3oMembership\Domain\Model\Member::class => 'list',
)
);
// Import members
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\T3o\T3oMembership\Task\ImportMembersTask::class] = array(
'extension' => $_EXTKEY,
'title' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_db.xlf:tx_t3omembership_task_importmemberstask.name',
'description' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_db.xlf:tx_t3omembership_task_importmemberstask.description',
'additionalFields' => \T3o\T3oMembership\Task\ImportMembersTaskAdditionalFieldProvider::class
);
......@@ -2,17 +2,6 @@
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'T3o.' . $_EXTKEY,
'List',
'Association member list'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
$_EXTKEY,
'Configuration/TypoScript',
'TYPO3 Membership'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
'tx_t3omembership_domain_model_member',
......
Markdown is supported
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