Release of v4.1.1-beta2
Adds new JCB package engine. Fix issue with loading the Component Builder Wiki. Adds advanced version update notice to the Component Builder Dashboard. Completely refactors the class that builds the Component Dashboard. #1134. Adds Initialize, Reset, and Push functionality to the Repository entities. Completely refactors the SQL teaks and SQL dump classes. Changes J4 fields to allow NULL. Fix a bug in Dynamic Get JavaScript that causes table columns to not load.
This commit is contained in:
@@ -154,7 +154,7 @@ class Issue extends Api
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Git\Repository\TagsInterface;
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
@@ -20,7 +21,7 @@ use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Tags extends Api
|
||||
class Tags extends Api implements TagsInterface
|
||||
{
|
||||
/**
|
||||
* List a repository's tags
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace VDM\Joomla\Gitea\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Git\Repository\WikiInterface;
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
@@ -20,16 +21,16 @@ use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Wiki extends Api
|
||||
class Wiki extends Api implements WikiInterface
|
||||
{
|
||||
/**
|
||||
* Create a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $title The title of the wiki page.
|
||||
* @param string $contentBase64 The base64 encoded content of the wiki page.
|
||||
* @param string|null $message Optional commit message summarizing the change.
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $title The title of the wiki page.
|
||||
* @param string $contentBase64 The base64 encoded content of the wiki page.
|
||||
* @param string|null $message Optional commit message summarizing the change.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
@@ -67,9 +68,9 @@ class Wiki extends Api
|
||||
/**
|
||||
* Get a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
@@ -95,10 +96,10 @@ class Wiki extends Api
|
||||
/**
|
||||
* Get all wiki pages.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
@@ -127,9 +128,9 @@ class Wiki extends Api
|
||||
/**
|
||||
* Delete a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
@@ -155,12 +156,12 @@ class Wiki extends Api
|
||||
/**
|
||||
* Edit a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param string $title The new title of the wiki page.
|
||||
* @param string $content The new content of the wiki page.
|
||||
* @param string $message The optional commit message summarizing the change.
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param string $title The new title of the wiki page.
|
||||
* @param string $content The new content of the wiki page.
|
||||
* @param string $message The optional commit message summarizing the change.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
@@ -199,10 +200,10 @@ class Wiki extends Api
|
||||
/**
|
||||
* Get revisions of a wiki page.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $pageName The name of the wiki page.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
@@ -226,7 +227,6 @@ class Wiki extends Api
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,6 @@ namespace VDM\Joomla\Gitea\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Http as JoomlaHttp;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Gitea\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Response as JoomlaResponse;
|
||||
use Joomla\Http\Response as JoomlaResponse;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
@@ -36,7 +36,7 @@ final class Response
|
||||
* @since 3.2.0
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get($response, int $expectedCode = 200, $default = null)
|
||||
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
@@ -44,8 +44,7 @@ final class Response
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
throw new \DomainException("Invalid response received from API. $message", $response->code);
|
||||
|
||||
throw new \DomainException("Invalid response received from Gitea API. $message", $response->code);
|
||||
}
|
||||
|
||||
return $this->body($response, $default);
|
||||
@@ -62,7 +61,7 @@ final class Response
|
||||
* @since 3.2.0
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get_($response, array $validate = [200 => null])
|
||||
public function get_(JoomlaResponse $response, array $validate = [200 => null])
|
||||
{
|
||||
// Validate the response code.
|
||||
if (!isset($validate[$response->code]))
|
||||
@@ -70,8 +69,7 @@ final class Response
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
throw new \DomainException("Invalid response received from API. $message", $response->code);
|
||||
|
||||
throw new \DomainException("Invalid response received from Gitea API. $message", $response->code);
|
||||
}
|
||||
|
||||
return $this->body($response, $validate[$response->code]);
|
||||
@@ -86,11 +84,14 @@ final class Response
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected function body($response, $default = null)
|
||||
protected function body(JoomlaResponse $response, $default = null)
|
||||
{
|
||||
$body = $response->body ?? null;
|
||||
$body = is_object($response) && method_exists($response, 'getBody')
|
||||
? (string) $response->getBody()
|
||||
: (isset($response->body) ? (string) $response->body : null);
|
||||
|
||||
// check that we have a body
|
||||
if (StringHelper::check($body))
|
||||
if ($body !== null && StringHelper::check($body))
|
||||
{
|
||||
if (JsonHelper::check($body))
|
||||
{
|
||||
@@ -109,36 +110,51 @@ final class Response
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the return object
|
||||
* Extract an error message from a response object.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param JoomlaResponse $response The response object.
|
||||
*
|
||||
* @return string
|
||||
* @return string The extracted error message, or an empty string.
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected function error($response): string
|
||||
*/
|
||||
protected function error(JoomlaResponse $response): string
|
||||
{
|
||||
// do we have a json string
|
||||
if (isset($response->body) && JsonHelper::check($response->body))
|
||||
// Try to get the raw response body
|
||||
$body = method_exists($response, 'getBody') ? (string) $response->getBody() : '';
|
||||
|
||||
// Try to decode as JSON object
|
||||
$errorData = JsonHelper::check($body) ? json_decode($body) : null;
|
||||
|
||||
if (is_object($errorData))
|
||||
{
|
||||
$error = json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
// Try to extract a useful error field
|
||||
if (!empty($errorData->error))
|
||||
{
|
||||
return $errorData->error;
|
||||
}
|
||||
|
||||
if (!empty($errorData->message))
|
||||
{
|
||||
return $errorData->message;
|
||||
}
|
||||
|
||||
// Fallback to a serialized message
|
||||
return json_encode($errorData, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
// check
|
||||
if (isset($error->error))
|
||||
// Fallback to reason phrase or body
|
||||
if (!empty($body))
|
||||
{
|
||||
return $error->error;
|
||||
}
|
||||
elseif (isset($error->message))
|
||||
{
|
||||
return $error->message;
|
||||
return $body;
|
||||
}
|
||||
|
||||
return '';
|
||||
// Try getting the reason phrase from response
|
||||
if (method_exists($response, 'getReasonPhrase'))
|
||||
{
|
||||
return $response->getReasonPhrase();
|
||||
}
|
||||
|
||||
return 'No error information found in Gitea API response.';
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user