Skip to content

Commit

Permalink
New methods have been introduced for Web object
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Jun 29, 2018
1 parent b05be0e commit c5e0101
Show file tree
Hide file tree
Showing 40 changed files with 169 additions and 71 deletions.
8 changes: 4 additions & 4 deletions examples/Settings.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

$Settings = array(
'Url' => "https://mediadev23.sharepoint.com",
'OneDriveUrl' => "https://mediadev23-my.SharePoint.com",
'Url' => "https://mediadev88.sharepoint.com",
'OneDriveUrl' => "https://mediadev88-my.SharePoint.com",
'Password' => "P@ssw0rd",
'UserName' => "mattim@mediadev23.onmicrosoft.com"
'UserName' => "mattim@mediadev88.onmicrosoft.com"
);

$AppSettings = array(
'TenantName' => "mediadev23.onmicrosoft.com",
'TenantName' => "mediadev88.onmicrosoft.com",
'ClientId' => "d426369e-c84b-47db-b6b1-b9c824ac2ea2",
'ClientSecret' => "wrizJBW41]|=@govNEDR059",
'Title' => "Office365 Graph explorer",
Expand Down
Binary file removed examples/data/SharePoint User Guide - 2007.docx
Binary file not shown.
Binary file removed examples/data/SharePoint User Guide - 2010.docx
Binary file not shown.
8 changes: 4 additions & 4 deletions src/OutlookServices/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function reply($comment)
{
$parameter = new ClientValueObject();
$parameter->setProperty("Comment",$comment);
$qry = new InvokePostMethodQuery($this,"Reply",null,$parameter);
$qry = new InvokePostMethodQuery($this->getResourcePath(),"Reply",null,$parameter);
$this->getContext()->addQuery($qry);
}

Expand All @@ -34,7 +34,7 @@ public function replyAll($comment)
{
$parameter = new ClientValueObject();
$parameter->setProperty("Comment",$comment);
$qry = new InvokePostMethodQuery($this,"ReplyAll",null,$parameter);
$qry = new InvokePostMethodQuery($this->getResourcePath(),"ReplyAll",null,$parameter);
$this->getContext()->addQuery($qry);
}

Expand All @@ -49,7 +49,7 @@ public function forward($comment,$toRecipients)
$parameter = new ClientValueObject();
$parameter->setProperty("Comment",$comment);
$parameter->setProperty("ToRecipients",$toRecipients);
$qry = new InvokePostMethodQuery($this,"Forward",null,$parameter);
$qry = new InvokePostMethodQuery($this->getResourcePath(),"Forward",null,$parameter);
$this->getContext()->addQuery($qry);
}

Expand All @@ -62,7 +62,7 @@ public function forward($comment,$toRecipients)
public function move($destinationId){
$parameter = new ClientValueObject();
$parameter->setProperty("DestinationId",$destinationId);
$qry = new InvokePostMethodQuery($this,"Move",null,$parameter);
$qry = new InvokePostMethodQuery($this->getResourcePath(),"Move",null,$parameter);
$this->getContext()->addQuery($qry);
}

Expand Down
2 changes: 1 addition & 1 deletion src/OutlookServices/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function sendEmail(Message $message, $saveToSentItems)
$payload = new ClientValueObject();
$payload->setProperty("Message", $message);
$payload->setProperty("SaveToSentItems", $saveToSentItems);
$action = new InvokePostMethodQuery($this, "SendMail",null,$payload);
$action = new InvokePostMethodQuery($this->getResourcePath(), "SendMail",null,$payload);
$this->getContext()->addQuery($action);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Runtime/Auth/SamlTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ public function getAuthenticationCookie()
return 'FedAuth=' . $this->FedAuth . '; rtFa=' . $this->rtFa;
}



