code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function expand($value)
{
if(is_array($value))
$this->queryOptions->Expand = implode(',', $value);
else
$this->queryOptions->Expand = $value;
return $this;
} | Directs that related records should be retrieved in the record or collection being retrieved.
@param string|string[] $value
@return ClientObject $this | expand | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
public function select($value)
{
if(is_array($value))
$this->queryOptions->Select = implode(',', $value);
else
$this->queryOptions->Select = $value;
return $this;
} | Specifies a subset of properties to return.
@param string|string[] $value
@return ClientObject $this | select | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
public function getServerTypeInfo()
{
return ServerTypeInfo::resolve($this);
} | Gets entity type name
@return ServerTypeInfo | getServerTypeInfo | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
function toJson($onlyChanges=false)
{
if($onlyChanges){
$result = array();
foreach ($this->properties as $k => $v) {
if (array_key_exists($k, $this->changes)) {
$result[$k] = $v;
}
}
return $result;
}
return $this->properties;
} | @return array | toJson | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
public function isPropertyAvailable($name)
{
return isset($this->properties[$name]);
} | Determine whether client object property has been loaded
@param string $name
@return bool | isPropertyAvailable | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
public function getServerObjectIsNull(){
return is_null($this->properties);
} | Determine whether client object has been retrieved from the server
@return bool | getServerObjectIsNull | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
public function getProperty($name,$defaultValue=null,$resolve=false)
{
if($this->isPropertyAvailable($name))
return $this->properties[$name];
else if(is_null($defaultValue) && $resolve) {
$getter = "get$name";
if(method_exists($this,$getter)) {
$defaultValue = $this->$getter();
}
}
return $defaultValue;
} | A preferred way of getting the client object property
@param string $name
@param mixed|null $defaultValue
@return mixed|null | getProperty | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
public function ensureProperty($propName, $loadedCallback=null)
{
return $this->ensureProperties(array($propName), $loadedCallback);
} | Ensures property is loaded
@param string $propName
@param callable $loadedCallback
@return self | ensureProperty | php | vgrem/phpSPO | src/Runtime/ClientObject.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientObject.php | MIT |
function __construct($ctx, $returnValue=null)
{
$this->context = $ctx;
$this->value = $returnValue;
} | @param ClientRuntimeContext $ctx
@param ClientObject|ClientValue|int|bool|string|null $returnValue | __construct | php | vgrem/phpSPO | src/Runtime/ClientResult.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientResult.php | MIT |
public function buildRequest(){
return $this->context->buildRequest();
} | @return RequestOptions | buildRequest | php | vgrem/phpSPO | src/Runtime/ClientResult.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientResult.php | MIT |
public function executeQuery(){
$this->context->executeQuery();
return $this;
} | @return $this | executeQuery | php | vgrem/phpSPO | src/Runtime/ClientResult.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientResult.php | MIT |
public function getValue(){
return $this->value;
} | @return bool|int|string|ClientObject|ClientValue|null | getValue | php | vgrem/phpSPO | src/Runtime/ClientResult.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/ClientResult.php | MIT |
public function __construct($message, $statusCode = 0, $responseBody = null)
{
parent::__construct($message, $statusCode);
$this->responseBody = $responseBody;
} | ClientRequestException constructor.
@param string $message an error message for the logs
@param int $statusCode the HTTP status code returned by the remote service
@param string|null $responseBody the body of the remote service response. | __construct | php | vgrem/phpSPO | src/Runtime/Http/RequestException.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/RequestException.php | MIT |
public function getResponseBody()
{
return $this->responseBody;
} | The response returned by the remote service, or `null` if the body was empty.
@return string|null | getResponseBody | php | vgrem/phpSPO | src/Runtime/Http/RequestException.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/RequestException.php | MIT |
public function toArray()
{
return get_object_vars($this);
} | @return array | toArray | php | vgrem/phpSPO | src/Runtime/Http/RequestOptions.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/RequestOptions.php | MIT |
public function ensureHeader($name, $value)
{
if (is_null($this->Headers)) {
$this->Headers = array();
}
if (!array_key_exists($name, $this->Headers)) {
$this->Headers[$name] = $value;
}
} | @param string $name
@param string $value | ensureHeader | php | vgrem/phpSPO | src/Runtime/Http/RequestOptions.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/RequestOptions.php | MIT |
public function getRawHeaders()
{
return array_map(
function ($k, $v) {
return "$k:$v";
},
array_keys($this->Headers),
array_values($this->Headers)
);
} | @return string[] | getRawHeaders | php | vgrem/phpSPO | src/Runtime/Http/RequestOptions.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/RequestOptions.php | MIT |
public function getHeaders()
{
if (!empty($this->Headers)) {
return $this->Headers;
}
// Headers where not included into the response.
if (!$this->RequestOptions->IncludeHeaders) {
return [];
}
$endOfHeaderPos = strpos($this->Content, "\r\n\r\n");
$lines = [];
if ($endOfHeaderPos === false) {
$lines = explode("\r\n", $this->Content);
} else {
$lines = explode("\r\n", substr($this->Content, 0, $endOfHeaderPos));
}
$this->Headers = [];
foreach ($lines as $line){
if($line){
list($k, $v) = preg_split("/[ :]/", $line, 2);
$this->Headers[strtolower(trim($k))] = trim($v);
}
}
return $this->Headers;
} | returns a Array including all response headers of
this request. when RequestOptions::IncludeHeaders was not
set to true this will be empty.
@return array | getHeaders | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getHeader($key) {
$headers = $this->getHeaders();
return $headers[strtolower($key)] ?? null;
} | Returns a specific response header or null when he was not set.
@param String $key
@return String|null | getHeader | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getBody() {
if ($this->RequestOptions->IncludeHeaders) {
// return body without header
$endOfHeaderPos = strpos($this->getContent(), "\r\n\r\n");
if ($endOfHeaderPos !== false) {
return substr($this->getContent(), $endOfHeaderPos + 4);
}
}
return $this->getContent();
} | Returns the body of the response without the header part.
@return String | getBody | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function validate()
{
if ($this->getStatusCode() >= 400) {
if ($this->getHeader('Content-Length') !== null && (int)$this->getHeader('Content-Length') === 0) {
if ($this->getHeader('X-MSDAVEXT_Error')) {
$this->Content = urldecode($this->getHeader('X-MSDAVEXT_Error'));
}
throw new RequestException($this->Content, $this->getStatusCode());
}
}
} | @throws RequestException | validate | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getContentType()
{
return $this->CurlInfo['content_type'] ?? null;
} | returns the Content-Type of the response or null when not provided.
@return String|null | getContentType | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getCurlInfo()
{
return $this->CurlInfo ?? array();
} | returns the array of curl_getinfo.
Check https://www.php.net/manual/function.curl-getinfo.php for the available keys.
@return array | getCurlInfo | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getStatusCode()
{
return isset($this->CurlInfo['http_code']) ? (int)$this->CurlInfo['http_code'] : null;
} | returns the HTTP status code of the response
@return Int|null | getStatusCode | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getRequestOptions()
{
return $this->RequestOptions;
} | returns the RequestOptions object which was used to perform the request.
@return RequestOptions | getRequestOptions | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public function getContent()
{
return $this->Content;
} | returns the content of the response. When IncludeHeaders was set to true
this will contain header and body.
@return String | getContent | php | vgrem/phpSPO | src/Runtime/Http/Response.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Response.php | MIT |
public static function execute(RequestOptions $options)
{
$ch = Requests::init($options);
$response = curl_exec($ch);
$curlInfo = curl_getinfo($ch);
if ($response === false) {
throw new RequestException(curl_error($ch), curl_errno($ch));
}
curl_close($ch);
return new Response($response, $curlInfo, $options);
} | @param RequestOptions $options
@return Response
@throws RequestException | execute | php | vgrem/phpSPO | src/Runtime/Http/Requests.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Requests.php | MIT |
public static function get($url,$headers)
{
$options = new RequestOptions($url);
$options->Headers = $headers;
return Requests::execute($options);
} | @param string $url
@param array $headers
@return Response
@throws RequestException | get | php | vgrem/phpSPO | src/Runtime/Http/Requests.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Requests.php | MIT |
public static function head($url,$headers,$includeBody = false)
{
$options = new RequestOptions($url);
$options->IncludeHeaders = true;
$options->IncludeBody = $includeBody;
$options->Headers = $headers;
return Requests::execute($options);
} | @param $url
@param $headers
@param bool $includeBody
@return Response
@throws RequestException | head | php | vgrem/phpSPO | src/Runtime/Http/Requests.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Requests.php | MIT |
public static function post($url, $headers, $data, $includeHeaders = false)
{
$options = new RequestOptions($url);
$options->Method = HttpMethod::Post;
$options->Headers = $headers;
$options->Data = $data;
$options->IncludeHeaders = $includeHeaders;
return Requests::execute($options);
} | @param $url
@param $headers
@param $data
@param bool $includeHeaders
@return Response
@throws RequestException | post | php | vgrem/phpSPO | src/Runtime/Http/Requests.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Requests.php | MIT |
private static function init(RequestOptions $options)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $options->Url);
curl_setopt_array($ch, self::$defaultOptions); //default options
//include headers in response
curl_setopt($ch, CURLOPT_HEADER, $options->IncludeHeaders);
//include body in response
curl_setopt($ch, CURLOPT_NOBODY, !$options->IncludeBody);
//set re-use policy
curl_setopt($ch, CURLOPT_FORBID_REUSE, $options->ForbidReuse);
//Set method
if($options->Method === HttpMethod::Post) {
curl_setopt($ch, CURLOPT_POST, 1);
//if true, add the "Transfer-Encoding: chunked" HTTP header if the "Content-Length" header is absent.
if ($options->TransferEncodingChunkedAllowed && !array_key_exists('Content-Length', $options->Headers)) {
$options->ensureHeader("Transfer-Encoding", "chunked");
}
} else if($options->Method == HttpMethod::Patch) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $options->Method);
} else if($options->Method == HttpMethod::Put) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $options->Method);
} else if($options->Method == HttpMethod::Delete) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $options->Method);
}
//set Post Body
if(isset($options->Data))
curl_setopt($ch, CURLOPT_POSTFIELDS, $options->Data);
if(is_resource($options->StreamHandle)) {
$opt = $options->Method === HttpMethod::Get ? CURLOPT_FILE : CURLOPT_INFILE;
curl_setopt($ch, $opt, $options->StreamHandle);
}
$options->ensureHeader("Content-Length",strlen((string) $options->Data));
//custom HTTP headers
if($options->Headers)
curl_setopt($ch, CURLOPT_HTTPHEADER, $options->getRawHeaders());
//debugging mode
curl_setopt($ch,CURLOPT_VERBOSE, $options->Verbose);
//SSL Version
if(!is_null($options->SSLVersion)) {
curl_setopt($ch,CURLOPT_SSLVERSION, $options->SSLVersion);
}
//authentication
if(!is_null($options->AuthType))
curl_setopt($ch,CURLOPT_HTTPAUTH, $options->AuthType);
if(!is_null($options->UserCredentials))
curl_setopt($ch,CURLOPT_USERPWD, $options->UserCredentials->toString());
if(!is_null($options->ConnectTimeout))
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $options->ConnectTimeout);
if($options->FollowLocation)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if(!is_null($options->IPResolve))
curl_setopt($ch, CURLOPT_IPRESOLVE, $options->IPResolve);
return $ch;
} | Init Curl with the default parameters
@param RequestOptions $options
@return resource [type] [description] | init | php | vgrem/phpSPO | src/Runtime/Http/Requests.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Http/Requests.php | MIT |
public function __construct(ClientObject $entityToCreate)
{
parent::__construct(
$entityToCreate->getParentCollection(),
null,
null,
null,
$entityToCreate);
} | @param ClientObject $entityToCreate | __construct | php | vgrem/phpSPO | src/Runtime/Actions/CreateEntityQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/CreateEntityQuery.php | MIT |
public function __construct($context, $bindingType,$returnType)
{
$this->context = $context;
$this->BindingType = $bindingType;
$this->ReturnType = $returnType;
} | @param ClientRuntimeContext $context
@param ClientObject|null $bindingType
@param ClientObject|ClientValue|ClientResult|null $returnType | __construct | php | vgrem/phpSPO | src/Runtime/Actions/ClientAction.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/ClientAction.php | MIT |
public function getContext(){
return $this->context;
} | @return ClientRuntimeContext | getContext | php | vgrem/phpSPO | src/Runtime/Actions/ClientAction.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/ClientAction.php | MIT |
public function getId(){
return spl_object_hash($this);
} | @return string | getId | php | vgrem/phpSPO | src/Runtime/Actions/ClientAction.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/ClientAction.php | MIT |
public function getUrl()
{
return $this->BindingType->getResourceUrl();
} | Build action url
@return string | getUrl | php | vgrem/phpSPO | src/Runtime/Actions/ClientAction.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/ClientAction.php | MIT |
public function __construct(ClientObject $entityToUpdate)
{
parent::__construct($entityToUpdate,null,null,null,$entityToUpdate);
} | @param ClientObject $entityToUpdate | __construct | php | vgrem/phpSPO | src/Runtime/Actions/UpdateEntityQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/UpdateEntityQuery.php | MIT |
public function __construct($entityToDelete)
{
parent::__construct($entityToDelete);
} | @param ClientObject $entityToDelete | __construct | php | vgrem/phpSPO | src/Runtime/Actions/DeleteEntityQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/DeleteEntityQuery.php | MIT |
public function __construct($bindingType, $methodName = null, $methodParameters=null, $parameterName=null, $parameterType=null)
{
parent::__construct($bindingType,$methodName, $methodParameters);
$this->ParameterName = $parameterName;
$this->ParameterType = $parameterType;
} | @param ClientObject $bindingType
@param string $methodName
@param array $methodParameters
@param string $parameterName
@param string|ClientObject|ClientValue|array $parameterType | __construct | php | vgrem/phpSPO | src/Runtime/Actions/InvokePostMethodQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/InvokePostMethodQuery.php | MIT |
public function __construct($bindingType, $methodName=null, $methodParameters=null)
{
parent::__construct($bindingType->getContext(),$bindingType,null);
$this->MethodName = $methodName;
$this->MethodParameters = $methodParameters;
$this->BindingType->getQueryOptions()->clear();
} | @param ClientObject $bindingType
@param string $methodName
@param array $methodParameters | __construct | php | vgrem/phpSPO | src/Runtime/Actions/InvokeMethodQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/InvokeMethodQuery.php | MIT |
public function getPath(){
if ($this->IsStatic) {
$entityTypeName = (string)$this->BindingType->getServerTypeInfo();
$staticName = implode(".",[$entityTypeName, $this->MethodName]);
return new ServiceOperationPath($staticName,$this->MethodParameters);
}
return new ServiceOperationPath($this->MethodName, $this->MethodParameters);
} | @return ResourcePath | getPath | php | vgrem/phpSPO | src/Runtime/Actions/InvokeMethodQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/InvokeMethodQuery.php | MIT |
public function getUrl()
{
if(is_null($this->MethodName)){
return parent::getUrl();
}
if ($this->IsStatic) {
return implode("", [$this->getContext()->getServiceRootUrl(), $this->getPath()->toUrl()]);
}
return implode("", [$this->BindingType->getResourceUrl(), $this->getPath()->toUrl()]);
} | @return string | getUrl | php | vgrem/phpSPO | src/Runtime/Actions/InvokeMethodQuery.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Actions/InvokeMethodQuery.php | MIT |
public function executeQuery()
{
//$batchBoundary = $this->createBoundary("batch_");
parent::executeQuery();
} | private $mediaType = "multipart/mixed"; | executeQuery | php | vgrem/phpSPO | src/Runtime/OData/ODataBatchRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataBatchRequest.php | MIT |
protected function setRequestHeaders(RequestOptions $request)
{
// TODO: Implement setRequestHeaders() method.
} | @param RequestOptions $request | setRequestHeaders | php | vgrem/phpSPO | src/Runtime/OData/ODataBatchRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataBatchRequest.php | MIT |
public function processResponse($response)
{
// TODO: Implement processResponse() method.
} | @param string $response | processResponse | php | vgrem/phpSPO | src/Runtime/OData/ODataBatchRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataBatchRequest.php | MIT |
private function createBoundary($prefix){
return $prefix . $this->hex16() . "-" . $this->hex16() . "-" . $this->hex16();
} | Creates a string that can be used as a multipart request boundary.
@param $prefix String to use as the start of the boundary string
@return string Boundary string of the format: <prefix><hex16>-<hex16>-<hex16> | createBoundary | php | vgrem/phpSPO | src/Runtime/OData/ODataBatchRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataBatchRequest.php | MIT |
private function hex16(){
$val = dechex(floor((1 + ((float)rand()/(float)getrandmax())) * 0x10000));
return substr($val,0,-1);
} | Calculates a random 16 bit number and returns it in hexadecimal format.
@return string A 16-bit number in hex format. | hex16 | php | vgrem/phpSPO | src/Runtime/OData/ODataBatchRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataBatchRequest.php | MIT |
public static function getMetadata(ClientRuntimeContext $ctx)
{
$metadataUrl = $ctx->getServiceRootUrl() . "/\$metadata";
$options = new RequestOptions($metadataUrl);
$response = $ctx->executeQueryDirect($options);
return $response->getContent();
} | @param ClientRuntimeContext $ctx
@return string
@throws \Exception | getMetadata | php | vgrem/phpSPO | src/Runtime/OData/MetadataResolver.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/MetadataResolver.php | MIT |
function generateModel($options)
{
$model = new ODataModel($options);
$model->onTypeResolved(function ($typeSchema){
echo "{$typeSchema['name']} type resolved." . PHP_EOL;
});
$edmx = file_get_contents($options['metadataPath']);
$this->parseEdmx($edmx, $model);
return $model;
} | @param array $options
@return ODataModel | generateModel | php | vgrem/phpSPO | src/Runtime/OData/ODataReader.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataReader.php | MIT |
public function isJson()
{
if($this instanceof JsonFormat || $this instanceof JsonLightFormat)
return true;
return false;
} | @return bool | isJson | php | vgrem/phpSPO | src/Runtime/OData/ODataFormat.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataFormat.php | MIT |
public function isAtom()
{
if($this instanceof AtomFormat)
return true;
return false;
} | @return bool | isAtom | php | vgrem/phpSPO | src/Runtime/OData/ODataFormat.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataFormat.php | MIT |
public function __construct(ODataFormat $format)
{
parent::__construct();
$this->format = $format;
} | @param ODataFormat $format | __construct | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
public function buildRequest($query){
$url = $query->getUrl();
$request = new RequestOptions($url);
if($query instanceof InvokeMethodQuery){
if($this->format instanceof JsonLightFormat){
$this->format->FunctionTag = $query->MethodName;
if($query instanceof InvokePostMethodQuery) {
$this->format->ParameterTag = $query->ParameterName;
}
}
if ($query instanceof InvokePostMethodQuery) {
$request->Method = HttpMethod::Post;
$payload = $query->ParameterType;
if ($payload) {
if (is_string($payload))
$request->Data = $payload;
else {
$payload = $this->normalizePayload($payload,$this->getFormat());
$request->Data = json_encode($payload);
}
}
}
}
return $request;
} | @param ClientAction $query
@return RequestOptions | buildRequest | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
protected function ensureAnnotation($type, &$json,$format)
{
$typeName = (string)$type->getServerTypeInfo();
if ($format instanceof JsonLightFormat && $format->MetadataLevel == ODataMetadataLevel::Verbose) {
$json[$format->MetadataTag] = array("type" => $typeName);
if(isset($format->ParameterTag)){
$json = array($format->ParameterTag => $json);
}
}
elseif ($format instanceof JsonFormat){
if(!($type instanceof ClientValueCollection))
$json[$format->TypeTag] = "$typeName";
}
} | @param ClientObject|ClientValue $type
@param array $json
@param ODataFormat $format | ensureAnnotation | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
function executeQueryDirect(RequestOptions $request)
{
$this->ensureMediaType($request);
return parent::executeQueryDirect($request);
} | @param RequestOptions $request
@return Response
@throws Exception | executeQueryDirect | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
protected function ensureMediaType(RequestOptions $request){
$request->ensureHeader("Accept", strtolower($this->getFormat()->getMediaType()));
$request->ensureHeader("Content-Type", $this->getFormat()->getMediaType());
} | @param RequestOptions $request | ensureMediaType | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
public function mapJson($json, $resultType, $format)
{
if($resultType instanceof ClientObjectCollection){
$resultType->clearData();
}
foreach ($this->nextProperty($json, $format) as $key => $value) {
if($resultType instanceof ClientObjectCollection
&& $format instanceof JsonLightFormat && $key === $format->NextCollectionTag){
$resultType->NextRequestUrl = $value;
}
else{
$resultType->setProperty($key, $value, false);
}
}
} | Maps response payload to client object
@param array $json
@param $resultType ClientObject|ClientValue|ClientResult
@param $format ODataFormat | mapJson | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
private function nextProperty($json, $format)
{
if ($format instanceof JsonLightFormat) {
if (isset($json[$format->SecurityTag]))
$json = $json[$format->SecurityTag];
if (isset($json[$format->FunctionTag]))
$json = $json[$format->FunctionTag];
}
if (!is_array($json))
yield "value" => $json;
if (isset($json[$format->CollectionTag]) && is_array($json[$format->CollectionTag])) {
if (isset($json[$format->NextCollectionTag])) {
yield $format->NextCollectionTag => $json[$format->NextCollectionTag];
}
$json = $json[$format->CollectionTag];
foreach ($json as $index => $item) {
if (is_array($item)) {
$item = array_map(function ($v) {
return $v;
},
iterator_to_array($this->nextProperty($item, $format)));
}
yield $index => $item;
}
} else if (is_array($json)) {
foreach ($json as $key => $value) {
if ($this->isValidProperty($key, $value, $format)) {
if (is_array($value)) {
$value = array_map(function ($v) {
return $v;
},
iterator_to_array($this->nextProperty($value, $format)));
}
yield $key => $value;
}
}
}
} | @param array $json
@param ODataFormat $format
@return Generator | nextProperty | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
private function isValidProperty($key,$value,$format)
{
if ($format instanceof JsonLightFormat) {
if (is_array($value) && array_key_exists($format->DeferredTag, $value))
return false;
$propsToExclude = array(
$format->MetadataTag
);
return !in_array($key, $propsToExclude);
} else if ($format instanceof JsonFormat) {
return fnmatch("$format->ControlFamilyTag.*", $key) !== true
&& fnmatch("*$format->ControlFamilyTag.*", $key) !== true
&& fnmatch("$format->TypeTag.*", $key) !== true
&& fnmatch("#microsoft.graph.*", $key) !== true;
}
return true;
} | @param string $key
@param array $value
@param ODataFormat $format
@return bool | isValidProperty | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
public function getFormat()
{
return $this->format;
} | @return ODataFormat | getFormat | php | vgrem/phpSPO | src/Runtime/OData/ODataRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataRequest.php | MIT |
public function getMediaType()
{
throw new Exception("Not implemented");
} | @return string
@throws Exception | getMediaType | php | vgrem/phpSPO | src/Runtime/OData/AtomFormat.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/AtomFormat.php | MIT |
public function __construct($options)
{
$this->options = $options;
$this->primitiveTypeMappings = array(
"Edm.String" => "string",
"Edm.Boolean" => "bool",
"Edm.Guid" => "string",
"Edm.Int32" => "integer",
"Edm.Binary" => "string",
"Edm.Byte" => "string",
"Edm.DateTime" => "string",
"Edm.Int64" => "integer",
"Edm.Double" => "double"
);
$collTypeMappings = array();
foreach ($this->primitiveTypeMappings as $k=>$v){
$collTypeMappings["Collection($k)"] = "array";
}
$this->primitiveTypeMappings = array_merge($this->primitiveTypeMappings, $collTypeMappings);
$this->functions = array();
} | @param array $options | __construct | php | vgrem/phpSPO | src/Runtime/OData/ODataModel.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataModel.php | MIT |
public function resolveFunction(array &$funcSchema)
{
if(is_null($funcSchema['name'])){
return false;
}
if (!$this->validateType($funcSchema['returnType'])) {
return false;
}
if($funcSchema['isBindable'] === false){
$funcName = $funcSchema['alias'];
$this->functions[$funcName] = &$funcSchema;
}
return true;
} | @param array $funcSchema
@return bool | resolveFunction | php | vgrem/phpSPO | src/Runtime/OData/ODataModel.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataModel.php | MIT |
public function resolveType(&$typeSchema)
{
$key = $typeSchema['name'];
//validate type
if (!$this->validateType($key)) {
//echo "Unknown type: $typeName" . PHP_EOL;
return false;
}
//ensure the existing type
if(isset($this->types[$key])) {
$this->types[$key] = array_merge($typeSchema, $this->types[$key]);
$typeSchema = $this->types[$key];
return true;
}
$typeInfo = $this->getTypeInfo($key);
$typeSchema['alias'] = $typeInfo['alias'];
try {
$class = new ReflectionClass($typeInfo['name']);
$typeSchema['state'] = 'attached';
$typeSchema['type'] = $class->getName();
$typeSchema['file'] = $class->getFileName();
$typeSchema['namespace'] = $class->getNamespaceName();
} catch (ReflectionException $e) {
$typeSchema['state'] = 'detached';
$typeSchema['file'] = $typeInfo['file'];
$typeSchema['type'] = $typeInfo['name'];
$typeSchema['namespace'] = $typeInfo['namespace'];
}
$this->types[$key] = $typeSchema;
if (is_callable($this->typeResolvedEvent)) {
call_user_func($this->typeResolvedEvent, $typeSchema);
}
return true;
} | @param $typeSchema
@return bool | resolveType | php | vgrem/phpSPO | src/Runtime/OData/ODataModel.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataModel.php | MIT |
public function getTypeInfo($typeName)
{
if (array_key_exists($typeName, $this->options['typeMappings'])) {
$typeName = $this->options['typeMappings'][$typeName];
}
if (array_key_exists($typeName, $this->primitiveTypeMappings)) {
return array(
'name' => $this->primitiveTypeMappings[$typeName],
'primitive' => true,
);
}
$collection = false;
if (substr($typeName, 0, strlen("Collection")) === "Collection") {
$itemTypeName = str_replace("Collection(", "", $typeName);
$itemTypeName = str_replace(")", "", $itemTypeName);
$typeName = $itemTypeName . "Collection";
$collection = true;
}
$parts = explode('.', $typeName);
$parts[0] = $this->options['rootNamespace'];
$typeAlias = array_pop($parts);
$namespace = implode("\\",array_filter($parts));
$filePath = implode(DIRECTORY_SEPARATOR,array_filter([str_replace($this->options['rootNamespace'],"",$namespace),$typeAlias . ".php"]));
return array(
'alias' => $typeAlias,
'name' => implode("\\",[$namespace,$typeAlias]),
'file' => implode(DIRECTORY_SEPARATOR,[$this->options['outputPath'],$filePath]),
'namespace' => $namespace,
'primitive' => false,
'collection' => $collection
);
} | @param $typeName string
@return array|null | getTypeInfo | php | vgrem/phpSPO | src/Runtime/OData/ODataModel.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataModel.php | MIT |
public function isEmpty(){
return (count($this->getProperties()) == 0);
} | @return bool | isEmpty | php | vgrem/phpSPO | src/Runtime/OData/ODataQueryOptions.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataQueryOptions.php | MIT |
public function toUrl()
{
return implode('&',array_map(
function ($key,$val) {
$key = "\$" . strtolower($key);
return "$key=$val";
},array_keys($this->getProperties()),$this->getProperties())
);
} | @return string | toUrl | php | vgrem/phpSPO | src/Runtime/OData/ODataQueryOptions.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataQueryOptions.php | MIT |
private function getProperties(){
return array_filter((array) $this);
} | @return array | getProperties | php | vgrem/phpSPO | src/Runtime/OData/ODataQueryOptions.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/ODataQueryOptions.php | MIT |
public function getMediaType()
{
$streamingValue = var_export($this->Streaming,true);
$IEEE754CompatibleValue = var_export($this->IEEE754Compatible,true);
switch($this->MetadataLevel){
case ODataMetadataLevel::Verbose:
$metadataValue = "full";
break;
case ODataMetadataLevel::MinimalMetadata:
$metadataValue = "minimal";
break;
case ODataMetadataLevel::NoMetadata:
$metadataValue = "none";
break;
default:
throw new Exception("Unsupported metadata");
}
return "application/json;OData.metadata={$metadataValue};OData.streaming={$streamingValue};IEEE754Compatible={$IEEE754CompatibleValue}";
} | @return string
@throws Exception | getMediaType | php | vgrem/phpSPO | src/Runtime/OData/V4/JsonFormat.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/V4/JsonFormat.php | MIT |
private function normalizeName($name){
$names = explode(".", $name);
$names = array_map(function ($n){
return ucfirst($n);
}, $names);
$name = implode("." ,$names);
if (substr($name, 0, strlen("Collection")) === "Collection") {
$names = explode("(", $name);
$names[1] = ucfirst($names[1]);
$name = implode("(" ,$names);
}
return $name;
} | @param string $name
@return string | normalizeName | php | vgrem/phpSPO | src/Runtime/OData/V4/ODataV4Reader.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/OData/V4/ODataV4Reader.php | MIT |
public function getSegments()
{
return [":/", rawurlencode($this->getName()), ":/"];
} | @return string[] | getSegments | php | vgrem/phpSPO | src/Runtime/Paths/ResourcePathUrl.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/ResourcePathUrl.php | MIT |
public function __construct($methodName=null, $methodParameters = null, ?ResourcePath $parent=null)
{
parent::__construct($this->buildSegment($methodName,$methodParameters), $parent);
$this->methodName = $methodName;
$this->methodParameters = $methodParameters;
} | ResourcePathMethod constructor.
@param string $methodName
@param array|ClientObject|ClientValue $methodParameters
@param ResourcePath|null $parent | __construct | php | vgrem/phpSPO | src/Runtime/Paths/ServiceOperationPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/ServiceOperationPath.php | MIT |
private function buildSegment($methodName,$methodParameters)
{
$url = isset($methodName) ? $methodName : "";
if (!isset($methodParameters) || !is_array($methodParameters))
return $url;
if (count(array_filter(array_keys($methodParameters), 'is_string')) === 0) {
$url = $url . "(" . implode(',', array_map(
function ($value) {
$encValue = self::escapeValue($value);
return "$encValue";
}, $methodParameters)
) . ")";
} else {
$url = $url . "(" . implode(',', array_map(
function ($key, $value) {
$encValue = self::escapeValue($value);
return "$key=$encValue";
}, array_keys($methodParameters), $methodParameters)
) . ")";
}
return $url;
} | @param string $methodName
@param array $methodParameters
@return string|null | buildSegment | php | vgrem/phpSPO | src/Runtime/Paths/ServiceOperationPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/ServiceOperationPath.php | MIT |
function getMethodName(){
return $this->methodName;
} | @return string|null | getMethodName | php | vgrem/phpSPO | src/Runtime/Paths/ServiceOperationPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/ServiceOperationPath.php | MIT |
function getMethodParameters(){
return $this->methodParameters;
} | @return array|ClientObject|ClientValue|null | getMethodParameters | php | vgrem/phpSPO | src/Runtime/Paths/ServiceOperationPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/ServiceOperationPath.php | MIT |
public function __construct($key = null, ?ResourcePath $parent = null)
{
parent::__construct($key, $parent);
} | @param string|null $key
@param ResourcePath|null $parent | __construct | php | vgrem/phpSPO | src/Runtime/Paths/EntityPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/EntityPath.php | MIT |
public function setKey($key)
{
$this->name = $key;
} | @param $key | setKey | php | vgrem/phpSPO | src/Runtime/Paths/EntityPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/EntityPath.php | MIT |
public function getSegments()
{
$entityKey = self::isUuid($this->name) ? "guid'$this->name'" :
(is_string($this->name) ? "'$this->name'" : $this->name);
return ["(", $entityKey, ")"];
} | @return string[] | getSegments | php | vgrem/phpSPO | src/Runtime/Paths/EntityPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/EntityPath.php | MIT |
private static function isUuid($value)
{
if (!is_string($value) || (preg_match(self::$uuidPattern, $value) !== 1)) {
return false;
}
return true;
} | @param $value
@return bool | isUuid | php | vgrem/phpSPO | src/Runtime/Paths/EntityPath.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Paths/EntityPath.php | MIT |
public function executeQuery($query)
{
// TODO: Implement executeQuery() method.
} | Submit client request(s) to Office 365 API OData/SOAP service
@param $query | executeQuery | php | vgrem/phpSPO | src/Runtime/CSOM/CSOMRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/CSOM/CSOMRequest.php | MIT |
protected function setRequestHeaders(RequestOptions $request)
{
// TODO: Implement setRequestHeaders() method.
} | @param RequestOptions $request | setRequestHeaders | php | vgrem/phpSPO | src/Runtime/CSOM/CSOMRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/CSOM/CSOMRequest.php | MIT |
public function processResponse($response, $query)
{
// TODO: Implement processResponse() method.
} | @param Response $response
@param $query | processResponse | php | vgrem/phpSPO | src/Runtime/CSOM/CSOMRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/CSOM/CSOMRequest.php | MIT |
public function buildRequest($query)
{
// TODO: Implement buildRequest() method.
} | Build Client Request
@param $query
@return void | buildRequest | php | vgrem/phpSPO | src/Runtime/CSOM/CSOMRequest.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/CSOM/CSOMRequest.php | MIT |
public function __construct($clientId, $clientSecret)
{
$this->ClientId = $clientId;
$this->ClientSecret = $clientSecret;
} | @param string $clientId
@param string $clientSecret | __construct | php | vgrem/phpSPO | src/Runtime/Auth/ClientCredential.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/ClientCredential.php | MIT |
public function __construct($tenant, $clientId, $privateKey, $thumbprint, $scope=null)
{
$this->Tenant = $tenant;
$this->ClientId = $clientId;
$this->PrivateKey = $privateKey;
$this->Thumbprint = $thumbprint;
$this->Scope = $scope;
} | @param string $tenant
@param string $clientId
@param string $privateKey
@param string $thumbprint
@param string[] $scope | __construct | php | vgrem/phpSPO | src/Runtime/Auth/CertificateCredentials.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/CertificateCredentials.php | MIT |
public function acquireToken($parameters)
{
throw new Exception("Not implemented");
} | private static $StsUrl = 'https://login.live.com/oauth20_token.srf'; | acquireToken | php | vgrem/phpSPO | src/Runtime/Auth/LiveConnectProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/LiveConnectProvider.php | MIT |
public function __construct($url)
{
$this->url = $url;
} | ACSTokenProvider constructor.
@param string $url | __construct | php | vgrem/phpSPO | src/Runtime/Auth/ACSTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/ACSTokenProvider.php | MIT |
public function acquireToken($parameters)
{
$realm = $this->getRealmFromTargetUrl();
$urlInfo = parse_url($this->url);
return $this->getAppOnlyAccessToken(
$parameters["clientId"],
$parameters["clientSecret"],
$urlInfo["host"],
$realm);
} | Acquires the access token from a Microsoft ACS
@param array $parameters
@return mixed
@throws RequestException | acquireToken | php | vgrem/phpSPO | src/Runtime/Auth/ACSTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/ACSTokenProvider.php | MIT |
private function getRealmFromTargetUrl()
{
$headers = array();
$headers['Authorization'] = 'Bearer';
$response = Requests::head($this->url, $headers);
return $this->processRealmResponse($response->getContent());
} | @return string
@throws RequestException | getRealmFromTargetUrl | php | vgrem/phpSPO | src/Runtime/Auth/ACSTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/ACSTokenProvider.php | MIT |
private function getAppOnlyAccessToken($clientId, $clientSecret, $targetHost,$targetRealm)
{
$resource = $this->getFormattedPrincipal(self::$SharePointPrincipal,$targetHost,$targetRealm);
$principalId = $this->getFormattedPrincipal($clientId,null, $targetRealm);
$stsUrl = $this->getSecurityTokenServiceUrl($targetRealm);
$oauth2Request = $this->createAccessTokenRequestWithClientCredentials($principalId,$clientSecret,$resource);
$headers = array();
$headers[] = 'content-Type: application/x-www-form-urlencoded';
$response = Requests::post($stsUrl, $headers, $oauth2Request);
return json_decode($response->getContent(),true);
} | Obtain access token from Azure ACS
@param string $clientId
@param string $clientSecret
@param string $targetHost
@param string $targetRealm
@return mixed
@throws RequestException | getAppOnlyAccessToken | php | vgrem/phpSPO | src/Runtime/Auth/ACSTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/ACSTokenProvider.php | MIT |
public function __construct($tenant)
{
$this->authorityUrl = self::$AuthorityUrl . $tenant;
} | @param string $tenant | __construct | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function acquireRefreshToken($resource, $clientId, $clientSecret, $refreshToken, $redirectUri)
{
$parameters = array(
'grant_type' => 'refresh_token',
'client_id' => $clientId,
'client_secret' => $clientSecret,
'resource' => $resource,
'redirect_uri' => $redirectUri,
'refresh_token' => $refreshToken
);
return $this->acquireToken($parameters);
} | @param string $resource
@param string $clientId
@param string $clientSecret
@param string $refreshToken
@param string $redirectUri
@throws Exception | acquireRefreshToken | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function acquireTokenForClientCredential($resource, $clientCredentials, $scopes)
{
$parameters = array(
'grant_type' => 'client_credentials',
'client_id' => $clientCredentials->ClientId,
'client_secret' => $clientCredentials->ClientSecret,
'scope' => implode(" ", $scopes),
'resource' => $resource
);
return $this->acquireToken($parameters);
} | @param string $resource
@param ClientCredential $clientCredentials
@throws Exception | acquireTokenForClientCredential | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function acquireTokenForClientCertificate($credentials){
$header = [
'x5t' => base64_encode(hex2bin($credentials->Thumbprint)),
];
$now = time();
$payload = [
'aud' => $this->getTokenUrl(true),
'exp' => $now + 360,
'iat' => $now,
'iss' => $credentials->ClientId,
'jti' => bin2hex(random_bytes(20)),
'nbf' => $now,
'sub' => $credentials->ClientId,
];
$jwt = JWT::encode($payload, str_replace('\n', "\n", $credentials->PrivateKey), 'RS256', null, $header);
$params['client_assertion_type'] = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
$params['client_assertion'] = $jwt;
$params['grant_type'] = "client_credentials";
$params['scope'] = implode(" ", $credentials->Scope);
return $this->acquireToken($params, true);
} | @param CertificateCredentials $credentials
@throws Exception | acquireTokenForClientCertificate | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function acquireTokenForPassword($resource, $clientId, $userCredentials, $clientSecret = FALSE)
{
$parameters = array(
'grant_type' => 'password',
'client_id' => $clientId,
'username' => $userCredentials->Username,
'password' => $userCredentials->Password,
'resource' => $resource
);
if($clientSecret) {
$parameters += array('client_secret' => $clientSecret);
}
return $this->acquireToken($parameters);
} | @param string $resource
@param string $clientId
@param UserCredentials $userCredentials
@param FALSE|string $clientSecret
Use $clientSecret in case your app is a confidential client.
@throws Exception Resource owner password credential (ROPC) grant
(https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc) | acquireTokenForPassword | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function acquireTokenByAuthorizationCode($resource, $clientId, $clientSecret, $code, $redirectUrl)
{
$parameters = array(
'grant_type' => 'authorization_code',
'client_id' => $clientId,
'client_secret' => $clientSecret,
'code' => $code,
'resource' => $resource,
"redirect_uri" => $redirectUrl
);
return $this->acquireToken($parameters);
} | @param string $resource
@param string $clientId
@param string $clientSecret
@param string $code
@param string $redirectUrl
@throws Exception | acquireTokenByAuthorizationCode | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function acquireToken($parameters, $useV2=false)
{
$request = $this->prepareTokenRequest($parameters, $useV2);
$response = Requests::execute($request);
$response->validate();
return $this->normalizeToken($response->getContent());
} | Acquires the access token
@param array $parameters
@param bool $useV2
@return mixed
@throws Exception | acquireToken | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
private function prepareTokenRequest($parameters, $useV2)
{
$tokenUrl = $this->getTokenUrl($useV2);
$request = new RequestOptions($tokenUrl);
$request->ensureHeader('content-Type', 'application/x-www-form-urlencoded');
$request->Method = HttpMethod::Post;
$request->Data = http_build_query($parameters);
return $request;
} | @param array $parameters
@param bool $useV2
@return RequestOptions | prepareTokenRequest | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
private function normalizeToken($tokenValue)
{
return json_decode($tokenValue,true);
} | Parse the id token that represents a JWT token that contains information about the user
@param string $tokenValue
@return mixed | normalizeToken | php | vgrem/phpSPO | src/Runtime/Auth/AADTokenProvider.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/AADTokenProvider.php | MIT |
public function __construct($username, $password){
$this->userCredentials = new UserCredentials($username,$password);
$this->AuthType = CURLAUTH_BASIC; //default Auth schema
} | NetworkCredentialContext constructor.
@param string $username
@param string $password | __construct | php | vgrem/phpSPO | src/Runtime/Auth/NetworkCredentialContext.php | https://github.com/vgrem/phpSPO/blob/master/src/Runtime/Auth/NetworkCredentialContext.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.