Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MailtemplateList | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| prioritizeByName | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsentities\Collection; |
| 4 | |
| 5 | class MailtemplateList extends Base |
| 6 | { |
| 7 | public const ENTITY_CLASS = '\BO\Zmsentities\Mailtemplate'; |
| 8 | |
| 9 | public function prioritizeByName(array $priorityNames) |
| 10 | { |
| 11 | $prioritized = []; |
| 12 | $others = []; |
| 13 | |
| 14 | foreach ($this as $key => $mailtemplate) { |
| 15 | $name = $mailtemplate->name; |
| 16 | if (in_array($name, $priorityNames)) { |
| 17 | $index = array_search($name, $priorityNames); |
| 18 | $prioritized[$index] = $mailtemplate; |
| 19 | } else { |
| 20 | $others[$key] = $mailtemplate; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | ksort($prioritized); |
| 25 | |
| 26 | $mergedList = array_merge($prioritized, $others); |
| 27 | |
| 28 | $this->exchangeArray($mergedList); |
| 29 | |
| 30 | return $this; |
| 31 | } |
| 32 | } |