-
Notifications
You must be signed in to change notification settings - Fork 55
Updated folder methods #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -307,6 +307,55 @@ public function getFolder($identifier, $options = []) | |
| return $response; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Apply a set of field changes to a folder. | ||
| * | ||
| * $foldersFields are the contents of the <Updates> element, e.g. | ||
| * [ | ||
| * 'FieldURI' => ['FieldURI' => 'folder:DisplayName'], | ||
| * 'Folder' =>['DisplayName' => 'New Folder Name'], | ||
| * ]; | ||
| * | ||
| * @param BaseFolderIdType $folderId | ||
| * @param array $foldersFields | ||
| * @param array $options | ||
| * @return Type\BaseFolderType[]|Type | ||
| */ | ||
| public function updateFolder(BaseFolderIdType $folderId, $foldersFields, $options = []) | ||
| { | ||
| $folderChange = $folderId->toArray(true); | ||
| $folderChange['Updates'] =['SetFolderField' => $foldersFields]; | ||
| $request = [ | ||
| 'FolderChanges' => [ | ||
| 'FolderChange' => $folderChange | ||
| ] | ||
| ]; | ||
|
|
||
| $request = array_replace_recursive($request, $options); | ||
|
|
||
| $request = Type::buildFromArray($request); | ||
|
|
||
| try { | ||
| $response = $this->getClient()->UpdateFolder($request); | ||
| } catch (API\Exception $e) { | ||
| // Exchange renames the folder but returns ErrorInternalServerError | ||
| // ("Value cannot be null. (Parameter 'participantResolver')") on | ||
| // cold/app-only mailboxes. The write succeeds, so verify the folder | ||
| // instead of failing outright; rethrow anything else. | ||
| if (stripos($e->getMessage(), 'internal server error') === false) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last one, the |
||
| throw $e; | ||
| } | ||
|
|
||
| return Utilities\ensureIsArray($this->getFolder($folderId->toArray(true))); | ||
| } | ||
|
|
||
| if ($response instanceof FolderInfoResponseMessageType) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jboomer007 thanks for the new commit. A few small things still need to be sorted out before we ask for another review from @Garethp First, there's a bug here: you check |
||
| return $response->getFolders(); | ||
| } | ||
| return Utilities\ensureIsArray($response); | ||
| } | ||
|
|
||
| /** | ||
| * Get a folder by it's distinguishedId | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second, it's still only handling
SetFolderField. To really match howupdateItems()works, it would need to supportDeleteFolderFieldandAppendToFolderFieldtoo, and ideally more than one field change per call. Right now it's wider than before but still a step short of that.