Merge branch 'content-hub' of github.com:h5p/h5p-php-library into content-hub
commit
645058f03e
|
@ -3728,11 +3728,11 @@ class H5PCore {
|
||||||
H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT . "/{$id}"),
|
H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT . "/{$id}"),
|
||||||
NULL, TRUE, NULL, TRUE, $headers
|
NULL, TRUE, NULL, TRUE, $headers
|
||||||
);
|
);
|
||||||
|
|
||||||
if (empty($response['data'])) {
|
if (empty($response['data'])) {
|
||||||
throw new Exception($this->h5pF->t('Unable to authorize with the H5P Hub. Please check your Hub registration and connection.'));
|
throw new Exception($this->h5pF->t('Unable to authorize with the H5P Hub. Please check your Hub registration and connection.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$hub_content = json_decode($response['data'])->data;
|
$hub_content = json_decode($response['data'])->data;
|
||||||
$hub_content->id = "$hub_content->id";
|
$hub_content->id = "$hub_content->id";
|
||||||
return $hub_content;
|
return $hub_content;
|
||||||
|
@ -3743,16 +3743,23 @@ class H5PCore {
|
||||||
*
|
*
|
||||||
* @param array $data Data from content publishing process
|
* @param array $data Data from content publishing process
|
||||||
* @param array $files Files to upload with the content publish
|
* @param array $files Files to upload with the content publish
|
||||||
|
* @param bigint $content_hub_id For updating existing content
|
||||||
* @return stdClass
|
* @return stdClass
|
||||||
*/
|
*/
|
||||||
public function hubPublishContent($data, $files) {
|
public function hubPublishContent($data, $files, $content_hub_id = NULL) {
|
||||||
$headers = array(
|
$headers = array(
|
||||||
'Authorization' => $this->hubGetAuthorizationHeader(),
|
'Authorization' => $this->hubGetAuthorizationHeader(),
|
||||||
'Accept' => 'application/json',
|
'Accept' => 'application/json',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$endpoint = H5PHubEndpoints::CONTENT;
|
||||||
|
if ($content_hub_id !== NULL) {
|
||||||
|
$endpoint .= "/{$content_hub_id}";
|
||||||
|
$data['_method'] = 'PUT';
|
||||||
|
}
|
||||||
|
|
||||||
$response = $this->h5pF->fetchExternalData(
|
$response = $this->h5pF->fetchExternalData(
|
||||||
H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT),
|
H5PHubEndpoints::createURL($endpoint),
|
||||||
$data, TRUE, NULL, TRUE, $headers, $files
|
$data, TRUE, NULL, TRUE, $headers, $files
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue