Skip to content

Commit

Permalink
SharePoint model updated to 16.0.21221.12006, examples update (taxono…
Browse files Browse the repository at this point in the history
…my export), release 2.4.5
  • Loading branch information
[email protected] authored and [email protected] committed May 6, 2021
1 parent 5ca4693 commit a7c965d
Show file tree
Hide file tree
Showing 24 changed files with 186 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function uploadFileAlt(ClientContext $ctx, $sourceFilePath, $targetFileUrl)


try {
$userCreds = new UserCredentials($settings['UserName'], $settings['Password']);
$ctx = (new ClientContext($settings['Url']))->withCredentials($userCreds);
$credentials = new UserCredentials($settings['UserName'], $settings['Password']);
$ctx = (new ClientContext($settings['Url']))->withCredentials($credentials);
$localPath = "../data/";
$targetLibraryTitle = "Documents";
$targetList = $ctx->getWeb()->getLists()->getByTitle($targetLibraryTitle);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php


require_once '../vendor/autoload.php';
$Settings = include('../../Settings.php');
require_once '../../vendor/autoload.php';
$Settings = include('../../../Settings.php');


use Office365\Runtime\Auth\UserCredentials;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$settings = include( __DIR__ . '/../../Settings.php');
require_once __DIR__ . '../../vendor/autoload.php';
$settings = include(__DIR__ . '../../../Settings.php');

use Office365\Runtime\Auth\ClientCredential;
use Office365\Runtime\Http\RequestOptions;
use Office365\Runtime\ResourcePath;
use Office365\SharePoint\ClientContext;
use Office365\SharePoint\Web;

try {
$credentials = new ClientCredential($settings['ClientId'], $settings['ClientSecret']);
Expand Down
23 changes: 23 additions & 0 deletions examples/SharePoint/Taxonomy/ExportTax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

require_once '../../vendor/autoload.php';

use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\ClientContext;
use Office365\SharePoint\Taxonomy\TaxonomyService;
use Office365\SharePoint\Taxonomy\TermGroup;

$settings = include('../../../Settings.php');
$appPrincipal = new ClientCredential($settings['ClientId'],$settings['ClientSecret']);
$ctx = (new ClientContext($settings['Url']))->withCredentials($appPrincipal);
$taxSvc = new TaxonomyService($ctx);
$groups = $taxSvc->getTermStore()->getTermGroups()->get()->executeQuery();

$fp = fopen('./SiteTaxonomy.csv', 'w');

/** @var TermGroup $group */
foreach ($groups as $group){
fputcsv($fp, $group->toJson());
}

fclose($fp);
4 changes: 4 additions & 0 deletions examples/SharePoint/Taxonomy/SiteTaxonomy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
be8ef61a-82f3-4838-a4af-2fdfc714ed79,,Geography,Geography,2020-11-11T17:04:50.907Z,2020-11-11T17:04:50.907Z,RegularGroup,global
d833b9ad-14f9-4851-b927-dab752026818,,People,People,2019-09-03T06:44:24.42Z,2019-09-03T06:44:26.327Z,RegularGroup,global
d87b6a37-c801-4a36-9046-6296d4779c87,,"Search Dictionaries","Search Dictionaries",2020-03-11T12:27:37.767Z,2020-03-11T12:27:37.767Z,RegularGroup,global
a807d2c3-e824-4115-8ba1-d4902a9b8635,"These term sets are used by the system itself.",System,System,2019-09-03T05:55:38.12Z,2019-09-03T05:55:38.12Z,SystemGroup,system
4 changes: 2 additions & 2 deletions generator/Settings.SharePoint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"docsRoot": "https:\/\/docs.microsoft.com\/en-us\/openspecs\/sharepoint_protocols\/ms-csomspt\/",
"rootNamespace": "Office365\\SharePoint",
"entityRootNamespace": "SP",
"version": "16.0.21207.12005",
"timestamp": "2021-04-23T09:48:34+00:00",
"version": "16.0.21221.12006",
"timestamp": "2021-05-05T14:47:20+00:00",
"placeholder": "This file was generated by phpSPO model generator",
"typeMappings": {
"SP.List": "SP.SPList",
Expand Down
2 changes: 1 addition & 1 deletion generator/metadata/SharePoint.xml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/OutlookServices/OutlookEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ public function deleteObject()


/**
* @param $onlyChanges
* @return array
*/
function toJson()
function toJson($onlyChanges=false)
{
$json = array();
$reflection = new ReflectionObject($this);
Expand Down
50 changes: 28 additions & 22 deletions src/Runtime/ClientObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,30 @@ public function getResourceUrl()

/**
* Directs that related records should be retrieved in the record or collection being retrieved.
* @param $value
* @param string|array $value
* @return ClientObject $this
*/
public function expand($value)
{
$this->queryOptions->Expand = $value;
if(is_array($value))
$this->queryOptions->Expand = implode(',', $value);
else
$this->queryOptions->Expand = $value;
return $this;
}


/**
* Specifies a subset of properties to return.
* @param $value
* @param string|array $value
* @return ClientObject $this
*/
public function select($value)
{
$this->queryOptions->Select = $value;
if(is_array($value))
$this->queryOptions->Select = implode(',', $value);
else
$this->queryOptions->Select = $value;
return $this;
}

Expand All @@ -210,9 +216,9 @@ public function getServerTypeName()
/**
* @return array
*/
function toJson()
function toJson($onlyChanges=false)
{
return $this->changes;
return $onlyChanges ? $this->changes : $this->properties;
}


Expand Down Expand Up @@ -261,19 +267,31 @@ public function setProperty($name, $value, $persistChanges = true)
return $this;
}

/**
* @param string $name
* @return mixed|null
*/
public function getPropertyType($name){
$getterName = "get$name";
if(method_exists($this,$getterName)) {
return $this->{$getterName}();
}
return $this->getProperty($name);
}

/**
* @param $name
* @param $value
*/
public function __set($name, $value)
{
if(is_array($value)) { /*Navigation property? */
$propType = $this->getPropertyType($name);
if($propType instanceof ClientObject || $propType instanceof ClientValue) {
$propVal = $this->getPropertyType($name);
if($propVal instanceof ClientObject || $propVal instanceof ClientValue) {
foreach ($value as $k=>$v){
$propType->setProperty($k,$v,False);
$propVal->setProperty($k,$v,False);
}
$this->properties[$name] = $propType;
$this->properties[$name] = $propVal;
}
else
$this->properties[$name] = $value;
Expand All @@ -282,18 +300,6 @@ public function __set($name, $value)
$this->properties[$name] = $value;
}

/**
* @param string $name
* @return mixed|null
*/
public function getPropertyType($name){
$getterName = "get$name";
if(method_exists($this,$getterName)) {
return $this->{$getterName}();
}
return $this->getProperty($name);
}

/**
* @param $name
* @return mixed|null
Expand Down
6 changes: 3 additions & 3 deletions src/Runtime/ClientObjectCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ public function getItemTypeName()
/**
* @return array
*/
function toJson()
function toJson($onlyChanges=false)
{
return array_map(function (ClientObject $item) {
return $item->toJson();
return array_map(function (ClientObject $item) use($onlyChanges) {
return $item->toJson($onlyChanges);
}, $this->getData());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/OData/ODataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function normalizePayload($value,ODataFormat $format)
if ($value instanceof ClientObject || $value instanceof ClientValue) {
$json = array_map(function ($property) use($format){
return $this->normalizePayload($property,$format);
}, $value->toJson());
}, $value->toJson(true));

$this->ensureAnnotation($value,$json,$format);
return $json;
Expand Down
8 changes: 8 additions & 0 deletions src/SharePoint/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Office365\SharePoint;
use Office365\Runtime\Actions\InvokePostMethodQuery;
use Office365\Runtime\ClientObject;
use Office365\Runtime\ClientRuntimeContext;
use Office365\Runtime\ResourcePath;
use Office365\Runtime\ResourcePathServiceOperation;


Expand All @@ -12,6 +15,11 @@
class FileCollection extends BaseEntityCollection
{

public function __construct(ClientRuntimeContext $ctx, ResourcePath $resourcePath = null, ClientObject $parent = null)
{
parent::__construct($ctx, $resourcePath, Field::class, $parent);
}

/**
* Creates a File resource
* @param FileCreationInformation $fileCreationInformation
Expand Down
9 changes: 6 additions & 3 deletions src/SharePoint/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function recycle()
public function getFiles()
{
if (!$this->isPropertyAvailable('Files')) {
$this->setProperty("Files", new FileCollection($this->getContext(), new ResourcePath("Files", $this->getResourcePath())));
$this->setProperty("Files",
new FileCollection($this->getContext(), new ResourcePath("Files", $this->getResourcePath())));
}
return $this->getProperty("Files");
}
Expand All @@ -125,7 +126,8 @@ public function getFiles()
public function getFolders()
{
if (!$this->isPropertyAvailable("Folders")) {
$this->setProperty("Folders", new FolderCollection($this->getContext(), new ResourcePath("folders", $this->getResourcePath())));
$this->setProperty("Folders",
new FolderCollection($this->getContext(), new ResourcePath("folders", $this->getResourcePath())));
}
return $this->getProperty("Folders");
}
Expand All @@ -152,7 +154,8 @@ function setProperty($name, $value, $persistChanges = true)
if ($name == "UniqueId") {
$this->resourcePath = new ResourcePath("GetFolderById(guid'{$value}')", new ResourcePath("Web"));
}
return parent::setProperty($name, $value, $persistChanges);
parent::setProperty($name, $value, $persistChanges);
return $this;
}
/**
* Gets a
Expand Down
33 changes: 33 additions & 0 deletions src/SharePoint/Publishing/FeedVideoPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* This file was generated by phpSPO model generator 2021-05-05T14:47:20+00:00 16.0.21221.12006
*/
namespace Office365\SharePoint\Publishing;


use Office365\SharePoint\BaseEntity;

class FeedVideoPage extends BaseEntity
{
/**
* @return integer
*/
public function getVideoDuration()
{
if (!$this->isPropertyAvailable("VideoDuration")) {
return null;
}
return $this->getProperty("VideoDuration");
}

/**
* @param $value
* @return $this
*/
public function setVideoDuration($value)
{
$this->setProperty("VideoDuration", $value, true);
return $this;
}
}
11 changes: 11 additions & 0 deletions src/SharePoint/Publishing/FeedVideoPageFieldsData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

/**
* This file was generated by phpSPO model generator 2021-05-05T14:47:20+00:00 16.0.21221.12006
*/
namespace Office365\SharePoint\Publishing;

use Office365\Runtime\ClientValue;
class FeedVideoPageFieldsData extends ClientValue
{
}
6 changes: 5 additions & 1 deletion src/SharePoint/RenderListDataOverrideParameters.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* This file was generated by phpSPO model generator 2020-04-22T21:18:30+00:00 16.0.20008.12009
* This file was generated by phpSPO model generator 2021-05-05T14:47:20+00:00 16.0.21221.12006
*/
namespace Office365\SharePoint;

Expand Down Expand Up @@ -820,4 +820,8 @@ class RenderListDataOverrideParameters extends ClientValue
* @var array
*/
public $QueryParams;
/**
* @var string
*/
public $OverrideRowLimit;
}
6 changes: 5 additions & 1 deletion src/SharePoint/RenderListFilterDataParameters.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* This file was generated by phpSPO model generator 2019-10-12T19:01:57+00:00 16.0.19402.12016
* This file was generated by phpSPO model generator 2021-05-05T14:47:20+00:00 16.0.21221.12006
*/
namespace Office365\SharePoint;

Expand Down Expand Up @@ -44,4 +44,8 @@ class RenderListFilterDataParameters extends ClientValue
* @var string
*/
public $ViewId;
/**
* @var string
*/
public $ViewXml;
}
7 changes: 7 additions & 0 deletions src/SharePoint/Taxonomy/TermGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ public function getTermSets(){
return $this->getProperty("termSets");
}

/**
* @return string|null
*/
public function getName(){
return $this->getProperty("name");
}

}
31 changes: 31 additions & 0 deletions src/SharePoint/VivaConnectionsUrlConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* This file was generated by phpSPO model generator 2021-05-05T14:47:20+00:00 16.0.21221.12006
*/
namespace Office365\SharePoint;

use Office365\Runtime\ClientValue;
class VivaConnectionsUrlConfiguration extends ClientValue
{
/**
* @var string
*/
public $ContentUrl;
/**
* @var string
*/
public $DashboardNotConfiguredWarning;
/**
* @var string
*/
public $GlobalNavNotConfiguredWarning;
/**
* @var string
*/
public $NotHomeSiteUrlWarning;
/**
* @var string
*/
public $SearchUrl;
}
Loading

0 comments on commit a7c965d

Please sign in to comment.