@@ -31,55 +31,55 @@ |
||
31 | 31 | |
32 | 32 | class ShareRecipientSorter implements ISorter { |
33 | 33 | |
34 | - /** @var IManager */ |
|
35 | - private $shareManager; |
|
36 | - /** @var Folder */ |
|
37 | - private $userFolder; |
|
34 | + /** @var IManager */ |
|
35 | + private $shareManager; |
|
36 | + /** @var Folder */ |
|
37 | + private $userFolder; |
|
38 | 38 | |
39 | - public function __construct(IManager $shareManager, Folder $userFolder) { |
|
40 | - $this->shareManager = $shareManager; |
|
41 | - $this->userFolder = $userFolder; |
|
42 | - } |
|
39 | + public function __construct(IManager $shareManager, Folder $userFolder) { |
|
40 | + $this->shareManager = $shareManager; |
|
41 | + $this->userFolder = $userFolder; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getId() { |
|
45 | - return 'share-recipients'; |
|
46 | - } |
|
44 | + public function getId() { |
|
45 | + return 'share-recipients'; |
|
46 | + } |
|
47 | 47 | |
48 | - public function sort(array &$sortArray, array $context) { |
|
49 | - // let's be tolerant. Comments uses "files" by default, other usages are often singular |
|
50 | - if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') { |
|
51 | - return; |
|
52 | - } |
|
53 | - /** @var Node[] $nodes */ |
|
54 | - $nodes = $this->userFolder->getById((int)$context['itemId']); |
|
55 | - if(count($nodes) === 0) { |
|
56 | - return; |
|
57 | - } |
|
58 | - $al = $this->shareManager->getAccessList($nodes[0]); |
|
48 | + public function sort(array &$sortArray, array $context) { |
|
49 | + // let's be tolerant. Comments uses "files" by default, other usages are often singular |
|
50 | + if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') { |
|
51 | + return; |
|
52 | + } |
|
53 | + /** @var Node[] $nodes */ |
|
54 | + $nodes = $this->userFolder->getById((int)$context['itemId']); |
|
55 | + if(count($nodes) === 0) { |
|
56 | + return; |
|
57 | + } |
|
58 | + $al = $this->shareManager->getAccessList($nodes[0]); |
|
59 | 59 | |
60 | - foreach ($sortArray as $type => &$byType) { |
|
61 | - if(!isset($al[$type]) || !is_array($al[$type])) { |
|
62 | - continue; |
|
63 | - } |
|
64 | - usort($byType, function ($a, $b) use ($al, $type) { |
|
65 | - return $this->compare($a, $b, $al[$type]); |
|
66 | - }); |
|
67 | - } |
|
68 | - } |
|
60 | + foreach ($sortArray as $type => &$byType) { |
|
61 | + if(!isset($al[$type]) || !is_array($al[$type])) { |
|
62 | + continue; |
|
63 | + } |
|
64 | + usort($byType, function ($a, $b) use ($al, $type) { |
|
65 | + return $this->compare($a, $b, $al[$type]); |
|
66 | + }); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @param array $a |
|
72 | - * @param array $b |
|
73 | - * @param array $al |
|
74 | - * @return int |
|
75 | - */ |
|
76 | - protected function compare(array $a, array $b, array $al) { |
|
77 | - $a = $a['value']['shareWith']; |
|
78 | - $b = $b['value']['shareWith']; |
|
70 | + /** |
|
71 | + * @param array $a |
|
72 | + * @param array $b |
|
73 | + * @param array $al |
|
74 | + * @return int |
|
75 | + */ |
|
76 | + protected function compare(array $a, array $b, array $al) { |
|
77 | + $a = $a['value']['shareWith']; |
|
78 | + $b = $b['value']['shareWith']; |
|
79 | 79 | |
80 | - $valueA = (int)in_array($a, $al, true); |
|
81 | - $valueB = (int)in_array($b, $al, true); |
|
80 | + $valueA = (int)in_array($a, $al, true); |
|
81 | + $valueB = (int)in_array($b, $al, true); |
|
82 | 82 | |
83 | - return $valueB - $valueA; |
|
84 | - } |
|
83 | + return $valueB - $valueA; |
|
84 | + } |
|
85 | 85 | } |
@@ -47,21 +47,21 @@ discard block |
||
47 | 47 | |
48 | 48 | public function sort(array &$sortArray, array $context) { |
49 | 49 | // let's be tolerant. Comments uses "files" by default, other usages are often singular |
50 | - if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') { |
|
50 | + if ($context['itemType'] !== 'files' && $context['itemType'] !== 'file') { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | /** @var Node[] $nodes */ |
54 | - $nodes = $this->userFolder->getById((int)$context['itemId']); |
|
55 | - if(count($nodes) === 0) { |
|
54 | + $nodes = $this->userFolder->getById((int) $context['itemId']); |
|
55 | + if (count($nodes) === 0) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | $al = $this->shareManager->getAccessList($nodes[0]); |
59 | 59 | |
60 | 60 | foreach ($sortArray as $type => &$byType) { |
61 | - if(!isset($al[$type]) || !is_array($al[$type])) { |
|
61 | + if (!isset($al[$type]) || !is_array($al[$type])) { |
|
62 | 62 | continue; |
63 | 63 | } |
64 | - usort($byType, function ($a, $b) use ($al, $type) { |
|
64 | + usort($byType, function($a, $b) use ($al, $type) { |
|
65 | 65 | return $this->compare($a, $b, $al[$type]); |
66 | 66 | }); |
67 | 67 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | $a = $a['value']['shareWith']; |
78 | 78 | $b = $b['value']['shareWith']; |
79 | 79 | |
80 | - $valueA = (int)in_array($a, $al, true); |
|
81 | - $valueB = (int)in_array($b, $al, true); |
|
80 | + $valueA = (int) in_array($a, $al, true); |
|
81 | + $valueB = (int) in_array($b, $al, true); |
|
82 | 82 | |
83 | 83 | return $valueB - $valueA; |
84 | 84 | } |
@@ -33,18 +33,18 @@ |
||
33 | 33 | */ |
34 | 34 | interface ISorter { |
35 | 35 | |
36 | - /** |
|
37 | - * @return string The ID of the sorter, e.g. commenters |
|
38 | - * @since 13.0.0 |
|
39 | - */ |
|
40 | - public function getId(); |
|
36 | + /** |
|
37 | + * @return string The ID of the sorter, e.g. commenters |
|
38 | + * @since 13.0.0 |
|
39 | + */ |
|
40 | + public function getId(); |
|
41 | 41 | |
42 | - /** |
|
43 | - * executes the sort action |
|
44 | - * |
|
45 | - * @param array $sortArray the array to be sorted, provided as reference |
|
46 | - * @param array $context carries key 'itemType' and 'itemId' of the source object (e.g. a file) |
|
47 | - * @since 13.0.0 |
|
48 | - */ |
|
49 | - public function sort(array &$sortArray, array $context); |
|
42 | + /** |
|
43 | + * executes the sort action |
|
44 | + * |
|
45 | + * @param array $sortArray the array to be sorted, provided as reference |
|
46 | + * @param array $context carries key 'itemType' and 'itemId' of the source object (e.g. a file) |
|
47 | + * @since 13.0.0 |
|
48 | + */ |
|
49 | + public function sort(array &$sortArray, array $context); |
|
50 | 50 | } |