Skip to content

Commit 41ec981

Browse files
committed
[TASK] Add sort order configuration to plugin
Related: #79
1 parent 015a8cf commit 41ec981

File tree

16 files changed

+540
-15
lines changed

16 files changed

+540
-15
lines changed

Classes/Controller/ActionController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public function injectCategoryRepository(CategoryRepository $categoryRepository)
3838
*/
3939
protected function createDemandObjectFromSettings(array $settings) : Demand
4040
{
41-
$demand = $this->objectManager->get(
42-
Demand::class
43-
);
41+
$demand = new Demand();
4442
$this->addCategoriesToDemandObjectFromSettings($demand);
43+
if ($this->settings['orderBy']) {
44+
$demand->setOrderBy($this->settings['orderBy']);
45+
}
4546

4647
$arguments = $this->request->getArguments();
4748

Classes/Controller/AddressController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public function injectZipRepository(ZipRepository $zipRepository)
4848

4949
public function searchAction()
5050
{
51-
/** @var AddressSearch $addressSearch */
52-
$addressSearch = $this->objectManager->get(AddressSearch::class);
51+
$addressSearch = new AddressSearch();
5352
if ($this->settings['orderBy']) {
5453
$addressSearch->setOrderBy($this->settings['orderBy']);
5554
if ($this->settings['fallbackOrderBy']) {

Classes/Domain/Model/Contact.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function getLastName()
167167
* @param string $seperator
168168
* @return string
169169
*/
170-
public function getFullName(string $seperator)
170+
public function getFullName(string $seperator = ' ')
171171
{
172172
return implode($seperator, [$this->getFirstName(), $this->getLastName()]);
173173
}
@@ -176,7 +176,7 @@ public function getFullName(string $seperator)
176176
* @param string $seperator
177177
* @return string
178178
*/
179-
public function getTitleFullName(string $seperator)
179+
public function getTitleFullName(string $seperator = ' ')
180180
{
181181
$titleFullName = [];
182182
if ($this->getTitle()) {

Classes/Domain/Model/Dto/Demand.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class Demand
3737
*/
3838
protected $class = '';
3939

40+
/**
41+
* @var string
42+
*/
43+
protected $orderBy = '';
44+
4045
/**
4146
* @return string
4247
*/
@@ -126,4 +131,20 @@ public function setActionAndClass($action, $class): void
126131
$this->action = $action;
127132
$this->class = $class;
128133
}
134+
135+
/**
136+
* @return string
137+
*/
138+
public function getOrderBy(): string
139+
{
140+
return $this->orderBy;
141+
}
142+
143+
/**
144+
* @param string $orderBy
145+
*/
146+
public function setOrderBy(string $orderBy): void
147+
{
148+
$this->orderBy = $orderBy;
149+
}
129150
}

Classes/Domain/Repository/CompanyRepository.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public function findDemanded(Demand $demand)
5757
);
5858
}
5959

60+
if (!empty($demand->getOrderBy())) {
61+
$query->setOrderings(
62+
[
63+
$demand->getOrderBy() => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
64+
]
65+
);
66+
}
67+
6068
return $query->execute();
6169
}
6270

Classes/Domain/Repository/ContactRepository.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ public function findDemanded(Demand $demand)
5858
);
5959
}
6060

61+
if (!empty($demand->getOrderBy())) {
62+
$query->setOrderings(
63+
[
64+
$demand->getOrderBy() => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
65+
]
66+
);
67+
}
68+
6169
return $query->execute();
6270
}
6371

Configuration/FlexForms/CompaniesPlugin.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@
3030
</TCEforms>
3131
</switchableControllerActions>
3232

33+
<settings.orderBy>
34+
<TCEforms>
35+
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.companies.action.company.list.orderBy</label>
36+
<config>
37+
<type>select</type>
38+
<items>
39+
<numIndex index="0" type="array">
40+
<numIndex index="0"></numIndex>
41+
<numIndex index="1"></numIndex>
42+
</numIndex>
43+
<numIndex index="2">
44+
<numIndex index="0">LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.companies.action.company.list.orderBy.name</numIndex>
45+
<numIndex index="1">name</numIndex>
46+
</numIndex>
47+
</items>
48+
</config>
49+
</TCEforms>
50+
</settings.orderBy>
51+
3352
<settings.companyUids>
3453
<TCEforms>
3554
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_db.xlf:tx_contacts_domain_model_company</label>

Configuration/FlexForms/ContactsPlugin.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@
3131
</TCEforms>
3232
</switchableControllerActions>
3333

34+
<settings.orderBy>
35+
<TCEforms>
36+
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.contacts.action.contact.list.orderBy</label>
37+
<config>
38+
<type>select</type>
39+
<items>
40+
<numIndex index="0" type="array">
41+
<numIndex index="0"></numIndex>
42+
<numIndex index="1"></numIndex>
43+
</numIndex>
44+
<numIndex index="2">
45+
<numIndex index="0">LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name</numIndex>
46+
<numIndex index="1">last_name</numIndex>
47+
</numIndex>
48+
</items>
49+
</config>
50+
</TCEforms>
51+
</settings.orderBy>
52+
3453
<settings.contactUids>
3554
<TCEforms>
3655
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_db.xlf:tx_contacts_domain_model_contact</label>

Resources/Private/Language/de.locallang_be.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@
8787
<target>Detailseite</target>
8888
</trans-unit>
8989

90+
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy">
91+
<source>Sort Order</source>
92+
<target>Sortierreihenfolge</target>
93+
</trans-unit>
94+
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name">
95+
<source>Last Name</source>
96+
<target>Nachname</target>
97+
</trans-unit>
9098
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.categories">
9199
<source>Categories</source>
92100
<target>Kategorie</target>
@@ -96,6 +104,14 @@
96104
<target>mit Unterkategorien</target>
97105
</trans-unit>
98106

107+
<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy">
108+
<source>Sort Order</source>
109+
<target>Sortierreihenfolge</target>
110+
</trans-unit>
111+
<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy.name">
112+
<source>Name</source>
113+
<target>Name</target>
114+
</trans-unit>
99115
<trans-unit id="tx_contacts.plugin.companies.action.company.list.categories">
100116
<source>Categories</source>
101117
<target>Kategorie</target>

Resources/Private/Language/locallang_be.xlf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,25 @@
6464
<source>Detail Page</source>
6565
</trans-unit>
6666

67+
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy">
68+
<source>Sort Order</source>
69+
</trans-unit>
70+
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name">
71+
<source>Last Name</source>
72+
</trans-unit>
6773
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.categories">
6874
<source>Categories</source>
6975
</trans-unit>
7076
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.subcategories">
7177
<source>with Subcategories</source>
7278
</trans-unit>
7379

80+
<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy">
81+
<source>Sort Order</source>
82+
</trans-unit>
83+
<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy.name">
84+
<source>Name</source>
85+
</trans-unit>
7486
<trans-unit id="tx_contacts.plugin.companies.action.company.list.categories">
7587
<source>Categories</source>
7688
</trans-unit>

0 commit comments

Comments
 (0)