예제 #1
0
 /**
  * Create a SharePoint Folder
  *
  * @param   SPFolderInterface $folder   Parent SharePoint Folder
  * @param   array             $name     SharePoint Folder name
  * @param   array             $settings Instantiation settings
  * @throws  SPRuntimeException
  * @return  SPFolder
  */
 public static function create(SPFolderInterface $folder, $name, array $settings = [])
 {
     if (!$folder->isWritable()) {
         throw new SPRuntimeException(sprintf('Folder/File operations are not allowed on a SPList Template Type [%s]', $folder->getTemplate()));
     }
     $body = json_encode(['odata.type' => 'SP.Folder', 'ServerRelativeUrl' => $folder->getRelativeUrl($name)]);
     $json = $folder->request('_api/web/Folders', ['headers' => ['Authorization' => 'Bearer ' . $folder->getSPAccessToken(), 'Accept' => 'application/json', 'X-RequestDigest' => $folder->getSPContextInfo()->getFormDigest(), 'Content-type' => 'application/json', 'Content-length' => strlen($body)], 'query' => ['$expand' => 'ListItemAllFields/ParentList,Properties'], 'body' => $body], 'POST');
     return new static($folder->getSPSite(), $json, $settings);
 }
예제 #2
0
파일: SPFile.php 프로젝트: impensavel/spoil
 /**
  * Check out a SharePoint File
  *
  * @throws  SPRuntimeException
  * @return  bool
  */
 public function checkOut()
 {
     $this->folder->request("_api/web/GetFileByServerRelativeUrl('" . $this->relativeUrl . "')/checkout()", ['headers' => ['Authorization' => 'Bearer ' . $this->folder->getSPAccessToken(), 'Accept' => 'application/json', 'X-RequestDigest' => $this->folder->getSPContextInfo()->getFormDigest()]], 'POST');
     return true;
 }