/**
* @param $parameters
* @throws Exception
*/
public function acquireToken($parameters)
{
$token = $this->acquireSecurityToken($parameters['username'], $parameters['password']);
Expand Down
23 changes: 23 additions & 0 deletions src/Runtime/ContextResourcePath.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


namespace Office365\PHP\Client\Runtime;


class ContextResourcePath extends ResourcePath
{

public function __construct(ClientRuntimeContext $context)
{
parent::__construct($context);
}


/**
* @return string
*/
public function toString()
{
return null;
}
}
2 changes: 1 addition & 1 deletion src/Runtime/CreateEntityQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CreateEntityQuery extends InvokePostMethodQuery
*/
public function __construct(ClientObject $entityCollection, ClientObject $entity)
{
parent::__construct($entityCollection,null,null,$entity);
parent::__construct($entityCollection->getResourcePath(),null,null,$entity);
}

}
2 changes: 1 addition & 1 deletion src/Runtime/DeleteEntityQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class DeleteEntityQuery extends InvokePostMethodQuery
*/
public function __construct(ClientObject $clientObject)
{
parent::__construct($clientObject);
parent::__construct($clientObject->getResourcePath());
}
}
8 changes: 4 additions & 4 deletions src/Runtime/InvokeMethodQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ class InvokeMethodQuery extends ClientAction

