From 62fb425bf2b90943e89ba621d684e187b07f8200 Mon Sep 17 00:00:00 2001 From: vgrem Date: Sat, 5 Feb 2022 19:55:58 +0200 Subject: [PATCH] Optimize odata request payload serializing, fixes for saving multi-choice field value (#261) --- ...ookupFieldValue.php => SetFieldValues.php} | 4 +- src/Outlook/OutlookItem.php | 10 +- src/Runtime/ClientObject.php | 14 +- src/Runtime/ClientResult.php | 2 +- src/Runtime/ClientValue.php | 6 +- src/Runtime/ClientValueCollection.php | 13 +- src/Runtime/OData/ODataRequest.php | 33 +---- src/Runtime/ServerTypeInfo.php | 121 ++++++++++++++++++ .../ContentTypeCreationInformation.php | 8 +- src/SharePoint/FieldCreationInformation.php | 9 +- src/SharePoint/FieldMultiChoiceValue.php | 32 +++++ src/SharePoint/FieldMultiLookupValue.php | 9 ++ src/SharePoint/Folder.php | 3 +- src/SharePoint/GroupCreationInformation.php | 8 +- src/SharePoint/ListCreationInformation.php | 9 +- src/SharePoint/ListItem.php | 18 ++- .../Portal/SPSiteCreationRequest.php | 8 +- .../Portal/SPSiteCreationResponse.php | 8 +- src/SharePoint/Portal/SPSiteManager.php | 8 +- src/SharePoint/Publishing/VideoChannel.php | 9 +- src/SharePoint/Publishing/VideoItem.php | 9 +- src/SharePoint/SPList.php | 10 +- src/SharePoint/Search/SearchRequest.php | 7 +- src/SharePoint/Search/SearchResult.php | 8 +- src/SharePoint/Taxonomy/TaxonomySession.php | 2 +- src/SharePoint/UserProfiles/ProfileLoader.php | 8 +- src/SharePoint/ViewCreationInformation.php | 9 +- 27 files changed, 290 insertions(+), 95 deletions(-) rename examples/SharePoint/ListItems/{SetLookupFieldValue.php => SetFieldValues.php} (85%) create mode 100644 src/Runtime/ServerTypeInfo.php create mode 100644 src/SharePoint/FieldMultiChoiceValue.php diff --git a/examples/SharePoint/ListItems/SetLookupFieldValue.php b/examples/SharePoint/ListItems/SetFieldValues.php similarity index 85% rename from examples/SharePoint/ListItems/SetLookupFieldValue.php rename to examples/SharePoint/ListItems/SetFieldValues.php index 195a5b3c..6026ece0 100644 --- a/examples/SharePoint/ListItems/SetLookupFieldValue.php +++ b/examples/SharePoint/ListItems/SetFieldValues.php @@ -7,6 +7,7 @@ use Office365\Runtime\Auth\ClientCredential; use Office365\SharePoint\ClientContext; use Office365\SharePoint\FieldLookupValue; +use Office365\SharePoint\FieldMultiChoiceValue; use Office365\SharePoint\FieldMultiLookupValue; use Office365\SharePoint\FieldUserValue; use Office365\SharePoint\ListItem; @@ -28,6 +29,7 @@ 'Title' => "New task N#" . rand(1, 100000), 'ParentTask' => new FieldLookupValue($taskId), 'PrimaryManager' => new FieldUserValue($me->getId()), - 'Managers' => new FieldMultiLookupValue([$me->getId()]) + 'Managers' => new FieldMultiLookupValue([$me->getId()]), + 'TaskCategories' => new FieldMultiChoiceValue(["Event", "Reminder"]) ); $item = $list->addItem($taskProps)->executeQuery(); diff --git a/src/Outlook/OutlookItem.php b/src/Outlook/OutlookItem.php index 408e0c0b..4544bee1 100644 --- a/src/Outlook/OutlookItem.php +++ b/src/Outlook/OutlookItem.php @@ -14,10 +14,7 @@ class OutlookItem extends Entity */ public function getChangeKey() { - if (!$this->isPropertyAvailable("ChangeKey")) { - return null; - } - return $this->getProperty("ChangeKey"); + return $this->getProperty("ChangeKey", null); } /** * @var string @@ -31,10 +28,7 @@ public function setChangeKey($value) */ public function getCategories() { - if (!$this->isPropertyAvailable("Categories")) { - return null; - } - return $this->getProperty("Categories"); + return $this->getProperty("Categories", null); } /** * @var array diff --git a/src/Runtime/ClientObject.php b/src/Runtime/ClientObject.php index 19f966ec..52b7f29f 100644 --- a/src/Runtime/ClientObject.php +++ b/src/Runtime/ClientObject.php @@ -127,14 +127,6 @@ public function getParentCollection() return $this->parentCollection; } - /** - * @return null - */ - protected function getServerTypeId() - { - return null; - } - /** * @return ClientRuntimeContext @@ -211,11 +203,11 @@ public function select($value) /** * Gets entity type name - * @return string + * @return ServerTypeInfo */ - public function getServerTypeName() + public function getServerTypeInfo() { - return null; + return ServerTypeInfo::resolve($this); } /** diff --git a/src/Runtime/ClientResult.php b/src/Runtime/ClientResult.php index 42b310e5..8735fa70 100644 --- a/src/Runtime/ClientResult.php +++ b/src/Runtime/ClientResult.php @@ -50,7 +50,7 @@ public function executeQuery(){ /** - * @return bool|int|ClientObject|ClientValue|string|null + * @return bool|int|string|ClientObject|ClientValue|null */ public function getValue(){ return $this->value; diff --git a/src/Runtime/ClientValue.php b/src/Runtime/ClientValue.php index b742aab2..e45c86ea 100644 --- a/src/Runtime/ClientValue.php +++ b/src/Runtime/ClientValue.php @@ -51,11 +51,11 @@ public function getProperty($name, $defaultValue=null) /** - * @return string + * @return ServerTypeInfo */ - public function getServerTypeName() + public function getServerTypeInfo() { - return null; + return ServerTypeInfo::resolve($this); } /** diff --git a/src/Runtime/ClientValueCollection.php b/src/Runtime/ClientValueCollection.php index b59246d1..6ad1f67a 100644 --- a/src/Runtime/ClientValueCollection.php +++ b/src/Runtime/ClientValueCollection.php @@ -30,7 +30,7 @@ public static function fromArray($itemTypeName,$values) /** * Adds property to collection - * @param ClientValue $value + * @param ClientValue|string $value */ public function addChild($value) { @@ -81,19 +81,12 @@ public function createType() */ function getItemTypeName() { - if(isset($this->itemTypeName)) + if(isset($this->itemTypeName)) { return $this->itemTypeName; + } return str_replace("Collection","",get_class($this)); } - /** - * @return string|null - */ - public function getServerTypeName() - { - return null; - } - /** * @return array */ diff --git a/src/Runtime/OData/ODataRequest.php b/src/Runtime/OData/ODataRequest.php index dd1ce32a..0c4c752e 100644 --- a/src/Runtime/OData/ODataRequest.php +++ b/src/Runtime/OData/ODataRequest.php @@ -75,30 +75,8 @@ public function buildRequest(){ */ public function normalizeTypeName($type) { - $collection = false; - $typeName = $type->getServerTypeName(); - if (is_null($typeName)) { - - if ($type instanceof ClientValueCollection) { - $collection = true; - $typeInfo = explode("\\", $type->getItemTypeName()); - } - else{ - $typeInfo = explode("\\", get_class($type)); - } - $typeName = end($typeInfo); - - //if ($this->context instanceof OutlookClient) - // $typeName = "#Microsoft.OutlookServices.$typeName"; - if ($this->context instanceof ClientContext) - $typeName = "SP.$typeName"; - else if ($this->context instanceof GraphServiceClient) { - $typeName = lcfirst($typeName); - $typeName = "microsoft.graph.$typeName"; - } - return $collection ? "Collection($typeName)" : $typeName; - } - return $typeName; + $typeInfo = $type->getServerTypeInfo()->patch($this->context); + return (string)$typeInfo; } @@ -119,8 +97,8 @@ protected function normalizePayload($value,ODataFormat $format) return $this->normalizePayload($property,$format); }, $value->toJson(true)); - if(!($value instanceof ClientValueCollection || $value instanceof ClientObjectCollection)) - $this->ensureAnnotation($value,$json,$format); + + $this->ensureAnnotation($value,$json,$format); return $json; } else if (is_array($value)) { return array_map(function ($item) use($format){ @@ -147,7 +125,8 @@ protected function ensureAnnotation($type, &$json,$format) } } elseif ($format instanceof JsonFormat){ - $json[$format->TypeTag] = "$typeName"; + if(!($type instanceof ClientValueCollection)) + $json[$format->TypeTag] = "$typeName"; } } diff --git a/src/Runtime/ServerTypeInfo.php b/src/Runtime/ServerTypeInfo.php new file mode 100644 index 00000000..341f19a4 --- /dev/null +++ b/src/Runtime/ServerTypeInfo.php @@ -0,0 +1,121 @@ +Namespace = $namespace; + $this->Name = $name; + $this->Id = null; + $this->Collection = $collection; + } + + /** + * @param string $value + * @return ServerTypeInfo + */ + public static function fromFullName($value){ + $parts = explode(".", $value); + $typeName = end($parts); + $namespace = implode(".", array_slice($parts, 0,-1)); + return new ServerTypeInfo($namespace, $typeName); + } + + /** + * @return ServerTypeInfo + * @throws Exception + */ + public static function primitive($typeName, $isCollection = false) + { + if (array_key_exists($typeName, self::$PrimitiveTypeMappings)) { + $primitiveTypeName = self::$PrimitiveTypeMappings[$typeName]; + return new ServerTypeInfo("Edm", $primitiveTypeName, $isCollection); + } + throw new Exception("Unknown primitive type: $typeName"); + } + + /** + * @param ClientValue|ClientObject $type + * @return ServerTypeInfo + */ + public static function resolve($type) + { + if($type instanceof ClientValueCollection || $type instanceof ClientObjectCollection){ + $itemTypeName = $type->getItemTypeName(); + $collection = true; + } + else { + $itemTypeName = get_class($type); + $collection = false; + } + $parts = explode("\\", $itemTypeName); + $typeName = end($parts); + //$namespace = implode(".", array_slice($parts, 1, count($parts) - 2)); + return new ServerTypeInfo(null, $typeName, $collection); + } + + /** + * @param ClientRuntimeContext $context + */ + public function patch($context){ + if ($context instanceof ClientContext) { + if(is_null($this->Namespace)) $this->Namespace = "SP"; + } + else if ($context instanceof GraphServiceClient) { + if(is_null($this->Namespace)) $this->Namespace = "microsoft.graph"; + $this->Name = lcfirst($this->Name); + } + return $this; + } + + public function __toString() + { + $fullName = "$this->Namespace.$this->Name"; + return $this->Collection ? "Collection($fullName)" : $fullName; + } + + + /** + * @var string + */ + public $Id; + + /** + * @var string + */ + public $Namespace; + + /** + * @var string + */ + public $Name; + + + /** + * @var boolean + */ + public $Collection; + + /** + * @var string[] + */ + static $PrimitiveTypeMappings = array( + "string" => "String", + "bool" => "Boolean", + "integer" => "Int32", + "double" => "Double" + ); + +} \ No newline at end of file diff --git a/src/SharePoint/ContentTypeCreationInformation.php b/src/SharePoint/ContentTypeCreationInformation.php index f29937df..89da38ae 100644 --- a/src/SharePoint/ContentTypeCreationInformation.php +++ b/src/SharePoint/ContentTypeCreationInformation.php @@ -3,6 +3,7 @@ namespace Office365\SharePoint; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; /** * Specifies properties that are used as parameters to initialize a new content type. @@ -15,9 +16,12 @@ public function __construct() } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "SP.ContentType"; + return new ServerTypeInfo("SP", "ContentType"); } diff --git a/src/SharePoint/FieldCreationInformation.php b/src/SharePoint/FieldCreationInformation.php index ddb34a1d..d8f7458b 100644 --- a/src/SharePoint/FieldCreationInformation.php +++ b/src/SharePoint/FieldCreationInformation.php @@ -6,6 +6,8 @@ namespace Office365\SharePoint; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; + /** * Represents properties that can be set when creating a field. */ @@ -16,9 +18,12 @@ public function __construct() parent::__construct(); } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "SP.Field"; + return new ServerTypeInfo("SP", "Field"); } /** diff --git a/src/SharePoint/FieldMultiChoiceValue.php b/src/SharePoint/FieldMultiChoiceValue.php new file mode 100644 index 00000000..ab0b2470 --- /dev/null +++ b/src/SharePoint/FieldMultiChoiceValue.php @@ -0,0 +1,32 @@ +addChild($choice); + } + } + + public function toJson() + { + return array('results' => $this->getData()); + } + + public function getServerTypeInfo() + { + return ServerTypeInfo::primitive("string",true); + } + +} \ No newline at end of file diff --git a/src/SharePoint/FieldMultiLookupValue.php b/src/SharePoint/FieldMultiLookupValue.php index 80380b52..df8ca31f 100644 --- a/src/SharePoint/FieldMultiLookupValue.php +++ b/src/SharePoint/FieldMultiLookupValue.php @@ -3,6 +3,7 @@ namespace Office365\SharePoint; use Office365\Runtime\ClientValueCollection; +use Office365\Runtime\ServerTypeInfo; class FieldMultiLookupValue extends ClientValueCollection { @@ -23,4 +24,12 @@ public function toJson() return array('results' => $lookupIds); } + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() + { + return ServerTypeInfo::primitive("integer", true); + } + } \ No newline at end of file diff --git a/src/SharePoint/Folder.php b/src/SharePoint/Folder.php index f895396b..09a53c16 100644 --- a/src/SharePoint/Folder.php +++ b/src/SharePoint/Folder.php @@ -92,8 +92,7 @@ public function rename($name) $item = $this->getListItemAllFields(); $item->setProperty('Title', $name); $item->setProperty('FileLeafRef', $name); - $qry = new UpdateEntityQuery($item); - $this->getContext()->addQueryAndResultObject($qry, $this); + $item->update(); return $this; } /** diff --git a/src/SharePoint/GroupCreationInformation.php b/src/SharePoint/GroupCreationInformation.php index 5778abd1..451bb450 100644 --- a/src/SharePoint/GroupCreationInformation.php +++ b/src/SharePoint/GroupCreationInformation.php @@ -3,6 +3,7 @@ namespace Office365\SharePoint; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; /** * An object used to facilitate creation of a cross-site group. @@ -27,9 +28,12 @@ public function __construct($title) parent::__construct(); } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "SP.Group"; + return new ServerTypeInfo("SP", "Group"); } } \ No newline at end of file diff --git a/src/SharePoint/ListCreationInformation.php b/src/SharePoint/ListCreationInformation.php index 3f785149..13dfe026 100644 --- a/src/SharePoint/ListCreationInformation.php +++ b/src/SharePoint/ListCreationInformation.php @@ -6,6 +6,8 @@ namespace Office365\SharePoint; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; + class ListCreationInformation extends ClientValue { /** @@ -47,9 +49,12 @@ public function __construct($title) parent::__construct(); } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "SP.List"; + return new ServerTypeInfo("SP", "List"); } } \ No newline at end of file diff --git a/src/SharePoint/ListItem.php b/src/SharePoint/ListItem.php index 2d9cf95f..44db850f 100644 --- a/src/SharePoint/ListItem.php +++ b/src/SharePoint/ListItem.php @@ -6,6 +6,8 @@ namespace Office365\SharePoint; use Office365\Runtime\ResourcePath; +use Office365\Runtime\ServerTypeInfo; + /** * Specifies * a list @@ -422,9 +424,12 @@ public function getFieldValuesForEdit() } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return $this->typeName; + return ServerTypeInfo::fromFullName($this->typeName); } @@ -444,6 +449,15 @@ public function setProperty($name, $value, $persistChanges = true) return $this; } + /** + * @return ListItem + */ + public function update() + { + $this->ensureTypeName($this->getParentList()); + return parent::update(); + } + /** * @var string */ diff --git a/src/SharePoint/Portal/SPSiteCreationRequest.php b/src/SharePoint/Portal/SPSiteCreationRequest.php index 1a4bb217..fa888b3f 100644 --- a/src/SharePoint/Portal/SPSiteCreationRequest.php +++ b/src/SharePoint/Portal/SPSiteCreationRequest.php @@ -3,13 +3,17 @@ namespace Office365\SharePoint\Portal; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; class SPSiteCreationRequest extends ClientValue { - function getServerTypeName() + /** + * @return ServerTypeInfo + */ + function getServerTypeInfo() { - return "Microsoft.SharePoint.Portal.SPSiteCreationRequest"; + return new ServerTypeInfo("Microsoft.SharePoint.Portal", "SPSiteCreationRequest"); } /** diff --git a/src/SharePoint/Portal/SPSiteCreationResponse.php b/src/SharePoint/Portal/SPSiteCreationResponse.php index 753c3eeb..59b5160f 100644 --- a/src/SharePoint/Portal/SPSiteCreationResponse.php +++ b/src/SharePoint/Portal/SPSiteCreationResponse.php @@ -3,12 +3,16 @@ namespace Office365\SharePoint\Portal; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; class SPSiteCreationResponse extends ClientValue { - function getServerTypeName() + /** + * @return ServerTypeInfo + */ + function getServerTypeInfo() { - return "Microsoft.SharePoint.Portal.SPSiteCreationResponse"; + return new ServerTypeInfo("Microsoft.SharePoint.Portal", "SPSiteCreationResponse"); } diff --git a/src/SharePoint/Portal/SPSiteManager.php b/src/SharePoint/Portal/SPSiteManager.php index 1a8f27c9..f476cdc2 100644 --- a/src/SharePoint/Portal/SPSiteManager.php +++ b/src/SharePoint/Portal/SPSiteManager.php @@ -7,6 +7,7 @@ use Office365\Runtime\Actions\InvokePostMethodQuery; use Office365\Runtime\ClientResult; use Office365\Runtime\ResourcePath; +use Office365\Runtime\ServerTypeInfo; use Office365\SharePoint\BaseEntity; use Office365\SharePoint\ClientContext; @@ -55,9 +56,12 @@ public function delete($siteId){ } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "Microsoft.SharePoint.Portal.SPSiteManager"; + return new ServerTypeInfo("Microsoft.SharePoint.Portal", "SPSiteManager"); } } \ No newline at end of file diff --git a/src/SharePoint/Publishing/VideoChannel.php b/src/SharePoint/Publishing/VideoChannel.php index 188e5683..f58ffcf9 100644 --- a/src/SharePoint/Publishing/VideoChannel.php +++ b/src/SharePoint/Publishing/VideoChannel.php @@ -7,6 +7,7 @@ use Office365\Runtime\ClientObject; use Office365\Runtime\ResourcePath; +use Office365\Runtime\ServerTypeInfo; class VideoChannel extends ClientObject { @@ -51,9 +52,13 @@ public function getVideos() { return new VideoCollection($this->getContext(), new ResourcePath("Videos", $this->getResourcePath())); } - public function getServerTypeName() + + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return implode(".", array("SP", "Publishing", parent::getServerTypeName())); + return new ServerTypeInfo("SP.Publishing", "VideoChannel"); } /** * @return bool diff --git a/src/SharePoint/Publishing/VideoItem.php b/src/SharePoint/Publishing/VideoItem.php index d82fcf6f..45595d87 100644 --- a/src/SharePoint/Publishing/VideoItem.php +++ b/src/SharePoint/Publishing/VideoItem.php @@ -8,6 +8,7 @@ use Office365\Runtime\ResourcePath; use Office365\Runtime\Http\HttpMethod; use Office365\Runtime\Http\RequestOptions; +use Office365\Runtime\ServerTypeInfo; use Office365\SharePoint\ClientContext; use Office365\SharePoint\Entity; @@ -42,9 +43,13 @@ function setProperty($name, $value, $persistChanges = true) } parent::setProperty($name, $value, $persistChanges); } - public function getServerTypeName() + + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return implode(".", array("SP", "Publishing", parent::getServerTypeName())); + return new ServerTypeInfo("SP.Publishing", "VideoItem"); } /** * @return string diff --git a/src/SharePoint/SPList.php b/src/SharePoint/SPList.php index b07865cf..8c3cd6ca 100644 --- a/src/SharePoint/SPList.php +++ b/src/SharePoint/SPList.php @@ -10,6 +10,8 @@ use Office365\Runtime\Actions\InvokePostMethodQuery; use Office365\Runtime\ResourcePath; use Office365\Runtime\ResourcePathServiceOperation; +use Office365\Runtime\ServerTypeInfo; + /** * Specifies * a list @@ -143,9 +145,13 @@ public function getParentWeb() { return $this->getProperty("ParentWeb", new Web($this->getContext(), new ResourcePath("ParentWeb", $this->getResourcePath()))); } - public function getServerTypeName() + + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "SP.List"; + return new ServerTypeInfo("SP", "List"); } /** * @return bool diff --git a/src/SharePoint/Search/SearchRequest.php b/src/SharePoint/Search/SearchRequest.php index f513d354..3b71ed46 100644 --- a/src/SharePoint/Search/SearchRequest.php +++ b/src/SharePoint/Search/SearchRequest.php @@ -5,16 +5,17 @@ use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; class SearchRequest extends ClientValue { /** - * @return string + * @return ServerTypeInfo */ - public function getServerTypeName() + public function getServerTypeInfo() { - return "Microsoft.Office.Server.Search.REST.SearchRequest"; + return new ServerTypeInfo("Microsoft.Office.Server.Search.REST", "SearchRequest"); } /** diff --git a/src/SharePoint/Search/SearchResult.php b/src/SharePoint/Search/SearchResult.php index b606fb1f..d3d3e858 100644 --- a/src/SharePoint/Search/SearchResult.php +++ b/src/SharePoint/Search/SearchResult.php @@ -5,14 +5,18 @@ use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; class SearchResult extends ClientValue { - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "Microsoft.Office.Server.Search.REST.SearchResult"; + return new ServerTypeInfo("Microsoft.Office.Server.Search.REST", "SearchResult"); } } \ No newline at end of file diff --git a/src/SharePoint/Taxonomy/TaxonomySession.php b/src/SharePoint/Taxonomy/TaxonomySession.php index 4219743d..10cb9672 100644 --- a/src/SharePoint/Taxonomy/TaxonomySession.php +++ b/src/SharePoint/Taxonomy/TaxonomySession.php @@ -28,7 +28,7 @@ public function getTaxonomySession(ClientRuntimeContext $ctx) if(is_null($ctx)) throw new InvalidArgumentException("Context is not initialized"); $qry = new InvokePostMethodQuery($this, null, "GetTaxonomySession", null,null); - $qry->TypeId = $this->getServerTypeId(); + $qry->TypeId = $this->getServerTypeInfo()->Id; $qry->IsStatic = true; $taxonomySession = new TaxonomySession($ctx); $this->context->addQuery($qry); diff --git a/src/SharePoint/UserProfiles/ProfileLoader.php b/src/SharePoint/UserProfiles/ProfileLoader.php index b1234468..cbaed761 100644 --- a/src/SharePoint/UserProfiles/ProfileLoader.php +++ b/src/SharePoint/UserProfiles/ProfileLoader.php @@ -8,6 +8,7 @@ use Office365\Runtime\Actions\InvokePostMethodQuery; use Office365\Runtime\ClientRuntimeContext; use Office365\Runtime\ResourcePath; +use Office365\Runtime\ServerTypeInfo; use Office365\SharePoint\BaseEntity; class ProfileLoader extends BaseEntity @@ -31,9 +32,12 @@ public static function getProfileLoader(ClientRuntimeContext $context) return $loader; } - function getServerTypeName() + /** + * @return ServerTypeInfo + */ + function getServerTypeInfo() { - return "SP.UserProfiles.ProfileLoader"; + return new ServerTypeInfo("SP.UserProfiles", "ProfileLoader"); } } diff --git a/src/SharePoint/ViewCreationInformation.php b/src/SharePoint/ViewCreationInformation.php index b98b03d4..e6df5f7a 100644 --- a/src/SharePoint/ViewCreationInformation.php +++ b/src/SharePoint/ViewCreationInformation.php @@ -6,6 +6,8 @@ namespace Office365\SharePoint; use Office365\Runtime\ClientValue; +use Office365\Runtime\ServerTypeInfo; + /** * Specifies * the properties used to create a new list view. @@ -50,9 +52,12 @@ public function __construct() parent::__construct(); } - public function getServerTypeName() + /** + * @return ServerTypeInfo + */ + public function getServerTypeInfo() { - return "SP.View"; + return new ServerTypeInfo("SP", "View"); } public $baseViewId;