sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function getLabelMeta($property = null, $fallbackValue = "")
{
if (is_null($property)) {
$varReturn = $this->__labelmeta;
} elseif (isset($this->__labelmeta[$property])
&& !is_null($this->__labelmeta[$property])
) {
$varReturn = $this->__labelmeta[$property];
} else {
$varReturn = $fallbackValue;
}
return $varReturn;
} | Get label meta property.
@param string $property Property to get from internal label meta array.
@param string $fallbackValue Optional fallback value if requested property has no value
@return string Property value or empty string of none is set. | entailment |
public function getName()
{
$strName = parent::getName();
if (empty($strName)) {
$strName = $this->__name = $this->__generateName();
}
return $strName;
} | Return the (original) name of the current field.
Use getDynamicName() to get the field name + dynamic count
@return string The original field name | entailment |
public function getDynamicName($intCount = 0)
{
$strName = $this->getName();
if ($intCount > 0) {
$strName = $strName . "_" . $intCount;
}
return $strName;
} | Same as getName() except getDynamicName adds the current dynamic count to the fieldname as a suffix (_1, _2 etc)
When the dynamic count === 0, the return value equals the output of getName()
@param integer $intCount The dynamic count
@return string The field name | entailment |
public function getShortLabel()
{
$strReturn = $this->getLabel();
$strShortLabel = $this->getMeta("summaryLabel", null);
if (! is_null($strShortLabel) && strlen($strShortLabel) > 0) {
$strReturn = $strShortLabel;
}
return $strReturn;
} | Get the short label (meta 'summaryLabel') if available.
Use the 'long' (regular)
label as a fallback return value.
@return string The short or regular element label | entailment |
protected function conditionsToJs($intDynamicPosition = 0)
{
$strReturn = "";
if ($this->hasConditions() && (count($this->getConditions()) > 0)) {
/* @var $objCondition \ValidFormBuilder\Condition */
foreach ($this->getConditions() as $objCondition) {
$strReturn .= "objForm.addCondition(" . json_encode($objCondition->jsonSerialize($intDynamicPosition)) . ");\n";
}
}
return $strReturn;
} | Generates needed javascript initialization code for client-side conditional logic
@param integer $intDynamicPosition Dynamic position
@return string Generated javascript code | entailment |
protected function matchWithToJs($intDynamicPosition = 0)
{
$strReturn = "";
$objMatchWith = $this->getValidator()->getMatchWith();
if (is_object($objMatchWith)) {
$strId = ($intDynamicPosition == 0) ? $this->__id : $this->__id . "_" . $intDynamicPosition;
$strMatchId = ($intDynamicPosition == 0) ? $objMatchWith->getId() : $objMatchWith->getId() . "_" . $intDynamicPosition;
$strReturn = "objForm.matchfields('{$strId}', '{$strMatchId}', '" . $this->__validator->getMatchWithError() . "');\n";
}
return $strReturn;
} | Generate matchWith javascript code
@param integer $intDynamicPosition
@return string Generated javascript | entailment |
public function setData($strKey = null, $varValue = null)
{
$arrData = $this->getMeta("data", array());
if (! is_null($strKey) && ! is_null($varValue)) {
$arrData[$strKey] = $varValue;
}
// Set and overwrite previous value.
$this->setMeta("data", $arrData, true);
// Return boolean value
return ! ! $this->getData($strKey);
} | Store data in the current object.
This data will not be visibile in any output and will only be used for internal purposes. For example, you
can store some custom data from your CMS or an other library in a field object, for later use.
**Note: Using this method will overwrite any previously set data with the same key!**
@param string $strKey The key for this storage
@param mixed $varValue The value to store
@return boolean True if set successful, false if not. | entailment |
public function getData($strKey = null)
{
$varReturn = false;
$arrData = $this->getMeta("data", null);
if (! is_null($arrData)) {
if ($strKey == null) {
$varReturn = $arrData;
} else {
if (isset($arrData[$strKey])) {
$varReturn = $arrData[$strKey];
}
}
}
return $varReturn;
} | Get a value from the internal data array.
@param string $strKey The key of the data attribute to return
@return mixed | entailment |
protected function __sanitizeCheckForJs($strCheck)
{
$strCheck = (empty($strCheck)) ? "''" : str_replace("'", "\\'", $strCheck);
$strCheck = (mb_substr($strCheck, -1) == "u") ? mb_substr($strCheck, 0, -1) : $strCheck;
return $strCheck;
} | Sanitize a regular expression check for javascript.
@param string $strCheck
@return mixed|string | entailment |
protected function __getMetaString()
{
$strOutput = "";
foreach ($this->__meta as $key => $value) {
if (! in_array($key, array_merge($this->__reservedmeta, $this->__fieldmeta))) {
$strOutput .= " {$key}=\"{$value}\"";
}
}
return $strOutput;
} | Convert meta array to html attributes+values
@return string | entailment |
protected function __getFieldMetaString()
{
$strOutput = "";
if (is_array($this->__fieldmeta)) {
foreach ($this->__fieldmeta as $key => $value) {
if (! in_array($key, $this->__reservedmeta)) {
$strOutput .= " {$key}=\"{$value}\"";
}
}
}
return $strOutput;
} | Convert fieldmeta array to html attributes+values
@return string | entailment |
protected function __getLabelMetaString()
{
$strOutput = "";
if (is_array($this->__labelmeta)) {
foreach ($this->__labelmeta as $key => $value) {
if (! in_array($key, $this->__reservedmeta)) {
$strOutput .= " {$key}=\"{$value}\"";
}
}
}
return $strOutput;
} | Convert labelmeta array to html attributes+values
@return string | entailment |
protected function __getTipMetaString()
{
$strOutput = "";
if (is_array($this->__tipmeta)) {
foreach ($this->__tipmeta as $key => $value) {
if (! in_array($key, $this->__reservedmeta)) {
$strOutput .= " {$key}=\"{$value}\"";
}
}
}
return $strOutput;
} | Convert tipmeta array to html attributes+values
@return string | entailment |
protected function __getDynamicLabelMetaString()
{
$strOutput = "";
if (is_array($this->__dynamiclabelmeta)) {
foreach ($this->__dynamiclabelmeta as $key => $value) {
if (! in_array($key, $this->__reservedmeta)) {
$strOutput .= " {$key}=\"{$value}\"";
}
}
}
return $strOutput;
} | Convert dynamiclabelmeta array to html attributes+values
@return string | entailment |
protected function __getDynamicRemoveLabelMetaString()
{
$strOutput = "";
if (is_array($this->__dynamicremovelabelmeta)) {
foreach ($this->__dynamicremovelabelmeta as $key => $value) {
if (! in_array($key, $this->__reservedmeta)) {
$strOutput .= " {$key}=\"{$value}\"";
}
}
}
return $strOutput;
} | Convert dynamicRemoveLabelMeta array to html attributes+values
@return string | entailment |
protected function __initializeMeta()
{
foreach ($this->__meta as $key => $value) {
if (in_array($key, $this->__reservedfieldmeta)) {
$key = "field" . $key;
}
if (in_array($key, $this->__reservedlabelmeta)) {
$key = "label" . $key;
}
$strMagicKey = null;
foreach ($this->__magicmeta as $strMagicMeta) {
if (strpos(strtolower($key), strtolower($strMagicMeta)) === 0
&& strlen($key) !== strlen($strMagicMeta)) {
$strMagicKey = $strMagicMeta;
break;
}
}
if (!is_null($strMagicKey) && !in_array($key, $this->__magicreservedmeta)) {
$strMethod = "set" . ucfirst($strMagicKey) . "Meta";
$this->$strMethod(strtolower(substr($key, - (strlen($key) - strlen($strMagicKey)))), $value);
unset($this->__meta[$key]);
}
}
} | Filter out special field or label specific meta tags from the main
meta array and add them to the designated meta arrays __fieldmeta or __labelmeta.
Example: `$meta["labelstyle"] = "width: 20px";` will become `$__fieldmeta["style"] = "width: 20px;"`
Any meta key that starts with 'label' or 'field' will be assigned to it's
corresponding internal meta array.
@return void | entailment |
protected function __setMeta($property, $value, $blnOverwrite = false)
{
$internalMetaArray = &$this->__meta;
/**
* Re-set internalMetaArray if property has magic key 'label', 'field', 'tip', 'dynamicLabel'
* or 'dynamicRemoveLabel'
*/
$strMagicKey = null;
foreach ($this->__magicmeta as $strMagicMeta) {
if (strpos(strtolower($property), strtolower($strMagicMeta)) === 0
&& strlen($property) !== strlen($strMagicMeta)) {
$strMagicKey = $strMagicMeta;
break;
}
}
if (!is_null($strMagicKey)) {
switch ($strMagicKey) {
case "field":
$internalMetaArray = &$this->__fieldmeta;
$property = strtolower(substr($property, - (strlen($property) - 5)));
break;
case "label":
$internalMetaArray = &$this->__labelmeta;
$property = strtolower(substr($property, - (strlen($property) - 5)));
break;
case "tip":
$internalMetaArray = &$this->__tipmeta;
$property = strtolower(substr($property, - (strlen($property) - 3)));
break;
case "dynamicLabel":
$internalMetaArray = &$this->__dynamiclabelmeta;
$property = strtolower(substr($property, - (strlen($property) - 12)));
break;
case "dynamicRemoveLabel":
$internalMetaArray = &$this->__dynamicremovelabelmeta;
$property = strtolower(substr($property, - (strlen($property) - 18)));
break;
default:
}
}
if ($blnOverwrite) {
if (empty($value) || is_null($value)) {
unset($internalMetaArray[$property]);
} else {
$internalMetaArray[$property] = $value;
}
return $value;
} else {
$varMeta = (isset($internalMetaArray[$property])) ? $internalMetaArray[$property] : "";
// *** If the id is being set and there is already a value we don't set the new value.
if ($property == "id" && $varMeta != "") {
return $varMeta;
}
// *** Define delimiter per meta property.
switch ($property) {
case "style":
$strDelimiter = ";";
break;
default:
$strDelimiter = " ";
}
// *** Add the value to the property string.
$arrMeta = (! is_array($varMeta)) ? explode($strDelimiter, $varMeta) : $varMeta;
$arrMeta[] = $value;
// Make sure no empty values are left in the array.
$arrMeta = array_filter($arrMeta);
// Make sure there are no duplicate entries for the 'class' property
if (strtolower($property) === 'class') {
$arrMeta = array_unique($arrMeta);
}
$varMeta = implode($strDelimiter, $arrMeta);
$internalMetaArray[$property] = $varMeta;
return $varMeta;
}
} | Helper method to set meta data
@param string $property The key to set in the meta array
@param string $value The corresponding value
@param boolean $blnOverwrite If true, overwrite pre-existing key-value pair
@return array|string|null | entailment |
public function getRouteOriginDestination($destination, $origin, $avoid = null, $connections = null, $datasource = 'tranquility', $flag = 'shortest', $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getRouteOriginDestinationWithHttpInfo($destination, $origin, $avoid, $connections, $datasource, $flag, $userAgent, $xUserAgent);
return $response;
} | Operation getRouteOriginDestination
Get route
@param int $destination destination solar system ID (required)
@param int $origin origin solar system ID (required)
@param int[] $avoid avoid solar system ID(s) (optional)
@param int[][] $connections connected solar system pairs (optional)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $flag route security preference (optional, default to shortest)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@throws \InvalidArgumentException
@return int[] | entailment |
public function getRouteOriginDestinationWithHttpInfo($destination, $origin, $avoid = null, $connections = null, $datasource = 'tranquility', $flag = 'shortest', $userAgent = null, $xUserAgent = null)
{
$returnType = 'int[]';
$request = $this->getRouteOriginDestinationRequest($destination, $origin, $avoid, $connections, $datasource, $flag, $userAgent, $xUserAgent);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'int[]',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 404:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\nullx27\ESI\nullx27\ESI\Models\GetRouteOriginDestinationNotFound',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 500:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\nullx27\ESI\nullx27\ESI\Models\InternalServerError',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
} | Operation getRouteOriginDestinationWithHttpInfo
Get route
@param int $destination destination solar system ID (required)
@param int $origin origin solar system ID (required)
@param int[] $avoid avoid solar system ID(s) (optional)
@param int[][] $connections connected solar system pairs (optional)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $flag route security preference (optional, default to shortest)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@throws \InvalidArgumentException
@return array of int[], HTTP status code, HTTP response headers (array of strings) | entailment |
public function getRouteOriginDestinationAsync($destination, $origin, $avoid = null, $connections = null, $datasource = 'tranquility', $flag = 'shortest', $userAgent = null, $xUserAgent = null)
{
return $this->getRouteOriginDestinationAsyncWithHttpInfo($destination, $origin, $avoid, $connections, $datasource, $flag, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getRouteOriginDestinationAsync
Get route
@param int $destination destination solar system ID (required)
@param int $origin origin solar system ID (required)
@param int[] $avoid avoid solar system ID(s) (optional)
@param int[][] $connections connected solar system pairs (optional)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $flag route security preference (optional, default to shortest)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \InvalidArgumentException
@return \GuzzleHttp\Promise\PromiseInterface | entailment |
public function getRouteOriginDestinationAsyncWithHttpInfo($destination, $origin, $avoid = null, $connections = null, $datasource = 'tranquility', $flag = 'shortest', $userAgent = null, $xUserAgent = null)
{
$returnType = 'int[]';
$request = $this->getRouteOriginDestinationRequest($destination, $origin, $avoid, $connections, $datasource, $flag, $userAgent, $xUserAgent);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
$responseBody = $response->getBody();
if ($returnType === '\SplFileObject') {
$content = $responseBody; //stream goes to serializer
} else {
$content = $responseBody->getContents();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
} | Operation getRouteOriginDestinationAsyncWithHttpInfo
Get route
@param int $destination destination solar system ID (required)
@param int $origin origin solar system ID (required)
@param int[] $avoid avoid solar system ID(s) (optional)
@param int[][] $connections connected solar system pairs (optional)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $flag route security preference (optional, default to shortest)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \InvalidArgumentException
@return \GuzzleHttp\Promise\PromiseInterface | entailment |
protected function getRouteOriginDestinationRequest($destination, $origin, $avoid = null, $connections = null, $datasource = 'tranquility', $flag = 'shortest', $userAgent = null, $xUserAgent = null)
{
// verify the required parameter 'destination' is set
if ($destination === null) {
throw new \InvalidArgumentException(
'Missing the required parameter $destination when calling getRouteOriginDestination'
);
}
// verify the required parameter 'origin' is set
if ($origin === null) {
throw new \InvalidArgumentException(
'Missing the required parameter $origin when calling getRouteOriginDestination'
);
}
if ($avoid !== null && count($avoid) > 100) {
throw new \InvalidArgumentException('invalid value for "$avoid" when calling RoutesApi.getRouteOriginDestination, number of items must be less than or equal to 100.');
}
if ($connections !== null && count($connections) > 100) {
throw new \InvalidArgumentException('invalid value for "$connections" when calling RoutesApi.getRouteOriginDestination, number of items must be less than or equal to 100.');
}
$resourcePath = '/route/{origin}/{destination}/';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// query params
if (is_array($avoid)) {
$avoid = ObjectSerializer::serializeCollection($avoid, 'csv', true);
}
if ($avoid !== null) {
$queryParams['avoid'] = ObjectSerializer::toQueryValue($avoid);
}
// query params
if (is_array($connections)) {
$connections = ObjectSerializer::serializeCollection($connections, 'csv', true);
}
if ($connections !== null) {
$queryParams['connections'] = ObjectSerializer::toQueryValue($connections);
}
// query params
if ($datasource !== null) {
$queryParams['datasource'] = ObjectSerializer::toQueryValue($datasource);
}
// query params
if ($flag !== null) {
$queryParams['flag'] = ObjectSerializer::toQueryValue($flag);
}
// query params
if ($userAgent !== null) {
$queryParams['user_agent'] = ObjectSerializer::toQueryValue($userAgent);
}
// header params
if ($xUserAgent !== null) {
$headerParams['X-User-Agent'] = ObjectSerializer::toHeaderValue($xUserAgent);
}
// path params
if ($destination !== null) {
$resourcePath = str_replace(
'{' . 'destination' . '}',
ObjectSerializer::toPathValue($destination),
$resourcePath
);
}
// path params
if ($origin !== null) {
$resourcePath = str_replace(
'{' . 'origin' . '}',
ObjectSerializer::toPathValue($origin),
$resourcePath
);
}
// body params
$_tempBody = null;
if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['application/json']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
}
// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
$httpBody = $_tempBody;
// \stdClass has no __toString(), so we should encode it manually
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($httpBody);
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValue
];
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
} | Create request for operation 'getRouteOriginDestination'
@param int $destination destination solar system ID (required)
@param int $origin origin solar system ID (required)
@param int[] $avoid avoid solar system ID(s) (optional)
@param int[][] $connections connected solar system pairs (optional)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $flag route security preference (optional, default to shortest)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \InvalidArgumentException
@return \GuzzleHttp\Psr7\Request | entailment |
private function clearContext()
{
$this->url = NULL;
$this->params = array();
$this->headers = array();
Logger::log('Context service for ' . static::class . ' cleared!');
$this->closeConnection();
} | Método que limpia el contexto de la llamada | entailment |
private function initialize()
{
$this->closeConnection();
$this->params = [];
$this->con = curl_init($this->url);
} | Initialize CURL | entailment |
public function yearly(\DateTime $firstExecution = null, \DateTime $lastExecution = null)
{
$this->task->setInterval(CronExpression::factory('@yearly'), $firstExecution, $lastExecution);
return $this;
} | {@inheritdoc} | entailment |
public function cron($cronExpression, \DateTime $firstExecution = null, \DateTime $lastExecution = null)
{
$this->task->setInterval(CronExpression::factory($cronExpression), $firstExecution, $lastExecution);
return $this;
} | {@inheritdoc} | entailment |
public function getQuery($queryParams)
{
return array_key_exists($queryParams, $this->query) ? $this->query[$queryParams] : null;
} | Get query params
@param string $queryParams
@return mixed | entailment |
public function get($param)
{
return array_key_exists($param, $this->data) ? $this->data[$param] : null;
} | Método que devuelve un parámetro de la solicitud
@param string $param
@return string|null | entailment |
public function redirect($url = null)
{
if (null === $url) {
$url = $this->getServer('HTTP_ORIGIN');
}
ob_start();
header('Location: ' . $url);
ob_end_clean();
Security::getInstance()->updateSession();
exit(t('Redireccionando...'));
} | Método que realiza una redirección a la url dada
@param string $url | entailment |
public function getServer($param, $default = null)
{
return array_key_exists($param, $this->server) ? $this->server[$param] : $default;
} | Devuelve un parámetro de $_SERVER
@param string $param
@param $default
@return string|null | entailment |
public function getRootUrl($hasProtocol = true)
{
$url = $this->getServerName();
$protocol = $hasProtocol ? $this->getProtocol() : '';
if (!empty($protocol)) {
$url = $protocol . $url;
}
if (!in_array((integer)$this->getServer('SERVER_PORT'), [80, 443], true)) {
$url .= ':' . $this->getServer('SERVER_PORT');
}
return $url;
} | Devuelve la url completa de base
@param boolean $hasProtocol
@return string | entailment |
public function init()
{
parent::init();
Logger::log(static::class . ' init', LOG_DEBUG);
$this->domain = $this->getDomain();
$this->hydrateRequestData();
$this->hydrateOrders();
if($this instanceof CustomApi === false) {
$this->createConnection($this->getTableMap());
}
$this->checkFieldType();
$this->setLoaded(true);
Logger::log(static::class . ' loaded', LOG_DEBUG);
} | Initialize api | entailment |
protected function hydrateOrders()
{
if (count($this->query)) {
Logger::log(static::class . ' gathering query string', LOG_DEBUG);
foreach ($this->query as $key => $value) {
if ($key === self::API_ORDER_FIELD && is_array($value)) {
foreach ($value as $field => $direction) {
$this->order->addOrder($field, $direction);
}
}
}
}
} | Hydrate order from request | entailment |
protected function extractPagination()
{
Logger::log(static::class . ' extract pagination start', LOG_DEBUG);
$page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1;
$limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100;
Logger::log(static::class . ' extract pagination end', LOG_DEBUG);
return array($page, (int)$limit);
} | Extract pagination values
@return array | entailment |
private function addOrders(ModelCriteria &$query)
{
Logger::log(static::class . ' extract orders start ', LOG_DEBUG);
$orderAdded = FALSE;
$tableMap = $this->getTableMap();
foreach ($this->order->getOrders() as $field => $direction) {
if ($column = ApiHelper::checkFieldExists($tableMap, $field)) {
$orderAdded = TRUE;
if ($direction === Order::ASC) {
$query->addAscendingOrderByColumn($column->getPhpName());
} else {
$query->addDescendingOrderByColumn($column->getPhpName());
}
}
}
if (!$orderAdded) {
$pks = $this->getPkDbName();
foreach(array_keys($pks) as $key) {
$query->addAscendingOrderByColumn($key);
}
}
Logger::log(static::class . ' extract orders end', LOG_DEBUG);
} | Add order fields to query
@param ModelCriteria $query
@throws \PSFS\base\exception\ApiException | entailment |
protected function addFilters(ModelCriteria &$query)
{
if (count($this->query) > 0) {
$tableMap = $this->getTableMap();
foreach ($this->query as $field => $value) {
if (self::API_COMBO_FIELD === $field) {
ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
} elseif(!preg_match('/^__/', $field)) {
ApiHelper::addModelField($tableMap, $query, $field, $value);
}
}
}
} | Add filters fields to query
@param ModelCriteria $query | entailment |
private function paginate()
{
$this->list = null;
try {
$query = $this->prepareQuery();
$this->addFilters($query);
$this->checkReturnFields($query);
$this->addOrders($query);
list($page, $limit) = $this->extractPagination();
if ($limit === -1) {
$this->list = $query->find($this->con);
} else {
$this->list = $query->paginate($page, $limit, $this->con);
}
} catch (\Exception $e) {
Logger::log($e->getMessage(), LOG_ERR);
}
} | Generate list page for model | entailment |
public function modelList()
{
$this->action = self::API_ACTION_LIST;
$code = 200;
list($return, $total, $pages) = $this->getList();
$message = null;
if(!$total) {
$message = t('No se han encontrado elementos para la búsqueda');
}
return $this->json(new JsonResponse($return, $code === 200, $total, $pages, $message), $code);
} | @label Get list of {__API__} elements filtered
@GET
@CACHE 600
@ROUTE /{__DOMAIN__}/api/{__API__}
@return \PSFS\base\dto\JsonResponse(data=[{__API__}]) | entailment |
public function get($pk)
{
$this->action = self::API_ACTION_GET;
$return = NULL;
$total = NULL;
$pages = 1;
$message = null;
list($code, $return) = $this->getSingleResult($pk);
if($code !== 200) {
$message = t('No se ha encontrado el elemento solicitado');
}
return $this->json(new JsonResponse($return, $code === 200, $total, $pages, $message), $code);
} | @label Get unique element for {__API__}
@GET
@CACHE 600
@ROUTE /{__DOMAIN__}/api/{__API__}/{pk}
@param int $pk
@return \PSFS\base\dto\JsonResponse(data={__API__}) | entailment |
public function post()
{
$this->action = self::API_ACTION_POST;
$saved = FALSE;
$status = 400;
$model = NULL;
$message = null;
try {
$this->hydrateFromRequest();
if (false !== $this->model->save($this->con)) {
$status = 200;
$saved = TRUE;
$model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
} else {
$message = t('No se ha podido guardar el modelo seleccionado');
}
} catch (\Exception $e) {
$message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
$context = [];
if(null !== $e->getPrevious()) {
$context[] = $e->getPrevious()->getMessage();
}
Logger::log($e->getMessage(), LOG_CRIT, $context);
}
return $this->json(new JsonResponse($model, $saved, $saved, 0, $message), $status);
} | @label Create a new {__API__}
@POST
@PAYLOAD {__API__}
@ROUTE /{__DOMAIN__}/api/{__API__}
@return \PSFS\base\dto\JsonResponse(data={__API__}) | entailment |
public function put($pk)
{
$this->action = self::API_ACTION_PUT;
$this->hydrateModel($pk);
$status = 400;
$updated = FALSE;
$model = NULL;
$message = null;
if (NULL !== $this->model) {
try {
$this->hydrateModelFromRequest($this->model, $this->data);
if ($this->model->save($this->con) !== FALSE) {
$updated = TRUE;
$status = 200;
$model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
} else {
$message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
}
} catch (\Exception $e) {
$message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
$context = [];
if(null !== $e->getPrevious()) {
$context[] = $e->getPrevious()->getMessage();
}
Logger::log($e->getMessage(), LOG_CRIT, $context);
}
} else {
$message = t('No se ha encontrado el modelo al que se hace referencia para actualizar');
}
return $this->json(new JsonResponse($model, $updated, $updated, 0, $message), $status);
} | @label Modify {__API__} model
@PUT
@PAYLOAD {__API__}
@ROUTE /{__DOMAIN__}/api/{__API__}/{pk}
@param string $pk
@return \PSFS\base\dto\JsonResponse(data={__API__}) | entailment |
public function delete($pk = NULL)
{
$this->action = self::API_ACTION_DELETE;
$this->closeTransaction(200);
$deleted = FALSE;
$message = null;
if (NULL !== $pk) {
try {
$this->con->beginTransaction();
$this->hydrateModel($pk);
if (NULL !== $this->model) {
if(method_exists('clearAllReferences', $this->model)) {
$this->model->clearAllReferences(true);
}
$this->model->delete($this->con);
$deleted = TRUE;
}
} catch (\Exception $e) {
$context = [];
if(null !== $e->getPrevious()) {
$context[] = $e->getPrevious()->getMessage();
}
Logger::log($e->getMessage(), LOG_CRIT, $context);
}
}
return $this->json(new JsonResponse(null, $deleted, $deleted, 0, $message), ($deleted) ? 200 : 400);
} | @label Delete {__API__} model
@DELETE
@ROUTE /{__DOMAIN__}/api/{__API__}/{pk}
@param string $pk
@return \PSFS\base\dto\JsonResponse(data={__API__}) | entailment |
public function bulk() {
$this->action = self::API_ACTION_BULK;
$saved = FALSE;
$status = 400;
$message = null;
try {
$this->hydrateBulkRequest();
$this->saveBulk();
$saved = true;
$status = 200;
} catch(\Exception $e) {
Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData());
$message = t('Bulk insert rolled back');
}
return $this->json(new JsonResponse($this->exportList(), $saved, count($this->list), 1, $message), $status);
} | @label Bulk insert for {__API__} model
@POST
@route /{__DOMAIN__}/api/{__API__}s
@payload [{__API__}]
@return \PSFS\base\dto\JsonResponse(data=[{__API__}]) | entailment |
protected function hydrateRequestData()
{
$request = Request::getInstance();
$this->query = array_merge($this->query, $request->getQueryParams());
$this->data = array_merge($this->data, $request->getRawData());
} | Hydrate data from request | entailment |
private function getSingleResult($pk)
{
$model = $this->_get($pk);
$code = 200;
$return = array();
if (NULL === $model || !method_exists($model, 'toArray')) {
$code = 404;
} else {
$return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
}
return array($code, $return);
} | @param integer $pk
@return array | entailment |
public function assertNotThrows(string $class, callable $execute) : void
{
try {
$execute();
} catch (ExpectationFailedException $e) {
throw $e;
} catch (Throwable $e) {
static::assertThat($e, new LogicalNot(new ConstraintException($class)));
return;
}
static::assertThat(null, new LogicalNot(new ConstraintException($class)));
} | Asserts that the callable doesn't throw a specified exception.
@param string $class The exception type expected not to be thrown.
@param callable $execute The callable.
@since 1.0.0 | entailment |
public function assertThrows(
string $class,
callable $execute,
callable $inspect = null
) : void {
try {
$execute();
} catch (ExpectationFailedException $e) {
throw $e;
} catch (Throwable $e) {
static::assertThat($e, new ConstraintException($class));
if ($inspect !== null) {
$inspect($e);
}
return;
}
static::assertThat(null, new ConstraintException($class));
} | Asserts that the callable throws a specified throwable.
If successful and the inspection callable is not null
then it is called and the caught exception is passed as argument.
@param string $class The exception type expected to be thrown.
@param callable $execute The callable.
@param callable|null $inspect [optional] The inspector.
@since 1.0.0 | entailment |
public function cachePoints($metricId, $num = 1000, $page = 1)
{
// If cache already exists return it
if ($this->cached != null) {
return $this->cached;
}
$this->cached = $this->client->call(
'GET',
"metrics/$metricId/points",
[
'query' => [
'per_page' => $num,
'current_page' => $page,
],
]
);
return $this->cached;
} | Cache Points for performance improvement.
@param int $metricId
@param int $num
@param int $page
@return array|bool | entailment |
public function indexPoints($metricId, $num = 1000, $page = 1)
{
if ($this->cache != false) {
return $this->cachePoints($metricId, $num, $page);
}
return $this->client->call(
'GET',
"metrics/$metricId/points",
[
'query' => [
'per_page' => $num,
'current_page' => $page,
],
]
);
} | Get a defined number of Points.
@param int $metricId
@param int $num
@param int $page
@return array|bool | entailment |
public function searchPoints($metricId, $search, $by, $limit = 1, $num = 1000, $page = 1)
{
$points = $this->indexPoints($metricId, $num, $page)['data'];
$filtered = array_filter(
$points,
function ($point) use ($search, $by) {
if (array_key_exists($by, $point)) {
if (strpos($point[$by], $search) !== false) {
return $point;
}
if ($point[$by] === $search) {
return $point;
}
}
return false;
}
);
if ($limit == 1) {
return array_shift($filtered);
}
return array_slice($filtered, 0, $limit);
} | Search if a defined number of Points exists.
@param $metricId
@param string $search
@param string $by
@param int $limit
@param int $num
@param int $page
@return mixed | entailment |
public function getAllRoutes()
{
$routes = [];
foreach ($this->getRoutes() as $path => $route) {
if (array_key_exists('slug', $route)) {
$routes[$route['slug']] = $path;
}
}
return $routes;
} | Method that extract all routes in the platform
@return array | entailment |
public function execute($route)
{
Logger::log('Executing the request');
try {
//Search action and execute
return $this->searchAction($route);
} catch (AccessDeniedException $e) {
Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
return Admin::staticAdminLogon($route);
} catch (RouterException $r) {
Logger::log($r->getMessage(), LOG_WARNING);
} catch (\Exception $e) {
Logger::log($e->getMessage(), LOG_ERR);
throw $e;
}
throw new RouterException(t('Página no encontrada'), 404);
} | @param string|null $route
@throws \Exception
@return string HTML | entailment |
public function getRoute($slug = '', $absolute = FALSE, array $params = [])
{
if ('' === $slug) {
return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/';
}
if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
throw new RouterException(t('No existe la ruta especificada'));
}
$url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
if (!empty($params)) {
foreach ($params as $key => $value) {
$url = str_replace('{' . $key . '}', $value, $url);
}
} elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
$url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
}
return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
} | @param string $slug
@param boolean $absolute
@param array $params
@return string|null
@throws RouterException | entailment |
private function generateSlugs($absoluteTranslationFileName)
{
$translations = I18nHelper::generateTranslationsFile($absoluteTranslationFileName);
foreach ($this->routing as $key => &$info) {
$keyParts = explode('#|#', $key);
$keyParts = array_key_exists(1, $keyParts) ? $keyParts[1] : $keyParts[0];
$slug = RouterHelper::slugify($keyParts);
if (NULL !== $slug && !array_key_exists($slug, $translations)) {
$translations[$slug] = $info['label'];
file_put_contents($absoluteTranslationFileName, "\$translations[\"{$slug}\"] = t(\"{$info['label']}\");\n", FILE_APPEND);
}
$this->slugs[$slug] = $key;
$info['slug'] = $slug;
}
} | Parse slugs to create translations
@param string $absoluteTranslationFileName | entailment |
public function setSystemMessageType($messageType): Envelope
{
if (!in_array($messageType, static::getLetterTypeOptions())) {
throw new InvalidArgumentException(
sprintf('Property %s is not supported for %s', $messageType, __FUNCTION__)
);
}
$this->data['letterType']['systemMessageType'] = $messageType;
return $this;
} | Specify the type of E-POST letter
@param string $messageType
@return self
@throws InvalidArgumentException | entailment |
public function addRecipientNormal(Recipient\Normal $recipient): Envelope
{
if ($this->isHybridLetter()) {
throw new LogicException(
sprintf('Can not set recipients if message type is "%s"', self::LETTER_TYPE_HYBRID)
);
}
$this->data['recipients'][] = $recipient;
return $this;
} | Add a normal (electronic) recipient
@param Recipient\Normal|AbstractRecipient $recipient
@return self | entailment |
public function addRecipientPrinted(Recipient\Hybrid $recipient): Envelope
{
if ($this->isNormalLetter()) {
throw new LogicException(
sprintf('Can not set recipientsPrinted if message type is "%s"', self::LETTER_TYPE_NORMAL)
);
}
if (count($this->getRecipients())) {
throw new LogicException('It must not be set more than one printed recipient');
}
$this->data['recipientsPrinted'][] = $recipient;
return $this;
} | Add a hybrid recipient for printed letters
@param Recipient\Hybrid|AbstractRecipient $recipient
@return self | entailment |
public function getRecipients()
{
switch ($this->getSystemMessageType()) {
case self::LETTER_TYPE_NORMAL:
return $this->data['recipients'];
break;
case self::LETTER_TYPE_HYBRID:
return $this->data['recipientsPrinted'];
break;
}
return null;
} | Get the recipients added to the envelope
@return AbstractRecipient[] | entailment |
public function setContactType($contactType)
{
$allowedValues = $this->getContactTypeAllowableValues();
if (!in_array($contactType, $allowedValues)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value for 'contactType', must be one of '%s'",
implode("', '", $allowedValues)
)
);
}
$this->container['contactType'] = $contactType;
return $this;
} | Sets contactType
@param string $contactType contact_type string
@return $this | entailment |
public function getEnvelope(): Envelope
{
if (null === $this->envelope) {
throw new MissingEnvelopeException('No Envelope provided! Provide one beforehand');
}
// Check for recipients
if (empty($this->envelope->getRecipients())) {
throw new MissingRecipientException('No recipients provided! Add them beforehand');
}
return $this->envelope;
} | Get the envelope
@return Envelope
@throws MissingEnvelopeException If the envelope is missing
@throws MissingRecipientException If there are no recipients | entailment |
public function addAttachment($attachment): Letter
{
if (!is_file($attachment)) {
throw new InvalidArgumentException('"%s" can not be found or is not a file');
}
$this->attachments[] = $attachment;
return $this;
} | Add an attachment
@param string $attachment The file path
@return self
@throws InvalidArgumentException If the file is not found or it is no file | entailment |
public function setDeliveryOptions(DeliveryOptions $deliveryOptions): Letter
{
if ($this->envelope && $this->envelope->isNormalLetter()) {
throw new LogicException('Delivery options are not supported for non-printed letters.');
}
$this->deliveryOptions = $deliveryOptions;
return $this;
} | Set the delivery options
@param DeliveryOptions $deliveryOptions
@return self
@throws LogicException If the letter isn't a hybrid (printed) letter | entailment |
public function getPostageInfo()
{
if (null === $this->postageInfo) {
throw new MissingPreconditionException('No postage info provided! Provide them beforehand');
}
// Set delivery options to postage info if they were passed to this instance
if (null === $this->postageInfo->getDeliveryOptions() && null !== $this->getDeliveryOptions()) {
$this->postageInfo->setDeliveryOptions($this->getDeliveryOptions());
}
// Set the attachment's file size for normal letters
if (!$this->postageInfo->getLetterSize() && $this->postageInfo->isNormalLetter() && $this->attachments) {
$size = array_reduce(
$this->attachments,
function ($carry, $path) {
$carry += filesize($path);
return $carry;
},
0
);
$this->postageInfo->setLetterSize(ceil($size / 1048576));
}
return $this->postageInfo;
} | Get the postage info
@return PostageInfo
@throws MissingPreconditionException If no postage info are given | entailment |
public function create(): Letter
{
$multipartElements = [
[
'name' => 'envelope',
'contents' => \GuzzleHttp\json_encode($this->getEnvelope()),
'headers' => ['Content-Type' => $this->getEnvelope()->getMimeType()],
],
];
if ($this->getCoverLetter()) {
$multipartElements[] = [
'name' => 'cover_letter',
'contents' => $this->getCoverLetter(),
'headers' => ['Content-Type' => 'text/html'],
];
}
foreach ($this->getAttachments() as $attachment) {
$multipartElements[] = [
'name' => 'file',
'contents' => fopen($attachment, 'rb'),
'headers' => ['Content-Type' => static::getMimeTypeOfFile($attachment)],
];
}
$multipart = new MultipartStream($multipartElements);
$requestOptions = [
'headers' => [
'Content-Type' => 'multipart/mixed; boundary='.$multipart->getBoundary(),
],
'body' => $multipart,
];
$response = $this->getHttpClientForMailbox()->request('POST', '/letters', $requestOptions);
$data = \GuzzleHttp\json_decode($response->getBody()->getContents());
$this->setLetterId($data->letterId);
return $this;
} | Create a draft by given envelope and attachments
@return self
@throws BadResponseException See API Send Reference | entailment |
public function send(): Letter
{
$options = [
'headers' => [
'Content-Source' => $this->getEndpointMailbox().'/letters/'.$this->getLetterId(),
],
];
if ($this->getEnvelope()->isHybridLetter() && null !== $this->getDeliveryOptions()) {
$options['headers']['Content-Type'] = $this->getDeliveryOptions()->getMimeType();
$options['json'] = $this->getDeliveryOptions();
}
$this->getHttpClientForSend()->request('POST', '/deliveries', $options);
return $this;
} | Send the given letter. Delivery options should be set optionally for physical letters
@return self
@throws BadResponseException See API Send Reference | entailment |
public function queryPriceInformation()
{
try {
// Try to fetch postage info for a particular draft that was created beforehand
$options = [
'headers' => [
'Content-Source' => $this->getEndpointMailbox().'/letters/'.$this->getLetterId(),
],
];
if ($this->getEnvelope()->isHybridLetter() && $this->getDeliveryOptions()) {
$options['headers']['Content-Type'] = $this->getDeliveryOptions()->getMimeType();
$options['json'] = $this->getDeliveryOptions();
}
} catch (MissingPreconditionException $e) {
// Fetch postage info without a given letter
$options = [
'headers' => [
'Content-Type' => $this->getPostageInfo()->getMimeType(),
],
'json' => $this->getPostageInfo(),
];
}
$response = $this->getHttpClientForSend()->request('POST', '/postage-info', $options);
return \GuzzleHttp\json_decode($response->getBody()->getContents());
} | Query price information for a given letter (created beforehand) or for general purposes (with given postage info)
@return \stdClass
@throws BadResponseException See API Send Reference
@throws MissingPreconditionException If neither letterId nor PostageInfo provided | entailment |
private static function getMimeTypeOfFile($path)
{
$fileInfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($fileInfo, $path);
finfo_close($fileInfo);
return $mime;
} | Get a file's mime type
@param $path
@return mixed | entailment |
public function getCharactersCharacterIdAttributes($characterId, $datasource = 'tranquility', $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdAttributesWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdAttributes
Get character attributes
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use if unable to set a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@throws \InvalidArgumentException
@return \nullx27\ESI\nullx27\ESI\Models\GetCharactersCharacterIdAttributesOk | entailment |
public function getCharactersCharacterIdAttributesAsync($characterId, $datasource = 'tranquility', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCharactersCharacterIdAttributesAsyncWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCharactersCharacterIdAttributesAsync
Get character attributes
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use if unable to set a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \InvalidArgumentException
@return \GuzzleHttp\Promise\PromiseInterface | entailment |
public function getCharactersCharacterIdSkillqueueAsync($characterId, $datasource = 'tranquility', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCharactersCharacterIdSkillqueueAsyncWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCharactersCharacterIdSkillqueueAsync
Get character's skill queue
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use if unable to set a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \InvalidArgumentException
@return \GuzzleHttp\Promise\PromiseInterface | entailment |
public function getCharactersCharacterIdSkills($characterId, $datasource = 'tranquility', $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdSkillsWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdSkills
Get character skills
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use if unable to set a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@throws \InvalidArgumentException
@return \nullx27\ESI\nullx27\ESI\Models\GetCharactersCharacterIdSkillsOk | entailment |
public function getCharactersCharacterIdSkillsAsync($characterId, $datasource = 'tranquility', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCharactersCharacterIdSkillsAsyncWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCharactersCharacterIdSkillsAsync
Get character skills
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use if unable to set a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \InvalidArgumentException
@return \GuzzleHttp\Promise\PromiseInterface | entailment |
public function getCharactersCharacterIdWallets($characterId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdWalletsWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdWallets
List wallets and balances
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use, if preferred over a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@return \nullx27\ESI\Models\GetCharactersCharacterIdWallets200Ok[] | entailment |
public function getCharacter($characterId, $fields = ['*'])
{
//dd(config('services.igdb.url'));
$apiUrl = $this->getEndpoint('characters');
$apiUrl .= $characterId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get character information
@param integer $characterId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getCompany($companyId, $fields = ['*'])
{
$apiUrl = $this->getEndpoint('companies');
$apiUrl .= $companyId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get company information by ID
@param integer $companyId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getFranchise($franchiseId, $fields = ['*'])
{
$apiUrl = $this->getEndpoint('franchises');
$apiUrl .= $franchiseId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get franchise information
@param integer $franchiseId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getGameMode($gameModeId, $fields = ['name', 'slug', 'url'])
{
$apiUrl = $this->getEndpoint('game_modes');
$apiUrl .= $gameModeId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get game mode information by ID
@param integer $gameModeId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function searchGameModes($search, $fields = ['name', 'slug', 'url'], $limit = 10, $offset = 0)
{
$apiUrl = $this->getEndpoint('game_modes');
$params = array(
'fields' => implode(',', $fields),
'limit' => $limit,
'offset' => $offset,
'search' => $search,
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeMultiple($apiData);
} | Search game modes by name
@param string $search
@param array $fields
@param integer $limit
@param integer $offset
@return \StdClass
@throws \Exception | entailment |
public function getGame($gameId, $fields = ['*'])
{
$apiUrl = $this->getEndpoint('games');
$apiUrl .= $gameId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get game information by ID
@param integer $gameId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function searchGames($search, $fields = ['*'], $limit = 10, $offset = 0, $order = null)
{
$apiUrl = $this->getEndpoint('games');
$params = array(
'fields' => implode(',', $fields),
'limit' => $limit,
'offset' => $offset,
'order' => $order,
'search' => $search,
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeMultiple($apiData);
} | Search games by name
@param string $search
@param array $fields
@param integer $limit
@param integer $offset
@param string $order
@return \StdClass
@throws \Exception | entailment |
public function getGenre($genreId, $fields = ['name', 'slug', 'url'])
{
$apiUrl = $this->getEndpoint('genres');
$apiUrl .= $genreId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get genre information by ID
@param integer $genreId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getKeyword($keywordId, $fields = ['name', 'slug', 'url'])
{
$apiUrl = $this->getEndpoint('keywords');
$apiUrl .= $keywordId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get keyword information by ID
@param integer $keywordId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getPerson($personId, $fields = ['*'])
{
$apiUrl = $this->getEndpoint('people');
$apiUrl .= $personId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get people information by ID
@param integer $personId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getPlatform($platformId, $fields = ['name', 'logo', 'slug', 'url'])
{
$apiUrl = $this->getEndpoint('platforms');
$apiUrl .= $platformId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get platform information by ID
@param integer $platformId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getPlayerPerspective($perspectiveId, $fields = ['name', 'slug', 'url'])
{
$apiUrl = $this->getEndpoint('player_perspectives');
$apiUrl .= $perspectiveId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get player perspective information by ID
@param integer $perspectiveId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getPulse($pulseId, $fields = ['*'])
{
$apiUrl = $this->getEndpoint('pulses');
$apiUrl .= $pulseId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get pulse information by ID
@param integer $pulseId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function fetchPulses($fields = ['*'], $limit = 10, $offset = 0)
{
$apiUrl = $this->getEndpoint('pulses');
$params = array(
'fields' => implode(',', $fields),
'limit' => $limit,
'offset' => $offset
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeMultiple($apiData);
} | Search pulses by title
@param array $fields
@param integer $limit
@param integer $offset
@return \StdClass
@throws \Exception | entailment |
public function getCollection($collectionId, $fields = ['*'])
{
$apiUrl = $this->getEndpoint('collections');
$apiUrl .= $collectionId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get collection information by ID
@param integer $collectionId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
public function getTheme($themeId, $fields = ['name', 'slug', 'url'])
{
$apiUrl = $this->getEndpoint('themes');
$apiUrl .= $themeId;
$params = array(
'fields' => implode(',', $fields)
);
$apiData = $this->apiGet($apiUrl, $params);
return $this->decodeSingle($apiData);
} | Get themes information by ID
@param integer $themeId
@param array $fields
@return \StdClass
@throws \Exception | entailment |
private function decodeSingle(&$apiData)
{
$resObj = json_decode($apiData);
if (isset($resObj->status)) {
$msg = "Error " . $resObj->status . " " . $resObj->message;
throw new \Exception($msg);
}
if (!is_array($resObj) || count($resObj) == 0) {
return false;
}
return $resObj[0];
} | Decode the response from IGDB, extract the single resource object.
(Don't use this to decode the response containing list of objects)
@param string $apiData the api response from IGDB
@throws \Exception
@return \StdClass an IGDB resource object | entailment |
private function decodeMultiple(&$apiData)
{
$resObj = json_decode($apiData);
if (isset($resObj->status)) {
$msg = "Error " . $resObj->status . " " . $resObj->message;
throw new \Exception($msg);
} else {
//$itemsArray = $resObj->items;
if (!is_array($resObj)) {
return false;
} else {
return $resObj;
}
}
} | Decode the response from IGDB, extract the multiple resource object.
@param string $apiData the api response from IGDB
@throws \Exception
@return \StdClass an IGDB resource object | entailment |
private function apiGet($url, $params)
{
$url = $url . (strpos($url, '?') === false ? '?' : '') . http_build_query($params);
try {
$response = $this->httpClient->request('GET', $url, [
'headers' => [
'user-key' => $this->igdbKey,
'Accept' => 'application/json'
]
]);
} catch (RequestException $exception) {
if ($response = $exception->getResponse()) {
throw new \Exception($exception);
}
throw new \Exception($exception);
} catch (Exception $exception) {
throw new \Exception($exception);
}
return $response->getBody();
} | Using CURL to issue a GET request
@param $url
@param $params
@return mixed
@throws \Exception | entailment |
public function init()
{
if (!in_array($this->layout, ['horizontal', 'stacked'])) {
throw new InvalidConfigException('Invalid layout type: ' . $this->layout);
}
Html::addCssClass($this->options, 'uk-form');
if ($this->layout !== 'grid') {
Html::addCssClass($this->options, 'uk-form-' . $this->layout);
}
if ($this->grid) {
Html::addCssClass($this->options, 'uk-grid uk-child-width-1-1');
$this->options['uk-grid'] = true;
}
parent::init();
} | {@inheritdoc} | entailment |
public function getCharactersCharacterIdPlanets($characterId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdPlanetsWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdPlanets
Get colonies
@param int $characterId Character id of the target character (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $token Access token to use, if preferred over a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@return \nullx27\ESI\Models\GetCharactersCharacterIdPlanets200Ok[] | entailment |
public function setFaction($faction)
{
$allowed_values = array('Minmatar', 'Gallente', 'Caldari', 'Amarr');
if (!is_null($faction) && (!in_array($faction, $allowed_values))) {
throw new \InvalidArgumentException("Invalid value for 'faction', must be one of 'Minmatar', 'Gallente', 'Caldari', 'Amarr'");
}
$this->container['faction'] = $faction;
return $this;
} | Sets faction
@param string $faction faction string
@return $this | entailment |
public function setTaxRate($taxRate)
{
if (($taxRate > 1)) {
throw new \InvalidArgumentException('invalid value for $taxRate when calling GetCorporationsCorporationIdOk., must be smaller than or equal to 1.');
}
if (($taxRate < 0)) {
throw new \InvalidArgumentException('invalid value for $taxRate when calling GetCorporationsCorporationIdOk., must be bigger than or equal to 0.');
}
$this->container['taxRate'] = $taxRate;
return $this;
} | Sets taxRate
@param float $taxRate tax_rate number
@return $this | entailment |
public function setFinishedLevel($finishedLevel)
{
if (($finishedLevel > 5)) {
throw new \InvalidArgumentException('invalid value for $finishedLevel when calling GetCharactersCharacterIdSkillqueue200Ok., must be smaller than or equal to 5.');
}
if (($finishedLevel < 0)) {
throw new \InvalidArgumentException('invalid value for $finishedLevel when calling GetCharactersCharacterIdSkillqueue200Ok., must be bigger than or equal to 0.');
}
$this->container['finishedLevel'] = $finishedLevel;
return $this;
} | Sets finishedLevel
@param int $finishedLevel finished_level integer
@return $this | entailment |
public function setOwnerType($ownerType)
{
$allowed_values = array('eve_server', 'corporation', 'faction', 'character', 'alliance');
if ((!in_array($ownerType, $allowed_values))) {
throw new \InvalidArgumentException("Invalid value for 'ownerType', must be one of 'eve_server', 'corporation', 'faction', 'character', 'alliance'");
}
$this->container['ownerType'] = $ownerType;
return $this;
} | Sets ownerType
@param string $ownerType owner_type string
@return $this | entailment |
private function checkAuth()
{
$namespace = explode('\\', $this->getModelTableMap());
$module = strtolower($namespace[0]);
$secret = Config::getInstance()->get($module . '.api.secret');
if (NULL === $secret) {
$secret = Config::getInstance()->get("api.secret");
}
if (NULL === $secret) {
$auth = TRUE;
} else {
$token = Request::getInstance()->getHeader('X-API-SEC-TOKEN');
if (array_key_exists('API_TOKEN', $this->query)) {
$token = $this->query['API_TOKEN'];
}
$auth = SecurityHelper::checkToken($token ?: '', $secret, $module);
}
return $auth || $this->isAdmin();
} | Check service authentication
@return bool | entailment |
public function getField($name)
{
return (null !== $name && array_key_exists($name, $this->fields)) ? $this->fields[$name] : null;
} | @param string $name
@return array|null | entailment |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.