@@ -49,6 +49,11 @@ class ListCollections implements Executable
49
49
*
50
50
* Supported options:
51
51
*
52
+ * * authorizedCollections (boolean): Determines which collections are
53
+ * returned based on the user privileges.
54
+ *
55
+ * For servers < 4.0, this option is ignored.
56
+ *
52
57
* * filter (document): Query by which to filter collections.
53
58
*
54
59
* * maxTimeMS (integer): The maximum amount of time to allow the query to
@@ -68,6 +73,10 @@ class ListCollections implements Executable
68
73
*/
69
74
public function __construct ($ databaseName , array $ options = [])
70
75
{
76
+ if (isset ($ options ['authorizedCollections ' ]) && ! is_bool ($ options ['authorizedCollections ' ])) {
77
+ throw InvalidArgumentException::invalidType ('"authorizedCollections" option ' , $ options ['authorizedCollections ' ], 'boolean ' );
78
+ }
79
+
71
80
if (isset ($ options ['filter ' ]) && ! is_array ($ options ['filter ' ]) && ! is_object ($ options ['filter ' ])) {
72
81
throw InvalidArgumentException::invalidType ('"filter" option ' , $ options ['filter ' ], 'array or object ' );
73
82
}
@@ -104,12 +113,10 @@ public function execute(Server $server)
104
113
$ cmd ['filter ' ] = (object ) $ this ->options ['filter ' ];
105
114
}
106
115
107
- if (isset ($ this ->options ['maxTimeMS ' ])) {
108
- $ cmd ['maxTimeMS ' ] = $ this ->options ['maxTimeMS ' ];
109
- }
110
-
111
- if (isset ($ this ->options ['nameOnly ' ])) {
112
- $ cmd ['nameOnly ' ] = $ this ->options ['nameOnly ' ];
116
+ foreach (['authorizedCollections ' , 'maxTimeMS ' , 'nameOnly ' ] as $ option ) {
117
+ if (isset ($ this ->options [$ option ])) {
118
+ $ cmd [$ option ] = $ this ->options [$ option ];
119
+ }
113
120
}
114
121
115
122
$ cursor = $ server ->executeReadCommand ($ this ->databaseName , new Command ($ cmd ), $ this ->createOptions ());
0 commit comments