/**
* InvokeMethodQuery constructor.
* @param ClientObject $parentClientObject
* @param ResourcePath $resourcePath
* @param string $methodName
* @param array|ISchemaType $methodParameters
*/
public function __construct(ClientObject $parentClientObject, $methodName=null, $methodParameters=null)
public function __construct(ResourcePath $resourcePath, $methodName=null, $methodParameters=null)
{

$path = new ResourcePathServiceOperation(
$parentClientObject->getContext(),
$parentClientObject->getResourcePath(),
$resourcePath->getContext(),
$resourcePath,
$methodName,
$methodParameters
);
Expand Down
7 changes: 3 additions & 4 deletions src/Runtime/InvokePostMethodQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
class InvokePostMethodQuery extends InvokeMethodQuery
{


/**
* ClientActionUpdateMethod constructor.
* @param ClientObject $parentClientObject
* @param ResourcePath $resourcePath
* @param string $methodName
* @param array $methodParameters
* @param string|ISchemaType $methodPayload
*/
public function __construct(ClientObject $parentClientObject, $methodName = null,$methodParameters=null,$methodPayload=null)
public function __construct(ResourcePath $resourcePath, $methodName = null,$methodParameters=null,$methodPayload=null)
{
$this->MethodPayload = $methodPayload;
parent::__construct($parentClientObject,$methodName, $methodParameters);
parent::__construct($resourcePath,$methodName, $methodParameters);
}


Expand Down
2 changes: 2 additions & 0 deletions src/Runtime/OData/ODataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ public function buildRequest(ClientAction $query)
$request->Method = HttpMethod::Post;
if (is_string($query->MethodPayload))
$request->Data = $query->MethodPayload;
if (is_array($query->MethodPayload))
$request->Data = json_encode($query->MethodPayload);
else if ($query->MethodPayload instanceof ISchemaType) {
//build request payload
$payload = $this->normalizePayload($query->MethodPayload);
Expand Down
3 changes: 2 additions & 1 deletion src/Runtime/ResourcePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function toUrl()
$paths = array();
$current = clone $this;
while (isset($current)) {
array_unshift($paths, $current->toString());
if(!is_null($current->toString()))
array_unshift($paths, $current->toString());
$current = $current->parent;
}
return implode("/", $paths);
Expand Down
4 changes: 2 additions & 2 deletions src/Runtime/ResourcePathServiceOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class ResourcePathServiceOperation extends ResourcePath implements ICSOMCallable
/**
* ResourcePathMethod constructor.
* @param ClientRuntimeContext $context
* @param ResourcePath $parent
* @param ResourcePath|null $parent
* @param string $methodName
* @param array $methodParameters
*/
public function __construct(ClientRuntimeContext $context, ResourcePath $parent, $methodName, $methodParameters = null)
public function __construct(ClientRuntimeContext $context, ResourcePath $parent=null, $methodName, $methodParameters = null)
{
parent::__construct($context, $parent);
$this->methodName = $methodName;
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/UpdateEntityQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UpdateEntityQuery extends InvokePostMethodQuery
*/
public function __construct(ClientObject $entity)
{
parent::__construct($entity,null,null,$entity);
parent::__construct($entity->getResourcePath(),null,null,$entity);
}


Expand Down
2 changes: 1 addition & 1 deletion src/SharePoint/AttachmentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function add(AttachmentCreationInformation $information)
{
$attachment = new Attachment($this->getContext(),$this->getResourcePath());
$qry = new InvokePostMethodQuery(
$this,
$this->getResourcePath(),
"add",
array("FileName" =>rawurlencode($information->FileName)),
$information->ContentStream);
Expand Down
2 changes: 1 addition & 1 deletion src/SharePoint/ContentTypeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getById($id)
public function add(ContentTypeCreationInformation $information)
{
$contentType = new ContentType($this->getContext());
$qry = new InvokePostMethodQuery($this,null,null,$information);
$qry = new InvokePostMethodQuery($this->getResourcePath(),null,null,$information);
$this->getContext()->addQuery($qry,$contentType);
$this->addChild($contentType);
return $contentType;
Expand Down
2 changes: 1 addition & 1 deletion src/SharePoint/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function deleteObject()
*/
public function setShowInDisplayForm($value){
$qry = new InvokePostMethodQuery(
$this,
$this->getResourcePath(),
"setShowInDisplayForm",
array($value)
);
Expand Down
2 changes: 1 addition & 1 deletion src/SharePoint/FieldCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FieldCollection extends ClientObjectCollection
public function add(FieldCreationInformation $parameters)
{
$field = new Field($this->getContext(),$this->getResourcePath());
$qry = new InvokePostMethodQuery($this,null,null,$parameters);
$qry = new InvokePostMethodQuery($this->getResourcePath(),null,null,$parameters);
$this->getContext()->addQuery($qry,$field);
$this->addChild($field);
return $field;
Expand Down
20 changes: 10 additions & 10 deletions src/SharePoint/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class File extends SecurableObject
* Checks out the file from a document library based on the check-out type.
*/
public function checkOut(){
$qry = new InvokePostMethodQuery($this,"checkout");
$qry = new InvokePostMethodQuery($this->getResourcePath(),"checkout");
$this->getContext()->addQuery($qry);
}

Expand All @@ -30,7 +30,7 @@ public function checkOut(){
* Reverts an existing checkout for the file.
*/
public function undoCheckout(){
$qry = new InvokePostMethodQuery($this,"undocheckout");
$qry = new InvokePostMethodQuery($this->getResourcePath(),"undocheckout");
$this->getContext()->addQuery($qry);
}

Expand All @@ -40,7 +40,7 @@ public function undoCheckout(){
* @param string $comment A comment for the check-in. Its length must be <= 1023.
*/
public function checkIn($comment){
$qry = new InvokePostMethodQuery($this,"checkIn",array(
$qry = new InvokePostMethodQuery($this->getResourcePath(),"checkIn",array(
"comment" =>$comment,
"checkintype" =>0
));
Expand All @@ -53,7 +53,7 @@ public function checkIn($comment){
* @param string $comment The comment for the approval.
*/
public function approve($comment){
$qry = new InvokePostMethodQuery($this,"approve",array(
$qry = new InvokePostMethodQuery($this->getResourcePath(),"approve",array(
"comment" =>$comment
));
$this->getContext()->addQuery($qry);
Expand All @@ -64,7 +64,7 @@ public function approve($comment){
* @param string $comment The comment for the denial.
*/
public function deny($comment){
$qry = new InvokePostMethodQuery($this, "deny",array(
$qry = new InvokePostMethodQuery($this->getResourcePath(), "deny",array(
"comment" =>$comment
));
$this->getContext()->addQuery($qry);
Expand All @@ -75,7 +75,7 @@ public function deny($comment){
* @param string $comment The comment for the published file. Its length must be <= 1023.
*/
public function publish($comment){
$qry = new InvokePostMethodQuery($this, "publish",array(
$qry = new InvokePostMethodQuery($this->getResourcePath(), "publish",array(
"comment" =>$comment
));
$this->getContext()->addQuery($qry);
Expand All @@ -87,7 +87,7 @@ public function publish($comment){
* @param string $comment The comment for the unpublish operation. Its length must be <= 1023.
*/
public function unpublish($comment){
$qry = new InvokePostMethodQuery($this,"unpublish", array(
$qry = new InvokePostMethodQuery($this->getResourcePath(),"unpublish", array(
"comment" => $comment
));
$this->getContext()->addQuery($qry);
Expand All @@ -100,7 +100,7 @@ public function unpublish($comment){
* @param bool $bOverWrite true to overwrite a file with the same name in the same location; otherwise false.
*/
public function copyTo($strNewUrl,$bOverWrite){
$qry = new InvokePostMethodQuery($this, "copyto", array(
$qry = new InvokePostMethodQuery($this->getResourcePath(), "copyto", array(
"strnewurl"=>$strNewUrl,
"boverwrite"=>$bOverWrite
));
Expand All @@ -113,7 +113,7 @@ public function copyTo($strNewUrl,$bOverWrite){
* @param int $flags The bitwise SP.MoveOperations value for how to move the file. Overwrite = 1; AllowBrokenThickets (move even if supporting files are separated from the file) = 8.
*/
public function moveTo($newUrl,$flags){
$qry = new InvokePostMethodQuery($this, "moveto", array(
$qry = new InvokePostMethodQuery($this->getResourcePath(), "moveto", array(
"newurl"=>$newUrl,
"flags"=>$flags
));
Expand All @@ -125,7 +125,7 @@ public function moveTo($newUrl,$flags){
* Moves the file to the Recycle Bin and returns the identifier of the new Recycle Bin item.
*/
public function recycle(){
$qry = new InvokePostMethodQuery($this, "recycle");
$qry = new InvokePostMethodQuery($this->getResourcePath(), "recycle");
$this->getContext()->addQuery($qry);
}

Expand Down
4 changes: 2 additions & 2 deletions src/SharePoint/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function add(FileCreationInformation $fileCreationInformation)
{
$file = new File($this->getContext(),$this->getResourcePath());
$qry = new InvokePostMethodQuery(
$this,
$this->getResourcePath(),
"add",
array("overwrite"=>$fileCreationInformation->Overwrite,"url"=>rawurlencode($fileCreationInformation->Url)),
$fileCreationInformation->Content
Expand All @@ -43,7 +43,7 @@ public function addTemplateFile($urlOfFile,$templateFileType)
{
$file = new File($this->getContext(),$this->getResourcePath());
$qry = new InvokePostMethodQuery(
$this,
$this->getResourcePath(),
"addTemplateFile",
array(
"urlOfFile" => $urlOfFile,
Expand Down
2 changes: 1 addition & 1 deletion src/SharePoint/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function rename($name){
* Moves the list folder to the Recycle Bin and returns the identifier of the new Recycle Bin item.
*/
public function recycle(){
$qry = new InvokePostMethodQuery($this,"recycle");
$qry = new InvokePostMethodQuery($this->getResourcePath(),"recycle");
$this->getContext()->addQuery($qry);
}

Expand Down
6 changes: 3 additions & 3 deletions src/SharePoint/GroupCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GroupCollection extends ClientObjectCollection
public function add(GroupCreationInformation $parameters)
{
$group = new Group($this->getContext(), $this->getResourcePath());
$qry = new InvokePostMethodQuery($this,null,null, $parameters);
$qry = new InvokePostMethodQuery($this->getResourcePath(),null,null, $parameters);
$this->getContext()->addQuery($qry, $group);
$this->addChild($group);
return $group;
Expand Down Expand Up @@ -66,7 +66,7 @@ public function getByName($name)
*/
public function removeById($id)
{
$qry = new InvokePostMethodQuery($this, "removebyid", array($id));
$qry = new InvokePostMethodQuery($this->getResourcePath(), "removebyid", array($id));
$this->getContext()->addQuery($qry);
}

Expand All @@ -77,7 +77,7 @@ public function removeById($id)
*/
public function removeByLoginName($groupName)
{
$qry = new InvokePostMethodQuery($this, "removeByLoginName", array($groupName));
$qry = new InvokePostMethodQuery($this->getResourcePath(), "removeByLoginName", array($groupName));
$this->getContext()->addQuery($qry);
}
}
2 changes: 1 addition & 1 deletion src/SharePoint/ListCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getById($id)
public function add(ListCreationInformation $properties)
{
$list = new SPList($this->getContext());
$qry = new InvokePostMethodQuery($this,null,null,$properties);
$qry = new InvokePostMethodQuery($this->getResourcePath(),null,null,$properties);
$this->getContext()->addQuery($qry,$list);
$this->addChild($list);
return $list;
Expand Down
Loading

0 comments on commit c5e0101

Please sign in to comment.