Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JGithubGists
+ Graphe d'héritage de JGithubGists:
+ Graphe de collaboration de JGithubGists:

Liste de tous les membres

Fonctions membres publiques

 create ($files, $public=false, $description=null)
 createComment ($gistId, $body)
 delete ($gistId)
 deleteComment ($commentId)
 edit ($gistId, $files=null, $public=null, $description=null)
 editComment ($commentId, $body)
 fork ($gistId)
 get ($gistId)
 getComment ($commentId)
 getComments ($gistId, $page=0, $limit=0)
 getList ($page=0, $limit=0)
 getListByUser ($user, $page=0, $limit=0)
 getListPublic ($page=0, $limit=0)
 getListStarred ($page=0, $limit=0)
 isStarred ($gistId)
 star ($gistId)
 unstar ($gistId)
- Fonctions membres publiques inherited from JGithubObject
 __construct (JRegistry $options=null, JGithubHttp $client=null)

Fonctions membres protégées

 buildFileData (array $files)
- Fonctions membres protégées inherited from JGithubObject
 fetchUrl ($path, $page=0, $limit=0)
 processResponse (JHttpResponse $response, $expectedCode=200)

Additional Inherited Members

- Attributs protégés inherited from JGithubObject
 $options
 $client

Description détaillée

Définition à la ligne 19 du fichier gists.php.


Documentation des fonctions membres

JGithubGists::buildFileData ( array  $files)
protected

Method to fetch a data array for transmitting to the GitHub API for a list of files based on an input array of file paths or filename and content pairs.

Paramètres:
array$filesThe list of file paths or filenames and content.
Renvoie:
array
Depuis:
11.3

Définition à la ligne 568 du fichier gists.php.

{
$data = array();
foreach ($files as $key => $file)
{
// If the key isn't numeric, then we are dealing with a file whose content has been supplied
if (!is_numeric($key))
{
$data[$key] = array('content' => $file);
}
// Otherwise, we have been given a path and we have to load the content
// Verify that the each file exists.
elseif (!file_exists($file))
{
throw new InvalidArgumentException('The file ' . $file . ' does not exist.');
}
else
{
$data[basename($file)] = array('content' => file_get_contents($file));
}
}
return $data;
}
JGithubGists::create (   $files,
  $public = false,
  $description = null 
)

Method to create a gist.

Paramètres:
mixed$filesEither an array of file paths or a single file path as a string.
boolean$publicTrue if the gist should be public.
string$descriptionThe optional description of the gist.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 32 du fichier gists.php.

