sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function dropDownList($items, $options = [])
{
Html::addCssClass($this->inputOptions,'uk-select');
return parent::dropDownList($items, $options);
} | {@inheritdoc} | entailment |
public function cacheComponents($num = 1000, $page = 1)
{
if ($this->cached != null) {
return $this->cached;
}
$this->cached = $this->client->call(
'GET',
'components',
[
'query' => [
'per_page' => $num,
'current_page' => $page,
],
]
);
return $this->cached;
} | Cache Components for performance improvement.
@param int $num
@param int $page
@return array|bool | entailment |
public function indexComponents($num = 1000, $page = 1)
{
if ($this->cache === true) {
return $this->cacheComponents($num, $page);
}
return $this->client->call(
'GET',
'components',
[
'query' => [
'per_page' => $num,
'current_page' => $page,
],
]
);
} | Get a defined number of Components.
@param int $num
@param int $page
@return array|bool | entailment |
public function searchComponents($search, $by, $limit = 1, $num = 1000, $page = 1)
{
$components = $this->indexComponents($num, $page)['data'];
$filtered = array_filter(
$components,
function ($component) use ($search, $by) {
if (array_key_exists($by, $component)) {
if (strpos($component[$by], $search) !== false) {
return $component;
}
if ($component[$by] === $search) {
return $component;
}
}
return false;
}
);
if ($limit == 1) {
return array_shift($filtered);
}
return array_slice($filtered, 0, $limit);
} | Search if a defined number of Components exists.
@param string $search
@param string $by
@param int $num
@param int $page
@param int $limit
@return mixed | entailment |
public function setHeadId($headId)
{
if ($headId > 9.0) {
throw new \InvalidArgumentException('invalid value for $headId when calling GetCharactersCharacterIdPlanetsPlanetIdOkExtractorDetailsHeads., must be smaller than or equal to 9.0.');
}
if ($headId < 0.0) {
throw new \InvalidArgumentException('invalid value for $headId when calling GetCharactersCharacterIdPlanetsPlanetIdOkExtractorDetailsHeads., must be bigger than or equal to 0.0.');
}
$this->container['headId'] = $headId;
return $this;
} | Sets headId
@param int $headId head_id integer
@return $this | entailment |
public function getServiceNameAllowableValues()
{
return [
self::SERVICE_NAME_BOUNTY_MISSIONS,
self::SERVICE_NAME_ASSASSINATION_MISSIONS,
self::SERVICE_NAME_COURIER_MISSIONS,
self::SERVICE_NAME_INTERBUS,
self::SERVICE_NAME_REPROCESSING_PLANT,
self::SERVICE_NAME_REFINERY,
self::SERVICE_NAME_MARKET,
self::SERVICE_NAME_BLACK_MARKET,
self::SERVICE_NAME_STOCK_EXCHANGE,
self::SERVICE_NAME_CLONING,
self::SERVICE_NAME_SURGERY,
self::SERVICE_NAME_DNA_THERAPY,
self::SERVICE_NAME_REPAIR_FACILITIES,
self::SERVICE_NAME_FACTORY,
self::SERVICE_NAME_LABORATORY,
self::SERVICE_NAME_GAMBLING,
self::SERVICE_NAME_FITTING,
self::SERVICE_NAME_PAINTSHOP,
self::SERVICE_NAME_NEWS,
self::SERVICE_NAME_STORAGE,
self::SERVICE_NAME_INSURANCE,
self::SERVICE_NAME_DOCKING,
self::SERVICE_NAME_OFFICE_RENTAL,
self::SERVICE_NAME_JUMP_CLONE_FACILITY,
self::SERVICE_NAME_LOYALTY_POINT_STORE,
self::SERVICE_NAME_NAVY_OFFICES,
self::SERVICE_NAME_SECURITY_OFFICE,
];
} | Gets allowable values of the enum
@return string[] | entailment |
public function setServiceName($serviceName)
{
$allowedValues = $this->getServiceNameAllowableValues();
if (!in_array($serviceName, $allowedValues)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value for 'serviceName', must be one of '%s'",
implode("', '", $allowedValues)
)
);
}
$this->container['serviceName'] = $serviceName;
return $this;
} | Sets serviceName
@param string $serviceName service_name string
@return $this | entailment |
public static function validate($checkType, $value)
{
if (array_key_exists($checkType, self::$checks)) {
if (empty(self::$checks[$checkType])) {
$blnReturn = true;
} else {
if (is_array($value)) {
$arrValues = $value;
$blnSub = true;
foreach ($arrValues as $value) {
$blnSub = preg_match(self::$checks[$checkType], $value);
if (! $blnSub) {
// *** At least 1 value is not valid, skip the rest and return false;
exit();
}
}
$blnReturn = $blnSub;
} else {
$blnReturn = preg_match(self::$checks[$checkType], $value);
}
}
} else {
if (empty($checkType)) {
$blnReturn = true; // No custom validation set.
} else {
$blnReturn = @preg_match($checkType, $value); // Use custom validation
}
}
return $blnReturn;
} | Validate input against regular expression
@param integer $checkType The type to check for
@param string $value The value to validate
@return boolean True if valid, false if not. | entailment |
public static function getCheck($checkType)
{
$strReturn = "";
if (array_key_exists($checkType, self::$checks)) {
$strReturn = self::$checks[$checkType];
}
return $strReturn;
} | Get the regular expression that is used by the given field type
@param integer $checkType Field type
@return string The matching regular expression | entailment |
public function getIndustrySystems($datasource = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getIndustrySystemsWithHttpInfo($datasource, $userAgent, $xUserAgent);
return $response;
} | Operation getIndustrySystems
List solar system cost indices
@param string $datasource The server name you would like data from (optional, default to tranquility)
@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\GetIndustrySystems200Ok[] | entailment |
public function loadPluginConfiguration(): void
{
$builder = $this->getContainerBuilder();
$global = $this->compiler->getExtension()->getConfig();
$config = $this->getConfig();
$builder->addDefinition($this->prefix('entityAdapter'))
->setFactory(EntityAdapter::class);
$entityDefinition = $builder->addDefinition($this->prefix('entityDefinition'))
->setFactory(EntityDefinition::class);
$coreDefinition = $builder->addDefinition($this->prefix('coreDefinition'))
->setFactory(CoreDefinition::class);
$schemaBuilder = $builder->addDefinition($this->prefix('schemaBuilder'))
->setFactory(SchemaBuilder::class);
if ($config['definitions'] === null) {
$schemaBuilder
->addSetup('addDefinition', [new BaseDefinition()])
->addSetup('addDefinition', [$entityDefinition])
->addSetup('addDefinition', [$coreDefinition]);
foreach ($config['files'] as $file) {
if (Strings::endsWith($file, '.neon')) {
$schemaBuilder->addSetup('addDefinition', [new NeonDefinition($file)]);
} elseif (Strings::endsWith($file, '.yaml') || Strings::endsWith($file, '.yml')) {
$schemaBuilder->addSetup('addDefinition', [new YamlDefinition($file)]);
} elseif (Strings::endsWith($file, '.json')) {
$schemaBuilder->addSetup('addDefinition', [new JsonDefinition($file)]);
} else {
throw new InvalidArgumentException(sprintf(
'We cant parse file "%s" - unsupported file type',
$file
));
}
}
$schemaBuilder->addSetup('addDefinition', [new ArrayDefinition($config['definition'])]);
} else {
foreach ($config['definitions'] as $customDefinition) {
$schemaBuilder->addSetup('addDefinition', [$customDefinition]);
}
}
if ($global['debug'] !== true) {
return;
}
if ($config['swaggerUi']['panel']) {
$builder->addDefinition($this->prefix('swaggerUi.panel'))
->setFactory(SwaggerUIPanel::class)
->addSetup('setUrl', [$config['swaggerUi']['url']])
->addSetup('setExpansion', [$config['swaggerUi']['expansion']])
->addSetup('setFilter', [$config['swaggerUi']['filter']])
->addSetup('setTitle', [$config['swaggerUi']['title']])
->setAutowired(false);
}
} | Register services | entailment |
public function getCharactersCharacterIdLoyaltyPointsAsync($characterId, $datasource = 'tranquility', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCharactersCharacterIdLoyaltyPointsAsyncWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCharactersCharacterIdLoyaltyPointsAsync
Get loyalty points
@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 getLoyaltyStoresCorporationIdOffers($corporationId, $datasource = 'tranquility', $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getLoyaltyStoresCorporationIdOffersWithHttpInfo($corporationId, $datasource, $userAgent, $xUserAgent);
return $response;
} | Operation getLoyaltyStoresCorporationIdOffers
List loyalty store offers
@param int $corporationId An EVE corporation ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@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\GetLoyaltyStoresCorporationIdOffers200Ok[] | entailment |
public function getLoyaltyStoresCorporationIdOffersAsync($corporationId, $datasource = 'tranquility', $userAgent = null, $xUserAgent = null)
{
return $this->getLoyaltyStoresCorporationIdOffersAsyncWithHttpInfo($corporationId, $datasource, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getLoyaltyStoresCorporationIdOffersAsync
List loyalty store offers
@param int $corporationId An EVE corporation ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@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 setStatus($status = null)
{
switch ($status) {
//TODO implement all status codes
case '500':
$this->setStatusCode('HTTP/1.0 500 Internal Server Error');
break;
case '404':
$this->setStatusCode('HTTP/1.0 404 Not Found');
break;
case '403':
$this->setStatusCode('HTTP/1.0 403 Forbidden');
break;
case '402':
$this->setStatusCode('HTTP/1.0 402 Payment Required');
break;
case '401':
$this->setStatusCode('HTTP/1.0 401 Unauthorized');
break;
case '400':
$this->setStatusCode('HTTP/1.0 400 Bad Request');
break;
case '200':
$this->setStatusCode(Template::STATUS_OK);
break;
default:
$this->setStatusCode('HTTP/1.0 ' .($status ?: 200));
break;
}
return $this;
} | Método que establece un header de http status code
@param string $status
@return $this | entailment |
private function setReponseHeaders($contentType = 'text/html', array $cookies = array())
{
$powered = Config::getParam('poweredBy', 'PSFS');
header('X-Powered-By: ' . $powered);
ResponseHelper::setStatusHeader($this->getStatusCode());
ResponseHelper::setAuthHeaders($this->isPublicZone());
ResponseHelper::setCookieHeaders($cookies);
header('Content-type: ' . $contentType);
} | Servicio que establece las cabeceras de la respuesta
@param string $contentType
@param array $cookies | entailment |
public function output($output = '', $contentType = 'text/html', array $cookies = array())
{
if(!self::isTest()) {
Logger::log('Start output response');
ob_start();
$this->setReponseHeaders($contentType, $cookies);
header('Content-length: ' . strlen($output));
header('CRC: ' . crc32($output));
$needCache = Cache::needCache();
$cache = Cache::getInstance();
list($path, $cacheDataName) = $cache->getRequestCacheHash();
if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) {
Logger::log('Saving output response into cache');
$cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output);
$cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON);
} elseif (Request::getInstance()->getMethod() !== 'GET') {
$cache->flushCache();
}
echo $output;
ob_flush();
ob_end_clean();
Logger::log('End output response');
$this->closeRender();
} else {
return $output;
}
} | Servicio que devuelve el output
@param string $output
@param string $contentType
@param array $cookies
@return string HTML | entailment |
public function closeRender()
{
Logger::log('Close template render');
$uri = Request::requestUri();
Security::getInstance()->setSessionKey('lastRequest', array(
'url' => Request::getInstance()->getRootUrl() . $uri,
'ts' => microtime(true),
));
Security::getInstance()->updateSession();
Logger::log('End request: ' . $uri, LOG_INFO);
exit;
} | Método que cierra y limpia los buffers de salida | entailment |
public function renderCache($data, $headers = array())
{
ob_start();
for ($i = 0, $ct = count($headers); $i < $ct; $i++) {
header($headers[$i]);
}
header('X-PSFS-CACHED: true');
echo $data;
ob_flush();
ob_end_clean();
$this->closeRender();
} | Método que devuelve los datos cacheados con las cabeceras que tenía por entonces
@param string $data
@param array $headers | entailment |
public function download($data, $content = 'text/html', $filename = 'data.txt')
{
ob_start();
header('Pragma: public');
/////////////////////////////////////////////////////////////
// prevent caching....
/////////////////////////////////////////////////////////////
// Date in the past sets the value to already have been expired.
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache');
header('Expires: 0');
header('Content-Transfer-Encoding: binary');
header('Content-type: ' . $content);
header('Content-length: ' . strlen($data));
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Access-Control-Expose-Headers: Filename');
header('Filename: ' . $filename);
echo $data;
ob_flush();
ob_end_clean();
exit;
} | Método que fuerza la descarga de un fichero
@param $data
@param string $content
@param string $filename
@return mixed | entailment |
public function addColumns(Column $column, $amount)
{
for ($i = 0; $i < $amount; $i++) {
$this->addColumn($column);
}
return $this;
} | @param Column $column
@param $amount
@return $this | entailment |
public function getPanel(): string
{
ob_start();
$spec = $this->schemaBuilder->build()->toArray();
$url = $this->url;
$expansion = $this->expansion;
$filter = $this->filter;
require __DIR__ . '/templates/panel.phtml';
return (string) ob_get_clean();
} | Renders HTML code for custom panel. | entailment |
public function deleteCharactersCharacterIdContacts($characterId, $contactIds, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->deleteCharactersCharacterIdContactsWithHttpInfo($characterId, $contactIds, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation deleteCharactersCharacterIdContacts
Delete contacts
@param int $characterId ID for a character (required)
@param int[] $contactIds A list of contacts to edit (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 void | entailment |
public function getCharactersCharacterIdContacts($characterId, $datasource = null, $page = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdContactsWithHttpInfo($characterId, $datasource, $page, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdContacts
Get contacts
@param int $characterId ID for a character (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page page integer (optional, default to 1)
@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\GetCharactersCharacterIdContacts200Ok[] | entailment |
public function putCharactersCharacterIdContacts($characterId, $contactIds, $standing, $datasource = null, $labelId = null, $token = null, $userAgent = null, $watched = null, $xUserAgent = null)
{
list($response) = $this->putCharactersCharacterIdContactsWithHttpInfo($characterId, $contactIds, $standing, $datasource, $labelId, $token, $userAgent, $watched, $xUserAgent);
return $response;
} | Operation putCharactersCharacterIdContacts
Edit contacts
@param int $characterId ID for a character (required)
@param int[] $contactIds A list of contacts to edit (required)
@param float $standing Standing for the contact (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $labelId Add a custom label to the contact, use 0 for clearing label (optional, default to 0)
@param string $token Access token to use, if preferred over a header (optional)
@param string $userAgent Client identifier, takes precedence over headers (optional)
@param bool $watched Whether the contact should be watched, note this is only effective on characters (optional, default to false)
@param string $xUserAgent Client identifier, takes precedence over User-Agent (optional)
@throws \nullx27\ESI\ApiException on non-2xx response
@return void | entailment |
protected function configure(): void
{
// First command : Test the DB Connexion
$this->setName($this->command)
->setDescription(
'Generate configuration for the Anonymizer'
)->setHelp(
'This command will connect to a DB and extract a list of tables / fields to a yaml file'.PHP_EOL.
"Usage: neuralyzer <info>{$this->command} -u app -p app -f neuralyzer.yml</info>"
)->addOption(
'driver',
'D',
InputOption::VALUE_REQUIRED,
'Driver (check Doctrine documentation to have the list)',
'pdo_mysql'
)->addOption(
'host',
'H',
InputOption::VALUE_REQUIRED,
'Host',
'127.0.0.1'
)->addOption(
'db',
'd',
InputOption::VALUE_REQUIRED,
'Database Name'
)->addOption(
'user',
'u',
InputOption::VALUE_REQUIRED,
'User Name',
get_current_user()
)->addOption(
'password',
'p',
InputOption::VALUE_REQUIRED,
"Password (or it'll be prompted)"
)->addOption(
'file',
'f',
InputOption::VALUE_REQUIRED,
'File',
'neuralyzer.yml'
)->addOption(
'protect',
null,
InputOption::VALUE_NONE,
'Protect IDs and other fields'
)->addOption(
'ignore-table',
null,
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'Table to ignore. Can be repeated'
)->addOption(
'ignore-field',
null,
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'Field to ignore. Regexp in the form "table.field". Can be repeated'
);
} | Configure the command
@return void | entailment |
protected function execute(InputInterface $input, OutputInterface $output): void
{
// Throw an exception immediately if we don't have the required DB parameter
if (empty($input->getOption('db'))) {
throw new \InvalidArgumentException('Database name is required (--db)');
}
$password = $input->getOption('password');
if (null === $password) {
$question = new Question('Password: ');
$question->setHidden(true)->setHiddenFallback(false);
$password = $this->getHelper('question')->ask($input, $output, $question);
}
$ignoreFields = $input->getOption('ignore-field');
$this->dbUtils->configure([
'driver' => $input->getOption('driver'),
'host' => $input->getOption('host'),
'dbname' => $input->getOption('db'),
'user' => $input->getOption('user'),
'password' => $password,
]);
$writer = new \Edyan\Neuralyzer\Configuration\Writer;
$writer->protectCols($input->getOption('protect'));
// Override the protection if fields are defined
if (!empty($ignoreFields)) {
$writer->protectCols(true);
$writer->setProtectedCols($ignoreFields);
}
$writer->setIgnoredTables($input->getOption('ignore-table'));
$data = $writer->generateConfFromDB($this->dbUtils, new \Edyan\Neuralyzer\Guesser);
$writer->save($data, $input->getOption('file'));
$output->writeln('<comment>Configuration written to '.$input->getOption('file').'</comment>');
} | @param InputInterface $input
@param OutputInterface $output
@return void
@throws \Doctrine\DBAL\DBALException
@throws \Edyan\Neuralyzer\Exception\NeuralyzerConfigurationException | entailment |
public function getDogmaAttributes($datasource = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getDogmaAttributesWithHttpInfo($datasource, $userAgent, $xUserAgent);
return $response;
} | Operation getDogmaAttributes
Get attributes
@param string $datasource The server name you would like data from (optional, default to tranquility)
@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 int[] | entailment |
public function getDogmaEffectsEffectId($effectId, $datasource = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getDogmaEffectsEffectIdWithHttpInfo($effectId, $datasource, $userAgent, $xUserAgent);
return $response;
} | Operation getDogmaEffectsEffectId
Get effect information
@param int $effectId A dogma effect ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@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\GetDogmaEffectsEffectIdOk | entailment |
public static function translateSwaggerFormats($format)
{
switch (strtolower(preg_replace('/\\\\/im', '', $format))) {
case 'bool':
case 'boolean':
$swaggerType = 'boolean';
$swaggerFormat = '';
break;
default:
case 'string':
case 'varchar':
$swaggerType = 'string';
$swaggerFormat = '';
break;
case 'binary':
case 'varbinary':
$swaggerType = 'string';
$swaggerFormat = 'password';
break;
case 'int':
case 'integer':
$swaggerType = 'integer';
$swaggerFormat = 'int32';
break;
case 'float':
case 'double':
$swaggerType = 'number';
$swaggerFormat = strtolower($format);
break;
case 'date':
$swaggerType = 'string';
$swaggerFormat = 'date';
break;
case 'timestamp':
case 'datetime':
$swaggerType = 'string';
$swaggerFormat = 'date-time';
break;
}
return [$swaggerType, $swaggerFormat];
} | Translator from php types to swagger types
@param string $format
@return array | entailment |
public static function extractSwaggerDefinition($name, array $fields)
{
$definition = [
$name => [
"type" => "object",
"properties" => [],
],
];
foreach ($fields as $field => $info) {
if(array_key_exists('type', $info) && in_array($info['type'], ['array', 'object'])) {
$definition[$name]['properties'][$field] = $info;
} elseif(array_key_exists('type', $info)) {
list($type, $format) = self::translateSwaggerFormats($info['type']);
$fieldData = [
"type" => $type,
"required" => $info['required'],
];
if(array_key_exists('description', $info)) {
$fieldData['description'] = $info['description'];
}
if(array_key_exists('format', $info)) {
$fieldData['format'] = $info['format'];
}
$dto['properties'][$field] = $fieldData;
$definition[$name]['properties'][$field] = $fieldData;
if (strlen($format)) {
$definition[$name]['properties'][$field]['format'] = $format;
}
}
}
return $definition;
} | Method that parse the definitions for the api's
@param string $name
@param array $fields
@return array | entailment |
public function listInvalidProperties()
{
$invalidProperties = [];
if ($this->container['typeId'] === null) {
$invalidProperties[] = "'typeId' can't be null";
}
if ($this->container['quantity'] === null) {
$invalidProperties[] = "'quantity' can't be null";
}
if ($this->container['locationId'] === null) {
$invalidProperties[] = "'locationId' can't be null";
}
if ($this->container['locationType'] === null) {
$invalidProperties[] = "'locationType' can't be null";
}
$allowedValues = $this->getLocationTypeAllowableValues();
if (!in_array($this->container['locationType'], $allowedValues)) {
$invalidProperties[] = sprintf(
"invalid value for 'locationType', must be one of '%s'",
implode("', '", $allowedValues)
);
}
if ($this->container['itemId'] === null) {
$invalidProperties[] = "'itemId' can't be null";
}
if ($this->container['locationFlag'] === null) {
$invalidProperties[] = "'locationFlag' can't be null";
}
$allowedValues = $this->getLocationFlagAllowableValues();
if (!in_array($this->container['locationFlag'], $allowedValues)) {
$invalidProperties[] = sprintf(
"invalid value for 'locationFlag', must be one of '%s'",
implode("', '", $allowedValues)
);
}
if ($this->container['isSingleton'] === null) {
$invalidProperties[] = "'isSingleton' can't be null";
}
return $invalidProperties;
} | Show all the invalid properties with reasons.
@return array invalid properties with reasons | entailment |
public function valid()
{
if ($this->container['typeId'] === null) {
return false;
}
if ($this->container['quantity'] === null) {
return false;
}
if ($this->container['locationId'] === null) {
return false;
}
if ($this->container['locationType'] === null) {
return false;
}
$allowedValues = $this->getLocationTypeAllowableValues();
if (!in_array($this->container['locationType'], $allowedValues)) {
return false;
}
if ($this->container['itemId'] === null) {
return false;
}
if ($this->container['locationFlag'] === null) {
return false;
}
$allowedValues = $this->getLocationFlagAllowableValues();
if (!in_array($this->container['locationFlag'], $allowedValues)) {
return false;
}
if ($this->container['isSingleton'] === null) {
return false;
}
return true;
} | Validate all the properties in the model
return true if all passed
@return bool True if all properties are valid | entailment |
public function getFleetsFleetId($fleetId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getFleetsFleetIdWithHttpInfo($fleetId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getFleetsFleetId
Get fleet information
@param int $fleetId ID for a fleet (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\GetFleetsFleetIdOk | entailment |
public function getFleetsFleetIdWings($fleetId, $datasource = null, $language = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getFleetsFleetIdWingsWithHttpInfo($fleetId, $datasource, $language, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getFleetsFleetIdWings
Get fleet wings
@param int $fleetId ID for a fleet (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param string $language Language to use in the response (optional, default to en-us)
@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\GetFleetsFleetIdWings200Ok[] | entailment |
public function postFleetsFleetIdWingsWingIdSquads($fleetId, $wingId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->postFleetsFleetIdWingsWingIdSquadsWithHttpInfo($fleetId, $wingId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation postFleetsFleetIdWingsWingIdSquads
Create fleet squad
@param int $fleetId ID for a fleet (required)
@param int $wingId The wing_id to create squad in (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\PostFleetsFleetIdWingsWingIdSquadsCreated | entailment |
public function putFleetsFleetIdMembersMemberId($fleetId, $memberId, $movement, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->putFleetsFleetIdMembersMemberIdWithHttpInfo($fleetId, $memberId, $movement, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation putFleetsFleetIdMembersMemberId
Move fleet member
@param int $fleetId ID for a fleet (required)
@param int $memberId The character ID of a member in this fleet (required)
@param \nullx27\ESI\Models\PutFleetsFleetIdMembersMemberIdMovement $movement Details of the invitation (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 void | entailment |
public function putFleetsFleetIdSquadsSquadId($fleetId, $naming, $squadId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->putFleetsFleetIdSquadsSquadIdWithHttpInfo($fleetId, $naming, $squadId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation putFleetsFleetIdSquadsSquadId
Rename fleet squad
@param int $fleetId ID for a fleet (required)
@param \nullx27\ESI\Models\PutFleetsFleetIdSquadsSquadIdNaming $naming New name of the squad (required)
@param int $squadId The squad to rename (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 void | entailment |
public function find()
{
$keys = [];
$functions = ['trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans',
'Lang::transChoice', '@lang', '@choice', '__', ];
$pattern = // See http://regexr.com/392hu
"[^\w|>]". // Must not have an alphanum or _ or > before real method
'('.implode('|', $functions).')'. // Must start with one of the functions
"\(". // Match opening parenthese
"[\'\"]". // Match " or '
'('. // Start a new group to match:
'[a-zA-Z0-9_-]+'. // Must start with group
"([.][^\1)]+)+". // Be followed by one or more items/keys
')'. // Close group
"[\'\"]". // Closing quote
"[\),]"; // Close parentheses or new parameter
$finder = new Finder();
$finder->in(base_path())->exclude('storage')->name('*.php')->files();
$bar = $this->output->createProgressBar($finder->count());
$this->line('');
$this->info('Laravel Multi-Language - Preparing to search in '.$finder->count().' files');
$this->line('');
foreach ($finder as $file) {
if (preg_match_all("/$pattern/siU", $file->getContents(), $matches)) {
foreach ($matches[2] as $key) {
$keys[] = $key;
}
}
$bar->advance();
}
$bar->finish();
$keys = array_unique($keys);
$this->languageKeys = $keys;
$this->line('');
$this->line('');
$this->info('Found '.count($keys).' sentences');
} | /*
This method is based in Laravel Translation Manager
Created by Barry vd. Heuvel
GitHub: https://github.com/barryvdh/laravel-translation-manager | entailment |
public function getCharactersCharacterIdSkillqueue($characterId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdSkillqueueWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdSkillqueue
Get character's skill queue
@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\GetCharactersCharacterIdSkillqueue200Ok[] | entailment |
public function getCharactersCharacterIdSkillqueueWithHttpInfo($characterId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
// verify the required parameter 'characterId' is set
if ($characterId === null) {
throw new \InvalidArgumentException('Missing the required parameter $characterId when calling getCharactersCharacterIdSkillqueue');
}
// parse inputs
$resourcePath = "/characters/{character_id}/skillqueue/";
$httpBody = '';
$queryParams = [];
$headerParams = [];
$formParams = [];
$_header_accept = $this->apiClient->selectHeaderAccept(['application/json']);
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType([]);
// query params
if ($datasource !== null) {
$queryParams['datasource'] = $this->apiClient->getSerializer()->toQueryValue($datasource);
}
// query params
if ($token !== null) {
$queryParams['token'] = $this->apiClient->getSerializer()->toQueryValue($token);
}
// query params
if ($userAgent !== null) {
$queryParams['user_agent'] = $this->apiClient->getSerializer()->toQueryValue($userAgent);
}
// header params
if ($xUserAgent !== null) {
$headerParams['X-User-Agent'] = $this->apiClient->getSerializer()->toHeaderValue($xUserAgent);
}
// path params
if ($characterId !== null) {
$resourcePath = str_replace(
"{" . "character_id" . "}",
$this->apiClient->getSerializer()->toPathValue($characterId),
$resourcePath
);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath,
'GET',
$queryParams,
$httpBody,
$headerParams,
'\nullx27\ESI\Models\GetCharactersCharacterIdSkillqueue200Ok[]',
'/characters/{character_id}/skillqueue/'
);
return [$this->apiClient->getSerializer()->deserialize($response, '\nullx27\ESI\Models\GetCharactersCharacterIdSkillqueue200Ok[]', $httpHeader), $statusCode, $httpHeader];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\nullx27\ESI\Models\GetCharactersCharacterIdSkillqueue200Ok[]', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
case 403:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\nullx27\ESI\Models\GetCharactersCharacterIdSkillqueueForbidden', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
case 500:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\nullx27\ESI\Models\GetCharactersCharacterIdSkillqueueInternalServerError', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
} | Operation getCharactersCharacterIdSkillqueueWithHttpInfo
Get character's skill queue
@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 array of \nullx27\ESI\Models\GetCharactersCharacterIdSkillqueue200Ok[], HTTP status code, HTTP response headers (array of strings) | entailment |
public function cacheIncidents($num = 1000, $page = 1)
{
if ($this->cached != null) {
return $this->cached;
}
$this->cached = $this->client->call(
'GET',
'incidents',
[
'query' => [
'per_page' => $num,
'current_page' => $page,
],
]
);
return $this->cached;
} | Cache Incidents for performance improvement.
@param int $num
@param int $page
@return array|bool | entailment |
public function indexIncidents($num = 1000, $page = 1)
{
if ($this->cache != false) {
return $this->cacheIncidents($num, $page);
}
return $this->client->call(
'GET',
'incidents',
[
'query' => [
'per_page' => $num,
'current_page' => $page,
],
]
);
} | Get a defined number of Incidents.
@param int $num
@param int $page
@return array|bool | entailment |
public function searchIncidents($search, $by, $limit = 1, $num = 1000, $page = 1)
{
$incidents = $this->indexIncidents($num, $page)['data'];
$filtered = array_filter(
$incidents,
function ($incident) use ($search, $by) {
if (array_key_exists($by, $incident)) {
if (strpos($incident[$by], $search) !== false) {
return $incident;
}
if ($incident[$by] === $search) {
return $incident;
}
}
return false;
}
);
if ($limit == 1) {
return array_shift($filtered);
}
return array_slice($filtered, 0, $limit);
} | Search if a defined number of Incidents exists.
@param string $search
@param string $by
@param int $num
@param int $page
@param int $limit
@return mixed | entailment |
public function getStatusAllowableValues()
{
return [
self::STATUS_ACTIVE,
self::STATUS_PAUSED,
self::STATUS_READY,
self::STATUS_DELIVERED,
self::STATUS_CANCELLED,
self::STATUS_REVERTED,
];
} | Gets allowable values of the enum
@return string[] | entailment |
public function setStatus($status)
{
$allowed_values = array('active', 'paused', 'ready', 'delivered', 'cancelled', 'reverted');
if ((!in_array($status, $allowed_values))) {
throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'active', 'paused', 'ready', 'delivered', 'cancelled', 'reverted'");
}
$this->container['status'] = $status;
return $this;
} | Sets status
@param string $status status string
@return $this | entailment |
public function createTask($handlerClass, $workload = null)
{
return $this->factory->createTaskBuilder($this->taskRepository->create($handlerClass, $workload), $this);
} | {@inheritdoc} | entailment |
public function addTask(TaskInterface $task)
{
$this->eventDispatcher->dispatch(Events::TASK_CREATE, new TaskEvent($task));
$this->taskRepository->save($task);
$this->scheduleTask($task);
return $this;
} | {@inheritdoc} | entailment |
public function scheduleTasks()
{
$tasks = $this->taskRepository->findEndBeforeNow();
foreach ($tasks as $task) {
$this->scheduleTask($task);
}
} | {@inheritdoc} | entailment |
protected function scheduleTask(TaskInterface $task)
{
if (null !== ($execution = $this->taskExecutionRepository->findPending($task))) {
return;
}
if ($task->getInterval() === null && 0 < count($this->taskExecutionRepository->findByTask($task))) {
return;
}
$scheduleTime = $task->getInterval() ? $task->getInterval()->getNextRunDate() : $task->getFirstExecution();
$execution = $this->taskExecutionRepository->create($task, $scheduleTime);
$execution->setStatus(TaskStatus::PLANNED);
$this->eventDispatcher->dispatch(
Events::TASK_EXECUTION_CREATE,
new TaskExecutionEvent($task, $execution)
);
$this->taskExecutionRepository->save($execution);
} | Schedule execution for given task.
@param TaskInterface $task | entailment |
public function start(Request $request, AuthenticationException $authException = null)
{
return new JsonResponse(['message' => $authException->getMessage()], Response::HTTP_UNAUTHORIZED);
} | Starts the authentication scheme.
@param Request $request The request that resulted in an AuthenticationException
@param AuthenticationException $authException The exception that started the authentication process
@return Response | entailment |
public function getModules($requestModule)
{
$modules = [];
$domains = $this->route->getDomains();
if (count($domains)) {
foreach ($domains as $module => $info) {
try {
$module = preg_replace('/(@|\/)/', '', $module);
if ($module === $requestModule && !preg_match('/^ROOT/i', $module)) {
$modules = [
'name' => $module,
'path' => dirname($info['base'] . DIRECTORY_SEPARATOR . '..'),
];
}
} catch (\Exception $e) {
$modules[] = $e->getMessage();
}
}
}
return $modules;
} | Method that extract all modules
@param string $requestModule
@return array | entailment |
public function extractApiEndpoints(array $module)
{
$modulePath = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
$moduleName = $module['name'];
$endpoints = [];
if (file_exists($modulePath)) {
$finder = new Finder();
$finder->files()->in($modulePath)->depth(0)->name('*.php');
if (count($finder)) {
/** @var \SplFileInfo $file */
foreach ($finder as $file) {
$namespace = "\\{$moduleName}\\Api\\" . str_replace('.php', '', $file->getFilename());
$info = $this->extractApiInfo($namespace, $moduleName);
if (!empty($info)) {
$endpoints[$namespace] = $info;
}
}
}
}
return $endpoints;
} | Method that extract all endpoints for each module
@param array $module
@return array | entailment |
protected function extractVisibility($comments = '')
{
$visible = TRUE;
preg_match('/@visible\ (true|false)\n/i', $comments, $visibility);
if (count($visibility)) {
$visible = !('false' === $visibility[1]);
}
return $visible;
} | Extract visibility from doc comments
@param string $comments
@return boolean | entailment |
protected function extractDescription($comments = '')
{
$description = '';
$docs = explode("\n", $comments);
if (count($docs)) {
foreach ($docs as &$doc) {
if (!preg_match('/(\*\*|\@)/', $doc) && preg_match('/\*\ /', $doc)) {
$doc = explode('* ', $doc);
$description = $doc[1];
}
}
}
return $description;
} | Method that extract the description for the endpoint
@param string $comments
@return string | entailment |
public static function extractVarType($comments = '')
{
$type = 'string';
preg_match('/@var\ (.*) (.*)\n/i', $comments, $varType);
if (count($varType)) {
$aux = trim($varType[1]);
$type = str_replace(' ', '', strlen($aux) > 0 ? $varType[1] : $varType[2]);
}
return $type;
} | Method that extract the type of a variable
@param string $comments
@return string | entailment |
protected function extractPayload($model, $comments = '')
{
$payload = [];
preg_match('/@payload\ (.*)\n/i', $comments, $doc);
$isArray = false;
if (count($doc)) {
$namespace = str_replace('{__API__}', $model, $doc[1]);
if (false !== strpos($namespace, '[') && false !== strpos($namespace, ']')) {
$namespace = str_replace(']', '', str_replace('[', '', $namespace));
$isArray = true;
}
$payload = $this->extractModelFields($namespace);
$reflector = new \ReflectionClass($namespace);
$shortName = $reflector->getShortName();
} else {
$namespace = $model;
$shortName = $model;
}
return [$namespace, $shortName, $payload, $isArray];
} | Method that extract the payload for the endpoint
@param string $model
@param string $comments
@return array | entailment |
protected function extractDtoProperties($class)
{
$properties = [];
$reflector = new \ReflectionClass($class);
if ($reflector->isSubclassOf(self::DTO_INTERFACE)) {
$properties = array_merge($properties, InjectorHelper::extractVariables($reflector));
}
return $properties;
} | Extract all the properties from Dto class
@param string $class
@return array | entailment |
protected function extractReturn($model, $comments = '')
{
$modelDto = [];
preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes);
if (count($returnTypes)) {
// Extract principal DTO information
if (array_key_exists(1, $returnTypes)) {
$modelDto = $this->extractDtoProperties($returnTypes[1]);
}
if (array_key_exists(2, $returnTypes)) {
$subDtos = preg_split('/,?\ /', str_replace('{__API__}', $model, $returnTypes[2]));
if (count($subDtos)) {
foreach ($subDtos as $subDto) {
list($field, $dtoName) = explode('=', $subDto);
$isArray = false;
if (false !== strpos($dtoName, '[') && false !== strpos($dtoName, ']')) {
$dtoName = str_replace(']', '', str_replace('[', '', $dtoName));
$isArray = true;
}
$dto = $this->extractModelFields($dtoName);
$modelDto[$field] = $isArray ? [$dto] : $dto;
$modelDto['objects'][$dtoName] = $dto;
$modelDto = $this->checkDtoAttributes($dto, $modelDto, $dtoName);
}
}
}
}
return $modelDto;
} | Extract return class for api endpoint
@param string $model
@param string $comments
@return array | entailment |
protected function extractModelFields($namespace)
{
$payload = [];
try {
$reflector = new \ReflectionClass($namespace);
// Checks if reflector is a subclass of propel ActiveRecords
if (NULL !== $reflector && $reflector->isSubclassOf(self::MODEL_INTERFACE)) {
$tableMap = $namespace::TABLE_MAP;
$tableMap = $tableMap::getTableMap();
/** @var ColumnMap $field */
foreach ($tableMap->getColumns() as $field) {
list($type, $format) = DocumentorHelper::translateSwaggerFormats($field->getType());
$info = [
"required" => $field->isNotNull(),
'format' => $format,
];
if(count($field->getValueSet())) {
$info['enum'] = array_values($field->getValueSet());
}
if(null !== $field->getDefaultValue()) {
$info['default'] = $field->getDefaultValue();
}
$payload[ApiHelper::getColumnMapName($field)] = $info;
}
} elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
$payload = $this->extractDtoProperties($namespace);
}
} catch (\Exception $e) {
Logger::log($e->getMessage(), LOG_ERR);
}
return $payload;
} | Extract all fields from a ActiveResource model
@param string $namespace
@return mixed | entailment |
protected function extractMethodInfo($namespace, \ReflectionMethod $method, \ReflectionClass $reflection, $module)
{
$methodInfo = NULL;
$docComments = $method->getDocComment();
if (FALSE !== $docComments && preg_match('/\@route\ /i', $docComments)) {
$api = $this->extractApi($reflection->getDocComment());
list($route, $info) = RouterHelper::extractRouteInfo($method, $api, $module);
$route = explode('#|#', $route);
$modelNamespace = str_replace('Api', 'Models', $namespace);
if ($info['visible'] && !$this->checkDeprecated($docComments)) {
try {
$return = $this->extractReturn($modelNamespace, $docComments);
$url = array_pop($route);
$methodInfo = [
'url' => str_replace('/' . $module . '/api', '', $url),
'method' => $info['http'],
'description' => $info['label'],
'return' => $return,
'objects' => array_key_exists('objects', $return) ? $return['objects'] : [],
'class' => $reflection->getShortName(),
];
unset($methodInfo['return']['objects']);
$this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments);
$this->setQueryParams($method, $methodInfo);
$this->setRequestHeaders($reflection, $methodInfo);
} catch (\Exception $e) {
Logger::log($e->getMessage(), LOG_ERR);
}
}
}
return $methodInfo;
} | Method that extract all the needed info for each method in each API
@param string $namespace
@param \ReflectionMethod $method
@param \ReflectionClass $reflection
@param string $module
@return array | entailment |
public static function swaggerFormatter(array $module)
{
$formatted = [
"swagger" => "2.0",
"host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)),
"basePath" => '/' . $module['name'] . '/api',
"schemes" => [Request::getInstance()->getServer('HTTPS') === 'on' ? 'https' : 'http'],
"info" => [
"title" => t('Documentación API módulo ') . $module['name'],
"version" => Config::getParam('api.version', '1.0.0'),
"contact" => [
"name" => Config::getParam("author", "Fran López"),
"email" => Config::getParam("author.email", "[email protected]"),
]
]
];
$dtos = $paths = [];
$endpoints = DocumentorService::getInstance()->extractApiEndpoints($module);
foreach ($endpoints as $model) {
foreach ($model as $endpoint) {
if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) {
$url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']);
$description = $endpoint['description'];
$method = strtolower($endpoint['method']);
$paths[$url][$method] = [
'summary' => $description,
'produces' => ['application/json'],
'consumes' => ['application/json'],
'responses' => self::swaggerResponses(),
'parameters' => [],
];
if (array_key_exists('parameters', $endpoint)) {
foreach ($endpoint['parameters'] as $parameter => $type) {
list($type, $format) = DocumentorHelper::translateSwaggerFormats($type);
$paths[$url][$method]['parameters'][] = [
'in' => 'path',
'required' => true,
'name' => $parameter,
'type' => $type,
'format' => $format,
];
}
}
if (array_key_exists('query', $endpoint)) {
foreach ($endpoint['query'] as $query) {
$paths[$url][$method]['parameters'][] = $query;
}
}
if (array_key_exists('headers', $endpoint)) {
foreach ($endpoint['headers'] as $query) {
$paths[$url][$method]['parameters'][] = $query;
}
}
$isReturn = true;
foreach ($endpoint['objects'] as $name => $object) {
DocumentorHelper::parseObjects($paths, $dtos, $name, $endpoint, $object, $url, $method, $isReturn);
$isReturn = false;
}
}
}
}
ksort($dtos);
uasort($paths, function($path1, $path2) {
$key1 = array_keys($path1)[0];
$key2 = array_keys($path2)[0];
return strcmp($path1[$key1]['tags'][0], $path2[$key2]['tags'][0]);
});
$formatted['definitions'] = $dtos;
$formatted['paths'] = $paths;
return $formatted;
} | Method that export
@param array $module
@return array | entailment |
protected function extractDtoName($dto, $isArray = false)
{
$dto = explode('\\', $dto);
$modelDto = array_pop($dto) . "Dto";
if ($isArray) {
$modelDto .= "List";
}
return $modelDto;
} | Method that extract the Dto class for the api documentation
@param string $dto
@param boolean $isArray
@return string | entailment |
public static function extractProperties(\ReflectionClass $reflector, $type = \ReflectionProperty::IS_PROTECTED, $pattern = self::INJECTABLE_PATTERN)
{
$properties = [];
foreach ($reflector->getProperties($type) as $property) {
$doc = $property->getDocComment();
if (preg_match($pattern, $doc)) {
$instanceType = self::extractVarType($property->getDocComment());
if (null !== $instanceType) {
$properties[$property->getName()] = $instanceType;
}
}
}
return $properties;
} | Method that extract the properties of a Class
@param \ReflectionClass $reflector
@param integer $type
@param string $pattern
@return array | entailment |
public static function extractVarType($doc)
{
$type = null;
if (false !== preg_match('/@var\s+([^\s]+)/', $doc, $matches)) {
list(, $type) = $matches;
}
return $type;
} | Method that extract the instance of the class
@param $doc
@return null|string | entailment |
public static function checkIsRequired($doc)
{
$required = false;
if (false !== preg_match('/@required/', $doc, $matches)) {
$required = (bool)count($matches);
}
return $required;
} | Method extract if a variable is required
@param $doc
@return null|string | entailment |
public static function checkIsVisible($doc)
{
$visible = false;
if (false !== preg_match('/@visible\s+([^\s]+)/', $doc, $matches)) {
$visible = count($matches) < 2 || 'false' !== strtolower($matches[1]);
}
return $visible;
} | Method extract if a class or variable is visible
@param $doc
@return null|string | entailment |
public static function getClassProperties($class)
{
$properties = [];
Logger::log('Extracting annotations properties from class ' . $class);
$selfReflector = new \ReflectionClass($class);
if (false !== $selfReflector->getParentClass()) {
$properties = self::getClassProperties($selfReflector->getParentClass()->getName());
}
$properties = array_merge($properties, self::extractProperties($selfReflector));
return $properties;
} | Method that extract all the properties of a class
@param string $class
@return array | entailment |
public function getConfigParams()
{
$response = array_merge(Config::$required, Config::$optional);
$domains = Router::getInstance()->getDomains();
foreach ($domains as $domain => $routes) {
$pDomain = str_replace('@', '', $domain);
$pDomain = str_replace('/', '', $pDomain);
$response[] = strtolower($pDomain) . '.api.secret';
}
return $this->json($response);
} | Servicio que devuelve los parámetros disponibles
@GET
@route /admin/config/params
@label Parámetros de configuración de PSFS
@visible false
@return mixed | entailment |
public function config()
{
Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri());
/* @var $form \PSFS\base\config\ConfigForm */
$form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig());
$form->build();
return $this->render('welcome.html.twig', array(
'text' => t("Bienvenido a PSFS"),
'config' => $form,
'typeahead_data' => array_merge(Config::$required, Config::$optional),
));
} | Método que gestiona la configuración de las variables
@GET
@Route /admin/config
@return string|null
@throws \HttpException | entailment |
public function saveConfig()
{
Logger::log(t("Guardando configuración"), LOG_INFO);
/* @var $form \PSFS\base\config\ConfigForm */
$form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig());
$form->build();
$form->hydrate();
if ($form->isValid()) {
$debug = Config::getInstance()->getDebugMode();
$newDebug = $form->getFieldValue("debug");
if (Config::save($form->getData(), $form->getExtraData())) {
Logger::log(t('Configuración guardada correctamente'));
//Verificamos si tenemos que limpiar la cache del DocumentRoot
if (boolval($debug) !== boolval($newDebug)) {
GeneratorHelper::clearDocumentRoot();
}
Security::getInstance()->setFlash("callback_message", t("Configuración actualizada correctamente"));
Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true));
} else {
throw new \HttpException(t('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
}
}
return $this->render('welcome.html.twig', array(
'text' => t("Bienvenido a PSFS"),
'config' => $form,
'typeahead_data' => array_merge(Config::$required, Config::$optional),
));
} | Servicio que guarda la configuración de la plataforma
@POST
@route /admin/config
@visible false
@return string
@throws \HttpException | entailment |
public function getCharactersCharacterIdLoyaltyPoints($characterId, $datasource = null, $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCharactersCharacterIdLoyaltyPointsWithHttpInfo($characterId, $datasource, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCharactersCharacterIdLoyaltyPoints
Get loyalty points
@param int $characterId ID for a 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\GetCharactersCharacterIdLoyaltyPoints200Ok[] | entailment |
protected static function saveConfigParams(array $data, array $extra)
{
Logger::log('Saving required config parameters');
//En caso de tener parámetros nuevos los guardamos
if (array_key_exists('label', $extra) && is_array($extra['label'])) {
foreach ($extra['label'] as $index => $field) {
if (array_key_exists($index, $extra['value']) && !empty($extra['value'][$index])) {
/** @var $data array */
$data[$field] = $extra['value'][$index];
}
}
}
return $data;
} | Method that saves the configuration
@param array $data
@param array $extra
@return array | entailment |
protected static function saveExtraParams(array $data)
{
$final_data = array();
if (count($data) > 0) {
Logger::log('Saving extra configuration parameters');
foreach ($data as $key => $value) {
if (null !== $value || $value !== '') {
$final_data[$key] = $value;
}
}
}
return $final_data;
} | Method that saves the extra parameters into the configuration
@param array $data
@return array | entailment |
public function isConfigured()
{
Logger::log('Checking configuration');
$configured = (count($this->config) > 0);
if ($configured) {
foreach (static::$required as $required) {
if (!array_key_exists($required, $this->config)) {
$configured = false;
break;
}
}
}
return $configured || $this->checkTryToSaveConfig() || self::isTest();
} | Method that checks if the platform is proper configured
@return boolean | entailment |
public function checkTryToSaveConfig()
{
$uri = Request::getInstance()->getRequestUri();
$method = Request::getInstance()->getMethod();
return (preg_match('/^\/admin\/(config|setup)$/', $uri) !== false && strtoupper($method) === 'POST');
} | Method that check if the user is trying to save the config
@return bool | entailment |
public static function save(array $data, array $extra = null)
{
$data = self::saveConfigParams($data, $extra);
$final_data = self::saveExtraParams($data);
$saved = false;
try {
$final_data = array_filter($final_data, function($key, $value) {
return in_array($key, self::$required, true) || !empty($value);
}, ARRAY_FILTER_USE_BOTH);
$saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
self::getInstance()->loadConfigData();
$saved = true;
} catch (ConfigException $e) {
Logger::log($e->getMessage(), LOG_ERR);
}
return $saved;
} | Method that saves all the configuration in the system
@param array $data
@param array|null $extra
@return boolean | entailment |
public function get($param, $defaultValue = null)
{
return array_key_exists($param, $this->config) ? $this->config[$param] : $defaultValue;
} | Method that returns a config value
@param string $param
@param mixed $defaultValue
@return mixed|null | entailment |
public function loadConfigData()
{
$this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: [];
$this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE;
} | Method that reloads config file | entailment |
public static function getParam($key, $defaultValue = null, $module = null)
{
if(null !== $module) {
return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue));
}
$param = self::getInstance()->get($key);
return (null !== $param) ? $param : $defaultValue;
} | Static wrapper for extracting params
@param string $key
@param mixed|null $defaultValue
@param string $module
@return mixed|null | entailment |
public static function setCookieHeaders($cookies)
{
if (!empty($cookies) && is_array($cookies) && false === headers_sent() && !self::isTest()) {
foreach ($cookies as $cookie) {
setcookie($cookie["name"],
$cookie["value"],
(array_key_exists('expire', $cookie)) ? $cookie["expire"] : NULL,
(array_key_exists('path', $cookie)) ? $cookie["path"] : "/",
(array_key_exists('domain', $cookie)) ? $cookie["domain"] : Request::getInstance()->getRootUrl(FALSE),
(array_key_exists('secure', $cookie)) ? $cookie["secure"] : FALSE,
(array_key_exists('http', $cookie)) ? $cookie["http"] : true
);
}
}
} | Method that sets the cookie headers
@param $cookies | entailment |
public static function setAuthHeaders($isPublic = true)
{
if ($isPublic) {
unset($_SERVER["PHP_AUTH_USER"]);
unset($_SERVER["PHP_AUTH_PW"]);
header_remove("Authorization");
} elseif(!self::isTest()) {
header('Authorization:');
}
} | Método que inyecta las cabeceras necesarias para la autenticación
@param boolean $isPublic | entailment |
public static function setDebugHeaders(array $vars)
{
if (Config::getParam('debug', true) && !self::isTest()) {
Logger::log('Adding debug headers to render response');
$vars["__DEBUG__"]["includes"] = get_included_files();
$vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s');
header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes');
header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened');
}
return $vars;
} | Método que mete en las variables de las plantillas las cabeceras de debug
@param array $vars
@return array | entailment |
public function toHtmlInternal($value = null)
{
$strOutput = "<optgroup label=\"{$this->__label}\">\n";
foreach ($this->__options as $option) {
$strOutput .= $option->toHtmlInternal($value);
}
$strOutput .= "</optgroup>\n";
return $strOutput;
} | Generte HTML output
@param string $value
@return string Generated HTML | entailment |
public function getCharactersCharacterIdBookmarksAsync($characterId, $datasource = 'tranquility', $page = '1', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCharactersCharacterIdBookmarksAsyncWithHttpInfo($characterId, $datasource, $page, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCharactersCharacterIdBookmarksAsync
List bookmarks
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page Which page of results to return (optional, default to 1)
@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 getCharactersCharacterIdBookmarksFoldersAsync($characterId, $datasource = 'tranquility', $page = '1', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCharactersCharacterIdBookmarksFoldersAsyncWithHttpInfo($characterId, $datasource, $page, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCharactersCharacterIdBookmarksFoldersAsync
List bookmark folders
@param int $characterId An EVE character ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page Which page of results to return (optional, default to 1)
@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 getCorporationsCorporationIdBookmarks($corporationId, $datasource = 'tranquility', $page = '1', $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCorporationsCorporationIdBookmarksWithHttpInfo($corporationId, $datasource, $page, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCorporationsCorporationIdBookmarks
List corporation bookmarks
@param int $corporationId An EVE corporation ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page Which page of results to return (optional, default to 1)
@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\GetCorporationsCorporationIdBookmarks200Ok[] | entailment |
public function getCorporationsCorporationIdBookmarksAsync($corporationId, $datasource = 'tranquility', $page = '1', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCorporationsCorporationIdBookmarksAsyncWithHttpInfo($corporationId, $datasource, $page, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCorporationsCorporationIdBookmarksAsync
List corporation bookmarks
@param int $corporationId An EVE corporation ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page Which page of results to return (optional, default to 1)
@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 getCorporationsCorporationIdBookmarksFolders($corporationId, $datasource = 'tranquility', $page = '1', $token = null, $userAgent = null, $xUserAgent = null)
{
list($response) = $this->getCorporationsCorporationIdBookmarksFoldersWithHttpInfo($corporationId, $datasource, $page, $token, $userAgent, $xUserAgent);
return $response;
} | Operation getCorporationsCorporationIdBookmarksFolders
List corporation bookmark folders
@param int $corporationId An EVE corporation ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page Which page of results to return (optional, default to 1)
@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\GetCorporationsCorporationIdBookmarksFolders200Ok[] | entailment |
public function getCorporationsCorporationIdBookmarksFoldersAsync($corporationId, $datasource = 'tranquility', $page = '1', $token = null, $userAgent = null, $xUserAgent = null)
{
return $this->getCorporationsCorporationIdBookmarksFoldersAsyncWithHttpInfo($corporationId, $datasource, $page, $token, $userAgent, $xUserAgent)
->then(
function ($response) {
return $response[0];
}
);
} | Operation getCorporationsCorporationIdBookmarksFoldersAsync
List corporation bookmark folders
@param int $corporationId An EVE corporation ID (required)
@param string $datasource The server name you would like data from (optional, default to tranquility)
@param int $page Which page of results to return (optional, default to 1)
@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 setColor($color): DeliveryOptions
{
if (!in_array($color, static::getOptionsForColor())) {
throw new InvalidArgumentException(sprintf('Property %s is not supported for %s', $color, __FUNCTION__));
}
$this->data['color'] = $color;
return $this;
} | The option specifies whether a color or black-and-white printing is carried out
@param string $color
@return self
@throws InvalidArgumentException | entailment |
public function setCoverLetter($coverLetter): DeliveryOptions
{
if (!in_array($coverLetter, static::getOptionsForCoverLetter())) {
throw new InvalidArgumentException(
sprintf('Property %s is not supported for %s', $coverLetter, __FUNCTION__)
);
}
$this->data['coverLetter'] = $coverLetter;
return $this;
} | The option specifies whether a cover letter is generated for delivery or if it is included in the PDF attachment
@param string $coverLetter
@return self
@throws InvalidArgumentException | entailment |
public function setRegistered($registered): DeliveryOptions
{
if (!in_array($registered, static::getOptionsForRegistered())) {
throw new InvalidArgumentException(
sprintf('Property %s is not supported for %s', $registered, __FUNCTION__)
);
}
$this->data['registered'] = $registered;
return $this;
} | The option specifies if the E‑POST letter is sent as a “Einschreiben” (registered letter), and, if so, which
registered letter type is to be selected
@param string $registered
@return self
@throws InvalidArgumentException | entailment |
public static function getOptionsForRegistered()
{
return [
self::OPTION_REGISTERED_STANDARD,
self::OPTION_REGISTERED_SUBMISSION_ONLY,
self::OPTION_REGISTERED_ADDRESSEE_ONLY,
self::OPTION_REGISTERED_WITH_RETURN_RECEIPT,
self::OPTION_REGISTERED_ADDRESSEE_ONLY_WITH_RETURN_RECEIPT,
self::OPTION_REGISTERED_NO,
];
} | Get all options that can be used for setRegistered()
@return array | entailment |
public function setEventResponse($eventResponse)
{
$allowed_values = array('declined', 'not_responded', 'accepted', 'tentative');
if (!is_null($eventResponse) && (!in_array($eventResponse, $allowed_values))) {
throw new \InvalidArgumentException("Invalid value for 'eventResponse', must be one of 'declined', 'not_responded', 'accepted', 'tentative'");
}
$this->container['eventResponse'] = $eventResponse;
return $this;
} | Sets eventResponse
@param string $eventResponse event_response string
@return $this | entailment |
public function setPlanetType($planetType)
{
$allowed_values = array('temperate', 'barren', 'oceanic', 'ice', 'gas', 'lava', 'storm', 'plasma');
if ((!in_array($planetType, $allowed_values))) {
throw new \InvalidArgumentException("Invalid value for 'planetType', must be one of 'temperate', 'barren', 'oceanic', 'ice', 'gas', 'lava', 'storm', 'plasma'");
}
$this->container['planetType'] = $planetType;
return $this;
} | Sets planetType
@param string $planetType planet_type string
@return $this | entailment |
public function findByUuid($uuid)
{
/** @var TaskInterface $task */
foreach ($this->taskCollection as $task) {
if ($task->getUuid() === $uuid) {
return $task;
}
}
} | {@inheritdoc} | entailment |
public function save(TaskInterface $task)
{
if ($this->taskCollection->contains($task)) {
return $this;
}
$this->taskCollection->add($task);
return $this;
} | {@inheritdoc} | entailment |
public function findAll($page = 1, $pageSize = null)
{
return array_values($this->taskCollection->slice(($page - 1) * $pageSize, $pageSize));
} | {@inheritdoc} | entailment |
public function findEndBeforeNow()
{
$now = new \DateTime();
return array_values(
$this->taskCollection->filter(
function (TaskInterface $task) use ($now) {
return $task->getLastExecution() === null || $task->getLastExecution() > $now;
}
)->toArray()
);
} | {@inheritdoc} | 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.