repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
TypiCMS/Pages
src/Http/Controllers/PublicController.php
PublicController.getBrowserLanguageOrDefault
private function getBrowserLanguageOrDefault() { if ($browserLanguage = getenv('HTTP_ACCEPT_LANGUAGE')) { $browserLocale = substr($browserLanguage, 0, 2); if (in_array($browserLocale, TypiCMS::enabledLocales())) { return $browserLocale; } } return config('app.locale'); }
php
private function getBrowserLanguageOrDefault() { if ($browserLanguage = getenv('HTTP_ACCEPT_LANGUAGE')) { $browserLocale = substr($browserLanguage, 0, 2); if (in_array($browserLocale, TypiCMS::enabledLocales())) { return $browserLocale; } } return config('app.locale'); }
[ "private", "function", "getBrowserLanguageOrDefault", "(", ")", "{", "if", "(", "$", "browserLanguage", "=", "getenv", "(", "'HTTP_ACCEPT_LANGUAGE'", ")", ")", "{", "$", "browserLocale", "=", "substr", "(", "$", "browserLanguage", ",", "0", ",", "2", ")", ";", "if", "(", "in_array", "(", "$", "browserLocale", ",", "TypiCMS", "::", "enabledLocales", "(", ")", ")", ")", "{", "return", "$", "browserLocale", ";", "}", "}", "return", "config", "(", "'app.locale'", ")", ";", "}" ]
Get browser language or app.locale. @return string
[ "Get", "browser", "language", "or", "app", ".", "locale", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Http/Controllers/PublicController.php#L97-L107
train
TypiCMS/Pages
src/Http/Controllers/PublicController.php
PublicController.langChooser
public function langChooser() { $homepage = $this->repository->findBy('is_home', 1); if (!$homepage) { app('log')->error('No homepage found.'); abort(404); } $locales = TypiCMS::enabledLocales(); return view('core::public.lang-chooser') ->with(compact('homepage', 'locales')); }
php
public function langChooser() { $homepage = $this->repository->findBy('is_home', 1); if (!$homepage) { app('log')->error('No homepage found.'); abort(404); } $locales = TypiCMS::enabledLocales(); return view('core::public.lang-chooser') ->with(compact('homepage', 'locales')); }
[ "public", "function", "langChooser", "(", ")", "{", "$", "homepage", "=", "$", "this", "->", "repository", "->", "findBy", "(", "'is_home'", ",", "1", ")", ";", "if", "(", "!", "$", "homepage", ")", "{", "app", "(", "'log'", ")", "->", "error", "(", "'No homepage found.'", ")", ";", "abort", "(", "404", ")", ";", "}", "$", "locales", "=", "TypiCMS", "::", "enabledLocales", "(", ")", ";", "return", "view", "(", "'core::public.lang-chooser'", ")", "->", "with", "(", "compact", "(", "'homepage'", ",", "'locales'", ")", ")", ";", "}" ]
Display the lang chooser. @return null
[ "Display", "the", "lang", "chooser", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Http/Controllers/PublicController.php#L114-L125
train
TypiCMS/Pages
src/Observers/UriObserver.php
UriObserver.creating
public function creating(Page $model) { $slugs = $model->getTranslations('slug'); foreach ($slugs as $locale => $slug) { $uri = $this->incrementWhileExists($model, $slug, $locale); $model->setTranslation('uri', $locale, $uri); } }
php
public function creating(Page $model) { $slugs = $model->getTranslations('slug'); foreach ($slugs as $locale => $slug) { $uri = $this->incrementWhileExists($model, $slug, $locale); $model->setTranslation('uri', $locale, $uri); } }
[ "public", "function", "creating", "(", "Page", "$", "model", ")", "{", "$", "slugs", "=", "$", "model", "->", "getTranslations", "(", "'slug'", ")", ";", "foreach", "(", "$", "slugs", "as", "$", "locale", "=>", "$", "slug", ")", "{", "$", "uri", "=", "$", "this", "->", "incrementWhileExists", "(", "$", "model", ",", "$", "slug", ",", "$", "locale", ")", ";", "$", "model", "->", "setTranslation", "(", "'uri'", ",", "$", "locale", ",", "$", "uri", ")", ";", "}", "}" ]
On create, update uri. @param Page $model @return null
[ "On", "create", "update", "uri", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Observers/UriObserver.php#L16-L23
train
TypiCMS/Pages
src/Observers/UriObserver.php
UriObserver.updating
public function updating(Page $model) { $slugs = $model->getTranslations('slug'); $parentUris = $this->getParentUris($model); foreach ($slugs as $locale => $slug) { $parentUri = $parentUris[$locale] ?? ''; if ($parentUri !== '') { $uri = $parentUri; if ($slug) { $uri .= '/'.$slug; } } else { $uri = $slug; } $uri = $this->incrementWhileExists($model, $uri, $locale, $model->id); $model->setTranslation('uri', $locale, $uri); } }
php
public function updating(Page $model) { $slugs = $model->getTranslations('slug'); $parentUris = $this->getParentUris($model); foreach ($slugs as $locale => $slug) { $parentUri = $parentUris[$locale] ?? ''; if ($parentUri !== '') { $uri = $parentUri; if ($slug) { $uri .= '/'.$slug; } } else { $uri = $slug; } $uri = $this->incrementWhileExists($model, $uri, $locale, $model->id); $model->setTranslation('uri', $locale, $uri); } }
[ "public", "function", "updating", "(", "Page", "$", "model", ")", "{", "$", "slugs", "=", "$", "model", "->", "getTranslations", "(", "'slug'", ")", ";", "$", "parentUris", "=", "$", "this", "->", "getParentUris", "(", "$", "model", ")", ";", "foreach", "(", "$", "slugs", "as", "$", "locale", "=>", "$", "slug", ")", "{", "$", "parentUri", "=", "$", "parentUris", "[", "$", "locale", "]", "??", "''", ";", "if", "(", "$", "parentUri", "!==", "''", ")", "{", "$", "uri", "=", "$", "parentUri", ";", "if", "(", "$", "slug", ")", "{", "$", "uri", ".=", "'/'", ".", "$", "slug", ";", "}", "}", "else", "{", "$", "uri", "=", "$", "slug", ";", "}", "$", "uri", "=", "$", "this", "->", "incrementWhileExists", "(", "$", "model", ",", "$", "uri", ",", "$", "locale", ",", "$", "model", "->", "id", ")", ";", "$", "model", "->", "setTranslation", "(", "'uri'", ",", "$", "locale", ",", "$", "uri", ")", ";", "}", "}" ]
On update, change uri. @param Page $model @return null
[ "On", "update", "change", "uri", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Observers/UriObserver.php#L32-L50
train
TypiCMS/Pages
src/Observers/UriObserver.php
UriObserver.uriExists
private function uriExists(Page $model, $uri, $locale, $id) { $query = $model->where('uri->'.$locale, $uri); if ($id) { $query->where('id', '!=', $id); } if ($query->first()) { return true; } return false; }
php
private function uriExists(Page $model, $uri, $locale, $id) { $query = $model->where('uri->'.$locale, $uri); if ($id) { $query->where('id', '!=', $id); } if ($query->first()) { return true; } return false; }
[ "private", "function", "uriExists", "(", "Page", "$", "model", ",", "$", "uri", ",", "$", "locale", ",", "$", "id", ")", "{", "$", "query", "=", "$", "model", "->", "where", "(", "'uri->'", ".", "$", "locale", ",", "$", "uri", ")", ";", "if", "(", "$", "id", ")", "{", "$", "query", "->", "where", "(", "'id'", ",", "'!='", ",", "$", "id", ")", ";", "}", "if", "(", "$", "query", "->", "first", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if the uri exists. @param Page $model @param string $uri @param int $id @return bool
[ "Check", "if", "the", "uri", "exists", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Observers/UriObserver.php#L75-L87
train
TypiCMS/Pages
src/Observers/UriObserver.php
UriObserver.incrementWhileExists
private function incrementWhileExists(Page $model, $uri, $locale, $id = null) { if (!$uri) { return ''; } $originalUri = $uri; $i = 0; // Check if uri is unique while ($this->uriExists($model, $uri, $locale, $id)) { $i++; // increment uri if it exists $uri = $originalUri.'-'.$i; } return $uri; }
php
private function incrementWhileExists(Page $model, $uri, $locale, $id = null) { if (!$uri) { return ''; } $originalUri = $uri; $i = 0; // Check if uri is unique while ($this->uriExists($model, $uri, $locale, $id)) { $i++; // increment uri if it exists $uri = $originalUri.'-'.$i; } return $uri; }
[ "private", "function", "incrementWhileExists", "(", "Page", "$", "model", ",", "$", "uri", ",", "$", "locale", ",", "$", "id", "=", "null", ")", "{", "if", "(", "!", "$", "uri", ")", "{", "return", "''", ";", "}", "$", "originalUri", "=", "$", "uri", ";", "$", "i", "=", "0", ";", "// Check if uri is unique", "while", "(", "$", "this", "->", "uriExists", "(", "$", "model", ",", "$", "uri", ",", "$", "locale", ",", "$", "id", ")", ")", "{", "$", "i", "++", ";", "// increment uri if it exists", "$", "uri", "=", "$", "originalUri", ".", "'-'", ".", "$", "i", ";", "}", "return", "$", "uri", ";", "}" ]
Add '-x' on uri if it exists in page_translations table. @param Page $model @param string $uri @param int $id @return string
[ "Add", "-", "x", "on", "uri", "if", "it", "exists", "in", "page_translations", "table", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Observers/UriObserver.php#L98-L115
train
ekyna/PayumPayzen
Api/Api.php
Api.getTransactionId
public function getTransactionId() { $path = $this->getDirectoryPath() . 'transaction_id'; // Create file if not exists if (!file_exists($path)) { touch($path); chmod($path, 0600); } $date = (new \DateTime())->format('Ymd'); $fileDate = date('Ymd', filemtime($path)); $isDailyFirstAccess = ($date != $fileDate); // Open file $handle = fopen($path, 'r+'); if (false === $handle) { throw new RuntimeException('Failed to open the transaction ID file.'); } // Lock File if (!flock($handle, LOCK_EX)) { throw new RuntimeException('Failed to lock the transaction ID file.'); } $id = 1; // If not daily first access, read and increment the id if (!$isDailyFirstAccess) { $id = (int)fread($handle, 6); $id++; } // Truncate, write, unlock and close. fseek($handle, 0); ftruncate($handle, 0); fwrite($handle, (string)$id); fflush($handle); flock($handle, LOCK_UN); fclose($handle); if ($this->config['debug']) { $id += 89000; } return str_pad($id, 6, '0', STR_PAD_LEFT); }
php
public function getTransactionId() { $path = $this->getDirectoryPath() . 'transaction_id'; // Create file if not exists if (!file_exists($path)) { touch($path); chmod($path, 0600); } $date = (new \DateTime())->format('Ymd'); $fileDate = date('Ymd', filemtime($path)); $isDailyFirstAccess = ($date != $fileDate); // Open file $handle = fopen($path, 'r+'); if (false === $handle) { throw new RuntimeException('Failed to open the transaction ID file.'); } // Lock File if (!flock($handle, LOCK_EX)) { throw new RuntimeException('Failed to lock the transaction ID file.'); } $id = 1; // If not daily first access, read and increment the id if (!$isDailyFirstAccess) { $id = (int)fread($handle, 6); $id++; } // Truncate, write, unlock and close. fseek($handle, 0); ftruncate($handle, 0); fwrite($handle, (string)$id); fflush($handle); flock($handle, LOCK_UN); fclose($handle); if ($this->config['debug']) { $id += 89000; } return str_pad($id, 6, '0', STR_PAD_LEFT); }
[ "public", "function", "getTransactionId", "(", ")", "{", "$", "path", "=", "$", "this", "->", "getDirectoryPath", "(", ")", ".", "'transaction_id'", ";", "// Create file if not exists", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "touch", "(", "$", "path", ")", ";", "chmod", "(", "$", "path", ",", "0600", ")", ";", "}", "$", "date", "=", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "format", "(", "'Ymd'", ")", ";", "$", "fileDate", "=", "date", "(", "'Ymd'", ",", "filemtime", "(", "$", "path", ")", ")", ";", "$", "isDailyFirstAccess", "=", "(", "$", "date", "!=", "$", "fileDate", ")", ";", "// Open file", "$", "handle", "=", "fopen", "(", "$", "path", ",", "'r+'", ")", ";", "if", "(", "false", "===", "$", "handle", ")", "{", "throw", "new", "RuntimeException", "(", "'Failed to open the transaction ID file.'", ")", ";", "}", "// Lock File", "if", "(", "!", "flock", "(", "$", "handle", ",", "LOCK_EX", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Failed to lock the transaction ID file.'", ")", ";", "}", "$", "id", "=", "1", ";", "// If not daily first access, read and increment the id", "if", "(", "!", "$", "isDailyFirstAccess", ")", "{", "$", "id", "=", "(", "int", ")", "fread", "(", "$", "handle", ",", "6", ")", ";", "$", "id", "++", ";", "}", "// Truncate, write, unlock and close.", "fseek", "(", "$", "handle", ",", "0", ")", ";", "ftruncate", "(", "$", "handle", ",", "0", ")", ";", "fwrite", "(", "$", "handle", ",", "(", "string", ")", "$", "id", ")", ";", "fflush", "(", "$", "handle", ")", ";", "flock", "(", "$", "handle", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "handle", ")", ";", "if", "(", "$", "this", "->", "config", "[", "'debug'", "]", ")", "{", "$", "id", "+=", "89000", ";", "}", "return", "str_pad", "(", "$", "id", ",", "6", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}" ]
Returns the next transaction id. @return string
[ "Returns", "the", "next", "transaction", "id", "." ]
ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb
https://github.com/ekyna/PayumPayzen/blob/ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb/Api/Api.php#L50-L94
train
ekyna/PayumPayzen
Api/Api.php
Api.createRequestUrl
public function createRequestUrl(array $data) { $this->ensureApiIsConfigured(); $data = $this->createRequestData($data); $url = $this->getEndpoint() . '?' . implode('&', array_map(function ($key, $value) { return $key . '=' . rawurlencode($value); }, array_keys($data), $data)); return $url; }
php
public function createRequestUrl(array $data) { $this->ensureApiIsConfigured(); $data = $this->createRequestData($data); $url = $this->getEndpoint() . '?' . implode('&', array_map(function ($key, $value) { return $key . '=' . rawurlencode($value); }, array_keys($data), $data)); return $url; }
[ "public", "function", "createRequestUrl", "(", "array", "$", "data", ")", "{", "$", "this", "->", "ensureApiIsConfigured", "(", ")", ";", "$", "data", "=", "$", "this", "->", "createRequestData", "(", "$", "data", ")", ";", "$", "url", "=", "$", "this", "->", "getEndpoint", "(", ")", ".", "'?'", ".", "implode", "(", "'&'", ",", "array_map", "(", "function", "(", "$", "key", ",", "$", "value", ")", "{", "return", "$", "key", ".", "'='", ".", "rawurlencode", "(", "$", "value", ")", ";", "}", ",", "array_keys", "(", "$", "data", ")", ",", "$", "data", ")", ")", ";", "return", "$", "url", ";", "}" ]
Creates the request url. @param array $data @return string
[ "Creates", "the", "request", "url", "." ]
ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb
https://github.com/ekyna/PayumPayzen/blob/ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb/Api/Api.php#L103-L115
train
ekyna/PayumPayzen
Api/Api.php
Api.createRequestData
public function createRequestData(array $data) { $data = $this ->getRequestOptionsResolver() ->resolve(array_replace($data, [ 'vads_page_action' => 'PAYMENT', 'vads_version' => 'V2', ])); $data = array_filter($data, function ($value) { return null !== $value; }); $data['vads_site_id'] = $this->config['site_id']; $data['vads_ctx_mode'] = $this->config['ctx_mode']; $data['signature'] = $this->generateSignature($data); return $data; }
php
public function createRequestData(array $data) { $data = $this ->getRequestOptionsResolver() ->resolve(array_replace($data, [ 'vads_page_action' => 'PAYMENT', 'vads_version' => 'V2', ])); $data = array_filter($data, function ($value) { return null !== $value; }); $data['vads_site_id'] = $this->config['site_id']; $data['vads_ctx_mode'] = $this->config['ctx_mode']; $data['signature'] = $this->generateSignature($data); return $data; }
[ "public", "function", "createRequestData", "(", "array", "$", "data", ")", "{", "$", "data", "=", "$", "this", "->", "getRequestOptionsResolver", "(", ")", "->", "resolve", "(", "array_replace", "(", "$", "data", ",", "[", "'vads_page_action'", "=>", "'PAYMENT'", ",", "'vads_version'", "=>", "'V2'", ",", "]", ")", ")", ";", "$", "data", "=", "array_filter", "(", "$", "data", ",", "function", "(", "$", "value", ")", "{", "return", "null", "!==", "$", "value", ";", "}", ")", ";", "$", "data", "[", "'vads_site_id'", "]", "=", "$", "this", "->", "config", "[", "'site_id'", "]", ";", "$", "data", "[", "'vads_ctx_mode'", "]", "=", "$", "this", "->", "config", "[", "'ctx_mode'", "]", ";", "$", "data", "[", "'signature'", "]", "=", "$", "this", "->", "generateSignature", "(", "$", "data", ")", ";", "return", "$", "data", ";", "}" ]
Creates the request data. @param array $data @return array
[ "Creates", "the", "request", "data", "." ]
ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb
https://github.com/ekyna/PayumPayzen/blob/ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb/Api/Api.php#L124-L143
train
ekyna/PayumPayzen
Api/Api.php
Api.checkResponseIntegrity
public function checkResponseIntegrity(array $data) { if (!isset($data['signature'])) { return false; } return $data['vads_site_id'] === (string)$this->config['site_id'] && $data['vads_ctx_mode'] === (string)$this->config['ctx_mode'] && $data['signature'] === $this->generateSignature($data); }
php
public function checkResponseIntegrity(array $data) { if (!isset($data['signature'])) { return false; } return $data['vads_site_id'] === (string)$this->config['site_id'] && $data['vads_ctx_mode'] === (string)$this->config['ctx_mode'] && $data['signature'] === $this->generateSignature($data); }
[ "public", "function", "checkResponseIntegrity", "(", "array", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'signature'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "data", "[", "'vads_site_id'", "]", "===", "(", "string", ")", "$", "this", "->", "config", "[", "'site_id'", "]", "&&", "$", "data", "[", "'vads_ctx_mode'", "]", "===", "(", "string", ")", "$", "this", "->", "config", "[", "'ctx_mode'", "]", "&&", "$", "data", "[", "'signature'", "]", "===", "$", "this", "->", "generateSignature", "(", "$", "data", ")", ";", "}" ]
Checks the response signature. @param array $data @return bool
[ "Checks", "the", "response", "signature", "." ]
ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb
https://github.com/ekyna/PayumPayzen/blob/ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb/Api/Api.php#L152-L161
train
ekyna/PayumPayzen
Api/Api.php
Api.getDirectoryPath
private function getDirectoryPath() { $path = $this->config['directory']; // Create directory if not exists if (!is_dir($path)) { mkdir($path, 0755, true); } return $path . DIRECTORY_SEPARATOR; }
php
private function getDirectoryPath() { $path = $this->config['directory']; // Create directory if not exists if (!is_dir($path)) { mkdir($path, 0755, true); } return $path . DIRECTORY_SEPARATOR; }
[ "private", "function", "getDirectoryPath", "(", ")", "{", "$", "path", "=", "$", "this", "->", "config", "[", "'directory'", "]", ";", "// Create directory if not exists", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "mkdir", "(", "$", "path", ",", "0755", ",", "true", ")", ";", "}", "return", "$", "path", ".", "DIRECTORY_SEPARATOR", ";", "}" ]
Returns the directory path and creates it if not exists. @return string
[ "Returns", "the", "directory", "path", "and", "creates", "it", "if", "not", "exists", "." ]
ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb
https://github.com/ekyna/PayumPayzen/blob/ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb/Api/Api.php#L191-L201
train
ekyna/PayumPayzen
Action/Api/AbstractApiAction.php
AbstractApiAction.logData
protected function logData($message, array $data, array $filterKeys = []) { if (!$this->logger) { return; } if (!empty($filterKeys)) { $data = array_intersect_key($data, array_flip($filterKeys)); } $data = array_map(function($key, $value) { return "$key: $value"; }, array_keys($data), $data); $this->logger->debug($message . ': ' . implode(', ', $data)); }
php
protected function logData($message, array $data, array $filterKeys = []) { if (!$this->logger) { return; } if (!empty($filterKeys)) { $data = array_intersect_key($data, array_flip($filterKeys)); } $data = array_map(function($key, $value) { return "$key: $value"; }, array_keys($data), $data); $this->logger->debug($message . ': ' . implode(', ', $data)); }
[ "protected", "function", "logData", "(", "$", "message", ",", "array", "$", "data", ",", "array", "$", "filterKeys", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "logger", ")", "{", "return", ";", "}", "if", "(", "!", "empty", "(", "$", "filterKeys", ")", ")", "{", "$", "data", "=", "array_intersect_key", "(", "$", "data", ",", "array_flip", "(", "$", "filterKeys", ")", ")", ";", "}", "$", "data", "=", "array_map", "(", "function", "(", "$", "key", ",", "$", "value", ")", "{", "return", "\"$key: $value\"", ";", "}", ",", "array_keys", "(", "$", "data", ")", ",", "$", "data", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "$", "message", ".", "': '", ".", "implode", "(", "', '", ",", "$", "data", ")", ")", ";", "}" ]
Logs the given message and data. @param string $message @param array $data @param array $filterKeys
[ "Logs", "the", "given", "message", "and", "data", "." ]
ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb
https://github.com/ekyna/PayumPayzen/blob/ff4f764d9a55b78e1e81f78b4dc74a2cf78996fb/Action/Api/AbstractApiAction.php#L75-L90
train
nilportugues/laravel5-jsonapi
src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
JsonApiController.index
public function index() { $apiRequest = RequestFactory::create(); $page = $apiRequest->getPage(); if (!$page->size()) { $page->setSize($this->pageSize); } $fields = $apiRequest->getFields(); $sorting = $apiRequest->getSort(); $included = $apiRequest->getIncludedRelationships(); $filters = $apiRequest->getFilters(); $resource = new ListResource($this->serializer, $page, $fields, $sorting, $included, $filters); $totalAmount = $this->totalAmountResourceCallable(); $results = $this->listResourceCallable(); $controllerAction = '\\'.get_called_class().'@index'; $uri = $this->uriGenerator($controllerAction); return $this->addHeaders($resource->get($totalAmount, $results, $uri, get_class($this->getDataModel()))); }
php
public function index() { $apiRequest = RequestFactory::create(); $page = $apiRequest->getPage(); if (!$page->size()) { $page->setSize($this->pageSize); } $fields = $apiRequest->getFields(); $sorting = $apiRequest->getSort(); $included = $apiRequest->getIncludedRelationships(); $filters = $apiRequest->getFilters(); $resource = new ListResource($this->serializer, $page, $fields, $sorting, $included, $filters); $totalAmount = $this->totalAmountResourceCallable(); $results = $this->listResourceCallable(); $controllerAction = '\\'.get_called_class().'@index'; $uri = $this->uriGenerator($controllerAction); return $this->addHeaders($resource->get($totalAmount, $results, $uri, get_class($this->getDataModel()))); }
[ "public", "function", "index", "(", ")", "{", "$", "apiRequest", "=", "RequestFactory", "::", "create", "(", ")", ";", "$", "page", "=", "$", "apiRequest", "->", "getPage", "(", ")", ";", "if", "(", "!", "$", "page", "->", "size", "(", ")", ")", "{", "$", "page", "->", "setSize", "(", "$", "this", "->", "pageSize", ")", ";", "}", "$", "fields", "=", "$", "apiRequest", "->", "getFields", "(", ")", ";", "$", "sorting", "=", "$", "apiRequest", "->", "getSort", "(", ")", ";", "$", "included", "=", "$", "apiRequest", "->", "getIncludedRelationships", "(", ")", ";", "$", "filters", "=", "$", "apiRequest", "->", "getFilters", "(", ")", ";", "$", "resource", "=", "new", "ListResource", "(", "$", "this", "->", "serializer", ",", "$", "page", ",", "$", "fields", ",", "$", "sorting", ",", "$", "included", ",", "$", "filters", ")", ";", "$", "totalAmount", "=", "$", "this", "->", "totalAmountResourceCallable", "(", ")", ";", "$", "results", "=", "$", "this", "->", "listResourceCallable", "(", ")", ";", "$", "controllerAction", "=", "'\\\\'", ".", "get_called_class", "(", ")", ".", "'@index'", ";", "$", "uri", "=", "$", "this", "->", "uriGenerator", "(", "$", "controllerAction", ")", ";", "return", "$", "this", "->", "addHeaders", "(", "$", "resource", "->", "get", "(", "$", "totalAmount", ",", "$", "results", ",", "$", "uri", ",", "get_class", "(", "$", "this", "->", "getDataModel", "(", ")", ")", ")", ")", ";", "}" ]
Get many resources. @return \Symfony\Component\HttpFoundation\Response
[ "Get", "many", "resources", "." ]
8a90fd4a4373bc052c8ed50a29fe71154260568d
https://github.com/nilportugues/laravel5-jsonapi/blob/8a90fd4a4373bc052c8ed50a29fe71154260568d/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php#L36-L59
train
nilportugues/laravel5-jsonapi
src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
JsonApiController.show
public function show($id) { $apiRequest = RequestFactory::create(); $resource = new GetResource( $this->serializer, $apiRequest->getFields(), $apiRequest->getIncludedRelationships() ); $find = $this->findResourceCallable($id); return $this->addHeaders($resource->get($id, get_class($this->getDataModel()), $find)); }
php
public function show($id) { $apiRequest = RequestFactory::create(); $resource = new GetResource( $this->serializer, $apiRequest->getFields(), $apiRequest->getIncludedRelationships() ); $find = $this->findResourceCallable($id); return $this->addHeaders($resource->get($id, get_class($this->getDataModel()), $find)); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "apiRequest", "=", "RequestFactory", "::", "create", "(", ")", ";", "$", "resource", "=", "new", "GetResource", "(", "$", "this", "->", "serializer", ",", "$", "apiRequest", "->", "getFields", "(", ")", ",", "$", "apiRequest", "->", "getIncludedRelationships", "(", ")", ")", ";", "$", "find", "=", "$", "this", "->", "findResourceCallable", "(", "$", "id", ")", ";", "return", "$", "this", "->", "addHeaders", "(", "$", "resource", "->", "get", "(", "$", "id", ",", "get_class", "(", "$", "this", "->", "getDataModel", "(", ")", ")", ",", "$", "find", ")", ")", ";", "}" ]
Get single resource. @param $id @return \Symfony\Component\HttpFoundation\Response
[ "Get", "single", "resource", "." ]
8a90fd4a4373bc052c8ed50a29fe71154260568d
https://github.com/nilportugues/laravel5-jsonapi/blob/8a90fd4a4373bc052c8ed50a29fe71154260568d/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php#L68-L81
train
nilportugues/laravel5-jsonapi
src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
JsonApiController.store
public function store(Request $request) { $createResource = $this->createResourceCallable(); $resource = new CreateResource($this->serializer); $model = $this->getDataModel(); $data = (array) $request->get('data'); if (array_key_exists('attributes', $data) && $model->timestamps) { $data['attributes'][$model::CREATED_AT] = Carbon::now()->toDateTimeString(); $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString(); } return $this->addHeaders( $resource->get($data, get_class($this->getDataModel()), $createResource) ); }
php
public function store(Request $request) { $createResource = $this->createResourceCallable(); $resource = new CreateResource($this->serializer); $model = $this->getDataModel(); $data = (array) $request->get('data'); if (array_key_exists('attributes', $data) && $model->timestamps) { $data['attributes'][$model::CREATED_AT] = Carbon::now()->toDateTimeString(); $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString(); } return $this->addHeaders( $resource->get($data, get_class($this->getDataModel()), $createResource) ); }
[ "public", "function", "store", "(", "Request", "$", "request", ")", "{", "$", "createResource", "=", "$", "this", "->", "createResourceCallable", "(", ")", ";", "$", "resource", "=", "new", "CreateResource", "(", "$", "this", "->", "serializer", ")", ";", "$", "model", "=", "$", "this", "->", "getDataModel", "(", ")", ";", "$", "data", "=", "(", "array", ")", "$", "request", "->", "get", "(", "'data'", ")", ";", "if", "(", "array_key_exists", "(", "'attributes'", ",", "$", "data", ")", "&&", "$", "model", "->", "timestamps", ")", "{", "$", "data", "[", "'attributes'", "]", "[", "$", "model", "::", "CREATED_AT", "]", "=", "Carbon", "::", "now", "(", ")", "->", "toDateTimeString", "(", ")", ";", "$", "data", "[", "'attributes'", "]", "[", "$", "model", "::", "UPDATED_AT", "]", "=", "Carbon", "::", "now", "(", ")", "->", "toDateTimeString", "(", ")", ";", "}", "return", "$", "this", "->", "addHeaders", "(", "$", "resource", "->", "get", "(", "$", "data", ",", "get_class", "(", "$", "this", "->", "getDataModel", "(", ")", ")", ",", "$", "createResource", ")", ")", ";", "}" ]
Post Action. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Post", "Action", "." ]
8a90fd4a4373bc052c8ed50a29fe71154260568d
https://github.com/nilportugues/laravel5-jsonapi/blob/8a90fd4a4373bc052c8ed50a29fe71154260568d/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php#L98-L113
train
nilportugues/laravel5-jsonapi
src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php
JsonApiTrait.totalAmountResourceCallable
protected function totalAmountResourceCallable() { return function () { $idKey = $this->getDataModel()->getKeyName(); return $this->getDataModel()->query()->count([$idKey]); }; }
php
protected function totalAmountResourceCallable() { return function () { $idKey = $this->getDataModel()->getKeyName(); return $this->getDataModel()->query()->count([$idKey]); }; }
[ "protected", "function", "totalAmountResourceCallable", "(", ")", "{", "return", "function", "(", ")", "{", "$", "idKey", "=", "$", "this", "->", "getDataModel", "(", ")", "->", "getKeyName", "(", ")", ";", "return", "$", "this", "->", "getDataModel", "(", ")", "->", "query", "(", ")", "->", "count", "(", "[", "$", "idKey", "]", ")", ";", "}", ";", "}" ]
Returns the total number of results available for the current resource. @return callable @codeCoverageIgnore
[ "Returns", "the", "total", "number", "of", "results", "available", "for", "the", "current", "resource", "." ]
8a90fd4a4373bc052c8ed50a29fe71154260568d
https://github.com/nilportugues/laravel5-jsonapi/blob/8a90fd4a4373bc052c8ed50a29fe71154260568d/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php#L61-L68
train
nilportugues/laravel5-jsonapi
src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php
JsonApiTrait.listResourceCallable
protected function listResourceCallable() { return function () { return EloquentHelper::paginate($this->serializer, $this->getDataModel()->query(), $this->pageSize)->get(); }; }
php
protected function listResourceCallable() { return function () { return EloquentHelper::paginate($this->serializer, $this->getDataModel()->query(), $this->pageSize)->get(); }; }
[ "protected", "function", "listResourceCallable", "(", ")", "{", "return", "function", "(", ")", "{", "return", "EloquentHelper", "::", "paginate", "(", "$", "this", "->", "serializer", ",", "$", "this", "->", "getDataModel", "(", ")", "->", "query", "(", ")", ",", "$", "this", "->", "pageSize", ")", "->", "get", "(", ")", ";", "}", ";", "}" ]
Returns a list of resources based on pagination criteria. @return callable @codeCoverageIgnore
[ "Returns", "a", "list", "of", "resources", "based", "on", "pagination", "criteria", "." ]
8a90fd4a4373bc052c8ed50a29fe71154260568d
https://github.com/nilportugues/laravel5-jsonapi/blob/8a90fd4a4373bc052c8ed50a29fe71154260568d/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php#L83-L88
train
nilportugues/laravel5-jsonapi
src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php
JsonApiTrait.createResourceCallable
protected function createResourceCallable() { return function (array $data, array $values, ErrorBag $errorBag) { $model = $this->getDataModel()->newInstance(); foreach ($values as $attribute => $value) { $model->setAttribute($attribute, $value); } if (!empty($data['id'])) { $model->setAttribute($model->getKeyName(), $data['id']); } try { $model->save(); //We need to load the model from the DB in case the user is utilizing getRequiredFields() on the transformer. $model = $model->fresh(); } catch (\Exception $e) { $errorBag[] = new Error('creation_error', 'Resource could not be created'); throw $e; } return $model; }; }
php
protected function createResourceCallable() { return function (array $data, array $values, ErrorBag $errorBag) { $model = $this->getDataModel()->newInstance(); foreach ($values as $attribute => $value) { $model->setAttribute($attribute, $value); } if (!empty($data['id'])) { $model->setAttribute($model->getKeyName(), $data['id']); } try { $model->save(); //We need to load the model from the DB in case the user is utilizing getRequiredFields() on the transformer. $model = $model->fresh(); } catch (\Exception $e) { $errorBag[] = new Error('creation_error', 'Resource could not be created'); throw $e; } return $model; }; }
[ "protected", "function", "createResourceCallable", "(", ")", "{", "return", "function", "(", "array", "$", "data", ",", "array", "$", "values", ",", "ErrorBag", "$", "errorBag", ")", "{", "$", "model", "=", "$", "this", "->", "getDataModel", "(", ")", "->", "newInstance", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "model", "->", "setAttribute", "(", "$", "attribute", ",", "$", "value", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "data", "[", "'id'", "]", ")", ")", "{", "$", "model", "->", "setAttribute", "(", "$", "model", "->", "getKeyName", "(", ")", ",", "$", "data", "[", "'id'", "]", ")", ";", "}", "try", "{", "$", "model", "->", "save", "(", ")", ";", "//We need to load the model from the DB in case the user is utilizing getRequiredFields() on the transformer.", "$", "model", "=", "$", "model", "->", "fresh", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "errorBag", "[", "]", "=", "new", "Error", "(", "'creation_error'", ",", "'Resource could not be created'", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "model", ";", "}", ";", "}" ]
Reads the input and creates and saves a new Eloquent Model. @return callable @codeCoverageIgnore
[ "Reads", "the", "input", "and", "creates", "and", "saves", "a", "new", "Eloquent", "Model", "." ]
8a90fd4a4373bc052c8ed50a29fe71154260568d
https://github.com/nilportugues/laravel5-jsonapi/blob/8a90fd4a4373bc052c8ed50a29fe71154260568d/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php#L122-L147
train
chobie/jira-api-restclient
src/Jira/Api/Client/MemcacheProxyClient.php
MemcacheProxyClient.getFromCache
protected function getFromCache($url, array $data, $endpoint) { $key = $endpoint . $url; $key .= http_build_query($data); $key = sha1($key); return $this->mc->get('jira:cache:' . $key); }
php
protected function getFromCache($url, array $data, $endpoint) { $key = $endpoint . $url; $key .= http_build_query($data); $key = sha1($key); return $this->mc->get('jira:cache:' . $key); }
[ "protected", "function", "getFromCache", "(", "$", "url", ",", "array", "$", "data", ",", "$", "endpoint", ")", "{", "$", "key", "=", "$", "endpoint", ".", "$", "url", ";", "$", "key", ".=", "http_build_query", "(", "$", "data", ")", ";", "$", "key", "=", "sha1", "(", "$", "key", ")", ";", "return", "$", "this", "->", "mc", "->", "get", "(", "'jira:cache:'", ".", "$", "key", ")", ";", "}" ]
Retrieves data from cache. @param string $url URL. @param array $data Data. @param string $endpoint Endpoint. @return mixed
[ "Retrieves", "data", "from", "cache", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api/Client/MemcacheProxyClient.php#L111-L118
train
chobie/jira-api-restclient
src/Jira/Api/Client/MemcacheProxyClient.php
MemcacheProxyClient.setCache
protected function setCache($url, array $data, $endpoint, $result) { $key = $endpoint . $url; $key .= http_build_query($data); $key = sha1($key); return $this->mc->set('jira:cache:' . $key, $result, 86400); }
php
protected function setCache($url, array $data, $endpoint, $result) { $key = $endpoint . $url; $key .= http_build_query($data); $key = sha1($key); return $this->mc->set('jira:cache:' . $key, $result, 86400); }
[ "protected", "function", "setCache", "(", "$", "url", ",", "array", "$", "data", ",", "$", "endpoint", ",", "$", "result", ")", "{", "$", "key", "=", "$", "endpoint", ".", "$", "url", ";", "$", "key", ".=", "http_build_query", "(", "$", "data", ")", ";", "$", "key", "=", "sha1", "(", "$", "key", ")", ";", "return", "$", "this", "->", "mc", "->", "set", "(", "'jira:cache:'", ".", "$", "key", ",", "$", "result", ",", "86400", ")", ";", "}" ]
Sets data into cache. @param string $url URL. @param array $data Data. @param string $endpoint Endpoint. @param mixed $result Result. @return boolean
[ "Sets", "data", "into", "cache", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api/Client/MemcacheProxyClient.php#L130-L137
train
chobie/jira-api-restclient
src/Jira/Issue.php
Issue.get
public function get($field_key) { if ( isset($this->fields[$field_key]) ) { return $this->fields[$field_key]; } return null; }
php
public function get($field_key) { if ( isset($this->fields[$field_key]) ) { return $this->fields[$field_key]; } return null; }
[ "public", "function", "get", "(", "$", "field_key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "field_key", "]", ")", ")", "{", "return", "$", "this", "->", "fields", "[", "$", "field_key", "]", ";", "}", "return", "null", ";", "}" ]
Gets field by name. @param string $field_key Field key. @return array
[ "Gets", "field", "by", "name", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Issue.php#L327-L334
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.setEndpoint
public function setEndpoint($url) { // Remove trailing slash in the url. $url = rtrim($url, '/'); if ( $url !== $this->endpoint ) { $this->endpoint = $url; $this->clearLocalCaches(); } }
php
public function setEndpoint($url) { // Remove trailing slash in the url. $url = rtrim($url, '/'); if ( $url !== $this->endpoint ) { $this->endpoint = $url; $this->clearLocalCaches(); } }
[ "public", "function", "setEndpoint", "(", "$", "url", ")", "{", "// Remove trailing slash in the url.", "$", "url", "=", "rtrim", "(", "$", "url", ",", "'/'", ")", ";", "if", "(", "$", "url", "!==", "$", "this", "->", "endpoint", ")", "{", "$", "this", "->", "endpoint", "=", "$", "url", ";", "$", "this", "->", "clearLocalCaches", "(", ")", ";", "}", "}" ]
Set Endpoint URL. @param string $url Endpoint URL. @return void
[ "Set", "Endpoint", "URL", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L149-L158
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.clearLocalCaches
protected function clearLocalCaches() { $this->fields = null; $this->priorities = null; $this->statuses = null; $this->resolutions = null; }
php
protected function clearLocalCaches() { $this->fields = null; $this->priorities = null; $this->statuses = null; $this->resolutions = null; }
[ "protected", "function", "clearLocalCaches", "(", ")", "{", "$", "this", "->", "fields", "=", "null", ";", "$", "this", "->", "priorities", "=", "null", ";", "$", "this", "->", "statuses", "=", "null", ";", "$", "this", "->", "resolutions", "=", "null", ";", "}" ]
Helper method to clear the local caches. Is called when switching endpoints @return void
[ "Helper", "method", "to", "clear", "the", "local", "caches", ".", "Is", "called", "when", "switching", "endpoints" ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L165-L171
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getFields
public function getFields() { // Fetch fields when the method is called for the first time. if ( $this->fields === null ) { $fields = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/field', array(), true); /* set hash key as custom field id */ foreach ( $result as $field ) { $fields[$field['id']] = $field; } $this->fields = $fields; } return $this->fields; }
php
public function getFields() { // Fetch fields when the method is called for the first time. if ( $this->fields === null ) { $fields = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/field', array(), true); /* set hash key as custom field id */ foreach ( $result as $field ) { $fields[$field['id']] = $field; } $this->fields = $fields; } return $this->fields; }
[ "public", "function", "getFields", "(", ")", "{", "// Fetch fields when the method is called for the first time.", "if", "(", "$", "this", "->", "fields", "===", "null", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/field'", ",", "array", "(", ")", ",", "true", ")", ";", "/* set hash key as custom field id */", "foreach", "(", "$", "result", "as", "$", "field", ")", "{", "$", "fields", "[", "$", "field", "[", "'id'", "]", "]", "=", "$", "field", ";", "}", "$", "this", "->", "fields", "=", "$", "fields", ";", "}", "return", "$", "this", "->", "fields", ";", "}" ]
Get fields definitions. @return array
[ "Get", "fields", "definitions", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L178-L194
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getIssue
public function getIssue($issue_key, $expand = '') { return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/issue/%s', $issue_key), array('expand' => $expand)); }
php
public function getIssue($issue_key, $expand = '') { return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/issue/%s', $issue_key), array('expand' => $expand)); }
[ "public", "function", "getIssue", "(", "$", "issue_key", ",", "$", "expand", "=", "''", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "sprintf", "(", "'/rest/api/2/issue/%s'", ",", "$", "issue_key", ")", ",", "array", "(", "'expand'", "=>", "$", "expand", ")", ")", ";", "}" ]
Get specified issue. @param string $issue_key Issue key should be "YOURPROJ-221". @param string $expand Expand. @return Result|false
[ "Get", "specified", "issue", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L204-L207
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.editIssue
public function editIssue($issue_key, array $params) { return $this->api(self::REQUEST_PUT, sprintf('/rest/api/2/issue/%s', $issue_key), $params); }
php
public function editIssue($issue_key, array $params) { return $this->api(self::REQUEST_PUT, sprintf('/rest/api/2/issue/%s', $issue_key), $params); }
[ "public", "function", "editIssue", "(", "$", "issue_key", ",", "array", "$", "params", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_PUT", ",", "sprintf", "(", "'/rest/api/2/issue/%s'", ",", "$", "issue_key", ")", ",", "$", "params", ")", ";", "}" ]
Edits the issue. @param string $issue_key Issue key. @param array $params Params. @return Result|false
[ "Edits", "the", "issue", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L217-L220
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getRoleDetails
public function getRoleDetails($project_key, $role_id) { return $this->api( self::REQUEST_GET, sprintf('/rest/api/2/project/%s/role/%s', $project_key, $role_id), array(), true ); }
php
public function getRoleDetails($project_key, $role_id) { return $this->api( self::REQUEST_GET, sprintf('/rest/api/2/project/%s/role/%s', $project_key, $role_id), array(), true ); }
[ "public", "function", "getRoleDetails", "(", "$", "project_key", ",", "$", "role_id", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "sprintf", "(", "'/rest/api/2/project/%s/role/%s'", ",", "$", "project_key", ",", "$", "role_id", ")", ",", "array", "(", ")", ",", "true", ")", ";", "}" ]
Returns role details. @param string $project_key Project key. @param string $role_id Role ID. @return array|false
[ "Returns", "role", "details", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L287-L295
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getCreateMeta
public function getCreateMeta( array $project_ids = null, array $project_keys = null, array $issue_type_ids = null, array $issue_type_names = null, array $expand = null ) { // Create comma separated query parameters for the supplied filters. $data = array(); if ( $project_ids !== null ) { $data['projectIds'] = implode(',', $project_ids); } if ( $project_keys !== null ) { $data['projectKeys'] = implode(',', $project_keys); } if ( $issue_type_ids !== null ) { $data['issuetypeIds'] = implode(',', $issue_type_ids); } if ( $issue_type_names !== null ) { $data['issuetypeNames'] = implode(',', $issue_type_names); } if ( $expand !== null ) { $data['expand'] = implode(',', $expand); } return $this->api(self::REQUEST_GET, '/rest/api/2/issue/createmeta', $data, true); }
php
public function getCreateMeta( array $project_ids = null, array $project_keys = null, array $issue_type_ids = null, array $issue_type_names = null, array $expand = null ) { // Create comma separated query parameters for the supplied filters. $data = array(); if ( $project_ids !== null ) { $data['projectIds'] = implode(',', $project_ids); } if ( $project_keys !== null ) { $data['projectKeys'] = implode(',', $project_keys); } if ( $issue_type_ids !== null ) { $data['issuetypeIds'] = implode(',', $issue_type_ids); } if ( $issue_type_names !== null ) { $data['issuetypeNames'] = implode(',', $issue_type_names); } if ( $expand !== null ) { $data['expand'] = implode(',', $expand); } return $this->api(self::REQUEST_GET, '/rest/api/2/issue/createmeta', $data, true); }
[ "public", "function", "getCreateMeta", "(", "array", "$", "project_ids", "=", "null", ",", "array", "$", "project_keys", "=", "null", ",", "array", "$", "issue_type_ids", "=", "null", ",", "array", "$", "issue_type_names", "=", "null", ",", "array", "$", "expand", "=", "null", ")", "{", "// Create comma separated query parameters for the supplied filters.", "$", "data", "=", "array", "(", ")", ";", "if", "(", "$", "project_ids", "!==", "null", ")", "{", "$", "data", "[", "'projectIds'", "]", "=", "implode", "(", "','", ",", "$", "project_ids", ")", ";", "}", "if", "(", "$", "project_keys", "!==", "null", ")", "{", "$", "data", "[", "'projectKeys'", "]", "=", "implode", "(", "','", ",", "$", "project_keys", ")", ";", "}", "if", "(", "$", "issue_type_ids", "!==", "null", ")", "{", "$", "data", "[", "'issuetypeIds'", "]", "=", "implode", "(", "','", ",", "$", "issue_type_ids", ")", ";", "}", "if", "(", "$", "issue_type_names", "!==", "null", ")", "{", "$", "data", "[", "'issuetypeNames'", "]", "=", "implode", "(", "','", ",", "$", "issue_type_names", ")", ";", "}", "if", "(", "$", "expand", "!==", "null", ")", "{", "$", "data", "[", "'expand'", "]", "=", "implode", "(", "','", ",", "$", "expand", ")", ";", "}", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/issue/createmeta'", ",", "$", "data", ",", "true", ")", ";", "}" ]
Returns the meta data for creating issues. This includes the available projects, issue types and fields, including field types and whether or not those fields are required. Projects will not be returned if the user does not have permission to create issues in that project. Fields will only be returned if "projects.issuetypes.fields" is added as expand parameter. @param array $project_ids Combined with the projectKeys param, lists the projects with which to filter the results. If absent, all projects are returned. Specifying a project that does not exist (or that you cannot create issues in) is not an error, but it will not be in the results. @param array $project_keys Combined with the projectIds param, lists the projects with which to filter the results. If null, all projects are returned. Specifying a project that does not exist (or that you cannot create issues in) is not an error, but it will not be in the results. @param array $issue_type_ids Combined with issuetypeNames, lists the issue types with which to filter the results. If null, all issue types are returned. Specifying an issue type that does not exist is not an error. @param array $issue_type_names Combined with issuetypeIds, lists the issue types with which to filter the results. If null, all issue types are returned. This parameter can be specified multiple times, but is NOT interpreted as a comma-separated list. Specifying an issue type that does not exist is not an error. @param array $expand Optional list of entities to expand in the response. @return array|false
[ "Returns", "the", "meta", "data", "for", "creating", "issues", ".", "This", "includes", "the", "available", "projects", "issue", "types", "and", "fields", "including", "field", "types", "and", "whether", "or", "not", "those", "fields", "are", "required", ".", "Projects", "will", "not", "be", "returned", "if", "the", "user", "does", "not", "have", "permission", "to", "create", "issues", "in", "that", "project", ".", "Fields", "will", "only", "be", "returned", "if", "projects", ".", "issuetypes", ".", "fields", "is", "added", "as", "expand", "parameter", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L323-L354
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.addComment
public function addComment($issue_key, $params) { if ( is_string($params) ) { // If $params is scalar string value -> wrapping it properly. $params = array( 'body' => $params, ); } return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/comment', $issue_key), $params); }
php
public function addComment($issue_key, $params) { if ( is_string($params) ) { // If $params is scalar string value -> wrapping it properly. $params = array( 'body' => $params, ); } return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/comment', $issue_key), $params); }
[ "public", "function", "addComment", "(", "$", "issue_key", ",", "$", "params", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "// If $params is scalar string value -> wrapping it properly.", "$", "params", "=", "array", "(", "'body'", "=>", "$", "params", ",", ")", ";", "}", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "sprintf", "(", "'/rest/api/2/issue/%s/comment'", ",", "$", "issue_key", ")", ",", "$", "params", ")", ";", "}" ]
Add a comment to a ticket. @param string $issue_key Issue key should be "YOURPROJ-221". @param array|string $params Params. @return Result|false
[ "Add", "a", "comment", "to", "a", "ticket", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L364-L374
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getWorklogs
public function getWorklogs($issue_key, array $params) { return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/issue/%s/worklog', $issue_key), $params); }
php
public function getWorklogs($issue_key, array $params) { return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/issue/%s/worklog', $issue_key), $params); }
[ "public", "function", "getWorklogs", "(", "$", "issue_key", ",", "array", "$", "params", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "sprintf", "(", "'/rest/api/2/issue/%s/worklog'", ",", "$", "issue_key", ")", ",", "$", "params", ")", ";", "}" ]
Get all worklogs for an issue. @param string $issue_key Issue key should be "YOURPROJ-22". @param array $params Params. @return Result|false @since 2.0.0
[ "Get", "all", "worklogs", "for", "an", "issue", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L385-L388
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getTransitions
public function getTransitions($issue_key, array $params) { return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/issue/%s/transitions', $issue_key), $params); }
php
public function getTransitions($issue_key, array $params) { return $this->api(self::REQUEST_GET, sprintf('/rest/api/2/issue/%s/transitions', $issue_key), $params); }
[ "public", "function", "getTransitions", "(", "$", "issue_key", ",", "array", "$", "params", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "sprintf", "(", "'/rest/api/2/issue/%s/transitions'", ",", "$", "issue_key", ")", ",", "$", "params", ")", ";", "}" ]
Get available transitions for a ticket. @param string $issue_key Issue key should be "YOURPROJ-22". @param array $params Params. @return Result|false
[ "Get", "available", "transitions", "for", "a", "ticket", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L398-L401
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.transition
public function transition($issue_key, array $params) { return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/transitions', $issue_key), $params); }
php
public function transition($issue_key, array $params) { return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/transitions', $issue_key), $params); }
[ "public", "function", "transition", "(", "$", "issue_key", ",", "array", "$", "params", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "sprintf", "(", "'/rest/api/2/issue/%s/transitions'", ",", "$", "issue_key", ")", ",", "$", "params", ")", ";", "}" ]
Transition a ticket. @param string $issue_key Issue key should be "YOURPROJ-22". @param array $params Params. @return Result|false
[ "Transition", "a", "ticket", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L411-L414
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getIssueTypes
public function getIssueTypes() { $result = array(); $types = $this->api(self::REQUEST_GET, '/rest/api/2/issuetype', array(), true); foreach ( $types as $issue_type ) { $result[] = new IssueType($issue_type); } return $result; }
php
public function getIssueTypes() { $result = array(); $types = $this->api(self::REQUEST_GET, '/rest/api/2/issuetype', array(), true); foreach ( $types as $issue_type ) { $result[] = new IssueType($issue_type); } return $result; }
[ "public", "function", "getIssueTypes", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "types", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/issuetype'", ",", "array", "(", ")", ",", "true", ")", ";", "foreach", "(", "$", "types", "as", "$", "issue_type", ")", "{", "$", "result", "[", "]", "=", "new", "IssueType", "(", "$", "issue_type", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get available issue types. @return IssueType[]
[ "Get", "available", "issue", "types", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L421-L431
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.findVersionByName
public function findVersionByName($project_key, $name) { // Fetch all versions of this project. $versions = $this->getVersions($project_key); // Filter results on the name. $matching_versions = array_filter($versions, function (array $version) use ($name) { return $version['name'] == $name; }); // Early out for no results. if ( empty($matching_versions) ) { return null; } // Multiple results should not happen since name is unique. return reset($matching_versions); }
php
public function findVersionByName($project_key, $name) { // Fetch all versions of this project. $versions = $this->getVersions($project_key); // Filter results on the name. $matching_versions = array_filter($versions, function (array $version) use ($name) { return $version['name'] == $name; }); // Early out for no results. if ( empty($matching_versions) ) { return null; } // Multiple results should not happen since name is unique. return reset($matching_versions); }
[ "public", "function", "findVersionByName", "(", "$", "project_key", ",", "$", "name", ")", "{", "// Fetch all versions of this project.", "$", "versions", "=", "$", "this", "->", "getVersions", "(", "$", "project_key", ")", ";", "// Filter results on the name.", "$", "matching_versions", "=", "array_filter", "(", "$", "versions", ",", "function", "(", "array", "$", "version", ")", "use", "(", "$", "name", ")", "{", "return", "$", "version", "[", "'name'", "]", "==", "$", "name", ";", "}", ")", ";", "// Early out for no results.", "if", "(", "empty", "(", "$", "matching_versions", ")", ")", "{", "return", "null", ";", "}", "// Multiple results should not happen since name is unique.", "return", "reset", "(", "$", "matching_versions", ")", ";", "}" ]
Helper method to find a specific version based on the name of the version. @param string $project_key Project Key. @param string $name The version name to match on. @return array|null Version data on match or null when there is no match. @since 2.0.0
[ "Helper", "method", "to", "find", "a", "specific", "version", "based", "on", "the", "name", "of", "the", "version", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L454-L471
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getPriorities
public function getPriorities() { // Fetch priorities when the method is called for the first time. if ( $this->priorities === null ) { $priorities = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/priority', array(), true); /* set hash key as custom field id */ foreach ( $result as $priority ) { $priorities[$priority['id']] = $priority; } $this->priorities = $priorities; } return $this->priorities; }
php
public function getPriorities() { // Fetch priorities when the method is called for the first time. if ( $this->priorities === null ) { $priorities = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/priority', array(), true); /* set hash key as custom field id */ foreach ( $result as $priority ) { $priorities[$priority['id']] = $priority; } $this->priorities = $priorities; } return $this->priorities; }
[ "public", "function", "getPriorities", "(", ")", "{", "// Fetch priorities when the method is called for the first time.", "if", "(", "$", "this", "->", "priorities", "===", "null", ")", "{", "$", "priorities", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/priority'", ",", "array", "(", ")", ",", "true", ")", ";", "/* set hash key as custom field id */", "foreach", "(", "$", "result", "as", "$", "priority", ")", "{", "$", "priorities", "[", "$", "priority", "[", "'id'", "]", "]", "=", "$", "priority", ";", "}", "$", "this", "->", "priorities", "=", "$", "priorities", ";", "}", "return", "$", "this", "->", "priorities", ";", "}" ]
Get available priorities. @return array @since 2.0.0
[ "Get", "available", "priorities", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L479-L495
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getStatuses
public function getStatuses() { // Fetch statuses when the method is called for the first time. if ( $this->statuses === null ) { $statuses = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/status', array(), true); /* set hash key as custom field id */ foreach ( $result as $status ) { $statuses[$status['id']] = $status; } $this->statuses = $statuses; } return $this->statuses; }
php
public function getStatuses() { // Fetch statuses when the method is called for the first time. if ( $this->statuses === null ) { $statuses = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/status', array(), true); /* set hash key as custom field id */ foreach ( $result as $status ) { $statuses[$status['id']] = $status; } $this->statuses = $statuses; } return $this->statuses; }
[ "public", "function", "getStatuses", "(", ")", "{", "// Fetch statuses when the method is called for the first time.", "if", "(", "$", "this", "->", "statuses", "===", "null", ")", "{", "$", "statuses", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/status'", ",", "array", "(", ")", ",", "true", ")", ";", "/* set hash key as custom field id */", "foreach", "(", "$", "result", "as", "$", "status", ")", "{", "$", "statuses", "[", "$", "status", "[", "'id'", "]", "]", "=", "$", "status", ";", "}", "$", "this", "->", "statuses", "=", "$", "statuses", ";", "}", "return", "$", "this", "->", "statuses", ";", "}" ]
Get available statuses. @return array
[ "Get", "available", "statuses", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L502-L518
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.createIssue
public function createIssue($project_key, $summary, $issue_type, array $options = array()) { $default = array( 'project' => array( 'key' => $project_key, ), 'summary' => $summary, 'issuetype' => array( 'id' => $issue_type, ), ); $default = array_merge($default, $options); return $this->api(self::REQUEST_POST, '/rest/api/2/issue/', array('fields' => $default)); }
php
public function createIssue($project_key, $summary, $issue_type, array $options = array()) { $default = array( 'project' => array( 'key' => $project_key, ), 'summary' => $summary, 'issuetype' => array( 'id' => $issue_type, ), ); $default = array_merge($default, $options); return $this->api(self::REQUEST_POST, '/rest/api/2/issue/', array('fields' => $default)); }
[ "public", "function", "createIssue", "(", "$", "project_key", ",", "$", "summary", ",", "$", "issue_type", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'project'", "=>", "array", "(", "'key'", "=>", "$", "project_key", ",", ")", ",", "'summary'", "=>", "$", "summary", ",", "'issuetype'", "=>", "array", "(", "'id'", "=>", "$", "issue_type", ",", ")", ",", ")", ";", "$", "default", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "'/rest/api/2/issue/'", ",", "array", "(", "'fields'", "=>", "$", "default", ")", ")", ";", "}" ]
Creates an issue. @param string $project_key Project key. @param string $summary Summary. @param string $issue_type Issue type. @param array $options Options. @return Result|false
[ "Creates", "an", "issue", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L530-L545
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.search
public function search($jql, $start_at = 0, $max_results = 20, $fields = '*navigable') { $result = $this->api( self::REQUEST_GET, '/rest/api/2/search', array( 'jql' => $jql, 'startAt' => $start_at, 'maxResults' => $max_results, 'fields' => $fields, ) ); return $result; }
php
public function search($jql, $start_at = 0, $max_results = 20, $fields = '*navigable') { $result = $this->api( self::REQUEST_GET, '/rest/api/2/search', array( 'jql' => $jql, 'startAt' => $start_at, 'maxResults' => $max_results, 'fields' => $fields, ) ); return $result; }
[ "public", "function", "search", "(", "$", "jql", ",", "$", "start_at", "=", "0", ",", "$", "max_results", "=", "20", ",", "$", "fields", "=", "'*navigable'", ")", "{", "$", "result", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/search'", ",", "array", "(", "'jql'", "=>", "$", "jql", ",", "'startAt'", "=>", "$", "start_at", ",", "'maxResults'", "=>", "$", "max_results", ",", "'fields'", "=>", "$", "fields", ",", ")", ")", ";", "return", "$", "result", ";", "}" ]
Query issues. @param string $jql JQL. @param integer $start_at Start at. @param integer $max_results Max results. @param string $fields Fields. @return Result|false
[ "Query", "issues", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L557-L571
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.createVersion
public function createVersion($project_key, $version, array $options = array()) { $options = array_merge( array( 'name' => $version, 'description' => '', 'project' => $project_key, // 'userReleaseDate' => '', // 'releaseDate' => '', 'released' => false, 'archived' => false, ), $options ); return $this->api(self::REQUEST_POST, '/rest/api/2/version', $options); }
php
public function createVersion($project_key, $version, array $options = array()) { $options = array_merge( array( 'name' => $version, 'description' => '', 'project' => $project_key, // 'userReleaseDate' => '', // 'releaseDate' => '', 'released' => false, 'archived' => false, ), $options ); return $this->api(self::REQUEST_POST, '/rest/api/2/version', $options); }
[ "public", "function", "createVersion", "(", "$", "project_key", ",", "$", "version", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "array", "(", "'name'", "=>", "$", "version", ",", "'description'", "=>", "''", ",", "'project'", "=>", "$", "project_key", ",", "// 'userReleaseDate' => '',", "// 'releaseDate' => '',", "'released'", "=>", "false", ",", "'archived'", "=>", "false", ",", ")", ",", "$", "options", ")", ";", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "'/rest/api/2/version'", ",", "$", "options", ")", ";", "}" ]
Creates new version. @param string $project_key Project key. @param string $version Version. @param array $options Options. @return Result|false
[ "Creates", "new", "version", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L582-L598
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.updateVersion
public function updateVersion($version_id, array $params = array()) { return $this->api(self::REQUEST_PUT, sprintf('/rest/api/2/version/%d', $version_id), $params); }
php
public function updateVersion($version_id, array $params = array()) { return $this->api(self::REQUEST_PUT, sprintf('/rest/api/2/version/%d', $version_id), $params); }
[ "public", "function", "updateVersion", "(", "$", "version_id", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_PUT", ",", "sprintf", "(", "'/rest/api/2/version/%d'", ",", "$", "version_id", ")", ",", "$", "params", ")", ";", "}" ]
Updates version. @param integer $version_id Version ID. @param array $params Key->Value list to update the version with. @return false @since 2.0.0 @link https://docs.atlassian.com/jira/REST/latest/#api/2/version-updateVersion
[ "Updates", "version", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L610-L613
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.releaseVersion
public function releaseVersion($version_id, $release_date = null, array $params = array()) { if ( !$release_date ) { $release_date = date('Y-m-d'); } $params = array_merge( array( 'releaseDate' => $release_date, 'released' => true, ), $params ); return $this->updateVersion($version_id, $params); }
php
public function releaseVersion($version_id, $release_date = null, array $params = array()) { if ( !$release_date ) { $release_date = date('Y-m-d'); } $params = array_merge( array( 'releaseDate' => $release_date, 'released' => true, ), $params ); return $this->updateVersion($version_id, $params); }
[ "public", "function", "releaseVersion", "(", "$", "version_id", ",", "$", "release_date", "=", "null", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "release_date", ")", "{", "$", "release_date", "=", "date", "(", "'Y-m-d'", ")", ";", "}", "$", "params", "=", "array_merge", "(", "array", "(", "'releaseDate'", "=>", "$", "release_date", ",", "'released'", "=>", "true", ",", ")", ",", "$", "params", ")", ";", "return", "$", "this", "->", "updateVersion", "(", "$", "version_id", ",", "$", "params", ")", ";", "}" ]
Shorthand to mark a version as Released. @param integer $version_id Version ID. @param string|null $release_date Date in Y-m-d format (defaults to today). @param array $params Optionally extra parameters. @return false @since 2.0.0
[ "Shorthand", "to", "mark", "a", "version", "as", "Released", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L625-L640
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.createAttachment
public function createAttachment($issue_key, $filename, $name = null) { $options = array( 'file' => '@' . $filename, 'name' => $name, ); return $this->api( self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/attachments', $issue_key), $options, false, true ); }
php
public function createAttachment($issue_key, $filename, $name = null) { $options = array( 'file' => '@' . $filename, 'name' => $name, ); return $this->api( self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/attachments', $issue_key), $options, false, true ); }
[ "public", "function", "createAttachment", "(", "$", "issue_key", ",", "$", "filename", ",", "$", "name", "=", "null", ")", "{", "$", "options", "=", "array", "(", "'file'", "=>", "'@'", ".", "$", "filename", ",", "'name'", "=>", "$", "name", ",", ")", ";", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "sprintf", "(", "'/rest/api/2/issue/%s/attachments'", ",", "$", "issue_key", ")", ",", "$", "options", ",", "false", ",", "true", ")", ";", "}" ]
Create attachment. @param string $issue_key Issue key. @param string $filename Filename. @param string $name Name. @return Result|false
[ "Create", "attachment", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L651-L665
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.createRemoteLink
public function createRemoteLink( $issue_key, array $object = array(), $relationship = null, $global_id = null, array $application = null ) { $options = array( 'globalId' => $global_id, 'relationship' => $relationship, 'object' => $object, ); if ( !is_null($application) ) { $options['application'] = $application; } return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/remotelink', $issue_key), $options, true); }
php
public function createRemoteLink( $issue_key, array $object = array(), $relationship = null, $global_id = null, array $application = null ) { $options = array( 'globalId' => $global_id, 'relationship' => $relationship, 'object' => $object, ); if ( !is_null($application) ) { $options['application'] = $application; } return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/remotelink', $issue_key), $options, true); }
[ "public", "function", "createRemoteLink", "(", "$", "issue_key", ",", "array", "$", "object", "=", "array", "(", ")", ",", "$", "relationship", "=", "null", ",", "$", "global_id", "=", "null", ",", "array", "$", "application", "=", "null", ")", "{", "$", "options", "=", "array", "(", "'globalId'", "=>", "$", "global_id", ",", "'relationship'", "=>", "$", "relationship", ",", "'object'", "=>", "$", "object", ",", ")", ";", "if", "(", "!", "is_null", "(", "$", "application", ")", ")", "{", "$", "options", "[", "'application'", "]", "=", "$", "application", ";", "}", "return", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "sprintf", "(", "'/rest/api/2/issue/%s/remotelink'", ",", "$", "issue_key", ")", ",", "$", "options", ",", "true", ")", ";", "}" ]
Creates a remote link. @param string $issue_key Issue key. @param array $object Object. @param string $relationship Relationship. @param string $global_id Global ID. @param array $application Application. @return array|false @since 2.0.0
[ "Creates", "a", "remote", "link", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L679-L697
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.api
public function api( $method = self::REQUEST_GET, $url, $data = array(), $return_as_array = false, $is_file = false, $debug = false ) { $result = $this->client->sendRequest( $method, $url, $data, $this->getEndpoint(), $this->authentication, $is_file, $debug ); if ( strlen($result) ) { $json = json_decode($result, true); if ( $this->options & self::AUTOMAP_FIELDS ) { if ( isset($json['issues']) ) { if ( $this->fields === null ) { $this->getFields(); } foreach ( $json['issues'] as $offset => $issue ) { $json['issues'][$offset] = $this->automapFields($issue); } } } if ( $return_as_array ) { return $json; } else { return new Result($json); } } else { return false; } }
php
public function api( $method = self::REQUEST_GET, $url, $data = array(), $return_as_array = false, $is_file = false, $debug = false ) { $result = $this->client->sendRequest( $method, $url, $data, $this->getEndpoint(), $this->authentication, $is_file, $debug ); if ( strlen($result) ) { $json = json_decode($result, true); if ( $this->options & self::AUTOMAP_FIELDS ) { if ( isset($json['issues']) ) { if ( $this->fields === null ) { $this->getFields(); } foreach ( $json['issues'] as $offset => $issue ) { $json['issues'][$offset] = $this->automapFields($issue); } } } if ( $return_as_array ) { return $json; } else { return new Result($json); } } else { return false; } }
[ "public", "function", "api", "(", "$", "method", "=", "self", "::", "REQUEST_GET", ",", "$", "url", ",", "$", "data", "=", "array", "(", ")", ",", "$", "return_as_array", "=", "false", ",", "$", "is_file", "=", "false", ",", "$", "debug", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "client", "->", "sendRequest", "(", "$", "method", ",", "$", "url", ",", "$", "data", ",", "$", "this", "->", "getEndpoint", "(", ")", ",", "$", "this", "->", "authentication", ",", "$", "is_file", ",", "$", "debug", ")", ";", "if", "(", "strlen", "(", "$", "result", ")", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "$", "this", "->", "options", "&", "self", "::", "AUTOMAP_FIELDS", ")", "{", "if", "(", "isset", "(", "$", "json", "[", "'issues'", "]", ")", ")", "{", "if", "(", "$", "this", "->", "fields", "===", "null", ")", "{", "$", "this", "->", "getFields", "(", ")", ";", "}", "foreach", "(", "$", "json", "[", "'issues'", "]", "as", "$", "offset", "=>", "$", "issue", ")", "{", "$", "json", "[", "'issues'", "]", "[", "$", "offset", "]", "=", "$", "this", "->", "automapFields", "(", "$", "issue", ")", ";", "}", "}", "}", "if", "(", "$", "return_as_array", ")", "{", "return", "$", "json", ";", "}", "else", "{", "return", "new", "Result", "(", "$", "json", ")", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Send request to specified host. @param string $method Request method. @param string $url URL. @param array|string $data Data. @param boolean $return_as_array Return results as associative array. @param boolean $is_file Is file-related request. @param boolean $debug Debug this request. @return array|Result|false
[ "Send", "request", "to", "specified", "host", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L711-L754
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.downloadAttachment
public function downloadAttachment($url) { $result = $this->client->sendRequest( self::REQUEST_GET, $url, array(), null, $this->authentication, true, false ); return $result; }
php
public function downloadAttachment($url) { $result = $this->client->sendRequest( self::REQUEST_GET, $url, array(), null, $this->authentication, true, false ); return $result; }
[ "public", "function", "downloadAttachment", "(", "$", "url", ")", "{", "$", "result", "=", "$", "this", "->", "client", "->", "sendRequest", "(", "self", "::", "REQUEST_GET", ",", "$", "url", ",", "array", "(", ")", ",", "null", ",", "$", "this", "->", "authentication", ",", "true", ",", "false", ")", ";", "return", "$", "result", ";", "}" ]
Downloads attachment. @param string $url URL. @return array|string
[ "Downloads", "attachment", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L763-L776
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.automapFields
protected function automapFields(array $issue) { if ( isset($issue['fields']) ) { $x = array(); foreach ( $issue['fields'] as $kk => $vv ) { if ( isset($this->fields[$kk]) ) { $x[$this->fields[$kk]['name']] = $vv; } else { $x[$kk] = $vv; } } $issue['fields'] = $x; } return $issue; }
php
protected function automapFields(array $issue) { if ( isset($issue['fields']) ) { $x = array(); foreach ( $issue['fields'] as $kk => $vv ) { if ( isset($this->fields[$kk]) ) { $x[$this->fields[$kk]['name']] = $vv; } else { $x[$kk] = $vv; } } $issue['fields'] = $x; } return $issue; }
[ "protected", "function", "automapFields", "(", "array", "$", "issue", ")", "{", "if", "(", "isset", "(", "$", "issue", "[", "'fields'", "]", ")", ")", "{", "$", "x", "=", "array", "(", ")", ";", "foreach", "(", "$", "issue", "[", "'fields'", "]", "as", "$", "kk", "=>", "$", "vv", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "kk", "]", ")", ")", "{", "$", "x", "[", "$", "this", "->", "fields", "[", "$", "kk", "]", "[", "'name'", "]", "]", "=", "$", "vv", ";", "}", "else", "{", "$", "x", "[", "$", "kk", "]", "=", "$", "vv", ";", "}", "}", "$", "issue", "[", "'fields'", "]", "=", "$", "x", ";", "}", "return", "$", "issue", ";", "}" ]
Automaps issue fields. @param array $issue Issue. @return array
[ "Automaps", "issue", "fields", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L785-L803
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.setWatchers
public function setWatchers($issue_key, array $watchers) { $result = array(); foreach ( $watchers as $watcher ) { $result[] = $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/watchers', $issue_key), $watcher); } return $result; }
php
public function setWatchers($issue_key, array $watchers) { $result = array(); foreach ( $watchers as $watcher ) { $result[] = $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/watchers', $issue_key), $watcher); } return $result; }
[ "public", "function", "setWatchers", "(", "$", "issue_key", ",", "array", "$", "watchers", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "watchers", "as", "$", "watcher", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_POST", ",", "sprintf", "(", "'/rest/api/2/issue/%s/watchers'", ",", "$", "issue_key", ")", ",", "$", "watcher", ")", ";", "}", "return", "$", "result", ";", "}" ]
Set issue watchers. @param string $issue_key Issue key. @param array $watchers Watchers. @return Result|false
[ "Set", "issue", "watchers", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L813-L822
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.closeIssue
public function closeIssue($issue_key) { $result = array(); // Get available transitions. $tmp_transitions = $this->getTransitions($issue_key, array()); $tmp_transitions_result = $tmp_transitions->getResult(); $transitions = $tmp_transitions_result['transitions']; // Look for "Close Issue" transition in issue transitions. foreach ( $transitions as $v ) { // Close issue if required id was found. if ( $v['name'] == 'Close Issue' ) { $result = $this->transition( $issue_key, array( 'transition' => array('id' => $v['id']), ) ); break; } } return $result; }
php
public function closeIssue($issue_key) { $result = array(); // Get available transitions. $tmp_transitions = $this->getTransitions($issue_key, array()); $tmp_transitions_result = $tmp_transitions->getResult(); $transitions = $tmp_transitions_result['transitions']; // Look for "Close Issue" transition in issue transitions. foreach ( $transitions as $v ) { // Close issue if required id was found. if ( $v['name'] == 'Close Issue' ) { $result = $this->transition( $issue_key, array( 'transition' => array('id' => $v['id']), ) ); break; } } return $result; }
[ "public", "function", "closeIssue", "(", "$", "issue_key", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// Get available transitions.", "$", "tmp_transitions", "=", "$", "this", "->", "getTransitions", "(", "$", "issue_key", ",", "array", "(", ")", ")", ";", "$", "tmp_transitions_result", "=", "$", "tmp_transitions", "->", "getResult", "(", ")", ";", "$", "transitions", "=", "$", "tmp_transitions_result", "[", "'transitions'", "]", ";", "// Look for \"Close Issue\" transition in issue transitions.", "foreach", "(", "$", "transitions", "as", "$", "v", ")", "{", "// Close issue if required id was found.", "if", "(", "$", "v", "[", "'name'", "]", "==", "'Close Issue'", ")", "{", "$", "result", "=", "$", "this", "->", "transition", "(", "$", "issue_key", ",", "array", "(", "'transition'", "=>", "array", "(", "'id'", "=>", "$", "v", "[", "'id'", "]", ")", ",", ")", ")", ";", "break", ";", "}", "}", "return", "$", "result", ";", "}" ]
Closes issue. @param string $issue_key Issue key. @return Result|array @TODO: Should have parameters? (e.g comment)
[ "Closes", "issue", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L832-L856
train
chobie/jira-api-restclient
src/Jira/Api.php
Api.getResolutions
public function getResolutions() { // Fetch resolutions when the method is called for the first time. if ( $this->resolutions === null ) { $resolutions = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/resolution', array(), true); foreach ( $result as $resolution ) { $resolutions[$resolution['id']] = $resolution; } $this->resolutions = $resolutions; } return $this->resolutions; }
php
public function getResolutions() { // Fetch resolutions when the method is called for the first time. if ( $this->resolutions === null ) { $resolutions = array(); $result = $this->api(self::REQUEST_GET, '/rest/api/2/resolution', array(), true); foreach ( $result as $resolution ) { $resolutions[$resolution['id']] = $resolution; } $this->resolutions = $resolutions; } return $this->resolutions; }
[ "public", "function", "getResolutions", "(", ")", "{", "// Fetch resolutions when the method is called for the first time.", "if", "(", "$", "this", "->", "resolutions", "===", "null", ")", "{", "$", "resolutions", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "api", "(", "self", "::", "REQUEST_GET", ",", "'/rest/api/2/resolution'", ",", "array", "(", ")", ",", "true", ")", ";", "foreach", "(", "$", "result", "as", "$", "resolution", ")", "{", "$", "resolutions", "[", "$", "resolution", "[", "'id'", "]", "]", "=", "$", "resolution", ";", "}", "$", "this", "->", "resolutions", "=", "$", "resolutions", ";", "}", "return", "$", "this", "->", "resolutions", ";", "}" ]
Returns a list of all resolutions. @return array @since 2.0.0
[ "Returns", "a", "list", "of", "all", "resolutions", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api.php#L890-L905
train
chobie/jira-api-restclient
src/Jira/Issues/Walker.php
Walker.push
public function push($jql, $fields = null) { $this->jql = $jql; $this->fields = $fields; }
php
public function push($jql, $fields = null) { $this->jql = $jql; $this->fields = $fields; }
[ "public", "function", "push", "(", "$", "jql", ",", "$", "fields", "=", "null", ")", "{", "$", "this", "->", "jql", "=", "$", "jql", ";", "$", "this", "->", "fields", "=", "$", "fields", ";", "}" ]
Pushes JQL. @param string $jql JQL. @param string|array|null $fields Fields. @return void
[ "Pushes", "JQL", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Issues/Walker.php#L140-L144
train
chobie/jira-api-restclient
src/Jira/Issues/Walker.php
Walker.setResult
protected function setResult(Api\Result $result) { $this->total = $result->getTotal(); $this->offset = 0; $this->max = $result->getIssuesCount(); $this->issues = $result->getIssues(); $this->startAt++; }
php
protected function setResult(Api\Result $result) { $this->total = $result->getTotal(); $this->offset = 0; $this->max = $result->getIssuesCount(); $this->issues = $result->getIssues(); $this->startAt++; }
[ "protected", "function", "setResult", "(", "Api", "\\", "Result", "$", "result", ")", "{", "$", "this", "->", "total", "=", "$", "result", "->", "getTotal", "(", ")", ";", "$", "this", "->", "offset", "=", "0", ";", "$", "this", "->", "max", "=", "$", "result", "->", "getIssuesCount", "(", ")", ";", "$", "this", "->", "issues", "=", "$", "result", "->", "getIssues", "(", ")", ";", "$", "this", "->", "startAt", "++", ";", "}" ]
Sets result. @param Api\Result $result Result. @return void
[ "Sets", "result", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Issues/Walker.php#L314-L321
train
chobie/jira-api-restclient
src/Jira/Api/Result.php
Result.getIssues
public function getIssues() { if ( isset($this->result['issues']) ) { $result = array(); foreach ( $this->result['issues'] as $issue ) { $result[] = new Issue($issue); } return $result; } return array(); }
php
public function getIssues() { if ( isset($this->result['issues']) ) { $result = array(); foreach ( $this->result['issues'] as $issue ) { $result[] = new Issue($issue); } return $result; } return array(); }
[ "public", "function", "getIssues", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "result", "[", "'issues'", "]", ")", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "result", "[", "'issues'", "]", "as", "$", "issue", ")", "{", "$", "result", "[", "]", "=", "new", "Issue", "(", "$", "issue", ")", ";", "}", "return", "$", "result", ";", "}", "return", "array", "(", ")", ";", "}" ]
Returns issues. @return array
[ "Returns", "issues", "." ]
9e55fa0515da8b2e7d702fd0b6708be02428afe9
https://github.com/chobie/jira-api-restclient/blob/9e55fa0515da8b2e7d702fd0b6708be02428afe9/src/Jira/Api/Result.php#L119-L132
train
mmoreram/php-formatter
src/PHPFormatter/Loader/ConfigLoader.php
ConfigLoader.loadConfigValue
public function loadConfigValue( $commandName, $configValue, $commandValue, $defaultValue ) { return array_key_exists($commandName, $configValue) ? ($configValue[$commandName] ?? '') : (!is_null($commandValue) ? $commandValue : $defaultValue); }
php
public function loadConfigValue( $commandName, $configValue, $commandValue, $defaultValue ) { return array_key_exists($commandName, $configValue) ? ($configValue[$commandName] ?? '') : (!is_null($commandValue) ? $commandValue : $defaultValue); }
[ "public", "function", "loadConfigValue", "(", "$", "commandName", ",", "$", "configValue", ",", "$", "commandValue", ",", "$", "defaultValue", ")", "{", "return", "array_key_exists", "(", "$", "commandName", ",", "$", "configValue", ")", "?", "(", "$", "configValue", "[", "$", "commandName", "]", "??", "''", ")", ":", "(", "!", "is_null", "(", "$", "commandValue", ")", "?", "$", "commandValue", ":", "$", "defaultValue", ")", ";", "}" ]
This method parses the config file, if exists, and determines the real option value. * If an option is defined as a command parameter, this will be used * Otherwise, if an option is defined in the configuration file, this will be used. * Otherwise, default values will be used If none of these is defined, then return null @param string $commandName @param mixed $configValue @param mixed $commandValue @param mixed $defaultValue @return mixed|null
[ "This", "method", "parses", "the", "config", "file", "if", "exists", "and", "determines", "the", "real", "option", "value", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Loader/ConfigLoader.php#L91-L102
train
mmoreram/php-formatter
src/PHPFormatter/Fixer/UseSortFixer.php
UseSortFixer.createGroups
private function createGroups(array $namespaces) { $groups = []; foreach ($this->groups as $group) { if (is_array($group)) { $groups[] = array_fill_keys($group, []); } else { $groups[$group] = []; } } if (!array_key_exists('_main', $groups)) { $groups = array_merge( ['_main' => []], $groups ); } foreach ($namespaces as $namespace) { foreach ($groups as $groupKey => $group) { if (is_int($groupKey)) { foreach ($group as $subGroupKey => $subGroup) { if (strpos($namespace, $subGroupKey) === 0) { array_push($groups[$groupKey][$subGroupKey], $namespace); continue 3; } } } elseif (is_string($groupKey) && strpos($namespace, $groupKey) === 0) { array_push($groups[$groupKey], $namespace); continue 2; } } array_push($groups['_main'], $namespace); } return $groups; }
php
private function createGroups(array $namespaces) { $groups = []; foreach ($this->groups as $group) { if (is_array($group)) { $groups[] = array_fill_keys($group, []); } else { $groups[$group] = []; } } if (!array_key_exists('_main', $groups)) { $groups = array_merge( ['_main' => []], $groups ); } foreach ($namespaces as $namespace) { foreach ($groups as $groupKey => $group) { if (is_int($groupKey)) { foreach ($group as $subGroupKey => $subGroup) { if (strpos($namespace, $subGroupKey) === 0) { array_push($groups[$groupKey][$subGroupKey], $namespace); continue 3; } } } elseif (is_string($groupKey) && strpos($namespace, $groupKey) === 0) { array_push($groups[$groupKey], $namespace); continue 2; } } array_push($groups['_main'], $namespace); } return $groups; }
[ "private", "function", "createGroups", "(", "array", "$", "namespaces", ")", "{", "$", "groups", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "if", "(", "is_array", "(", "$", "group", ")", ")", "{", "$", "groups", "[", "]", "=", "array_fill_keys", "(", "$", "group", ",", "[", "]", ")", ";", "}", "else", "{", "$", "groups", "[", "$", "group", "]", "=", "[", "]", ";", "}", "}", "if", "(", "!", "array_key_exists", "(", "'_main'", ",", "$", "groups", ")", ")", "{", "$", "groups", "=", "array_merge", "(", "[", "'_main'", "=>", "[", "]", "]", ",", "$", "groups", ")", ";", "}", "foreach", "(", "$", "namespaces", "as", "$", "namespace", ")", "{", "foreach", "(", "$", "groups", "as", "$", "groupKey", "=>", "$", "group", ")", "{", "if", "(", "is_int", "(", "$", "groupKey", ")", ")", "{", "foreach", "(", "$", "group", "as", "$", "subGroupKey", "=>", "$", "subGroup", ")", "{", "if", "(", "strpos", "(", "$", "namespace", ",", "$", "subGroupKey", ")", "===", "0", ")", "{", "array_push", "(", "$", "groups", "[", "$", "groupKey", "]", "[", "$", "subGroupKey", "]", ",", "$", "namespace", ")", ";", "continue", "3", ";", "}", "}", "}", "elseif", "(", "is_string", "(", "$", "groupKey", ")", "&&", "strpos", "(", "$", "namespace", ",", "$", "groupKey", ")", "===", "0", ")", "{", "array_push", "(", "$", "groups", "[", "$", "groupKey", "]", ",", "$", "namespace", ")", ";", "continue", "2", ";", "}", "}", "array_push", "(", "$", "groups", "[", "'_main'", "]", ",", "$", "namespace", ")", ";", "}", "return", "$", "groups", ";", "}" ]
Create blocks. @param array $namespaces Namespaces @return array Groups
[ "Create", "blocks", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Fixer/UseSortFixer.php#L277-L317
train
mmoreram/php-formatter
src/PHPFormatter/Fixer/UseSortFixer.php
UseSortFixer.sortGroup
private function sortGroup(array $group) { if (empty($group)) { return []; } if ($this->sortType == self::SORT_TYPE_LENGTH) { usort($group, function ($a, $b) { $cmp = strlen($b) - strlen($a); if ($cmp === 0) { $a = strtolower($a); $b = strtolower($b); $cmp = strcmp($b, $a); } return $cmp; }); } elseif ($this->sortType == self::SORT_TYPE_ALPHABETIC) { usort($group, function ($a, $b) { $a = strtolower($a); $b = strtolower($b); $cmp = strcmp($b, $a); if ($cmp === 0) { $cmp = strlen($b) - strlen($a); } return $cmp; }); } if ($this->sortDirection == self::SORT_DIRECTION_ASC) { $group = array_reverse($group); } return $group; }
php
private function sortGroup(array $group) { if (empty($group)) { return []; } if ($this->sortType == self::SORT_TYPE_LENGTH) { usort($group, function ($a, $b) { $cmp = strlen($b) - strlen($a); if ($cmp === 0) { $a = strtolower($a); $b = strtolower($b); $cmp = strcmp($b, $a); } return $cmp; }); } elseif ($this->sortType == self::SORT_TYPE_ALPHABETIC) { usort($group, function ($a, $b) { $a = strtolower($a); $b = strtolower($b); $cmp = strcmp($b, $a); if ($cmp === 0) { $cmp = strlen($b) - strlen($a); } return $cmp; }); } if ($this->sortDirection == self::SORT_DIRECTION_ASC) { $group = array_reverse($group); } return $group; }
[ "private", "function", "sortGroup", "(", "array", "$", "group", ")", "{", "if", "(", "empty", "(", "$", "group", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "$", "this", "->", "sortType", "==", "self", "::", "SORT_TYPE_LENGTH", ")", "{", "usort", "(", "$", "group", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "$", "cmp", "=", "strlen", "(", "$", "b", ")", "-", "strlen", "(", "$", "a", ")", ";", "if", "(", "$", "cmp", "===", "0", ")", "{", "$", "a", "=", "strtolower", "(", "$", "a", ")", ";", "$", "b", "=", "strtolower", "(", "$", "b", ")", ";", "$", "cmp", "=", "strcmp", "(", "$", "b", ",", "$", "a", ")", ";", "}", "return", "$", "cmp", ";", "}", ")", ";", "}", "elseif", "(", "$", "this", "->", "sortType", "==", "self", "::", "SORT_TYPE_ALPHABETIC", ")", "{", "usort", "(", "$", "group", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "$", "a", "=", "strtolower", "(", "$", "a", ")", ";", "$", "b", "=", "strtolower", "(", "$", "b", ")", ";", "$", "cmp", "=", "strcmp", "(", "$", "b", ",", "$", "a", ")", ";", "if", "(", "$", "cmp", "===", "0", ")", "{", "$", "cmp", "=", "strlen", "(", "$", "b", ")", "-", "strlen", "(", "$", "a", ")", ";", "}", "return", "$", "cmp", ";", "}", ")", ";", "}", "if", "(", "$", "this", "->", "sortDirection", "==", "self", "::", "SORT_DIRECTION_ASC", ")", "{", "$", "group", "=", "array_reverse", "(", "$", "group", ")", ";", "}", "return", "$", "group", ";", "}" ]
Sort a group. @param array $group Group to sort @return array $group Sorted
[ "Sort", "a", "group", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Fixer/UseSortFixer.php#L326-L364
train
mmoreram/php-formatter
src/PHPFormatter/Fixer/UseSortFixer.php
UseSortFixer.renderGroup
private function renderGroup(array $group) { if (empty($group)) { return ''; } if ($this->groupType === self::GROUP_TYPE_EACH) { return implode(PHP_EOL, array_map(function ($namespace) { return 'use ' . $namespace . ';'; }, $group)); } elseif ($this->groupType === self::GROUP_TYPE_ONE) { $group = implode(',' . PHP_EOL . ' ', $group); return 'use ' . $group . ';'; } }
php
private function renderGroup(array $group) { if (empty($group)) { return ''; } if ($this->groupType === self::GROUP_TYPE_EACH) { return implode(PHP_EOL, array_map(function ($namespace) { return 'use ' . $namespace . ';'; }, $group)); } elseif ($this->groupType === self::GROUP_TYPE_ONE) { $group = implode(',' . PHP_EOL . ' ', $group); return 'use ' . $group . ';'; } }
[ "private", "function", "renderGroup", "(", "array", "$", "group", ")", "{", "if", "(", "empty", "(", "$", "group", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "this", "->", "groupType", "===", "self", "::", "GROUP_TYPE_EACH", ")", "{", "return", "implode", "(", "PHP_EOL", ",", "array_map", "(", "function", "(", "$", "namespace", ")", "{", "return", "'use '", ".", "$", "namespace", ".", "';'", ";", "}", ",", "$", "group", ")", ")", ";", "}", "elseif", "(", "$", "this", "->", "groupType", "===", "self", "::", "GROUP_TYPE_ONE", ")", "{", "$", "group", "=", "implode", "(", "','", ".", "PHP_EOL", ".", "' '", ",", "$", "group", ")", ";", "return", "'use '", ".", "$", "group", ".", "';'", ";", "}", "}" ]
Render a group. @param array $group Group @return string Group rendered
[ "Render", "a", "group", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Fixer/UseSortFixer.php#L373-L387
train
mmoreram/php-formatter
src/PHPFormatter/Command/PHPFormatterCommand.php
PHPFormatterCommand.printInitMessage
protected function printInitMessage( InputInterface $input, OutputInterface $output, string $path, array $excludes ) { $output->writeln('# PHP Formatter'); /* * Dry-run message */ if ($input->getOption('dry-run')) { $output->writeln('# <info> This process has been executed in mode dry-run'); } $output->writeln('# Executing process in ' . $path); foreach ($excludes as $exclude) { $output->writeln('# Path excluded - ' . $exclude); } }
php
protected function printInitMessage( InputInterface $input, OutputInterface $output, string $path, array $excludes ) { $output->writeln('# PHP Formatter'); /* * Dry-run message */ if ($input->getOption('dry-run')) { $output->writeln('# <info> This process has been executed in mode dry-run'); } $output->writeln('# Executing process in ' . $path); foreach ($excludes as $exclude) { $output->writeln('# Path excluded - ' . $exclude); } }
[ "protected", "function", "printInitMessage", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "string", "$", "path", ",", "array", "$", "excludes", ")", "{", "$", "output", "->", "writeln", "(", "'# PHP Formatter'", ")", ";", "/*\n * Dry-run message\n */", "if", "(", "$", "input", "->", "getOption", "(", "'dry-run'", ")", ")", "{", "$", "output", "->", "writeln", "(", "'# <info> This process has been executed in mode dry-run'", ")", ";", "}", "$", "output", "->", "writeln", "(", "'# Executing process in '", ".", "$", "path", ")", ";", "foreach", "(", "$", "excludes", "as", "$", "exclude", ")", "{", "$", "output", "->", "writeln", "(", "'# Path excluded - '", ".", "$", "exclude", ")", ";", "}", "}" ]
Print the Dry-run message if needed. @param InputInterface $input @param OutputInterface $output @param string $path @param array $excludes
[ "Print", "the", "Dry", "-", "run", "message", "if", "needed", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Command/PHPFormatterCommand.php#L148-L167
train
mmoreram/php-formatter
src/PHPFormatter/Command/PHPFormatterCommand.php
PHPFormatterCommand.loadFiles
protected function loadFiles( string $path, array $excludes ) { $fileFinder = new FileFinder(); /** * Building the real directory or file to work in. */ $filesystem = new Filesystem(); if (!$filesystem->isAbsolutePath($path)) { $path = getcwd() . DIRECTORY_SEPARATOR . ltrim($path, '/'); } if (!is_file($path) && !is_dir($path)) { throw new Exception('Directory or file "' . $path . '" does not exist'); } return $fileFinder ->findPHPFilesByPath( $path, $excludes ); }
php
protected function loadFiles( string $path, array $excludes ) { $fileFinder = new FileFinder(); /** * Building the real directory or file to work in. */ $filesystem = new Filesystem(); if (!$filesystem->isAbsolutePath($path)) { $path = getcwd() . DIRECTORY_SEPARATOR . ltrim($path, '/'); } if (!is_file($path) && !is_dir($path)) { throw new Exception('Directory or file "' . $path . '" does not exist'); } return $fileFinder ->findPHPFilesByPath( $path, $excludes ); }
[ "protected", "function", "loadFiles", "(", "string", "$", "path", ",", "array", "$", "excludes", ")", "{", "$", "fileFinder", "=", "new", "FileFinder", "(", ")", ";", "/**\n * Building the real directory or file to work in.\n */", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "if", "(", "!", "$", "filesystem", "->", "isAbsolutePath", "(", "$", "path", ")", ")", "{", "$", "path", "=", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "}", "if", "(", "!", "is_file", "(", "$", "path", ")", "&&", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "Exception", "(", "'Directory or file \"'", ".", "$", "path", ".", "'\" does not exist'", ")", ";", "}", "return", "$", "fileFinder", "->", "findPHPFilesByPath", "(", "$", "path", ",", "$", "excludes", ")", ";", "}" ]
Load files to work with. @param string $path @param array $excludes @return Finder|SplFileInfo[] @throws Exception
[ "Load", "files", "to", "work", "with", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Command/PHPFormatterCommand.php#L228-L251
train
mmoreram/php-formatter
src/PHPFormatter/Command/PHPFormatterCommand.php
PHPFormatterCommand.fixFiles
protected function fixFiles( InputInterface $input, OutputInterface $output, Finder $files, FixerInterface $fixer ) { $verbose = $output->getVerbosity(); /* * Each found php file is processed */ foreach ($files as $file) { $data = $file->getContents(); $result = $fixer->fix($data); if ($result === false || $data === $result) { continue; } if ($verbose >= OutputInterface::VERBOSITY_NORMAL) { $output->writeln('# ' . $file); } if (!$input->getOption('dry-run')) { file_put_contents($file->getRealPath(), $result); } } }
php
protected function fixFiles( InputInterface $input, OutputInterface $output, Finder $files, FixerInterface $fixer ) { $verbose = $output->getVerbosity(); /* * Each found php file is processed */ foreach ($files as $file) { $data = $file->getContents(); $result = $fixer->fix($data); if ($result === false || $data === $result) { continue; } if ($verbose >= OutputInterface::VERBOSITY_NORMAL) { $output->writeln('# ' . $file); } if (!$input->getOption('dry-run')) { file_put_contents($file->getRealPath(), $result); } } }
[ "protected", "function", "fixFiles", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "Finder", "$", "files", ",", "FixerInterface", "$", "fixer", ")", "{", "$", "verbose", "=", "$", "output", "->", "getVerbosity", "(", ")", ";", "/*\n * Each found php file is processed\n */", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "data", "=", "$", "file", "->", "getContents", "(", ")", ";", "$", "result", "=", "$", "fixer", "->", "fix", "(", "$", "data", ")", ";", "if", "(", "$", "result", "===", "false", "||", "$", "data", "===", "$", "result", ")", "{", "continue", ";", "}", "if", "(", "$", "verbose", ">=", "OutputInterface", "::", "VERBOSITY_NORMAL", ")", "{", "$", "output", "->", "writeln", "(", "'# '", ".", "$", "file", ")", ";", "}", "if", "(", "!", "$", "input", "->", "getOption", "(", "'dry-run'", ")", ")", "{", "file_put_contents", "(", "$", "file", "->", "getRealPath", "(", ")", ",", "$", "result", ")", ";", "}", "}", "}" ]
Fix files with given fixer. @param InputInterface $input @param OutputInterface $output @param Finder $files @param FixerInterface $fixer
[ "Fix", "files", "with", "given", "fixer", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Command/PHPFormatterCommand.php#L261-L288
train
mmoreram/php-formatter
src/PHPFormatter/Command/UseSortCommand.php
UseSortCommand.getCommandConfigValue
protected function getCommandConfigValue(InputInterface $input) { $config = []; if (!empty($input->getOption('group'))) { $config['group'] = $input->getOption('group'); } if (true === ($input->getOption('group-skip-empty'))) { $config['group-skip-empty'] = true; } return array_merge( $config, array_filter([ 'group-type' => $input->getOption('group-type'), 'sort-type' => $input->getOption('sort-type'), 'sort-direction' => $input->getOption('sort-direction'), ], function ($element) { return !is_null($element); }) ); }
php
protected function getCommandConfigValue(InputInterface $input) { $config = []; if (!empty($input->getOption('group'))) { $config['group'] = $input->getOption('group'); } if (true === ($input->getOption('group-skip-empty'))) { $config['group-skip-empty'] = true; } return array_merge( $config, array_filter([ 'group-type' => $input->getOption('group-type'), 'sort-type' => $input->getOption('sort-type'), 'sort-direction' => $input->getOption('sort-direction'), ], function ($element) { return !is_null($element); }) ); }
[ "protected", "function", "getCommandConfigValue", "(", "InputInterface", "$", "input", ")", "{", "$", "config", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "input", "->", "getOption", "(", "'group'", ")", ")", ")", "{", "$", "config", "[", "'group'", "]", "=", "$", "input", "->", "getOption", "(", "'group'", ")", ";", "}", "if", "(", "true", "===", "(", "$", "input", "->", "getOption", "(", "'group-skip-empty'", ")", ")", ")", "{", "$", "config", "[", "'group-skip-empty'", "]", "=", "true", ";", "}", "return", "array_merge", "(", "$", "config", ",", "array_filter", "(", "[", "'group-type'", "=>", "$", "input", "->", "getOption", "(", "'group-type'", ")", ",", "'sort-type'", "=>", "$", "input", "->", "getOption", "(", "'sort-type'", ")", ",", "'sort-direction'", "=>", "$", "input", "->", "getOption", "(", "'sort-direction'", ")", ",", "]", ",", "function", "(", "$", "element", ")", "{", "return", "!", "is_null", "(", "$", "element", ")", ";", "}", ")", ")", ";", "}" ]
Get command config values. @param InputInterface $input @return mixed
[ "Get", "command", "config", "values", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Command/UseSortCommand.php#L91-L112
train
mmoreram/php-formatter
src/PHPFormatter/Command/UseSortCommand.php
UseSortCommand.getFixer
protected function getFixer($config) : FixerInterface { $useSortFixer = new UseSortFixer(); $useSortFixer ->setGroups($config['group']) ->setGroupType($config['group-type']) ->setGroupSkipEmpty($config['group-skip-empty']) ->setSortType($config['sort-type']) ->setSortDirection($config['sort-direction']); return $useSortFixer; }
php
protected function getFixer($config) : FixerInterface { $useSortFixer = new UseSortFixer(); $useSortFixer ->setGroups($config['group']) ->setGroupType($config['group-type']) ->setGroupSkipEmpty($config['group-skip-empty']) ->setSortType($config['sort-type']) ->setSortDirection($config['sort-direction']); return $useSortFixer; }
[ "protected", "function", "getFixer", "(", "$", "config", ")", ":", "FixerInterface", "{", "$", "useSortFixer", "=", "new", "UseSortFixer", "(", ")", ";", "$", "useSortFixer", "->", "setGroups", "(", "$", "config", "[", "'group'", "]", ")", "->", "setGroupType", "(", "$", "config", "[", "'group-type'", "]", ")", "->", "setGroupSkipEmpty", "(", "$", "config", "[", "'group-skip-empty'", "]", ")", "->", "setSortType", "(", "$", "config", "[", "'sort-type'", "]", ")", "->", "setSortDirection", "(", "$", "config", "[", "'sort-direction'", "]", ")", ";", "return", "$", "useSortFixer", ";", "}" ]
Get a fixer instance given the configuration. @param mixed $config @return FixerInterface
[ "Get", "a", "fixer", "instance", "given", "the", "configuration", "." ]
1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e
https://github.com/mmoreram/php-formatter/blob/1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e/src/PHPFormatter/Command/UseSortCommand.php#L156-L167
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Tool/RESTRequest.php
RESTRequest.executePutMultipart
protected function executePutMultipart ($ch) { $post = $this->request_body; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $this->response_body = curl_exec($ch); $this->response_info = curl_getinfo($ch); $this->closeCurlHandle(); }
php
protected function executePutMultipart ($ch) { $post = $this->request_body; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $this->response_body = curl_exec($ch); $this->response_info = curl_getinfo($ch); $this->closeCurlHandle(); }
[ "protected", "function", "executePutMultipart", "(", "$", "ch", ")", "{", "$", "post", "=", "$", "this", "->", "request_body", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "'PUT'", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "post", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "this", "->", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "this", "->", "response_body", "=", "curl_exec", "(", "$", "ch", ")", ";", "$", "this", "->", "response_info", "=", "curl_getinfo", "(", "$", "ch", ")", ";", "$", "this", "->", "closeCurlHandle", "(", ")", ";", "}" ]
Set verb to PUT_MP to use this function
[ "Set", "verb", "to", "PUT_MP", "to", "use", "this", "function" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Tool/RESTRequest.php#L205-L219
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/Job/Calendar/DatedCalendar.php
DatedCalendar.removeExcludeDate
public function removeExcludeDate($date) { $key = array_search($date, $this->excludeDays); if (!($key === False)) { unset($this->excludeDays[$key]); $this->excludeDays = array_values($this->excludeDays); } }
php
public function removeExcludeDate($date) { $key = array_search($date, $this->excludeDays); if (!($key === False)) { unset($this->excludeDays[$key]); $this->excludeDays = array_values($this->excludeDays); } }
[ "public", "function", "removeExcludeDate", "(", "$", "date", ")", "{", "$", "key", "=", "array_search", "(", "$", "date", ",", "$", "this", "->", "excludeDays", ")", ";", "if", "(", "!", "(", "$", "key", "===", "False", ")", ")", "{", "unset", "(", "$", "this", "->", "excludeDays", "[", "$", "key", "]", ")", ";", "$", "this", "->", "excludeDays", "=", "array_values", "(", "$", "this", "->", "excludeDays", ")", ";", "}", "}" ]
Remove a date from the exclude list @param string $date YYYY-MM-DD
[ "Remove", "a", "date", "from", "the", "exclude", "list" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/Job/Calendar/DatedCalendar.php#L42-L48
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ServerService.php
ServerService.addOrUpdateAttribute
public function addOrUpdateAttribute(Attribute $attribute) { $url = self::makeAttributeUrl(null, $attribute->name); $body = json_encode($attribute); $response = $this->service->prepAndSend($url, array(200, 201), 'PUT', $body, true); if (!empty($response)) { return Attribute::createFromJSON(json_decode($response)); } else { return true; } }
php
public function addOrUpdateAttribute(Attribute $attribute) { $url = self::makeAttributeUrl(null, $attribute->name); $body = json_encode($attribute); $response = $this->service->prepAndSend($url, array(200, 201), 'PUT', $body, true); if (!empty($response)) { return Attribute::createFromJSON(json_decode($response)); } else { return true; } }
[ "public", "function", "addOrUpdateAttribute", "(", "Attribute", "$", "attribute", ")", "{", "$", "url", "=", "self", "::", "makeAttributeUrl", "(", "null", ",", "$", "attribute", "->", "name", ")", ";", "$", "body", "=", "json_encode", "(", "$", "attribute", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ",", "201", ")", ",", "'PUT'", ",", "$", "body", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "response", ")", ")", "{", "return", "Attribute", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Create a new attribute, or update an existing attribute. If created, "true" is returned. If updated, the server-side representation of the attribute is returned. @param \Jaspersoft\Dto\Attribute\Attribute $attribute @return \Jaspersoft\Dto\Attribute\Attribute|bool
[ "Create", "a", "new", "attribute", "or", "update", "an", "existing", "attribute", ".", "If", "created", "true", "is", "returned", ".", "If", "updated", "the", "server", "-", "side", "representation", "of", "the", "attribute", "is", "returned", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ServerService.php#L77-L88
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ServerService.php
ServerService.replaceAttributes
public function replaceAttributes(array $attributes) { $url = self::makeAttributeUrl(); $data = json_encode(array("attribute" => $attributes)); $replaced = $this->service->prepAndSend($url, array(200), 'PUT', $data, true); $replaced = json_decode($replaced); $result = array(); foreach ($replaced->attribute as $attr) { $result[] = Attribute::createFromJSON($attr); } return $result; }
php
public function replaceAttributes(array $attributes) { $url = self::makeAttributeUrl(); $data = json_encode(array("attribute" => $attributes)); $replaced = $this->service->prepAndSend($url, array(200), 'PUT', $data, true); $replaced = json_decode($replaced); $result = array(); foreach ($replaced->attribute as $attr) { $result[] = Attribute::createFromJSON($attr); } return $result; }
[ "public", "function", "replaceAttributes", "(", "array", "$", "attributes", ")", "{", "$", "url", "=", "self", "::", "makeAttributeUrl", "(", ")", ";", "$", "data", "=", "json_encode", "(", "array", "(", "\"attribute\"", "=>", "$", "attributes", ")", ")", ";", "$", "replaced", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'PUT'", ",", "$", "data", ",", "true", ")", ";", "$", "replaced", "=", "json_decode", "(", "$", "replaced", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "replaced", "->", "attribute", "as", "$", "attr", ")", "{", "$", "result", "[", "]", "=", "Attribute", "::", "createFromJSON", "(", "$", "attr", ")", ";", "}", "return", "$", "result", ";", "}" ]
Replace all existing attributes with the provided set, the server's representation of the attributes will be returned. @param array $attributes @return array
[ "Replace", "all", "existing", "attributes", "with", "the", "provided", "set", "the", "server", "s", "representation", "of", "the", "attributes", "will", "be", "returned", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ServerService.php#L97-L109
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ServerService.php
ServerService.deleteAttributes
public function deleteAttributes($attributes = null) { $url = self::makeAttributeUrl(); if (!empty($attributes)) { $url .= '?' . Util::query_suffix(array('name' => $attributes)); } return $this->service->prepAndSend($url, array(204), 'DELETE', null, false); }
php
public function deleteAttributes($attributes = null) { $url = self::makeAttributeUrl(); if (!empty($attributes)) { $url .= '?' . Util::query_suffix(array('name' => $attributes)); } return $this->service->prepAndSend($url, array(204), 'DELETE', null, false); }
[ "public", "function", "deleteAttributes", "(", "$", "attributes", "=", "null", ")", "{", "$", "url", "=", "self", "::", "makeAttributeUrl", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "attributes", ")", ")", "{", "$", "url", ".=", "'?'", ".", "Util", "::", "query_suffix", "(", "array", "(", "'name'", "=>", "$", "attributes", ")", ")", ";", "}", "return", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "204", ")", ",", "'DELETE'", ",", "null", ",", "false", ")", ";", "}" ]
Remove all attributes, or specific attributes from an organization. If no attributes are defined, they will all be deleted. Some server attributes are unable to be deleted @param array $attributes An array of attribute names @return bool
[ "Remove", "all", "attributes", "or", "specific", "attributes", "from", "an", "organization", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ServerService.php#L119-L127
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/OptionsService.php
OptionsService.getReportOptions
public function getReportOptions($uri) { $url = $this->service_url . '/reports' . $uri . '/options'; $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', 'application/json'); return ReportOptions::createFromJSON($data); }
php
public function getReportOptions($uri) { $url = $this->service_url . '/reports' . $uri . '/options'; $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', 'application/json'); return ReportOptions::createFromJSON($data); }
[ "public", "function", "getReportOptions", "(", "$", "uri", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/reports'", ".", "$", "uri", ".", "'/options'", ";", "$", "data", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ",", "'application/json'", ",", "'application/json'", ")", ";", "return", "ReportOptions", "::", "createFromJSON", "(", "$", "data", ")", ";", "}" ]
Get report options @param string $uri @return array
[ "Get", "report", "options" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/OptionsService.php#L20-L25
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/OptionsService.php
OptionsService.updateReportOptions
public function updateReportOptions($uri, $controlOptions, $label, $overwrite) { $url = $this->service_url . '/reports' . $uri . '/options'; $url .= '?' . Util::query_suffix(array('label' => utf8_encode($label), 'overwrite' => $overwrite)); $body = json_encode($controlOptions); $data = $this->service->prepAndSend($url, array(200), 'POST', $body, true, 'application/json', 'application/json'); $data_array = json_decode($data, true); return new ReportOptions($data_array['uri'], $data_array['id'], $data_array['label']); }
php
public function updateReportOptions($uri, $controlOptions, $label, $overwrite) { $url = $this->service_url . '/reports' . $uri . '/options'; $url .= '?' . Util::query_suffix(array('label' => utf8_encode($label), 'overwrite' => $overwrite)); $body = json_encode($controlOptions); $data = $this->service->prepAndSend($url, array(200), 'POST', $body, true, 'application/json', 'application/json'); $data_array = json_decode($data, true); return new ReportOptions($data_array['uri'], $data_array['id'], $data_array['label']); }
[ "public", "function", "updateReportOptions", "(", "$", "uri", ",", "$", "controlOptions", ",", "$", "label", ",", "$", "overwrite", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/reports'", ".", "$", "uri", ".", "'/options'", ";", "$", "url", ".=", "'?'", ".", "Util", "::", "query_suffix", "(", "array", "(", "'label'", "=>", "utf8_encode", "(", "$", "label", ")", ",", "'overwrite'", "=>", "$", "overwrite", ")", ")", ";", "$", "body", "=", "json_encode", "(", "$", "controlOptions", ")", ";", "$", "data", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'POST'", ",", "$", "body", ",", "true", ",", "'application/json'", ",", "'application/json'", ")", ";", "$", "data_array", "=", "json_decode", "(", "$", "data", ",", "true", ")", ";", "return", "new", "ReportOptions", "(", "$", "data_array", "[", "'uri'", "]", ",", "$", "data_array", "[", "'id'", "]", ",", "$", "data_array", "[", "'label'", "]", ")", ";", "}" ]
Update or Create new Report Options. The argument $controlOptions must be an array in the following form: array('key' => array('value1', 'value2'), 'key2' => array('value1-2', 'value2-2')) Note that even when there is only one value, it must be encapsulated within an array. @param string $uri @param array $controlOptions @param string $label @param boolean $overwrite @throws \Jaspersoft\Exception\RESTRequestException @return \Jaspersoft\Dto\Options\ReportOptions
[ "Update", "or", "Create", "new", "Report", "Options", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/OptionsService.php#L43-L51
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/OptionsService.php
OptionsService.deleteReportOptions
public function deleteReportOptions($uri, $optionsLabel) { $url = $this->service_url . '/reports' . $uri . '/options/' . $optionsLabel; $this->service->prepAndSend($url, array(200), 'DELETE', null, false); }
php
public function deleteReportOptions($uri, $optionsLabel) { $url = $this->service_url . '/reports' . $uri . '/options/' . $optionsLabel; $this->service->prepAndSend($url, array(200), 'DELETE', null, false); }
[ "public", "function", "deleteReportOptions", "(", "$", "uri", ",", "$", "optionsLabel", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/reports'", ".", "$", "uri", ".", "'/options/'", ".", "$", "optionsLabel", ";", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'DELETE'", ",", "null", ",", "false", ")", ";", "}" ]
Remove a pre-existing report options. Provide the URI and Label of the report options you wish to remove. this function is limited in its ability to accept labels with whitespace. If you must delete a report option with whitespace in the label name, use the deleteResources function instead. Using the URL to the report option. @param string $uri @param string $optionsLabel @throws \Jaspersoft\Exception\RESTRequestException
[ "Remove", "a", "pre", "-", "existing", "report", "options", ".", "Provide", "the", "URI", "and", "Label", "of", "the", "report", "options", "you", "wish", "to", "remove", ".", "this", "function", "is", "limited", "in", "its", "ability", "to", "accept", "labels", "with", "whitespace", ".", "If", "you", "must", "delete", "a", "report", "option", "with", "whitespace", "in", "the", "label", "name", "use", "the", "deleteResources", "function", "instead", ".", "Using", "the", "URL", "to", "the", "report", "option", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/OptionsService.php#L62-L66
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/DomainService.php
DomainService.getMetadata
public function getMetadata($domainUri) { $url = $this->service_url . '/domains'. $domainUri . '/metadata'; $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); return MetaData::createFromJSON(json_decode($response)); }
php
public function getMetadata($domainUri) { $url = $this->service_url . '/domains'. $domainUri . '/metadata'; $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); return MetaData::createFromJSON(json_decode($response)); }
[ "public", "function", "getMetadata", "(", "$", "domainUri", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/domains'", ".", "$", "domainUri", ".", "'/metadata'", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ")", ";", "return", "MetaData", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
Obtain the metadata about a domain at the given URL @param string $domainUri @return MetaData
[ "Obtain", "the", "metadata", "about", "a", "domain", "at", "the", "given", "URL" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/DomainService.php#L18-L24
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/Job/Alert.php
Alert.createFromJSON
public static function createFromJSON($json_obj) { $result = new self(); if (isset($json_obj->toAddresses)) { $result->toAddresses = (array) $json_obj->toAddresses->address; unset($json_obj->toAddresses); } foreach ($json_obj as $k => $v) { $result->$k = $v; } return $result; }
php
public static function createFromJSON($json_obj) { $result = new self(); if (isset($json_obj->toAddresses)) { $result->toAddresses = (array) $json_obj->toAddresses->address; unset($json_obj->toAddresses); } foreach ($json_obj as $k => $v) { $result->$k = $v; } return $result; }
[ "public", "static", "function", "createFromJSON", "(", "$", "json_obj", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "if", "(", "isset", "(", "$", "json_obj", "->", "toAddresses", ")", ")", "{", "$", "result", "->", "toAddresses", "=", "(", "array", ")", "$", "json_obj", "->", "toAddresses", "->", "address", ";", "unset", "(", "$", "json_obj", "->", "toAddresses", ")", ";", "}", "foreach", "(", "$", "json_obj", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "result", "->", "$", "k", "=", "$", "v", ";", "}", "return", "$", "result", ";", "}" ]
This function takes a \stdClass decoded by json_decode representing a scheduled job and casts it as an Alert Object @param \stdClass $json_obj @return Alert
[ "This", "function", "takes", "a", "\\", "stdClass", "decoded", "by", "json_decode", "representing", "a", "scheduled", "job", "and", "casts", "it", "as", "an", "Alert", "Object" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/Job/Alert.php#L114-L125
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.runReportExecution
public function runReportExecution(Request $request) { $url = $this->makeUrl(); $response = $this->service->prepAndSend($url, array(200), 'POST', $request->toJSON(), true); return ReportExecution::createFromJSON(json_decode($response)); }
php
public function runReportExecution(Request $request) { $url = $this->makeUrl(); $response = $this->service->prepAndSend($url, array(200), 'POST', $request->toJSON(), true); return ReportExecution::createFromJSON(json_decode($response)); }
[ "public", "function", "runReportExecution", "(", "Request", "$", "request", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'POST'", ",", "$", "request", "->", "toJSON", "(", ")", ",", "true", ")", ";", "return", "ReportExecution", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
Submit a request to begin a report execution @param Request $request @return ReportExecution
[ "Submit", "a", "request", "to", "begin", "a", "report", "execution" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L66-L72
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.getReportExecutionStatus
public function getReportExecutionStatus($executionId) { $url = $this->makeUrl($executionId, true); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true, "application/json", "application/status+json"); return Status::createFromJSON(json_decode($response)); }
php
public function getReportExecutionStatus($executionId) { $url = $this->makeUrl($executionId, true); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true, "application/json", "application/status+json"); return Status::createFromJSON(json_decode($response)); }
[ "public", "function", "getReportExecutionStatus", "(", "$", "executionId", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "true", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ",", "\"application/json\"", ",", "\"application/status+json\"", ")", ";", "return", "Status", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
Obtain the status of a report execution @param string $executionId @return Status
[ "Obtain", "the", "status", "of", "a", "report", "execution" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L80-L86
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.cancelReportExecution
public function cancelReportExecution($executionId) { $url = $this->makeUrl($executionId, true); try { $response = $this->service->prepAndSend($url, array(200), 'PUT', json_encode(array("value" => "cancelled")), true); } catch (RESTRequestException $e) { if ($e->statusCode == 204) { return false; } else { throw $e; } } return Status::createFromJSON(json_decode($response)); }
php
public function cancelReportExecution($executionId) { $url = $this->makeUrl($executionId, true); try { $response = $this->service->prepAndSend($url, array(200), 'PUT', json_encode(array("value" => "cancelled")), true); } catch (RESTRequestException $e) { if ($e->statusCode == 204) { return false; } else { throw $e; } } return Status::createFromJSON(json_decode($response)); }
[ "public", "function", "cancelReportExecution", "(", "$", "executionId", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "true", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'PUT'", ",", "json_encode", "(", "array", "(", "\"value\"", "=>", "\"cancelled\"", ")", ")", ",", "true", ")", ";", "}", "catch", "(", "RESTRequestException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "statusCode", "==", "204", ")", "{", "return", "false", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "return", "Status", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
If a report execution is already running, you can cancel the execution using this method. A boolean value of false will be returned in the event that the requested report has either already completed or was unable to be found. @param string $executionId @return Status|bool @throws \Jaspersoft\Exception\RESTRequestException @throws \Jaspersoft\Exception\ReportExecutionException
[ "If", "a", "report", "execution", "is", "already", "running", "you", "can", "cancel", "the", "execution", "using", "this", "method", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L99-L113
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.updateReportExecutionParameters
public function updateReportExecutionParameters($executionId, array $newParameters, $freshData = true) { $url = $this->makeUrl($executionId, false, true); if (is_bool($freshData)) { $url .= '?' . Util::query_suffix(array("freshData" => $freshData)); } $parameters = array(); foreach($newParameters as $p) { if ($p instanceof Parameter) { $parameters[] = $p->jsonSerialize(); } else { throw new DtoException(get_called_class() . ": The parameter field must contain only Jaspersoft\\DTO\\ReportExecution\\Parameter item(s)"); } } $this->service->prepAndSend($url, array(204), 'POST', json_encode($parameters), true); }
php
public function updateReportExecutionParameters($executionId, array $newParameters, $freshData = true) { $url = $this->makeUrl($executionId, false, true); if (is_bool($freshData)) { $url .= '?' . Util::query_suffix(array("freshData" => $freshData)); } $parameters = array(); foreach($newParameters as $p) { if ($p instanceof Parameter) { $parameters[] = $p->jsonSerialize(); } else { throw new DtoException(get_called_class() . ": The parameter field must contain only Jaspersoft\\DTO\\ReportExecution\\Parameter item(s)"); } } $this->service->prepAndSend($url, array(204), 'POST', json_encode($parameters), true); }
[ "public", "function", "updateReportExecutionParameters", "(", "$", "executionId", ",", "array", "$", "newParameters", ",", "$", "freshData", "=", "true", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "false", ",", "true", ")", ";", "if", "(", "is_bool", "(", "$", "freshData", ")", ")", "{", "$", "url", ".=", "'?'", ".", "Util", "::", "query_suffix", "(", "array", "(", "\"freshData\"", "=>", "$", "freshData", ")", ")", ";", "}", "$", "parameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "newParameters", "as", "$", "p", ")", "{", "if", "(", "$", "p", "instanceof", "Parameter", ")", "{", "$", "parameters", "[", "]", "=", "$", "p", "->", "jsonSerialize", "(", ")", ";", "}", "else", "{", "throw", "new", "DtoException", "(", "get_called_class", "(", ")", ".", "\": The parameter field must contain\n only Jaspersoft\\\\DTO\\\\ReportExecution\\\\Parameter item(s)\"", ")", ";", "}", "}", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "204", ")", ",", "'POST'", ",", "json_encode", "(", "$", "parameters", ")", ",", "true", ")", ";", "}" ]
Re-run the report using new report parameters @param string $executionId @param array<Jaspersoft\Dto\ReportExecution\Parameter> $newParameters An array of new reportParameters @param bool $freshData Should fresh data be fetched? (Default: true) @throws DtoException
[ "Re", "-", "run", "the", "report", "using", "new", "report", "parameters" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L167-L183
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.runExportExecution
public function runExportExecution($executionId, \Jaspersoft\Dto\ReportExecution\Export\Request $request) { $url = $this->makeUrl($executionId, false, false, true); $response = $this->service->prepAndSend($url, array(200), 'POST', $request->toJSON(), true); return Export::createFromJSON(json_decode($response)); }
php
public function runExportExecution($executionId, \Jaspersoft\Dto\ReportExecution\Export\Request $request) { $url = $this->makeUrl($executionId, false, false, true); $response = $this->service->prepAndSend($url, array(200), 'POST', $request->toJSON(), true); return Export::createFromJSON(json_decode($response)); }
[ "public", "function", "runExportExecution", "(", "$", "executionId", ",", "\\", "Jaspersoft", "\\", "Dto", "\\", "ReportExecution", "\\", "Export", "\\", "Request", "$", "request", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "false", ",", "false", ",", "true", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'POST'", ",", "$", "request", "->", "toJSON", "(", ")", ",", "true", ")", ";", "return", "Export", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
Re-run an execution using new export values @param string $executionId @param \Jaspersoft\Dto\ReportExecution\Export\Request $request @return Export
[ "Re", "-", "run", "an", "execution", "using", "new", "export", "values" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L192-L198
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.getExportExecutionStatus
public function getExportExecutionStatus($executionId, $exportId) { $url = $this->makeUrl($executionId, true, false, true, false, $exportId); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); return Status::createFromJSON(json_decode($response)); }
php
public function getExportExecutionStatus($executionId, $exportId) { $url = $this->makeUrl($executionId, true, false, true, false, $exportId); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); return Status::createFromJSON(json_decode($response)); }
[ "public", "function", "getExportExecutionStatus", "(", "$", "executionId", ",", "$", "exportId", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "true", ",", "false", ",", "true", ",", "false", ",", "$", "exportId", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ")", ";", "return", "Status", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
Get the status value of an Export Execution @param string $executionId @param string $exportId @return Status
[ "Get", "the", "status", "value", "of", "an", "Export", "Execution" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L207-L213
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.getExportOutputResource
public function getExportOutputResource($executionId, $exportId) { $url = $this->makeUrl($executionId, false, false, true, true, $exportId); $response = $this->service->makeRequest($url, array(200), 'GET', null, true, 'application/json', '*/*'); $headers = RESTRequest::splitHeaderArray($response['headers']); $outputResource = BinaryOutputResource::createFromHeaders($headers); $outputResource->binaryContent = $response['body']; return $outputResource; }
php
public function getExportOutputResource($executionId, $exportId) { $url = $this->makeUrl($executionId, false, false, true, true, $exportId); $response = $this->service->makeRequest($url, array(200), 'GET', null, true, 'application/json', '*/*'); $headers = RESTRequest::splitHeaderArray($response['headers']); $outputResource = BinaryOutputResource::createFromHeaders($headers); $outputResource->binaryContent = $response['body']; return $outputResource; }
[ "public", "function", "getExportOutputResource", "(", "$", "executionId", ",", "$", "exportId", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "false", ",", "false", ",", "true", ",", "true", ",", "$", "exportId", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "makeRequest", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ",", "'application/json'", ",", "'*/*'", ")", ";", "$", "headers", "=", "RESTRequest", "::", "splitHeaderArray", "(", "$", "response", "[", "'headers'", "]", ")", ";", "$", "outputResource", "=", "BinaryOutputResource", "::", "createFromHeaders", "(", "$", "headers", ")", ";", "$", "outputResource", "->", "binaryContent", "=", "$", "response", "[", "'body'", "]", ";", "return", "$", "outputResource", ";", "}" ]
This method will download an export resource, an array is returned, one with an outputResource object that describes the type of binary data, and the "body" which is the binary content of the resource. @param string $executionId @param string $exportId @return array
[ "This", "method", "will", "download", "an", "export", "resource", "an", "array", "is", "returned", "one", "with", "an", "outputResource", "object", "that", "describes", "the", "type", "of", "binary", "data", "and", "the", "body", "which", "is", "the", "binary", "content", "of", "the", "resource", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L223-L234
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/ReportExecutionService.php
ReportExecutionService.getExportOutputResourceAttachment
public function getExportOutputResourceAttachment($executionId, $exportId, $attachmentName) { $url = $this->makeUrl($executionId, false, false, true, false, $exportId, true, $attachmentName); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', '*/*'); return $response; }
php
public function getExportOutputResourceAttachment($executionId, $exportId, $attachmentName) { $url = $this->makeUrl($executionId, false, false, true, false, $exportId, true, $attachmentName); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', '*/*'); return $response; }
[ "public", "function", "getExportOutputResourceAttachment", "(", "$", "executionId", ",", "$", "exportId", ",", "$", "attachmentName", ")", "{", "$", "url", "=", "$", "this", "->", "makeUrl", "(", "$", "executionId", ",", "false", ",", "false", ",", "true", ",", "false", ",", "$", "exportId", ",", "true", ",", "$", "attachmentName", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ",", "'application/json'", ",", "'*/*'", ")", ";", "return", "$", "response", ";", "}" ]
Get the binary data of an attachment for a report @param string $executionId @param string $exportId @param string $attachmentName the name of the attachment (found in the fileName field of an Attachment object) @return string
[ "Get", "the", "binary", "data", "of", "an", "attachment", "for", "a", "report" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/ReportExecutionService.php#L244-L250
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/DTOObject.php
DTOObject.jsonSerialize
public function jsonSerialize() { $data = array(); foreach (get_object_vars($this) as $k => $v) { if (!empty($v)) { $data[$k] = $v; } } return $data; }
php
public function jsonSerialize() { $data = array(); foreach (get_object_vars($this) as $k => $v) { if (!empty($v)) { $data[$k] = $v; } } return $data; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "!", "empty", "(", "$", "v", ")", ")", "{", "$", "data", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "return", "$", "data", ";", "}" ]
Creates an array based representation of class data to be serialized @return array
[ "Creates", "an", "array", "based", "representation", "of", "class", "data", "to", "be", "serialized" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/DTOObject.php#L13-L22
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/DTOObject.php
DTOObject.jsonField
public static function jsonField($plural = false) { $field = explode('\\', get_called_class()); $field = lcfirst(end($field)); return $plural ? $field . "s" : $field; }
php
public static function jsonField($plural = false) { $field = explode('\\', get_called_class()); $field = lcfirst(end($field)); return $plural ? $field . "s" : $field; }
[ "public", "static", "function", "jsonField", "(", "$", "plural", "=", "false", ")", "{", "$", "field", "=", "explode", "(", "'\\\\'", ",", "get_called_class", "(", ")", ")", ";", "$", "field", "=", "lcfirst", "(", "end", "(", "$", "field", ")", ")", ";", "return", "$", "plural", "?", "$", "field", ".", "\"s\"", ":", "$", "field", ";", "}" ]
Get the name of this class if it were a key field in a JSON representation @param boolean $plural Suffix response with an s? @return string
[ "Get", "the", "name", "of", "this", "class", "if", "it", "were", "a", "key", "field", "in", "a", "JSON", "representation" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/DTOObject.php#L40-L45
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/DTOObject.php
DTOObject.createFromJSON
public static function createFromJSON($json_obj) { $source_class = get_called_class(); $result = new $source_class(); foreach ($json_obj as $k => $v) { if (!empty($v)) { $result->$k = $v; } } return $result; }
php
public static function createFromJSON($json_obj) { $source_class = get_called_class(); $result = new $source_class(); foreach ($json_obj as $k => $v) { if (!empty($v)) { $result->$k = $v; } } return $result; }
[ "public", "static", "function", "createFromJSON", "(", "$", "json_obj", ")", "{", "$", "source_class", "=", "get_called_class", "(", ")", ";", "$", "result", "=", "new", "$", "source_class", "(", ")", ";", "foreach", "(", "$", "json_obj", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "!", "empty", "(", "$", "v", ")", ")", "{", "$", "result", "->", "$", "k", "=", "$", "v", ";", "}", "}", "return", "$", "result", ";", "}" ]
If an object is composed of only properties, this will handle setting those properties as they match their field names. If a class expects to have subcomponents or arrays, it should be overridden. @param \stdClass $json_obj A decoded JSON response @return mixed Some type of \Jaspersoft\Dto\* object
[ "If", "an", "object", "is", "composed", "of", "only", "properties", "this", "will", "handle", "setting", "those", "properties", "as", "they", "match", "their", "field", "names", ".", "If", "a", "class", "expects", "to", "have", "subcomponents", "or", "arrays", "it", "should", "be", "overridden", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/DTOObject.php#L55-L66
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.createLogCollector
public function createLogCollector(LogCollectorSettings $collector) { $url = self::makeUrl(); $jsonData = json_encode($collector->jsonSerialize()); $result = $this->service->prepAndSend($url, array(200), "POST", $jsonData, true); $resultObject = json_decode($result); return LogCollectorSettings::createFromJSON($resultObject); }
php
public function createLogCollector(LogCollectorSettings $collector) { $url = self::makeUrl(); $jsonData = json_encode($collector->jsonSerialize()); $result = $this->service->prepAndSend($url, array(200), "POST", $jsonData, true); $resultObject = json_decode($result); return LogCollectorSettings::createFromJSON($resultObject); }
[ "public", "function", "createLogCollector", "(", "LogCollectorSettings", "$", "collector", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", ")", ";", "$", "jsonData", "=", "json_encode", "(", "$", "collector", "->", "jsonSerialize", "(", ")", ")", ";", "$", "result", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"POST\"", ",", "$", "jsonData", ",", "true", ")", ";", "$", "resultObject", "=", "json_decode", "(", "$", "result", ")", ";", "return", "LogCollectorSettings", "::", "createFromJSON", "(", "$", "resultObject", ")", ";", "}" ]
Create and start a diagnostic log collector @param \Jaspersoft\Dto\Diagnostic\LogCollectorSettings $collector @return \Jaspersoft\Dto\Diagnostic\LogCollectorSettings Representation of created log collector
[ "Create", "and", "start", "a", "diagnostic", "log", "collector" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L36-L44
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.logCollectorStates
public function logCollectorStates() { $url = self::makeUrl(); $result = array(); try { $response = $this->service->prepAndSend($url, array(200), "GET", null, true); $responseObject = json_decode($response); foreach ($responseObject->CollectorSettingsList as $lcs) { $result[] = LogCollectorSettings::createFromJSON($lcs); } /* * For now a facade has been created over this REST endpoint to return an empty array * in the case that we get a 404 with the message "Resource collectors not found" */ } catch (RESTRequestException $e) { if ($e->message == "Resource collectors not found" && $e->statusCode == 404) { return $result; } else { throw $e; } } return $result; }
php
public function logCollectorStates() { $url = self::makeUrl(); $result = array(); try { $response = $this->service->prepAndSend($url, array(200), "GET", null, true); $responseObject = json_decode($response); foreach ($responseObject->CollectorSettingsList as $lcs) { $result[] = LogCollectorSettings::createFromJSON($lcs); } /* * For now a facade has been created over this REST endpoint to return an empty array * in the case that we get a 404 with the message "Resource collectors not found" */ } catch (RESTRequestException $e) { if ($e->message == "Resource collectors not found" && $e->statusCode == 404) { return $result; } else { throw $e; } } return $result; }
[ "public", "function", "logCollectorStates", "(", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"GET\"", ",", "null", ",", "true", ")", ";", "$", "responseObject", "=", "json_decode", "(", "$", "response", ")", ";", "foreach", "(", "$", "responseObject", "->", "CollectorSettingsList", "as", "$", "lcs", ")", "{", "$", "result", "[", "]", "=", "LogCollectorSettings", "::", "createFromJSON", "(", "$", "lcs", ")", ";", "}", "/*\n * For now a facade has been created over this REST endpoint to return an empty array\n * in the case that we get a 404 with the message \"Resource collectors not found\"\n */", "}", "catch", "(", "RESTRequestException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "message", "==", "\"Resource collectors not found\"", "&&", "$", "e", "->", "statusCode", "==", "404", ")", "{", "return", "$", "result", ";", "}", "else", "{", "throw", "$", "e", ";", "}", "}", "return", "$", "result", ";", "}" ]
Obtain metadata about all Log Collectors @throws RESTRequestException @return array A set of LogCollectorSettings objects defining existing log collector states
[ "Obtain", "metadata", "about", "all", "Log", "Collectors" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L52-L76
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.logCollectorState
public function logCollectorState($id) { $url = self::makeUrl($id); $response = $this->service->prepAndSend($url, array(200), "GET", null, true); $responseObject = json_decode($response); return LogCollectorSettings::createFromJSON($responseObject); }
php
public function logCollectorState($id) { $url = self::makeUrl($id); $response = $this->service->prepAndSend($url, array(200), "GET", null, true); $responseObject = json_decode($response); return LogCollectorSettings::createFromJSON($responseObject); }
[ "public", "function", "logCollectorState", "(", "$", "id", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", "$", "id", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"GET\"", ",", "null", ",", "true", ")", ";", "$", "responseObject", "=", "json_decode", "(", "$", "response", ")", ";", "return", "LogCollectorSettings", "::", "createFromJSON", "(", "$", "responseObject", ")", ";", "}" ]
Obtain metadata about a specific Log Collector @param $id @return \Jaspersoft\Dto\Diagnostic\LogCollectorSettings
[ "Obtain", "metadata", "about", "a", "specific", "Log", "Collector" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L84-L92
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.downloadLogCollectorContentZip
public function downloadLogCollectorContentZip($id) { $url = self::makeUrl($id, true); $response = $this->service->prepAndSend($url, array(200), "GET", null, true, "application/json", "application/zip"); return $response; }
php
public function downloadLogCollectorContentZip($id) { $url = self::makeUrl($id, true); $response = $this->service->prepAndSend($url, array(200), "GET", null, true, "application/json", "application/zip"); return $response; }
[ "public", "function", "downloadLogCollectorContentZip", "(", "$", "id", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", "$", "id", ",", "true", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"GET\"", ",", "null", ",", "true", ",", "\"application/json\"", ",", "\"application/zip\"", ")", ";", "return", "$", "response", ";", "}" ]
Download the content of a Log Collector as a zip file @param $id @return string Binary content of zip file
[ "Download", "the", "content", "of", "a", "Log", "Collector", "as", "a", "zip", "file" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L100-L106
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.downloadAllLogCollectorContentZip
public function downloadAllLogCollectorContentZip() { $url = self::makeUrl(null, true); return $this->service->prepAndSend($url, array(200), "GET", null, true, "application/json", "application/zip"); }
php
public function downloadAllLogCollectorContentZip() { $url = self::makeUrl(null, true); return $this->service->prepAndSend($url, array(200), "GET", null, true, "application/json", "application/zip"); }
[ "public", "function", "downloadAllLogCollectorContentZip", "(", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", "null", ",", "true", ")", ";", "return", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"GET\"", ",", "null", ",", "true", ",", "\"application/json\"", ",", "\"application/zip\"", ")", ";", "}" ]
Download the content of all Log Collectors with status "STOPPED" as a zip file @return string Binary content of zip file
[ "Download", "the", "content", "of", "all", "Log", "Collectors", "with", "status", "STOPPED", "as", "a", "zip", "file" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L113-L117
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.updateLogCollector
public function updateLogCollector(LogCollectorSettings $collector) { if (!is_null($collector->id())) { $url = self::makeUrl($collector->id()); } else { throw new MissingValueException("LogCollectorSettings requires id to be set, first request the LogCollectorSettings using logCollectorStates method to allow server to set ID"); } $response = $this->service->prepAndSend($url, array(200), "PUT", $collector->toJSON(), true); return LogCollectorSettings::createFromJSON(json_decode($response)); }
php
public function updateLogCollector(LogCollectorSettings $collector) { if (!is_null($collector->id())) { $url = self::makeUrl($collector->id()); } else { throw new MissingValueException("LogCollectorSettings requires id to be set, first request the LogCollectorSettings using logCollectorStates method to allow server to set ID"); } $response = $this->service->prepAndSend($url, array(200), "PUT", $collector->toJSON(), true); return LogCollectorSettings::createFromJSON(json_decode($response)); }
[ "public", "function", "updateLogCollector", "(", "LogCollectorSettings", "$", "collector", ")", "{", "if", "(", "!", "is_null", "(", "$", "collector", "->", "id", "(", ")", ")", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", "$", "collector", "->", "id", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "MissingValueException", "(", "\"LogCollectorSettings requires id to be set,\n first request the LogCollectorSettings using logCollectorStates method to allow server to set ID\"", ")", ";", "}", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"PUT\"", ",", "$", "collector", "->", "toJSON", "(", ")", ",", "true", ")", ";", "return", "LogCollectorSettings", "::", "createFromJSON", "(", "json_decode", "(", "$", "response", ")", ")", ";", "}" ]
Update an existing Log Collector's settings, you cannot change "name" after a collectors has been created on the server. you cannot re-run a collector which has been stopped. @param \Jaspersoft\Dto\Diagnostic\LogCollectorSettings $collector @throws \Jaspersoft\Exception\MissingValueException @returns \Jaspersoft\Dto\Diagnostic\LogCollectorSettings
[ "Update", "an", "existing", "Log", "Collector", "s", "settings", "you", "cannot", "change", "name", "after", "a", "collectors", "has", "been", "created", "on", "the", "server", ".", "you", "cannot", "re", "-", "run", "a", "collector", "which", "has", "been", "stopped", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L128-L139
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.stopAllLogCollectors
public function stopAllLogCollectors() { $url = self::makeUrl(); $body = json_encode(array("patch" => array(array("field" => "status", "value" => "STOPPED")))); $response = $this->service->prepAndSend($url, array(200), "PATCH", $body, true); $responseObj = json_decode($response); if (!empty($responseObj)) { $result = array(); foreach ($responseObj->CollectorSettingsList as $lcs) { $result[] = LogCollectorSettings::createFromJSON($lcs); } return $result; } else { return array(); } }
php
public function stopAllLogCollectors() { $url = self::makeUrl(); $body = json_encode(array("patch" => array(array("field" => "status", "value" => "STOPPED")))); $response = $this->service->prepAndSend($url, array(200), "PATCH", $body, true); $responseObj = json_decode($response); if (!empty($responseObj)) { $result = array(); foreach ($responseObj->CollectorSettingsList as $lcs) { $result[] = LogCollectorSettings::createFromJSON($lcs); } return $result; } else { return array(); } }
[ "public", "function", "stopAllLogCollectors", "(", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", ")", ";", "$", "body", "=", "json_encode", "(", "array", "(", "\"patch\"", "=>", "array", "(", "array", "(", "\"field\"", "=>", "\"status\"", ",", "\"value\"", "=>", "\"STOPPED\"", ")", ")", ")", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"PATCH\"", ",", "$", "body", ",", "true", ")", ";", "$", "responseObj", "=", "json_decode", "(", "$", "response", ")", ";", "if", "(", "!", "empty", "(", "$", "responseObj", ")", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "responseObj", "->", "CollectorSettingsList", "as", "$", "lcs", ")", "{", "$", "result", "[", "]", "=", "LogCollectorSettings", "::", "createFromJSON", "(", "$", "lcs", ")", ";", "}", "return", "$", "result", ";", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Stop all running log collectors @return array New representation of existing Log Collectors following modification
[ "Stop", "all", "running", "log", "collectors" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L146-L165
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/LogCollectorService.php
LogCollectorService.deleteLogCollector
public function deleteLogCollector($id) { $url = self::makeUrl($id); return $this->service->prepAndSend($url, array(200), "DELETE"); }
php
public function deleteLogCollector($id) { $url = self::makeUrl($id); return $this->service->prepAndSend($url, array(200), "DELETE"); }
[ "public", "function", "deleteLogCollector", "(", "$", "id", ")", "{", "$", "url", "=", "self", "::", "makeUrl", "(", "$", "id", ")", ";", "return", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "\"DELETE\"", ")", ";", "}" ]
Delete a Log Collector by id @param $id @return bool True if delete was successful, false otherwise
[ "Delete", "a", "Log", "Collector", "by", "id" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/LogCollectorService.php#L184-L188
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/Job/MailNotification.php
MailNotification.jsonSerialize
public function jsonSerialize() { $result = array(); foreach (get_object_vars($this) as $k => $v) { if (isset($v)) { // JSON specification set by server requires sublevel of "address" for these // attributes of the MailNotification, so they are special cases handled below if ($k == "toAddresses") { $result[$k] = array("address" => $this->toAddresses); } else if ($k == "ccAddresses") { $result[$k] = array("address" => $this->ccAddresses); } else if ($k == "bccAddresses") { $result[$k] = array("address" => $this->bccAddresses); } else { $result[$k] = $v; } } } return $result; }
php
public function jsonSerialize() { $result = array(); foreach (get_object_vars($this) as $k => $v) { if (isset($v)) { // JSON specification set by server requires sublevel of "address" for these // attributes of the MailNotification, so they are special cases handled below if ($k == "toAddresses") { $result[$k] = array("address" => $this->toAddresses); } else if ($k == "ccAddresses") { $result[$k] = array("address" => $this->ccAddresses); } else if ($k == "bccAddresses") { $result[$k] = array("address" => $this->bccAddresses); } else { $result[$k] = $v; } } } return $result; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "isset", "(", "$", "v", ")", ")", "{", "// JSON specification set by server requires sublevel of \"address\" for these", "// attributes of the MailNotification, so they are special cases handled below", "if", "(", "$", "k", "==", "\"toAddresses\"", ")", "{", "$", "result", "[", "$", "k", "]", "=", "array", "(", "\"address\"", "=>", "$", "this", "->", "toAddresses", ")", ";", "}", "else", "if", "(", "$", "k", "==", "\"ccAddresses\"", ")", "{", "$", "result", "[", "$", "k", "]", "=", "array", "(", "\"address\"", "=>", "$", "this", "->", "ccAddresses", ")", ";", "}", "else", "if", "(", "$", "k", "==", "\"bccAddresses\"", ")", "{", "$", "result", "[", "$", "k", "]", "=", "array", "(", "\"address\"", "=>", "$", "this", "->", "bccAddresses", ")", ";", "}", "else", "{", "$", "result", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Create an associative array of the data which is set to a non-null value @return array
[ "Create", "an", "associative", "array", "of", "the", "data", "which", "is", "set", "to", "a", "non", "-", "null", "value" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/Job/MailNotification.php#L111-L133
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Dto/Job/MailNotification.php
MailNotification.createFromJSON
public static function createFromJSON($json_obj) { $result = new self(); foreach ($json_obj as $k => $v) { if ($k == "toAddresses") { $result->toAddresses = (array) $v->address; } else if ($k == "ccAddresses") { $result->ccAddresses = (array) $v->address; } else if ($k == "bccAddresses") { $result->bccAddresses = (array) $v->address; } else { $result->$k = $v; } } return $result; }
php
public static function createFromJSON($json_obj) { $result = new self(); foreach ($json_obj as $k => $v) { if ($k == "toAddresses") { $result->toAddresses = (array) $v->address; } else if ($k == "ccAddresses") { $result->ccAddresses = (array) $v->address; } else if ($k == "bccAddresses") { $result->bccAddresses = (array) $v->address; } else { $result->$k = $v; } } return $result; }
[ "public", "static", "function", "createFromJSON", "(", "$", "json_obj", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "foreach", "(", "$", "json_obj", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "k", "==", "\"toAddresses\"", ")", "{", "$", "result", "->", "toAddresses", "=", "(", "array", ")", "$", "v", "->", "address", ";", "}", "else", "if", "(", "$", "k", "==", "\"ccAddresses\"", ")", "{", "$", "result", "->", "ccAddresses", "=", "(", "array", ")", "$", "v", "->", "address", ";", "}", "else", "if", "(", "$", "k", "==", "\"bccAddresses\"", ")", "{", "$", "result", "->", "bccAddresses", "=", "(", "array", ")", "$", "v", "->", "address", ";", "}", "else", "{", "$", "result", "->", "$", "k", "=", "$", "v", ";", "}", "}", "return", "$", "result", ";", "}" ]
This function takes a \stdClass decoded by json_decode representing a scheduled job and casts it as a MailNotification Object @param \stdClass $json_obj @return MailNotification
[ "This", "function", "takes", "a", "\\", "stdClass", "decoded", "by", "json_decode", "representing", "a", "scheduled", "job", "and", "casts", "it", "as", "a", "MailNotification", "Object" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Dto/Job/MailNotification.php#L142-L157
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.searchJobs
public function searchJobs($reportUnitURI = null, $owner = null, $label = null, $example = null, $startIndex = null, $rows = null, $sortType = null, $ascending = null) { $result = array(); $url = self::makeUrl(array( 'reportUnitURI' => $reportUnitURI, 'owner' => $owner, 'label' => $label, 'example' => $example, 'startIndex' => $startIndex, 'numberOfRows' => $rows, 'sortType' => $sortType, 'isAscending' => $ascending )); $resp = $this->service->prepAndSend($url, array(200, 204), 'GET', null, true, 'application/json', 'application/json'); if (empty($resp)) return $result; $jobs = json_decode($resp); foreach($jobs->jobsummary as $job) { $result[] = @new JobSummary( $job->id, $job->label, $job->reportUnitURI, $job->version, $job->owner, $job->state->value, $job->state->nextFireTime, $job->state->previousFireTime ); } return $result; }
php
public function searchJobs($reportUnitURI = null, $owner = null, $label = null, $example = null, $startIndex = null, $rows = null, $sortType = null, $ascending = null) { $result = array(); $url = self::makeUrl(array( 'reportUnitURI' => $reportUnitURI, 'owner' => $owner, 'label' => $label, 'example' => $example, 'startIndex' => $startIndex, 'numberOfRows' => $rows, 'sortType' => $sortType, 'isAscending' => $ascending )); $resp = $this->service->prepAndSend($url, array(200, 204), 'GET', null, true, 'application/json', 'application/json'); if (empty($resp)) return $result; $jobs = json_decode($resp); foreach($jobs->jobsummary as $job) { $result[] = @new JobSummary( $job->id, $job->label, $job->reportUnitURI, $job->version, $job->owner, $job->state->value, $job->state->nextFireTime, $job->state->previousFireTime ); } return $result; }
[ "public", "function", "searchJobs", "(", "$", "reportUnitURI", "=", "null", ",", "$", "owner", "=", "null", ",", "$", "label", "=", "null", ",", "$", "example", "=", "null", ",", "$", "startIndex", "=", "null", ",", "$", "rows", "=", "null", ",", "$", "sortType", "=", "null", ",", "$", "ascending", "=", "null", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "url", "=", "self", "::", "makeUrl", "(", "array", "(", "'reportUnitURI'", "=>", "$", "reportUnitURI", ",", "'owner'", "=>", "$", "owner", ",", "'label'", "=>", "$", "label", ",", "'example'", "=>", "$", "example", ",", "'startIndex'", "=>", "$", "startIndex", ",", "'numberOfRows'", "=>", "$", "rows", ",", "'sortType'", "=>", "$", "sortType", ",", "'isAscending'", "=>", "$", "ascending", ")", ")", ";", "$", "resp", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ",", "204", ")", ",", "'GET'", ",", "null", ",", "true", ",", "'application/json'", ",", "'application/json'", ")", ";", "if", "(", "empty", "(", "$", "resp", ")", ")", "return", "$", "result", ";", "$", "jobs", "=", "json_decode", "(", "$", "resp", ")", ";", "foreach", "(", "$", "jobs", "->", "jobsummary", "as", "$", "job", ")", "{", "$", "result", "[", "]", "=", "@", "new", "JobSummary", "(", "$", "job", "->", "id", ",", "$", "job", "->", "label", ",", "$", "job", "->", "reportUnitURI", ",", "$", "job", "->", "version", ",", "$", "job", "->", "owner", ",", "$", "job", "->", "state", "->", "value", ",", "$", "job", "->", "state", "->", "nextFireTime", ",", "$", "job", "->", "state", "->", "previousFireTime", ")", ";", "}", "return", "$", "result", ";", "}" ]
Search for scheduled jobs. @param string $reportUnitURI URI of the report (optional) @param string $owner Search by user who created job @param string $label Search by job label title @param string $example Search by any field of Job description in JSON format (i.e: {"outputFormats" : ["RTF", "PDF" ]} ) @param int $startIndex Start at this number (pagination) @param int $rows Number of rows in a block (pagination) @param string $sortType How to sort by column, must be any of the following: NONE, SORTBY_JOBID, SORTBY_JOBNAME, SORTBY_REPORTURI, SORTBY_REPORTNAME, SORTBY_REPORTFOLDER, SORTBY_OWNER, SORTBY_STATUS, SORTBY_LASTRUN, SORTBY_NEXTRUN @param boolean $ascending @return array
[ "Search", "for", "scheduled", "jobs", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L42-L74
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.getJob
public function getJob($id) { $url = $this->service_url . '/jobs/' . $id; $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/job+json', 'application/job+json'); return Job::createFromJSON(json_decode($data)); }
php
public function getJob($id) { $url = $this->service_url . '/jobs/' . $id; $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/job+json', 'application/job+json'); return Job::createFromJSON(json_decode($data)); }
[ "public", "function", "getJob", "(", "$", "id", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/'", ".", "$", "id", ";", "$", "data", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ",", "'application/job+json'", ",", "'application/job+json'", ")", ";", "return", "Job", "::", "createFromJSON", "(", "json_decode", "(", "$", "data", ")", ")", ";", "}" ]
Get job descriptor @param int|string $id @return \Jaspersoft\Dto\Job\Job
[ "Get", "job", "descriptor" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L82-L87
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.deleteJob
public function deleteJob($id) { $url = $this->service_url . '/jobs/' . $id; $data = $this->service->prepAndSend($url, array(200), 'DELETE', null, true); return $data; }
php
public function deleteJob($id) { $url = $this->service_url . '/jobs/' . $id; $data = $this->service->prepAndSend($url, array(200), 'DELETE', null, true); return $data; }
[ "public", "function", "deleteJob", "(", "$", "id", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/'", ".", "$", "id", ";", "$", "data", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'DELETE'", ",", "null", ",", "true", ")", ";", "return", "$", "data", ";", "}" ]
Delete a job This function will delete a job that is scheduled. You must supply the Job's ID to this function to delete it. @param int|string $id @return string
[ "Delete", "a", "job" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L124-L129
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.getJobState
public function getJobState($id) { $url = $this->service_url . '/jobs/' . $id . '/state'; $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', 'application/json'); return JobState::createFromJSON(json_decode($data)); }
php
public function getJobState($id) { $url = $this->service_url . '/jobs/' . $id . '/state'; $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', 'application/json'); return JobState::createFromJSON(json_decode($data)); }
[ "public", "function", "getJobState", "(", "$", "id", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/'", ".", "$", "id", ".", "'/state'", ";", "$", "data", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ",", "'application/json'", ",", "'application/json'", ")", ";", "return", "JobState", "::", "createFromJSON", "(", "json_decode", "(", "$", "data", ")", ")", ";", "}" ]
Get the State of a Job @param int|string $id @return \Jaspersoft\Dto\Job\JobState
[ "Get", "the", "State", "of", "a", "Job" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L137-L142
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.pauseJob
public function pauseJob($jobsToStop = null) { $url = $this->service_url . '/jobs/pause'; $body = json_encode(array("jobId" => (array) $jobsToStop)); return $this->service->prepAndSend($url, array(200), 'POST', $body, false, 'application/json', 'application/json'); }
php
public function pauseJob($jobsToStop = null) { $url = $this->service_url . '/jobs/pause'; $body = json_encode(array("jobId" => (array) $jobsToStop)); return $this->service->prepAndSend($url, array(200), 'POST', $body, false, 'application/json', 'application/json'); }
[ "public", "function", "pauseJob", "(", "$", "jobsToStop", "=", "null", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/pause'", ";", "$", "body", "=", "json_encode", "(", "array", "(", "\"jobId\"", "=>", "(", "array", ")", "$", "jobsToStop", ")", ")", ";", "return", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'POST'", ",", "$", "body", ",", "false", ",", "'application/json'", ",", "'application/json'", ")", ";", "}" ]
Pause a job, all jobs, or multiple jobs. @param string|array|int|null $jobsToStop Setting this value to null implies 'all jobs' @return boolean
[ "Pause", "a", "job", "all", "jobs", "or", "multiple", "jobs", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L150-L155
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.resumeJob
public function resumeJob($jobsToResume = null) { $url = $this->service_url . '/jobs/resume'; $body = json_encode(array("jobId" => (array) $jobsToResume)); return $this->service->prepAndSend($url, array(200), 'POST', $body, false, 'application/json', 'application/json'); }
php
public function resumeJob($jobsToResume = null) { $url = $this->service_url . '/jobs/resume'; $body = json_encode(array("jobId" => (array) $jobsToResume)); return $this->service->prepAndSend($url, array(200), 'POST', $body, false, 'application/json', 'application/json'); }
[ "public", "function", "resumeJob", "(", "$", "jobsToResume", "=", "null", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/resume'", ";", "$", "body", "=", "json_encode", "(", "array", "(", "\"jobId\"", "=>", "(", "array", ")", "$", "jobsToResume", ")", ")", ";", "return", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'POST'", ",", "$", "body", ",", "false", ",", "'application/json'", ",", "'application/json'", ")", ";", "}" ]
Resume a job, all jobs, or multiple jobs. @param string|array|int|null $jobsToResume Setting this value to null implies 'all jobs' @return boolean
[ "Resume", "a", "job", "all", "jobs", "or", "multiple", "jobs", "." ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L163-L168
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.getCalendarNames
public function getCalendarNames($calendarType = null) { $url = $this->service_url . '/jobs/calendars'; $url .= (!empty($calendarType)) ? Util::query_suffix(array("calendarType" => $calendarType)) : null; $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); if (empty($response)) return null; $calendars = json_decode($response); return $calendars->calendarName; }
php
public function getCalendarNames($calendarType = null) { $url = $this->service_url . '/jobs/calendars'; $url .= (!empty($calendarType)) ? Util::query_suffix(array("calendarType" => $calendarType)) : null; $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); if (empty($response)) return null; $calendars = json_decode($response); return $calendars->calendarName; }
[ "public", "function", "getCalendarNames", "(", "$", "calendarType", "=", "null", ")", "{", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/calendars'", ";", "$", "url", ".=", "(", "!", "empty", "(", "$", "calendarType", ")", ")", "?", "Util", "::", "query_suffix", "(", "array", "(", "\"calendarType\"", "=>", "$", "calendarType", ")", ")", ":", "null", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "response", ")", ")", "return", "null", ";", "$", "calendars", "=", "json_decode", "(", "$", "response", ")", ";", "return", "$", "calendars", "->", "calendarName", ";", "}" ]
Obtain a listing of calendar names, optionally filtered by calendar type Possible calendarType values: "annual", "base", "cron", "daily", "holiday", "monthly", "weekly" @param string $calendarType Type of calendar to filter by @return array Set of defined calendar names
[ "Obtain", "a", "listing", "of", "calendar", "names", "optionally", "filtered", "by", "calendar", "type" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L179-L188
train
Jaspersoft/jrs-rest-php-client
src/Jaspersoft/Service/JobService.php
JobService.getCalendar
public function getCalendar($calendarName) { // rawurlencode will convert spaces to %20 as required by server $url = $this->service_url . '/jobs/calendars/' . rawurlencode($calendarName); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); $calendarData = json_decode($response); if (empty($calendarData->calendarType)) { throw new RESTRequestException("JobService: Data format not expected."); } $className = JobService::CALENDAR_NAMESPACE . '\\'. ucfirst($calendarData->calendarType) . "Calendar"; if (class_exists($className)) { return $className::createFromJSON($calendarData); } else { throw new RESTRequestException("JobService: Unrecognized calendar type returned by server"); } }
php
public function getCalendar($calendarName) { // rawurlencode will convert spaces to %20 as required by server $url = $this->service_url . '/jobs/calendars/' . rawurlencode($calendarName); $response = $this->service->prepAndSend($url, array(200), 'GET', null, true); $calendarData = json_decode($response); if (empty($calendarData->calendarType)) { throw new RESTRequestException("JobService: Data format not expected."); } $className = JobService::CALENDAR_NAMESPACE . '\\'. ucfirst($calendarData->calendarType) . "Calendar"; if (class_exists($className)) { return $className::createFromJSON($calendarData); } else { throw new RESTRequestException("JobService: Unrecognized calendar type returned by server"); } }
[ "public", "function", "getCalendar", "(", "$", "calendarName", ")", "{", "// rawurlencode will convert spaces to %20 as required by server", "$", "url", "=", "$", "this", "->", "service_url", ".", "'/jobs/calendars/'", ".", "rawurlencode", "(", "$", "calendarName", ")", ";", "$", "response", "=", "$", "this", "->", "service", "->", "prepAndSend", "(", "$", "url", ",", "array", "(", "200", ")", ",", "'GET'", ",", "null", ",", "true", ")", ";", "$", "calendarData", "=", "json_decode", "(", "$", "response", ")", ";", "if", "(", "empty", "(", "$", "calendarData", "->", "calendarType", ")", ")", "{", "throw", "new", "RESTRequestException", "(", "\"JobService: Data format not expected.\"", ")", ";", "}", "$", "className", "=", "JobService", "::", "CALENDAR_NAMESPACE", ".", "'\\\\'", ".", "ucfirst", "(", "$", "calendarData", "->", "calendarType", ")", ".", "\"Calendar\"", ";", "if", "(", "class_exists", "(", "$", "className", ")", ")", "{", "return", "$", "className", "::", "createFromJSON", "(", "$", "calendarData", ")", ";", "}", "else", "{", "throw", "new", "RESTRequestException", "(", "\"JobService: Unrecognized calendar type returned by server\"", ")", ";", "}", "}" ]
Retrieve a calendar and its properties @param string $calendarName Name of the calendar to obtain details of @return BaseCalendar @throws \Jaspersoft\Exception\RESTRequestException
[ "Retrieve", "a", "calendar", "and", "its", "properties" ]
32dc45485030c6339e636c309cd5280af6479bf4
https://github.com/Jaspersoft/jrs-rest-php-client/blob/32dc45485030c6339e636c309cd5280af6479bf4/src/Jaspersoft/Service/JobService.php#L197-L213
train