/** * Create a SharePoint List * * @param SPSite $site SharePoint Site * @param array $properties SharePoint List properties (Title, Description, ...) * @param array $settings Instantiation settings * @throws SPRuntimeException * @return SPList */ public static function create(SPSite $site, array $properties, array $settings = []) { $properties = array_replace_recursive(['BaseTemplate' => static::TPL_DOCUMENTLIBRARY], $properties, ['odata.type' => 'SP.List']); $body = json_encode($properties); $json = $site->request('_api/web/Lists', ['headers' => ['Authorization' => 'Bearer ' . $site->getSPAccessToken(), 'Accept' => 'application/json', 'X-RequestDigest' => $site->getSPContextInfo()->getFormDigest(), 'Content-type' => 'application/json', 'Content-length' => strlen($body)], 'query' => ['$expand' => 'RootFolder'], 'body' => $body], 'POST'); return new static($site, $json, $settings); }
/** * {@inheritdoc} */ public function getSPContextInfo() { return $this->site->getSPContextInfo(); }