{
// Build the request path.
$path = '/gists';
// Build the request data.
$data = json_encode(
array(
'files' => $this->buildFileData((array) $files),
'public' => (bool) $public,
'description' => $description
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::createComment (   $gistId,
  $body 
)

Method to create a comment on a gist.

Paramètres:
integer$gistIdThe gist number.
string$bodyThe comment body text.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 70 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/comments';
// Build the request data.
$data = json_encode(
array(
'body' => $body,
)
);
// Send the request.
$response = $this->client->post($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::delete (   $gistId)

Method to delete a gist.

Paramètres:
integer$gistIdThe gist number.
Renvoie:
void
Depuis:
11.3

Définition à la ligne 105 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
JGithubGists::deleteComment (   $commentId)

Method to delete a comment on a gist.

Paramètres:
integer$commentIdThe id of the comment to delete.
Renvoie:
void
Depuis:
11.3

Définition à la ligne 131 du fichier gists.php.

{
// Build the request path.
$path = '/gists/comments/' . (int) $commentId;
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
JGithubGists::edit (   $gistId,
  $files = null,
  $public = null,
  $description = null 
)

Method to update a gist.

Paramètres:
integer$gistIdThe gist number.
mixed$filesEither an array of file paths or a single file path as a string.
boolean$publicTrue if the gist should be public.
string$descriptionThe description of the gist.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 160 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Craete the data object.
$data = new stdClass;
// If a description is set add it to the data object.
if (isset($description))
{
$data->description = $description;
}
// If the public flag is set add it to the data object.
if (isset($public))
{
$data->public = $public;
}
// If a state is set add it to the data object.
if (isset($files))
{
$data->files = $this->buildFileData((array) $files);
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::editComment (   $commentId,
  $body 
)

Method to update a comment on a gist.

Paramètres:
integer$commentIdThe id of the comment to update.
string$bodyThe new body text for the comment.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 213 du fichier gists.php.

{
// Build the request path.
$path = '/gists/comments/' . (int) $commentId;
// Build the request data.
$data = json_encode(
array(
'body' => $body
)
);
// Send the request.
$response = $this->client->patch($this->fetchUrl($path), $data);
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::fork (   $gistId)

Method to fork a gist.

Paramètres:
integer$gistIdThe gist number.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 248 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/fork';
// Send the request.
// TODO: Verify change
$response = $this->client->post($this->fetchUrl($path), '');
// Validate the response code.
if ($response->code != 201)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::get (   $gistId)

Method to get a single gist.

Paramètres:
integer$gistIdThe gist number.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 277 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::getComment (   $commentId)

Method to get a specific comment on a gist.

Paramètres:
integer$commentIdThe comment id to get.
Renvoie:
object
Depuis:
11.3

Définition à la ligne 305 du fichier gists.php.

{
// Build the request path.
$path = '/gists/comments/' . (int) $commentId;
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::getComments (   $gistId,
  $page = 0,
  $limit = 0 
)

Method to get the list of comments on a gist.

Paramètres:
integer$gistIdThe gist number.
integer$pageThe page number from which to get items.
integer$limitThe number of items on a page.
Renvoie:
array
Depuis:
11.3

Définition à la ligne 335 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/comments';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::getList (   $page = 0,
  $limit = 0 
)

Method to list gists. If a user is authenticated it will return the user's gists, otherwise it will return all public gists.

Paramètres:
integer$pageThe page number from which to get items.
integer$limitThe number of items on a page.
Renvoie:
array
Depuis:
11.3

Définition à la ligne 365 du fichier gists.php.

{
// Build the request path.
$path = '/gists';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::getListByUser (   $user,
  $page = 0,
  $limit = 0 
)

Method to get a list of gists belonging to a given user.

Paramètres:
string$userThe name of the GitHub user from which to list gists.
integer$pageThe page number from which to get items.
integer$limitThe number of items on a page.
Renvoie:
array
Depuis:
11.3

Définition à la ligne 395 du fichier gists.php.

{
// Build the request path.
$path = '/users/' . $user . '/gists';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::getListPublic (   $page = 0,
  $limit = 0 
)

Method to get a list of all public gists.

Paramètres:
integer$pageThe page number from which to get items.
integer$limitThe number of items on a page.
Renvoie:
array
Depuis:
11.3

Définition à la ligne 424 du fichier gists.php.

{
// Build the request path.
$path = '/gists/public';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::getListStarred (   $page = 0,
  $limit = 0 
)

Method to get a list of the authenticated users' starred gists.

Paramètres:
integer$pageThe page number from which to get items.
integer$limitThe number of items on a page.
Renvoie:
array
Depuis:
11.3

Définition à la ligne 453 du fichier gists.php.

{
// Build the request path.
$path = '/gists/starred';
// Send the request.
$response = $this->client->get($this->fetchUrl($path, $page, $limit));
// Validate the response code.
if ($response->code != 200)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
return json_decode($response->body);
}
JGithubGists::isStarred (   $gistId)

Method to check if a gist has been starred.

Paramètres:
integer$gistIdThe gist number.
Renvoie:
boolean True if the gist is starred.
Depuis:
11.3

Définition à la ligne 481 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
// Validate the response code.
if ($response->code == 204)
{
return true;
}
elseif ($response->code == 404)
{
return false;
}
else
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
JGithubGists::star (   $gistId)

Method to star a gist.

Paramètres:
integer$gistIdThe gist number.
Renvoie:
void
Depuis:
11.3

Définition à la ligne 515 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$response = $this->client->put($this->fetchUrl($path), '');
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}
JGithubGists::unstar (   $gistId)

Method to star a gist.

Paramètres:
integer$gistIdThe gist number.
Renvoie:
void
Depuis:
11.3

Définition à la ligne 541 du fichier gists.php.

{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$response = $this->client->delete($this->fetchUrl($path));
// Validate the response code.
if ($response->code != 204)
{
// Decode the error response and throw an exception.
$error = json_decode($response->body);
throw new DomainException($error->message, $response->code);
}
}

La documentation de cette classe a été générée à partir du fichier suivant :