From b0ea3ad3366a59fa501112dcb54ede31ed2ece90 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Wed, 22 Apr 2020 18:20:06 +0200 Subject: [PATCH] [TASK] Add sort order configuration to plugin Related: #79 --- Classes/Controller/ActionController.php | 7 ++++--- Classes/Domain/Model/Dto/Demand.php | 21 +++++++++++++++++++ .../Domain/Repository/CompanyRepository.php | 8 +++++++ .../Domain/Repository/ContactRepository.php | 8 +++++++ Configuration/FlexForms/CompaniesPlugin.xml | 19 +++++++++++++++++ Configuration/FlexForms/ContactsPlugin.xml | 19 +++++++++++++++++ .../Private/Language/de.locallang_be.xlf | 16 ++++++++++++++ Resources/Private/Language/locallang_be.xlf | 12 +++++++++++ ext_emconf.php | 2 +- 9 files changed, 108 insertions(+), 4 deletions(-) diff --git a/Classes/Controller/ActionController.php b/Classes/Controller/ActionController.php index e118516..c0aa0f4 100644 --- a/Classes/Controller/ActionController.php +++ b/Classes/Controller/ActionController.php @@ -38,10 +38,11 @@ public function injectCategoryRepository(CategoryRepository $categoryRepository) */ protected function createDemandObjectFromSettings(array $settings) : Demand { - $demand = $this->objectManager->get( - Demand::class - ); + $demand = new Demand(); $this->addCategoriesToDemandObjectFromSettings($demand); + if ($this->settings['orderBy']) { + $demand->setOrderBy($this->settings['orderBy']); + } $arguments = $this->request->getArguments(); diff --git a/Classes/Domain/Model/Dto/Demand.php b/Classes/Domain/Model/Dto/Demand.php index 88c1270..9cd0984 100644 --- a/Classes/Domain/Model/Dto/Demand.php +++ b/Classes/Domain/Model/Dto/Demand.php @@ -37,6 +37,11 @@ class Demand extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity */ protected $class = ''; + /** + * @var string + */ + protected $orderBy = ''; + /** * @return string */ @@ -126,4 +131,20 @@ public function setActionAndClass($action, $class) $this->action = $action; $this->class = $class; } + + /** + * @return string + */ + public function getOrderBy(): string + { + return $this->orderBy; + } + + /** + * @param string $orderBy + */ + public function setOrderBy(string $orderBy): void + { + $this->orderBy = $orderBy; + } } diff --git a/Classes/Domain/Repository/CompanyRepository.php b/Classes/Domain/Repository/CompanyRepository.php index b8b37c4..7e44779 100755 --- a/Classes/Domain/Repository/CompanyRepository.php +++ b/Classes/Domain/Repository/CompanyRepository.php @@ -57,6 +57,14 @@ public function findDemanded(Demand $demand) ); } + if (!empty($demand->getOrderBy())) { + $query->setOrderings( + [ + $demand->getOrderBy() => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING + ] + ); + } + return $query->execute(); } diff --git a/Classes/Domain/Repository/ContactRepository.php b/Classes/Domain/Repository/ContactRepository.php index 62c68a6..3a4d037 100755 --- a/Classes/Domain/Repository/ContactRepository.php +++ b/Classes/Domain/Repository/ContactRepository.php @@ -58,6 +58,14 @@ public function findDemanded(Demand $demand) ); } + if (!empty($demand->getOrderBy())) { + $query->setOrderings( + [ + $demand->getOrderBy() => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING + ] + ); + } + return $query->execute(); } diff --git a/Configuration/FlexForms/CompaniesPlugin.xml b/Configuration/FlexForms/CompaniesPlugin.xml index 770aabb..29112d8 100755 --- a/Configuration/FlexForms/CompaniesPlugin.xml +++ b/Configuration/FlexForms/CompaniesPlugin.xml @@ -30,6 +30,25 @@ + + + + + select + + + + + + + LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.companies.action.company.list.orderBy.name + name + + + + + + diff --git a/Configuration/FlexForms/ContactsPlugin.xml b/Configuration/FlexForms/ContactsPlugin.xml index a90e65c..0f4a36a 100755 --- a/Configuration/FlexForms/ContactsPlugin.xml +++ b/Configuration/FlexForms/ContactsPlugin.xml @@ -31,6 +31,25 @@ + + + + + select + + + + + + + LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name + last_name + + + + + + diff --git a/Resources/Private/Language/de.locallang_be.xlf b/Resources/Private/Language/de.locallang_be.xlf index aef6172..7be0831 100644 --- a/Resources/Private/Language/de.locallang_be.xlf +++ b/Resources/Private/Language/de.locallang_be.xlf @@ -55,6 +55,14 @@ Standard + + Sort Order + Sortierreihenfolge + + + Last Name + Nachname + Categories Kategorie @@ -64,6 +72,14 @@ mit Unterkategorien + + Sort Order + Sortierreihenfolge + + + Name + Name + Categories Kategorie diff --git a/Resources/Private/Language/locallang_be.xlf b/Resources/Private/Language/locallang_be.xlf index 40b620b..ff1184c 100644 --- a/Resources/Private/Language/locallang_be.xlf +++ b/Resources/Private/Language/locallang_be.xlf @@ -40,6 +40,12 @@ Default + + Sort Order + + + Last Name + Categories @@ -47,6 +53,12 @@ with Subcategories + + Sort Order + + + Name + Categories diff --git a/ext_emconf.php b/ext_emconf.php index ff01d2a..f931aa6 100755 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,7 +17,7 @@ 'modify_tables' => '', 'clearCacheOnLoad' => 0, 'lockType' => '', - 'version' => '2.6.1', + 'version' => '2.7.0', 'constraints' => [ 'depends' => [ 'typo3' => '8.7.0-8.7.99',