id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
44,500 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/cookie/cookie.php | KHttpCookie.toString | public function toString()
{
$str = urlencode($this->name) . '=';
if ((string)$this->value !== '' )
{
$str .= urlencode($this->value);
if ($this->_expire !== 0) {
$str .= '; expires=' . gmdate(DateTime::COOKIE, $this->_expire);
}
}
else $str .= 'deleted; expires=' . gmdate(DateTime::COOKIE, time() - 31536001);
if ($this->_path) {
$str .= '; path=' . $this->_path;
}
if ($this->domain !== null) {
$str .= '; domain=' . $this->domain;
}
if ($this->isSecure() === true) {
$str .= '; secure';
}
if ($this->isHttpOnly() === true) {
$str .= '; httponly';
}
return $str;
} | php | public function toString()
{
$str = urlencode($this->name) . '=';
if ((string)$this->value !== '' )
{
$str .= urlencode($this->value);
if ($this->_expire !== 0) {
$str .= '; expires=' . gmdate(DateTime::COOKIE, $this->_expire);
}
}
else $str .= 'deleted; expires=' . gmdate(DateTime::COOKIE, time() - 31536001);
if ($this->_path) {
$str .= '; path=' . $this->_path;
}
if ($this->domain !== null) {
$str .= '; domain=' . $this->domain;
}
if ($this->isSecure() === true) {
$str .= '; secure';
}
if ($this->isHttpOnly() === true) {
$str .= '; httponly';
}
return $str;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"str",
"=",
"urlencode",
"(",
"$",
"this",
"->",
"name",
")",
".",
"'='",
";",
"if",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"value",
"!==",
"''",
")",
"{",
"$",
"str",
".=",
"urlencode",
... | Return a string representation of the cookie
@return string | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"cookie"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L221-L252 |
44,501 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/cookie/cookie.php | KHttpCookie.& | public function &__get($key)
{
$result = null;
if ($key == 'name') {
$result = $this->_name;
}
if ($key == 'expire') {
$result = $this->_expire;
}
if ($key == 'path') {
$result = $this->_path;
}
return $result;
} | php | public function &__get($key)
{
$result = null;
if ($key == 'name') {
$result = $this->_name;
}
if ($key == 'expire') {
$result = $this->_expire;
}
if ($key == 'path') {
$result = $this->_path;
}
return $result;
} | [
"public",
"function",
"&",
"__get",
"(",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"key",
"==",
"'name'",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_name",
";",
"}",
"if",
"(",
"$",
"key",
"==",
"'expire'",
... | Get a cookie attribute by key
@param string $key The key name.
@return string $value The corresponding value. | [
"Get",
"a",
"cookie",
"attribute",
"by",
"key"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L282-L299 |
44,502 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/behavior.php | ComKoowaTemplateHelperBehavior.koowa | public function koowa($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::koowa($config);
} | php | public function koowa($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::koowa($config);
} | [
"public",
"function",
"koowa",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'debug'",
"=>",
"JFactory",
"::",
"g... | Loads koowa.js
@param array|KObjectConfig $config
@return string | [
"Loads",
"koowa",
".",
"js"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L24-L32 |
44,503 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/behavior.php | ComKoowaTemplateHelperBehavior.vue | public function vue($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::vue($config);
} | php | public function vue($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::vue($config);
} | [
"public",
"function",
"vue",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'debug'",
"=>",
"JFactory",
"::",
"get... | Loads Vue.js
@param array|KObjectConfig $config
@return string | [
"Loads",
"Vue",
".",
"js"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L40-L48 |
44,504 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/behavior.php | ComKoowaTemplateHelperBehavior.kodekitui | public function kodekitui($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::kodekitui($config);
} | php | public function kodekitui($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::kodekitui($config);
} | [
"public",
"function",
"kodekitui",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'debug'",
"=>",
"JFactory",
"::",
... | Loads KUI initialize
@param array|KObjectConfig $config
@return string | [
"Loads",
"KUI",
"initialize"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L72-L80 |
44,505 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/behavior.php | ComKoowaTemplateHelperBehavior.tree | public function tree($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::tree($config);
} | php | public function tree($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug')
));
return parent::tree($config);
} | [
"public",
"function",
"tree",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'debug'",
"=>",
"JFactory",
"::",
"ge... | Loads the Koowa customized jQtree behavior and renders a sidebar-nav list useful in split views
@see http://mbraak.github.io/jqTree/
@note If no 'element' option is passed, then only assets will be loaded.
@param array|KObjectConfig $config
@throws InvalidArgumentException
@return string The html output | [
"Loads",
"the",
"Koowa",
"customized",
"jQtree",
"behavior",
"and",
"renders",
"a",
"sidebar",
"-",
"nav",
"list",
"useful",
"in",
"split",
"views"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L210-L218 |
44,506 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/helper/grid.php | KTemplateHelperGrid.publish | public function publish($config = array())
{
$translator = $this->getObject('translator');
$config = new KObjectConfigJson($config);
$config->append(array(
'entity' => null,
'field' => 'enabled',
'clickable' => true
))->append(array(
'enabled' => (bool) $config->entity->{$config->field},
))->append(array(
'alt' => $config->enabled ? $translator->translate('Published') : $translator->translate('Unpublished'),
'tooltip' => $config->enabled ? $translator->translate('Unpublish Item') : $translator->translate('Publish Item'),
'color' => $config->enabled ? '#468847' : '#b94a48',
'icon' => $config->enabled ? 'enabled' : 'disabled',
));
return $this->enable($config);
} | php | public function publish($config = array())
{
$translator = $this->getObject('translator');
$config = new KObjectConfigJson($config);
$config->append(array(
'entity' => null,
'field' => 'enabled',
'clickable' => true
))->append(array(
'enabled' => (bool) $config->entity->{$config->field},
))->append(array(
'alt' => $config->enabled ? $translator->translate('Published') : $translator->translate('Unpublished'),
'tooltip' => $config->enabled ? $translator->translate('Unpublish Item') : $translator->translate('Publish Item'),
'color' => $config->enabled ? '#468847' : '#b94a48',
'icon' => $config->enabled ? 'enabled' : 'disabled',
));
return $this->enable($config);
} | [
"public",
"function",
"publish",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'translator'",
")",
";",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
... | Render a publish field
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"a",
"publish",
"field"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/grid.php#L296-L315 |
44,507 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/lockable.php | KDatabaseBehaviorLockable.lock | public function lock()
{
//Prevent lock take over, only an saved and unlocked row and be locked
if(!$this->isNew() && !$this->isLocked())
{
$this->locked_by = (int) $this->getObject('user')->getId();
$this->locked_on = gmdate('Y-m-d H:i:s');
$this->save();
}
return true;
} | php | public function lock()
{
//Prevent lock take over, only an saved and unlocked row and be locked
if(!$this->isNew() && !$this->isLocked())
{
$this->locked_by = (int) $this->getObject('user')->getId();
$this->locked_on = gmdate('Y-m-d H:i:s');
$this->save();
}
return true;
} | [
"public",
"function",
"lock",
"(",
")",
"{",
"//Prevent lock take over, only an saved and unlocked row and be locked",
"if",
"(",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"{",
"$",
"this",
"->",
"loc... | Lock a row
Requires an 'locked_on' and 'locked_by' column
@return boolean If successful return TRUE, otherwise FALSE | [
"Lock",
"a",
"row"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/lockable.php#L90-L101 |
44,508 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/lockable.php | KDatabaseBehaviorLockable.unlock | public function unlock()
{
$userid = $this->getObject('user')->getId();
//Only an saved row can be unlocked by the user who locked it
if(!$this->isNew() && $this->locked_by != 0 && $this->locked_by == $userid)
{
$this->locked_by = 0;
$this->locked_on = 0;
$this->save();
}
return true;
} | php | public function unlock()
{
$userid = $this->getObject('user')->getId();
//Only an saved row can be unlocked by the user who locked it
if(!$this->isNew() && $this->locked_by != 0 && $this->locked_by == $userid)
{
$this->locked_by = 0;
$this->locked_on = 0;
$this->save();
}
return true;
} | [
"public",
"function",
"unlock",
"(",
")",
"{",
"$",
"userid",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'user'",
")",
"->",
"getId",
"(",
")",
";",
"//Only an saved row can be unlocked by the user who locked it",
"if",
"(",
"!",
"$",
"this",
"->",
"isNew",
... | Unlock a row
Requires an locked_on and locked_by column to be present in the table
@return boolean If successful return TRUE, otherwise FALSE | [
"Unlock",
"a",
"row"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/lockable.php#L110-L124 |
44,509 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/lockable.php | KDatabaseBehaviorLockable.isLocked | public function isLocked()
{
$result = false;
if(!$this->isNew())
{
if(isset($this->locked_on) && isset($this->locked_by))
{
$locked = strtotime($this->locked_on);
$current = strtotime(gmdate('Y-m-d H:i:s'));
//Check if the lock has gone stale
if($current - $locked < $this->_lifetime)
{
$userid = $this->getObject('user')->getId();
if($this->locked_by != 0 && $this->locked_by != $userid) {
$result= true;
}
}
}
}
return $result;
} | php | public function isLocked()
{
$result = false;
if(!$this->isNew())
{
if(isset($this->locked_on) && isset($this->locked_by))
{
$locked = strtotime($this->locked_on);
$current = strtotime(gmdate('Y-m-d H:i:s'));
//Check if the lock has gone stale
if($current - $locked < $this->_lifetime)
{
$userid = $this->getObject('user')->getId();
if($this->locked_by != 0 && $this->locked_by != $userid) {
$result= true;
}
}
}
}
return $result;
} | [
"public",
"function",
"isLocked",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"locked_on",
")",
"&&",
"isset",
"(",
"$",
"this",
"-... | Checks if a row is locked
@return boolean If the row is locked TRUE, otherwise FALSE | [
"Checks",
"if",
"a",
"row",
"is",
"locked"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/lockable.php#L131-L153 |
44,510 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/menubar.php | ComKoowaTemplateHelperMenubar.render | public function render($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'toolbar' => null
));
$html = '<ul class="k-navigation">';
foreach ($config->toolbar->getCommands() as $command)
{
$command->append(array(
'attribs' => array(
'href' => '#',
'class' => array()
)
));
if(!empty($command->href)) {
$command->attribs['href'] = $this->getTemplate()->route($command->href);
}
$url = KHttpUrl::fromString($command->attribs->href);
if (isset($url->query['view'])) {
$command->attribs->class->append('k-navigation-'.$url->query['view']);
}
$attribs = clone $command->attribs;
$attribs->class = implode(" ", KObjectConfig::unbox($attribs->class));
$html .= '<li'.($command->active ? ' class="k-is-active"' : '').'>';
$html .= '<a '.$this->buildAttributes($attribs).'>';
$html .= $this->getObject('translator')->translate($command->label);
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
return $html;
} | php | public function render($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'toolbar' => null
));
$html = '<ul class="k-navigation">';
foreach ($config->toolbar->getCommands() as $command)
{
$command->append(array(
'attribs' => array(
'href' => '#',
'class' => array()
)
));
if(!empty($command->href)) {
$command->attribs['href'] = $this->getTemplate()->route($command->href);
}
$url = KHttpUrl::fromString($command->attribs->href);
if (isset($url->query['view'])) {
$command->attribs->class->append('k-navigation-'.$url->query['view']);
}
$attribs = clone $command->attribs;
$attribs->class = implode(" ", KObjectConfig::unbox($attribs->class));
$html .= '<li'.($command->active ? ' class="k-is-active"' : '').'>';
$html .= '<a '.$this->buildAttributes($attribs).'>';
$html .= $this->getObject('translator')->translate($command->label);
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
return $html;
} | [
"public",
"function",
"render",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'toolbar'",
"=>",
"null",
")",
")",... | Render the menu bar
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"the",
"menu",
"bar"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/menubar.php#L24-L65 |
44,511 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php | ComKoowaDispatcherBehaviorDecoratable._beforeDispatch | protected function _beforeDispatch(KDispatcherContextInterface $context)
{
if ($this->getDecorator() != 'joomla')
{
$app = JFactory::getApplication();
if ($app->isSite()) {
$app->setTemplate('system');
}
}
} | php | protected function _beforeDispatch(KDispatcherContextInterface $context)
{
if ($this->getDecorator() != 'joomla')
{
$app = JFactory::getApplication();
if ($app->isSite()) {
$app->setTemplate('system');
}
}
} | [
"protected",
"function",
"_beforeDispatch",
"(",
"KDispatcherContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDecorator",
"(",
")",
"!=",
"'joomla'",
")",
"{",
"$",
"app",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
";",
... | Set the Joomla application context
@param KDispatcherContextInterface $context A command context object
@return void | [
"Set",
"the",
"Joomla",
"application",
"context"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L42-L52 |
44,512 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php | ComKoowaDispatcherBehaviorDecoratable._beforeSend | protected function _beforeSend(KDispatcherContextInterface $context)
{
$response = $context->getResponse();
if(!$response->isDownloadable() && !$response->isRedirect())
{
//Render the page
$result = $this->getObject('com:koowa.controller.page', array('response' => $response))
->layout($this->getDecorator())
->render();
//Set the result in the response
$response->setContent($result);
}
} | php | protected function _beforeSend(KDispatcherContextInterface $context)
{
$response = $context->getResponse();
if(!$response->isDownloadable() && !$response->isRedirect())
{
//Render the page
$result = $this->getObject('com:koowa.controller.page', array('response' => $response))
->layout($this->getDecorator())
->render();
//Set the result in the response
$response->setContent($result);
}
} | [
"protected",
"function",
"_beforeSend",
"(",
"KDispatcherContextInterface",
"$",
"context",
")",
"{",
"$",
"response",
"=",
"$",
"context",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"!",
"$",
"response",
"->",
"isDownloadable",
"(",
")",
"&&",
"!",
"$... | Decorate the response
@param KDispatcherContextInterface $context A command context object
@return void | [
"Decorate",
"the",
"response"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L60-L75 |
44,513 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php | ComKoowaDispatcherBehaviorDecoratable._beforeTerminate | protected function _beforeTerminate(KDispatcherContextInterface $context)
{
$response = $context->getResponse();
//Pass back to Joomla
if(!$response->isRedirect() && !$response->isDownloadable() && $this->getDecorator() == 'joomla')
{
// #237 - Since Joomla will wrap the page we do not know the actual content-length and should not send it
$response->getHeaders()->remove('Content-length');
header_remove('Content-Length');
//Contenttype
JFactory::getDocument()->setMimeEncoding($response->getContentType());
//Set messages for any request method
$messages = $response->getMessages();
foreach($messages as $type => $group)
{
if ($type === 'success') {
$type = 'message';
}
foreach($group as $message) {
JFactory::getApplication()->enqueueMessage($message, $type);
}
}
//Set the cache state
JFactory::getApplication()->allowCache($context->getRequest()->isCacheable());
//Do not flush the response
return false;
}
} | php | protected function _beforeTerminate(KDispatcherContextInterface $context)
{
$response = $context->getResponse();
//Pass back to Joomla
if(!$response->isRedirect() && !$response->isDownloadable() && $this->getDecorator() == 'joomla')
{
// #237 - Since Joomla will wrap the page we do not know the actual content-length and should not send it
$response->getHeaders()->remove('Content-length');
header_remove('Content-Length');
//Contenttype
JFactory::getDocument()->setMimeEncoding($response->getContentType());
//Set messages for any request method
$messages = $response->getMessages();
foreach($messages as $type => $group)
{
if ($type === 'success') {
$type = 'message';
}
foreach($group as $message) {
JFactory::getApplication()->enqueueMessage($message, $type);
}
}
//Set the cache state
JFactory::getApplication()->allowCache($context->getRequest()->isCacheable());
//Do not flush the response
return false;
}
} | [
"protected",
"function",
"_beforeTerminate",
"(",
"KDispatcherContextInterface",
"$",
"context",
")",
"{",
"$",
"response",
"=",
"$",
"context",
"->",
"getResponse",
"(",
")",
";",
"//Pass back to Joomla",
"if",
"(",
"!",
"$",
"response",
"->",
"isRedirect",
"("... | Pass the response to Joomla
@param KDispatcherContextInterface $context A command context object
@return bool | [
"Pass",
"the",
"response",
"to",
"Joomla"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L83-L116 |
44,514 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php | ComKoowaDispatcherBehaviorDecoratable.getDecorator | public function getDecorator()
{
$request = $this->getRequest();
$response = $this->getResponse();
if($request->getQuery()->tmpl === 'koowa' || $request->getHeaders()->has('X-Flush-Response') || $response->isError()) {
$result = 'koowa';
} else {
$result = $this->getController()->getView()->getDecorator();
}
return $result;
} | php | public function getDecorator()
{
$request = $this->getRequest();
$response = $this->getResponse();
if($request->getQuery()->tmpl === 'koowa' || $request->getHeaders()->has('X-Flush-Response') || $response->isError()) {
$result = 'koowa';
} else {
$result = $this->getController()->getView()->getDecorator();
}
return $result;
} | [
"public",
"function",
"getDecorator",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getQuery",
"(",
")",
... | Get the decorator name
@return string | [
"Get",
"the",
"decorator",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L123-L135 |
44,515 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/provider/abstract.php | KUserProviderAbstract.load | public function load($identifier, $refresh = false)
{
//Fetch a user from the backend
if($refresh || !$this->isLoaded($identifier))
{
$user = $this->fetch($identifier);
$this->_users[$identifier] = $user;
}
return $this->_users[$identifier];
} | php | public function load($identifier, $refresh = false)
{
//Fetch a user from the backend
if($refresh || !$this->isLoaded($identifier))
{
$user = $this->fetch($identifier);
$this->_users[$identifier] = $user;
}
return $this->_users[$identifier];
} | [
"public",
"function",
"load",
"(",
"$",
"identifier",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"//Fetch a user from the backend",
"if",
"(",
"$",
"refresh",
"||",
"!",
"$",
"this",
"->",
"isLoaded",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"user",... | Loads the user for the given user identifier
@param string $identifier A unique user identifier, (i.e a username or email address)
@param bool $refresh If TRUE and the user has already been loaded it will be re-loaded.
@return KUserInterface Returns a UserInterface object | [
"Loads",
"the",
"user",
"for",
"the",
"given",
"user",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/provider/abstract.php#L67-L77 |
44,516 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/config/config.php | KObjectConfig.get | public function get($name, $default = null)
{
$result = $default;
if(isset($this->__options[$name]) || array_key_exists($name, $this->__options)) {
$result = $this->__options[$name];
}
return $result;
} | php | public function get($name, $default = null)
{
$result = $default;
if(isset($this->__options[$name]) || array_key_exists($name, $this->__options)) {
$result = $this->__options[$name];
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"default",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__options",
"[",
"$",
"name",
"]",
")",
"||",
"array_key_exists",
"(",
... | Retrieve a configuration option
If the option does not exist return the default.
@param string $name
@param mixed $default
@return mixed | [
"Retrieve",
"a",
"configuration",
"option"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/config.php#L57-L65 |
44,517 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/event/subscriber/application.php | ComKoowaEventSubscriberApplication.onAfterApplicationInitialise | public function onAfterApplicationInitialise(KEventInterface $event)
{
if(JFactory::getUser()->guest)
{
$authenticator = $this->getObject('com:koowa.dispatcher.authenticator.jwt');
if ($authenticator->getAuthToken())
{
$dispatcher = $this->getObject('com:koowa.dispatcher.http');
$authenticator->authenticateRequest($dispatcher->getContext());
}
}
} | php | public function onAfterApplicationInitialise(KEventInterface $event)
{
if(JFactory::getUser()->guest)
{
$authenticator = $this->getObject('com:koowa.dispatcher.authenticator.jwt');
if ($authenticator->getAuthToken())
{
$dispatcher = $this->getObject('com:koowa.dispatcher.http');
$authenticator->authenticateRequest($dispatcher->getContext());
}
}
} | [
"public",
"function",
"onAfterApplicationInitialise",
"(",
"KEventInterface",
"$",
"event",
")",
"{",
"if",
"(",
"JFactory",
"::",
"getUser",
"(",
")",
"->",
"guest",
")",
"{",
"$",
"authenticator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'com:koowa.dispatc... | Log user in from the JWT token in the request if possible
onAfterInitialise is used here to make sure that Joomla doesn't display error messages for menu items
with registered and above access levels. | [
"Log",
"user",
"in",
"from",
"the",
"JWT",
"token",
"in",
"the",
"request",
"if",
"possible"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/event/subscriber/application.php#L33-L45 |
44,518 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/event/subscriber/application.php | ComKoowaEventSubscriberApplication.onBeforeApplicationTerminate | public function onBeforeApplicationTerminate(KEventInterface $event)
{
if (JDEBUG && !headers_sent())
{
$buffer = JProfiler::getInstance('Application')->getBuffer();
if ($buffer)
{
$data = strip_tags(end($buffer));
$row = array(array($data), null, 'info');
$header = array(
'version' => '4.1.0',
'columns' => array('log', 'backtrace', 'type'),
'rows' => array($row)
);
header('X-ChromeLogger-Data: ' . base64_encode(utf8_encode(json_encode($header))));
}
}
} | php | public function onBeforeApplicationTerminate(KEventInterface $event)
{
if (JDEBUG && !headers_sent())
{
$buffer = JProfiler::getInstance('Application')->getBuffer();
if ($buffer)
{
$data = strip_tags(end($buffer));
$row = array(array($data), null, 'info');
$header = array(
'version' => '4.1.0',
'columns' => array('log', 'backtrace', 'type'),
'rows' => array($row)
);
header('X-ChromeLogger-Data: ' . base64_encode(utf8_encode(json_encode($header))));
}
}
} | [
"public",
"function",
"onBeforeApplicationTerminate",
"(",
"KEventInterface",
"$",
"event",
")",
"{",
"if",
"(",
"JDEBUG",
"&&",
"!",
"headers_sent",
"(",
")",
")",
"{",
"$",
"buffer",
"=",
"JProfiler",
"::",
"getInstance",
"(",
"'Application'",
")",
"->",
"... | Adds application response time and memory usage to Chrome Inspector with ChromeLogger extension
See: https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd | [
"Adds",
"application",
"response",
"time",
"and",
"memory",
"usage",
"to",
"Chrome",
"Inspector",
"with",
"ChromeLogger",
"extension"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/event/subscriber/application.php#L105-L124 |
44,519 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/manager/manager.php | KObjectManager.getObject | public function getObject($identifier, array $config = array())
{
$identifier = $this->getIdentifier($identifier);
if (!$instance = $this->isRegistered($identifier))
{
//Instantiate the identifier
$instance = $this->_instantiate($identifier, $config);
//Mixins's are early mixed in KObject::_construct()
//$instance = $this->_mixin($identifier, $instance);
//Decorate the object
$instance = $this->_decorate($identifier, $instance);
//Auto register the object
if($this->isMultiton($identifier)) {
$this->setObject($identifier, $instance);
}
}
return $instance;
} | php | public function getObject($identifier, array $config = array())
{
$identifier = $this->getIdentifier($identifier);
if (!$instance = $this->isRegistered($identifier))
{
//Instantiate the identifier
$instance = $this->_instantiate($identifier, $config);
//Mixins's are early mixed in KObject::_construct()
//$instance = $this->_mixin($identifier, $instance);
//Decorate the object
$instance = $this->_decorate($identifier, $instance);
//Auto register the object
if($this->isMultiton($identifier)) {
$this->setObject($identifier, $instance);
}
}
return $instance;
} | [
"public",
"function",
"getObject",
"(",
"$",
"identifier",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"!",
"$",
"instance",
"... | Get an object instance based on an object identifier
If the object implements the ObjectInstantiable interface the manager will delegate object instantiation
to the object itself.
@param mixed $identifier An KObjectIdentifier, identifier string or object implementing KObjectInterface
@param array $config An optional associative array of configuration settings
@return KObjectInterface Return object on success, throws exception on failure
@throws KObjectExceptionInvalidIdentifier If the identifier is not valid
@throws KObjectExceptionInvalidObject If the object doesn't implement the KObjectInterface
@throws KObjectExceptionNotFound If object cannot be loaded
@throws KObjectExceptionNotInstantiated If object cannot be instantiated | [
"Get",
"an",
"object",
"instance",
"based",
"on",
"an",
"object",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/manager/manager.php#L154-L176 |
44,520 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/manager/manager.php | KObjectManager._configure | protected function _configure(KObjectIdentifier $identifier, array $data = array())
{
//Prevent config settings from being stored in the identifier
$config = clone $identifier->getConfig();
//Append the config data from the singleton
if($identifier->getType() != 'lib' && $this->isSingleton($identifier))
{
$parts = $identifier->toArray();
unset($parts['type']);
unset($parts['domain']);
unset($parts['package']);
//Append the config from the singleton
$config->append($this->getIdentifier($parts)->getConfig());
}
//Append the config data for the object
$config->append($data);
//Set the service container and identifier
$config->object_manager = $this;
$config->object_identifier = $identifier;
return $config;
} | php | protected function _configure(KObjectIdentifier $identifier, array $data = array())
{
//Prevent config settings from being stored in the identifier
$config = clone $identifier->getConfig();
//Append the config data from the singleton
if($identifier->getType() != 'lib' && $this->isSingleton($identifier))
{
$parts = $identifier->toArray();
unset($parts['type']);
unset($parts['domain']);
unset($parts['package']);
//Append the config from the singleton
$config->append($this->getIdentifier($parts)->getConfig());
}
//Append the config data for the object
$config->append($data);
//Set the service container and identifier
$config->object_manager = $this;
$config->object_identifier = $identifier;
return $config;
} | [
"protected",
"function",
"_configure",
"(",
"KObjectIdentifier",
"$",
"identifier",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"//Prevent config settings from being stored in the identifier",
"$",
"config",
"=",
"clone",
"$",
"identifier",
"->",
"g... | Configure an identifier
@param KObjectIdentifier $identifier
@param array $data
@return KObjectConfig | [
"Configure",
"an",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/manager/manager.php#L623-L649 |
44,521 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/model.php | ComKoowaControllerModel._actionRead | protected function _actionRead(KControllerContextInterface $context)
{
//Request
if($this->getIdentifier()->domain === 'admin')
{
if($this->isEditable() && KStringInflector::isSingular($this->getView()->getName()))
{
//Use JInput as we do not pass the request query back into the Joomla context
JFactory::getApplication()->input->set('hidemainmenu', 1);
}
}
return parent::_actionRead($context);
} | php | protected function _actionRead(KControllerContextInterface $context)
{
//Request
if($this->getIdentifier()->domain === 'admin')
{
if($this->isEditable() && KStringInflector::isSingular($this->getView()->getName()))
{
//Use JInput as we do not pass the request query back into the Joomla context
JFactory::getApplication()->input->set('hidemainmenu', 1);
}
}
return parent::_actionRead($context);
} | [
"protected",
"function",
"_actionRead",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"//Request",
"if",
"(",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"domain",
"===",
"'admin'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEditable"... | Generic read action, fetches an item
@param KControllerContextInterface $context A command context object
@throws KControllerExceptionResourceNotFound
@return KModelEntityInterface | [
"Generic",
"read",
"action",
"fetches",
"an",
"item"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/model.php#L51-L64 |
44,522 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/helper/paginator.php | KTemplateHelperPaginator._pages | protected function _pages($pages)
{
$html = '';
//$html .= $pages['first']->active ? '<li>'.$this->_link($pages['first'], '<i class="icon-fast-backward icon-first"></i>').'</li>' : '';
$html .= $pages['previous']->active ? '<li>'.$this->_link($pages['previous'], '«').'</li>' : '';
$previous = null;
foreach ($pages['pages'] as $page)
{
if ($previous && $page->page - $previous->page > 1) {
$html .= '<li class="k-is-disabled"><span>…</span></li>';
}
$html .= '<li class="'.($page->active && !$page->current ? '' : 'k-is-active').'">';
$html .= $this->_link($page, $page->page);
$html .= '</li>';
$previous = $page;
}
$html .= $pages['next']->active ? '<li>'.$this->_link($pages['next'], '»').'</li>' : '';
//$html .= $pages['last']->active ? '<li>'.$this->_link($pages['last'], '<i class="icon-fast-forward icon-last"></i>').'</li>' : '';
return $html;
} | php | protected function _pages($pages)
{
$html = '';
//$html .= $pages['first']->active ? '<li>'.$this->_link($pages['first'], '<i class="icon-fast-backward icon-first"></i>').'</li>' : '';
$html .= $pages['previous']->active ? '<li>'.$this->_link($pages['previous'], '«').'</li>' : '';
$previous = null;
foreach ($pages['pages'] as $page)
{
if ($previous && $page->page - $previous->page > 1) {
$html .= '<li class="k-is-disabled"><span>…</span></li>';
}
$html .= '<li class="'.($page->active && !$page->current ? '' : 'k-is-active').'">';
$html .= $this->_link($page, $page->page);
$html .= '</li>';
$previous = $page;
}
$html .= $pages['next']->active ? '<li>'.$this->_link($pages['next'], '»').'</li>' : '';
//$html .= $pages['last']->active ? '<li>'.$this->_link($pages['last'], '<i class="icon-fast-forward icon-last"></i>').'</li>' : '';
return $html;
} | [
"protected",
"function",
"_pages",
"(",
"$",
"pages",
")",
"{",
"$",
"html",
"=",
"''",
";",
"//$html .= $pages['first']->active ? '<li>'.$this->_link($pages['first'], '<i class=\"icon-fast-backward icon-first\"></i>').'</li>' : '';",
"$",
"html",
".=",
"$",
"pages",
"[",
"'p... | Render a list of page links
@param array $pages An array of page data
@return string Html | [
"Render",
"a",
"list",
"of",
"page",
"links"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/paginator.php#L168-L195 |
44,523 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/helper/paginator.php | KTemplateHelperPaginator._link | protected function _link($page, $title)
{
$url = $this->getObject('request')->getUrl();
$query = $url->getQuery(true);
//For compatibility with Joomla use limitstart instead of offset
$query['limit'] = $page->limit;
$query['limitstart'] = $page->offset;
unset($query['offset']);
$url->setQuery($query);
if ($page->active && !$page->current) {
$html = '<a href="'.$url.'">'.$this->getObject('translator')->translate($title).'</a>';
} else {
$html = '<a>'.$this->getObject('translator')->translate($title).'</a>';
}
return $html;
} | php | protected function _link($page, $title)
{
$url = $this->getObject('request')->getUrl();
$query = $url->getQuery(true);
//For compatibility with Joomla use limitstart instead of offset
$query['limit'] = $page->limit;
$query['limitstart'] = $page->offset;
unset($query['offset']);
$url->setQuery($query);
if ($page->active && !$page->current) {
$html = '<a href="'.$url.'">'.$this->getObject('translator')->translate($title).'</a>';
} else {
$html = '<a>'.$this->getObject('translator')->translate($title).'</a>';
}
return $html;
} | [
"protected",
"function",
"_link",
"(",
"$",
"page",
",",
"$",
"title",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'request'",
")",
"->",
"getUrl",
"(",
")",
";",
"$",
"query",
"=",
"$",
"url",
"->",
"getQuery",
"(",
"true",
... | Generates a pagination link
@param KObject $page Page object
@param string $title Page title
@return string | [
"Generates",
"a",
"pagination",
"link"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/paginator.php#L204-L224 |
44,524 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/timestamp.php | KFilterTimestamp._validateIsoDate | protected function _validateIsoDate($value)
{
// Test if value is blank.
if(trim($value) != '')
{
// Test basic date format (yyyy-mm-dd)
$pattern = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/D';
$return = preg_match($pattern, $value, $matches) && checkdate($matches[2], $matches[3], $matches[1]);
}
else $return = false;
return $return;
} | php | protected function _validateIsoDate($value)
{
// Test if value is blank.
if(trim($value) != '')
{
// Test basic date format (yyyy-mm-dd)
$pattern = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/D';
$return = preg_match($pattern, $value, $matches) && checkdate($matches[2], $matches[3], $matches[1]);
}
else $return = false;
return $return;
} | [
"protected",
"function",
"_validateIsoDate",
"(",
"$",
"value",
")",
"{",
"// Test if value is blank.",
"if",
"(",
"trim",
"(",
"$",
"value",
")",
"!=",
"''",
")",
"{",
"// Test basic date format (yyyy-mm-dd)",
"$",
"pattern",
"=",
"'/^([0-9]{4})-([0-9]{2})-([0-9]{2})... | Validates that the value is an ISO 8601 date string.
The format is "yyyy-mm-dd". Also checks to see that the date itself is valid (for example, no Feb 30).
@param string $value The value to validate.
@return bool True if valid, false if not. | [
"Validates",
"that",
"the",
"value",
"is",
"an",
"ISO",
"8601",
"date",
"string",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/timestamp.php#L171-L183 |
44,525 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/helper/date.php | KTemplateHelperDate.format | public function format($config = array())
{
$translator = $this->getObject('translator');
$config = new KObjectConfig($config);
$config->append(array(
'date' => 'now',
'timezone' => date_default_timezone_get(),
'format' => $translator->translate('DATE_FORMAT_LC1'),
'default' => ''
));
$return = $config->default;
if(!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00')))
{
try
{
$date = $this->getObject('lib:date', array('date' => $config->date, 'timezone' => 'UTC'));
$date->setTimezone(new DateTimeZone($config->timezone));
$return = $date->format($config->format);
}
catch(Exception $e) {}
}
return $return;
} | php | public function format($config = array())
{
$translator = $this->getObject('translator');
$config = new KObjectConfig($config);
$config->append(array(
'date' => 'now',
'timezone' => date_default_timezone_get(),
'format' => $translator->translate('DATE_FORMAT_LC1'),
'default' => ''
));
$return = $config->default;
if(!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00')))
{
try
{
$date = $this->getObject('lib:date', array('date' => $config->date, 'timezone' => 'UTC'));
$date->setTimezone(new DateTimeZone($config->timezone));
$return = $date->format($config->format);
}
catch(Exception $e) {}
}
return $return;
} | [
"public",
"function",
"format",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'translator'",
")",
";",
"$",
"config",
"=",
"new",
"KObjectConfig",
"(",
"$",
"config",
")",
";",
"$"... | Returns formatted date according to current local and adds time offset.
@param array $config An optional array with configuration options.
@return string Formatted date. | [
"Returns",
"formatted",
"date",
"according",
"to",
"current",
"local",
"and",
"adds",
"time",
"offset",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/date.php#L24-L51 |
44,526 | avalanche123/AvalancheImagineBundle | Imagine/CachePathResolver.php | CachePathResolver.getBrowserPath | public function getBrowserPath($path, $filter, $absolute = false)
{
// identify if current path is not under specified source root and return
// unmodified path in that case
$realPath = realpath($this->sourceRoot.$path);
if (!0 === strpos($realPath, $this->sourceRoot)) {
return $path;
}
$path = str_replace(
urlencode(ltrim($path, '/')),
urldecode(ltrim($path, '/')),
$this->router->generate('_imagine_'.$filter, array(
'path' => ltrim($path, '/')
), $absolute)
);
$cached = realpath($this->webRoot.$path);
if (file_exists($cached) && !is_dir($cached) && filemtime($realPath) > filemtime($cached)) {
unlink($cached);
}
return $path;
} | php | public function getBrowserPath($path, $filter, $absolute = false)
{
// identify if current path is not under specified source root and return
// unmodified path in that case
$realPath = realpath($this->sourceRoot.$path);
if (!0 === strpos($realPath, $this->sourceRoot)) {
return $path;
}
$path = str_replace(
urlencode(ltrim($path, '/')),
urldecode(ltrim($path, '/')),
$this->router->generate('_imagine_'.$filter, array(
'path' => ltrim($path, '/')
), $absolute)
);
$cached = realpath($this->webRoot.$path);
if (file_exists($cached) && !is_dir($cached) && filemtime($realPath) > filemtime($cached)) {
unlink($cached);
}
return $path;
} | [
"public",
"function",
"getBrowserPath",
"(",
"$",
"path",
",",
"$",
"filter",
",",
"$",
"absolute",
"=",
"false",
")",
"{",
"// identify if current path is not under specified source root and return",
"// unmodified path in that case",
"$",
"realPath",
"=",
"realpath",
"(... | Gets filtered path for rendering in the browser
@param string $path
@param string $filter
@param boolean $absolute | [
"Gets",
"filtered",
"path",
"for",
"rendering",
"in",
"the",
"browser"
] | 8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa | https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Imagine/CachePathResolver.php#L46-L71 |
44,527 | avalanche123/AvalancheImagineBundle | Controller/ImagineController.php | ImagineController.filter | public function filter($path, $filter)
{
try {
$cachedPath = $this->cacheManager->cacheImage($this->request->getBaseUrl(), $path, $filter);
} catch (RouteNotFoundException $e) {
throw new NotFoundHttpException('Filter doesn\'t exist.');
}
// if cache path cannot be determined, return 404
if (null === $cachedPath) {
throw new NotFoundHttpException('Image doesn\'t exist');
}
ob_start();
try {
$format = $this->filterManager->getOption($filter, "format", "png");
$this->imagine->open($cachedPath)->show($format);
$type = 'image/' . $format;
$length = ob_get_length();
$content = ob_get_clean();
// TODO: add more media headers
$response = new Response($content, 201, array(
'content-type' => $type,
'content-length' => $length,
));
// Cache
$cacheType = $this->filterManager->getOption($filter, "cache_type", false);
if (false == $cacheType) {
return $response;
}
($cacheType === "public") ? $response->setPublic() : $response->setPrivate();
$cacheExpires = $this->filterManager->getOption($filter, "cache_expires", "1 day");
$expirationDate = new \DateTime("+" . $cacheExpires);
$maxAge = $expirationDate->format("U") - time();
if ($maxAge < 0) {
throw new \InvalidArgumentException("Invalid cache expiration date");
}
$response->setExpires($expirationDate);
$response->setMaxAge($maxAge);
return $response;
} catch (\Exception $e) {
ob_end_clean();
throw $e;
}
} | php | public function filter($path, $filter)
{
try {
$cachedPath = $this->cacheManager->cacheImage($this->request->getBaseUrl(), $path, $filter);
} catch (RouteNotFoundException $e) {
throw new NotFoundHttpException('Filter doesn\'t exist.');
}
// if cache path cannot be determined, return 404
if (null === $cachedPath) {
throw new NotFoundHttpException('Image doesn\'t exist');
}
ob_start();
try {
$format = $this->filterManager->getOption($filter, "format", "png");
$this->imagine->open($cachedPath)->show($format);
$type = 'image/' . $format;
$length = ob_get_length();
$content = ob_get_clean();
// TODO: add more media headers
$response = new Response($content, 201, array(
'content-type' => $type,
'content-length' => $length,
));
// Cache
$cacheType = $this->filterManager->getOption($filter, "cache_type", false);
if (false == $cacheType) {
return $response;
}
($cacheType === "public") ? $response->setPublic() : $response->setPrivate();
$cacheExpires = $this->filterManager->getOption($filter, "cache_expires", "1 day");
$expirationDate = new \DateTime("+" . $cacheExpires);
$maxAge = $expirationDate->format("U") - time();
if ($maxAge < 0) {
throw new \InvalidArgumentException("Invalid cache expiration date");
}
$response->setExpires($expirationDate);
$response->setMaxAge($maxAge);
return $response;
} catch (\Exception $e) {
ob_end_clean();
throw $e;
}
} | [
"public",
"function",
"filter",
"(",
"$",
"path",
",",
"$",
"filter",
")",
"{",
"try",
"{",
"$",
"cachedPath",
"=",
"$",
"this",
"->",
"cacheManager",
"->",
"cacheImage",
"(",
"$",
"this",
"->",
"request",
"->",
"getBaseUrl",
"(",
")",
",",
"$",
"pat... | This action applies a given filter to a given image, saves the image and
outputs it to the browser at the same time
@param string $path
@param string $filter
@return Response | [
"This",
"action",
"applies",
"a",
"given",
"filter",
"to",
"a",
"given",
"image",
"saves",
"the",
"image",
"and",
"outputs",
"it",
"to",
"the",
"browser",
"at",
"the",
"same",
"time"
] | 8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa | https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Controller/ImagineController.php#L59-L112 |
44,528 | avalanche123/AvalancheImagineBundle | Imagine/CacheManager.php | CacheManager.cacheImage | public function cacheImage($basePath, $path, $filter)
{
$path = '/'.ltrim($path, '/');
//TODO: find out why I need double urldecode to get a valid path
$browserPath = urldecode(urldecode($this->cachePathResolver->getBrowserPath($path, $filter)));
if (!empty($basePath) && 0 === strpos($browserPath, $basePath)) {
$browserPath = substr($browserPath, strlen($basePath));
}
// if cache path cannot be determined, return 404
if (null === $browserPath) {
return null;
}
$realPath = $this->webRoot.$browserPath;
$sourcePathRoot = $this->filterManager->getOption($filter, "source_root", $this->sourceRoot);
$sourcePath = $sourcePathRoot.$path;
// if the file has already been cached, just return path
if (is_file($realPath)) {
return $realPath;
}
if (!is_file($sourcePath)) {
return null;
}
$dir = pathinfo($realPath, PATHINFO_DIRNAME);
if (!is_dir($dir)) {
try {
if (false === $this->filesystem->mkdir($dir)) {
throw new \RuntimeException(sprintf(
'Could not create directory %s', $dir
));
}
} catch (\Exception $e) {
if (!is_dir($dir)) {
throw $e;
}
}
}
// TODO: get rid of hard-coded quality and format
$this->filterManager->getFilter($filter)
->apply($this->imagine->open($sourcePath))
->save($realPath, array(
'quality' => $this->filterManager->getOption($filter, "quality", 100),
'format' => $this->filterManager->getOption($filter, "format", null)
))
;
try {
if (!chmod($realPath, $this->permissions))
{
throw new \RuntimeException(sprintf(
'Could not set permissions %s on image saved in %s', $this->permissions, $realPath
));
}
} catch (Exception $e) {
throw $e;
}
return $realPath;
} | php | public function cacheImage($basePath, $path, $filter)
{
$path = '/'.ltrim($path, '/');
//TODO: find out why I need double urldecode to get a valid path
$browserPath = urldecode(urldecode($this->cachePathResolver->getBrowserPath($path, $filter)));
if (!empty($basePath) && 0 === strpos($browserPath, $basePath)) {
$browserPath = substr($browserPath, strlen($basePath));
}
// if cache path cannot be determined, return 404
if (null === $browserPath) {
return null;
}
$realPath = $this->webRoot.$browserPath;
$sourcePathRoot = $this->filterManager->getOption($filter, "source_root", $this->sourceRoot);
$sourcePath = $sourcePathRoot.$path;
// if the file has already been cached, just return path
if (is_file($realPath)) {
return $realPath;
}
if (!is_file($sourcePath)) {
return null;
}
$dir = pathinfo($realPath, PATHINFO_DIRNAME);
if (!is_dir($dir)) {
try {
if (false === $this->filesystem->mkdir($dir)) {
throw new \RuntimeException(sprintf(
'Could not create directory %s', $dir
));
}
} catch (\Exception $e) {
if (!is_dir($dir)) {
throw $e;
}
}
}
// TODO: get rid of hard-coded quality and format
$this->filterManager->getFilter($filter)
->apply($this->imagine->open($sourcePath))
->save($realPath, array(
'quality' => $this->filterManager->getOption($filter, "quality", 100),
'format' => $this->filterManager->getOption($filter, "format", null)
))
;
try {
if (!chmod($realPath, $this->permissions))
{
throw new \RuntimeException(sprintf(
'Could not set permissions %s on image saved in %s', $this->permissions, $realPath
));
}
} catch (Exception $e) {
throw $e;
}
return $realPath;
} | [
"public",
"function",
"cacheImage",
"(",
"$",
"basePath",
",",
"$",
"path",
",",
"$",
"filter",
")",
"{",
"$",
"path",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"//TODO: find out why I need double urldecode to get a valid path",
"$",
... | Forces image caching and returns path to cached image.
@param string $basePath
@param string $path
@param string $filter
@return string|null | [
"Forces",
"image",
"caching",
"and",
"returns",
"path",
"to",
"cached",
"image",
"."
] | 8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa | https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Imagine/CacheManager.php#L51-L119 |
44,529 | avalanche123/AvalancheImagineBundle | Templating/ImagineExtension.php | ImagineExtension.applyFilter | public function applyFilter($path, $filter, $absolute = false)
{
return $this->cachePathResolver->getBrowserPath($path, $filter, $absolute);
} | php | public function applyFilter($path, $filter, $absolute = false)
{
return $this->cachePathResolver->getBrowserPath($path, $filter, $absolute);
} | [
"public",
"function",
"applyFilter",
"(",
"$",
"path",
",",
"$",
"filter",
",",
"$",
"absolute",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"cachePathResolver",
"->",
"getBrowserPath",
"(",
"$",
"path",
",",
"$",
"filter",
",",
"$",
"absolute",... | Gets cache path of an image to be filtered
@param string $path
@param string $filter
@param boolean $absolute
@return string | [
"Gets",
"cache",
"path",
"of",
"an",
"image",
"to",
"be",
"filtered"
] | 8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa | https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Templating/ImagineExtension.php#L45-L48 |
44,530 | jaimz22/Overcast | src/ClientAdapters/ClientAdapter.php | ClientAdapter.buildRequestURL | protected function buildRequestURL($latitude, $longitude, \DateTime $time = NULL, array $parameters = NULL)
{
$requestUrl = Overcast::API_ENDPOINT . Overcast::getApiKey() . '/' . $latitude . ',' . $longitude;
if (NULL !== $time) {
$requestUrl .= ',' . $time->getTimestamp();
}
$requestUrl .= '?' . $this->buildRequestParameters($parameters);
return $requestUrl;
} | php | protected function buildRequestURL($latitude, $longitude, \DateTime $time = NULL, array $parameters = NULL)
{
$requestUrl = Overcast::API_ENDPOINT . Overcast::getApiKey() . '/' . $latitude . ',' . $longitude;
if (NULL !== $time) {
$requestUrl .= ',' . $time->getTimestamp();
}
$requestUrl .= '?' . $this->buildRequestParameters($parameters);
return $requestUrl;
} | [
"protected",
"function",
"buildRequestURL",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"\\",
"DateTime",
"$",
"time",
"=",
"NULL",
",",
"array",
"$",
"parameters",
"=",
"NULL",
")",
"{",
"$",
"requestUrl",
"=",
"Overcast",
"::",
"API_ENDPOINT",
".",... | Builds the URL to request from the Dark Sky API
@param float $latitude
@param float $longitude
@param \DateTime|NULL $time
@param array|NULL $parameters
@return string | [
"Builds",
"the",
"URL",
"to",
"request",
"from",
"the",
"Dark",
"Sky",
"API"
] | f595f8876bf2b23965e2fb9104e019216bfda858 | https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/ClientAdapter.php#L27-L38 |
44,531 | jaimz22/Overcast | src/ClientAdapters/GuzzleClientAdapter.php | GuzzleClientAdapter.getForecast | public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null)
{
$this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters);
$response = $this->guzzleClient->get($this->requestedUrl);
$cacheDirectives = $this->buildCacheDirectives($response);
$this->responseHeaders = [
'cache' => $cacheDirectives,
'responseTime' => (int)$response->getHeader('x-response-time'),
'apiCalls' => (int)$response->getHeader('x-forecast-api-calls')
];
return json_decode($response->getBody(), true);
} | php | public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null)
{
$this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters);
$response = $this->guzzleClient->get($this->requestedUrl);
$cacheDirectives = $this->buildCacheDirectives($response);
$this->responseHeaders = [
'cache' => $cacheDirectives,
'responseTime' => (int)$response->getHeader('x-response-time'),
'apiCalls' => (int)$response->getHeader('x-forecast-api-calls')
];
return json_decode($response->getBody(), true);
} | [
"public",
"function",
"getForecast",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"\\",
"DateTime",
"$",
"time",
"=",
"null",
",",
"array",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"requestedUrl",
"=",
"$",
"this",
"->",
"build... | Returns the response data from the Dark Sky API in the
form of an array.
@param float $latitude
@param float $longitude
@param \DateTime $time
@param array $parameters
@return array | [
"Returns",
"the",
"response",
"data",
"from",
"the",
"Dark",
"Sky",
"API",
"in",
"the",
"form",
"of",
"an",
"array",
"."
] | f595f8876bf2b23965e2fb9104e019216bfda858 | https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/GuzzleClientAdapter.php#L53-L67 |
44,532 | jaimz22/Overcast | src/ClientAdapters/GuzzleClientAdapter.php | GuzzleClientAdapter.buildCacheDirectives | protected function buildCacheDirectives($response)
{
$cacheControlHeader = null;
if ($response->hasHeader('cache-control')) {
$cacheControlHeader = $this->parseHeader($response->getHeader('cache-control'));
$cacheControlHeader = current($cacheControlHeader);
$cacheControlHeader = (isset($cacheControlHeader['max-age'])?$cacheControlHeader['max-age']:null);
}
$expiresHeader = null;
if ($response->hasHeader('expires')){
$expiresHeader = implode(' ',array_column($this->parseHeader($response->getHeader('expires')),0));
}
return array_filter([
'maxAge'=>$cacheControlHeader,
'expires'=>$expiresHeader,
]);
} | php | protected function buildCacheDirectives($response)
{
$cacheControlHeader = null;
if ($response->hasHeader('cache-control')) {
$cacheControlHeader = $this->parseHeader($response->getHeader('cache-control'));
$cacheControlHeader = current($cacheControlHeader);
$cacheControlHeader = (isset($cacheControlHeader['max-age'])?$cacheControlHeader['max-age']:null);
}
$expiresHeader = null;
if ($response->hasHeader('expires')){
$expiresHeader = implode(' ',array_column($this->parseHeader($response->getHeader('expires')),0));
}
return array_filter([
'maxAge'=>$cacheControlHeader,
'expires'=>$expiresHeader,
]);
} | [
"protected",
"function",
"buildCacheDirectives",
"(",
"$",
"response",
")",
"{",
"$",
"cacheControlHeader",
"=",
"null",
";",
"if",
"(",
"$",
"response",
"->",
"hasHeader",
"(",
"'cache-control'",
")",
")",
"{",
"$",
"cacheControlHeader",
"=",
"$",
"this",
"... | Builds the cache directives from response headers.
@param $response
@return string[] | [
"Builds",
"the",
"cache",
"directives",
"from",
"response",
"headers",
"."
] | f595f8876bf2b23965e2fb9104e019216bfda858 | https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/GuzzleClientAdapter.php#L86-L104 |
44,533 | jaimz22/Overcast | src/ClientAdapters/FileGetContentsClientAdapter.php | FileGetContentsClientAdapter.getForecast | public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null)
{
$this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters);
$this->response = json_decode(file_get_contents($this->requestedUrl), true);
$this->responseHeaders = $this->parseForecastResponseHeaders($http_response_header);
return $this->response;
} | php | public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null)
{
$this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters);
$this->response = json_decode(file_get_contents($this->requestedUrl), true);
$this->responseHeaders = $this->parseForecastResponseHeaders($http_response_header);
return $this->response;
} | [
"public",
"function",
"getForecast",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"\\",
"DateTime",
"$",
"time",
"=",
"null",
",",
"array",
"$",
"parameters",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"requestedUrl",
"=",
"$",
"this",
"->",
"build... | Returns the response data from the Dark Sky API in the
form of an array
@param float $latitude
@param float $longitude
@param \DateTime $time
@param array $parameters
@return array | [
"Returns",
"the",
"response",
"data",
"from",
"the",
"Dark",
"Sky",
"API",
"in",
"the",
"form",
"of",
"an",
"array"
] | f595f8876bf2b23965e2fb9104e019216bfda858 | https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/FileGetContentsClientAdapter.php#L39-L47 |
44,534 | jaimz22/Overcast | src/ClientAdapters/FileGetContentsClientAdapter.php | FileGetContentsClientAdapter.parseForecastResponseHeaders | private function parseForecastResponseHeaders($headers)
{
$responseHeaders = [
'cache' => [
'maxAge' => null,
'expires' => null
],
'responseTime' => null,
'apiCalls' => null
];
foreach ($headers as $header) {
switch (true) {
case (substr($header, 0, 14) === 'Cache-Control:'):
$responseHeaders['cache']['maxAge'] = trim(substr($header, strrpos($header, '=') + 1));
break;
case (substr($header, 0, 8) === 'Expires:'):
$responseHeaders['cache']['expires'] = trim(substr($header, 8));
break;
case (substr($header, 0, 21) === 'X-Forecast-API-Calls:'):
$responseHeaders['apiCalls'] = trim(substr($header, 21));
break;
case (substr($header, 0, 16) === 'X-Response-Time:'):
$responseHeaders['responseTime'] = (int)trim(substr($header, 16));
break;
default:
break;
}
}
return $responseHeaders;
} | php | private function parseForecastResponseHeaders($headers)
{
$responseHeaders = [
'cache' => [
'maxAge' => null,
'expires' => null
],
'responseTime' => null,
'apiCalls' => null
];
foreach ($headers as $header) {
switch (true) {
case (substr($header, 0, 14) === 'Cache-Control:'):
$responseHeaders['cache']['maxAge'] = trim(substr($header, strrpos($header, '=') + 1));
break;
case (substr($header, 0, 8) === 'Expires:'):
$responseHeaders['cache']['expires'] = trim(substr($header, 8));
break;
case (substr($header, 0, 21) === 'X-Forecast-API-Calls:'):
$responseHeaders['apiCalls'] = trim(substr($header, 21));
break;
case (substr($header, 0, 16) === 'X-Response-Time:'):
$responseHeaders['responseTime'] = (int)trim(substr($header, 16));
break;
default:
break;
}
}
return $responseHeaders;
} | [
"private",
"function",
"parseForecastResponseHeaders",
"(",
"$",
"headers",
")",
"{",
"$",
"responseHeaders",
"=",
"[",
"'cache'",
"=>",
"[",
"'maxAge'",
"=>",
"null",
",",
"'expires'",
"=>",
"null",
"]",
",",
"'responseTime'",
"=>",
"null",
",",
"'apiCalls'",... | Parses the response headers
@param array $headers
@return array | [
"Parses",
"the",
"response",
"headers"
] | f595f8876bf2b23965e2fb9104e019216bfda858 | https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/FileGetContentsClientAdapter.php#L66-L95 |
44,535 | jaimz22/Overcast | src/Overcast.php | Overcast.getForecast | public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null)
{
try {
$response = $this->adapter->getForecast($latitude, $longitude, $time, $parameters);
$responseHeaders = $this->adapter->getHeaders();
if (NULL !== $responseHeaders['apiCalls']) {
$this->apiCalls = $responseHeaders['apiCalls'];
}
$cacheAge = 0;
if (NULL !== $responseHeaders['cache']['maxAge']) {
$cacheAge = $responseHeaders['cache']['maxAge'];
} elseif (NULL !== $responseHeaders['cache']['expires']) {
$cacheAge = (new \DateTime())->getTimestamp() - (new \DateTime($responseHeaders['cache']['expires']))->getTimestamp();
}
return new Forecast($response, $cacheAge, $responseHeaders['responseTime']);
} catch (\Exception $e) {
return null;
}
} | php | public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null)
{
try {
$response = $this->adapter->getForecast($latitude, $longitude, $time, $parameters);
$responseHeaders = $this->adapter->getHeaders();
if (NULL !== $responseHeaders['apiCalls']) {
$this->apiCalls = $responseHeaders['apiCalls'];
}
$cacheAge = 0;
if (NULL !== $responseHeaders['cache']['maxAge']) {
$cacheAge = $responseHeaders['cache']['maxAge'];
} elseif (NULL !== $responseHeaders['cache']['expires']) {
$cacheAge = (new \DateTime())->getTimestamp() - (new \DateTime($responseHeaders['cache']['expires']))->getTimestamp();
}
return new Forecast($response, $cacheAge, $responseHeaders['responseTime']);
} catch (\Exception $e) {
return null;
}
} | [
"public",
"function",
"getForecast",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"\\",
"DateTime",
"$",
"time",
"=",
"null",
",",
"array",
"$",
"parameters",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"adapter",
... | Retrieve the forecast for the specified latitude and longitude and
optionally the specified date and time.
@param $latitude
@param $longitude
@param \DateTime $time
@param array $parameters
@return Forecast | [
"Retrieve",
"the",
"forecast",
"for",
"the",
"specified",
"latitude",
"and",
"longitude",
"and",
"optionally",
"the",
"specified",
"date",
"and",
"time",
"."
] | f595f8876bf2b23965e2fb9104e019216bfda858 | https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/Overcast.php#L82-L103 |
44,536 | nezamy/view | system/Views/View.php | View.view | public function view($file, array $vars = [])
{
if ( is_file($file = $this->getPath($file . '.php')) ) {
$this->data = $vars;
extract($vars, EXTR_OVERWRITE|EXTR_REFS);
include($this->cache($file));
$this->end();
} else {
throw new \Exception("Views: File not found $file");
}
return $this;
} | php | public function view($file, array $vars = [])
{
if ( is_file($file = $this->getPath($file . '.php')) ) {
$this->data = $vars;
extract($vars, EXTR_OVERWRITE|EXTR_REFS);
include($this->cache($file));
$this->end();
} else {
throw new \Exception("Views: File not found $file");
}
return $this;
} | [
"public",
"function",
"view",
"(",
"$",
"file",
",",
"array",
"$",
"vars",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"file",
".",
"'.php'",
")",
")",
")",
"{",
"$",
"this",
"... | section in layout is calling section in view if is definded
@param string $file view file path name without .php
@param array $vars array of the vars "key => value"
@return this | [
"section",
"in",
"layout",
"is",
"calling",
"section",
"in",
"view",
"if",
"is",
"definded"
] | e19d3ad2c276a1e2588204a52fd0c3783c340440 | https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L75-L87 |
44,537 | nezamy/view | system/Views/View.php | View.end | public function end()
{
if ($this->config['layout'] !== false && is_file($file = $this->getLayoutPath()) ) {
extract($this->data, EXTR_OVERWRITE|EXTR_REFS);
require($this->cache($file, true));
}
} | php | public function end()
{
if ($this->config['layout'] !== false && is_file($file = $this->getLayoutPath()) ) {
extract($this->data, EXTR_OVERWRITE|EXTR_REFS);
require($this->cache($file, true));
}
} | [
"public",
"function",
"end",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'layout'",
"]",
"!==",
"false",
"&&",
"is_file",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"getLayoutPath",
"(",
")",
")",
")",
"{",
"extract",
"(",
"$",
"t... | end and include layout | [
"end",
"and",
"include",
"layout"
] | e19d3ad2c276a1e2588204a52fd0c3783c340440 | https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L122-L128 |
44,538 | nezamy/view | system/Views/View.php | View.ViewBag | public function ViewBag($k=null, $v=null)
{
if($v !== null){
$this->viewBag->$k = $v;
}elseif($k !== null){
return $this->viewBag->$k;
}else{
return $this->viewBag;
}
return $this;
} | php | public function ViewBag($k=null, $v=null)
{
if($v !== null){
$this->viewBag->$k = $v;
}elseif($k !== null){
return $this->viewBag->$k;
}else{
return $this->viewBag;
}
return $this;
} | [
"public",
"function",
"ViewBag",
"(",
"$",
"k",
"=",
"null",
",",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"viewBag",
"->",
"$",
"k",
"=",
"$",
"v",
";",
"}",
"elseif",
"(",
"$",
"k",... | share data to all views files
@param string $k
@param mixed $v
@return mixed | [
"share",
"data",
"to",
"all",
"views",
"files"
] | e19d3ad2c276a1e2588204a52fd0c3783c340440 | https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L138-L148 |
44,539 | nezamy/view | system/Views/View.php | View.cache | private function cache($file, $layout=false)
{
if(!$this->config['compiler']){
return $file;
}
return (new Cache([
'path' => $this->config['cache']
]))->compiled($file, $file, $this->setCacheCompiler($file, $layout));
} | php | private function cache($file, $layout=false)
{
if(!$this->config['compiler']){
return $file;
}
return (new Cache([
'path' => $this->config['cache']
]))->compiled($file, $file, $this->setCacheCompiler($file, $layout));
} | [
"private",
"function",
"cache",
"(",
"$",
"file",
",",
"$",
"layout",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'compiler'",
"]",
")",
"{",
"return",
"$",
"file",
";",
"}",
"return",
"(",
"new",
"Cache",
"(",
"[",... | Cache compiled file
@param string $file
@param bool $layout
@return string | [
"Cache",
"compiled",
"file"
] | e19d3ad2c276a1e2588204a52fd0c3783c340440 | https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L157-L166 |
44,540 | nezamy/view | system/Views/View.php | View.setCacheCompiler | private function setCacheCompiler($f, $layout=false)
{
$viewCompiler = new viewCompiler($this);
$viewCompiler->content = file_get_contents($f);
if($layout === true) {
return $viewCompiler->runCompiler([
'renderCompiler',
'startLayoutSectionCompiler',
'echoCompiler'
]);
} else {
return $viewCompiler->runCompiler(['startLayoutSectionCompiler'], true);
}
} | php | private function setCacheCompiler($f, $layout=false)
{
$viewCompiler = new viewCompiler($this);
$viewCompiler->content = file_get_contents($f);
if($layout === true) {
return $viewCompiler->runCompiler([
'renderCompiler',
'startLayoutSectionCompiler',
'echoCompiler'
]);
} else {
return $viewCompiler->runCompiler(['startLayoutSectionCompiler'], true);
}
} | [
"private",
"function",
"setCacheCompiler",
"(",
"$",
"f",
",",
"$",
"layout",
"=",
"false",
")",
"{",
"$",
"viewCompiler",
"=",
"new",
"viewCompiler",
"(",
"$",
"this",
")",
";",
"$",
"viewCompiler",
"->",
"content",
"=",
"file_get_contents",
"(",
"$",
"... | Set Cache Compiler
@param string $f
@param bool $layout
@return string | [
"Set",
"Cache",
"Compiler"
] | e19d3ad2c276a1e2588204a52fd0c3783c340440 | https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L175-L189 |
44,541 | emartech/magento2-extension | dev/Magento/Identifier.php | Identifier.markSections | public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
{
if (!$sectionNames) {
$sectionNames = array_keys($sectionsData);
}
$markId = $this->initMark($updateIds);
foreach ($sectionNames as $name) {
if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
$sectionsData[$name][self::SECTION_KEY] = $markId;
}
if(!isset($sectionsData[$name])){
$sectionsData[$name] = [];
}
}
return $sectionsData;
} | php | public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
{
if (!$sectionNames) {
$sectionNames = array_keys($sectionsData);
}
$markId = $this->initMark($updateIds);
foreach ($sectionNames as $name) {
if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
$sectionsData[$name][self::SECTION_KEY] = $markId;
}
if(!isset($sectionsData[$name])){
$sectionsData[$name] = [];
}
}
return $sectionsData;
} | [
"public",
"function",
"markSections",
"(",
"array",
"$",
"sectionsData",
",",
"$",
"sectionNames",
"=",
"null",
",",
"$",
"updateIds",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"sectionNames",
")",
"{",
"$",
"sectionNames",
"=",
"array_keys",
"(",
"$"... | Mark sections with data id
@param array $sectionsData
@param null $sectionNames
@param bool $updateIds
@return array | [
"Mark",
"sections",
"with",
"data",
"id"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/dev/Magento/Identifier.php#L74-L90 |
44,542 | emartech/magento2-extension | Block/Snippets.php | Snippets.getTrackingData | public function getTrackingData()
{
return [
'product' => $this->getCurrentProduct(),
'category' => $this->getCategory(),
'store' => $this->getStoreData(),
'search' => $this->getSearchData(),
'exchangeRate' => $this->getExchangeRate(),
'slug' => $this->getStoreSlug(),
];
} | php | public function getTrackingData()
{
return [
'product' => $this->getCurrentProduct(),
'category' => $this->getCategory(),
'store' => $this->getStoreData(),
'search' => $this->getSearchData(),
'exchangeRate' => $this->getExchangeRate(),
'slug' => $this->getStoreSlug(),
];
} | [
"public",
"function",
"getTrackingData",
"(",
")",
"{",
"return",
"[",
"'product'",
"=>",
"$",
"this",
"->",
"getCurrentProduct",
"(",
")",
",",
"'category'",
"=>",
"$",
"this",
"->",
"getCategory",
"(",
")",
",",
"'store'",
"=>",
"$",
"this",
"->",
"get... | Get Tracking Data
@return mixed
@throws \Exception | [
"Get",
"Tracking",
"Data"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L117-L127 |
44,543 | emartech/magento2-extension | Block/Snippets.php | Snippets.getExchangeRate | public function getExchangeRate()
{
try {
$currentCurrency = $this->storeManager->getStore()->getCurrentCurrency()->getCode();
$baseCurrency = $this->storeManager->getStore()->getBaseCurrency()->getCode();
return (float)$this->currencyFactory->create()->load($baseCurrency)->getAnyRate($currentCurrency);
} catch (\Exception $e) {
throw $e;
}
} | php | public function getExchangeRate()
{
try {
$currentCurrency = $this->storeManager->getStore()->getCurrentCurrency()->getCode();
$baseCurrency = $this->storeManager->getStore()->getBaseCurrency()->getCode();
return (float)$this->currencyFactory->create()->load($baseCurrency)->getAnyRate($currentCurrency);
} catch (\Exception $e) {
throw $e;
}
} | [
"public",
"function",
"getExchangeRate",
"(",
")",
"{",
"try",
"{",
"$",
"currentCurrency",
"=",
"$",
"this",
"->",
"storeManager",
"->",
"getStore",
"(",
")",
"->",
"getCurrentCurrency",
"(",
")",
"->",
"getCode",
"(",
")",
";",
"$",
"baseCurrency",
"=",
... | Get Exchange Rate
@return bool|float
@throws \Exception | [
"Get",
"Exchange",
"Rate"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L152-L161 |
44,544 | emartech/magento2-extension | Block/Snippets.php | Snippets.getCurrentProduct | public function getCurrentProduct()
{
try {
$product = $this->coreRegistry->registry('current_product');
if ($product instanceof Product) {
return [
'sku' => $product->getSku(),
'id' => $product->getId(),
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | php | public function getCurrentProduct()
{
try {
$product = $this->coreRegistry->registry('current_product');
if ($product instanceof Product) {
return [
'sku' => $product->getSku(),
'id' => $product->getId(),
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | [
"public",
"function",
"getCurrentProduct",
"(",
")",
"{",
"try",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"coreRegistry",
"->",
"registry",
"(",
"'current_product'",
")",
";",
"if",
"(",
"$",
"product",
"instanceof",
"Product",
")",
"{",
"return",
"[",... | Get Current Product
@return bool|mixed
@throws \Exception | [
"Get",
"Current",
"Product"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L186-L201 |
44,545 | emartech/magento2-extension | Block/Snippets.php | Snippets.getSearchData | public function getSearchData()
{
try {
$q = $this->_request->getParam('q');
if ($q != '') {
return [
'term' => $q,
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | php | public function getSearchData()
{
try {
$q = $this->_request->getParam('q');
if ($q != '') {
return [
'term' => $q,
];
}
} catch (\Exception $e) {
throw $e;
}
return false;
} | [
"public",
"function",
"getSearchData",
"(",
")",
"{",
"try",
"{",
"$",
"q",
"=",
"$",
"this",
"->",
"_request",
"->",
"getParam",
"(",
"'q'",
")",
";",
"if",
"(",
"$",
"q",
"!=",
"''",
")",
"{",
"return",
"[",
"'term'",
"=>",
"$",
"q",
",",
"]"... | Get Search Data
@return bool|mixed
@throws \Exception | [
"Get",
"Search",
"Data"
] | 6e3167fcc24894e3caa45cd2567cadd8d0005e17 | https://github.com/emartech/magento2-extension/blob/6e3167fcc24894e3caa45cd2567cadd8d0005e17/Block/Snippets.php#L209-L222 |
44,546 | bheisig/i-doit-api-client-php | src/CMDBObjectTypeCategories.php | CMDBObjectTypeCategories.batchReadByID | public function batchReadByID(array $objectTypeIDs) {
$requests = [];
foreach ($objectTypeIDs as $objectTypeID) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeID
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchReadByID(array $objectTypeIDs) {
$requests = [];
foreach ($objectTypeIDs as $objectTypeID) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeID
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchReadByID",
"(",
"array",
"$",
"objectTypeIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectTypeIDs",
"as",
"$",
"objectTypeID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
... | Fetches assigned categories for one or more objects types at once identified by their identifiers
@param array $objectTypeIDs List of object types identifiers as integers
@return array
@throws Exception on error | [
"Fetches",
"assigned",
"categories",
"for",
"one",
"or",
"more",
"objects",
"types",
"at",
"once",
"identified",
"by",
"their",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjectTypeCategories.php#L79-L92 |
44,547 | bheisig/i-doit-api-client-php | src/CMDBObjectTypeCategories.php | CMDBObjectTypeCategories.batchReadByConst | public function batchReadByConst(array $objectTypeConsts) {
$requests = [];
foreach ($objectTypeConsts as $objectTypeConst) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeConst
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchReadByConst(array $objectTypeConsts) {
$requests = [];
foreach ($objectTypeConsts as $objectTypeConst) {
$requests[] = [
'method' => 'cmdb.object_type_categories.read',
'params' => [
'type' => $objectTypeConst
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchReadByConst",
"(",
"array",
"$",
"objectTypeConsts",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectTypeConsts",
"as",
"$",
"objectTypeConst",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'"... | Fetches assigned categories for one or more objects types at once identified by their constants
@param array $objectTypeConsts List of object types constants as strings
@return array Result
@throws Exception on error | [
"Fetches",
"assigned",
"categories",
"for",
"one",
"or",
"more",
"objects",
"types",
"at",
"once",
"identified",
"by",
"their",
"constants"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObjectTypeCategories.php#L103-L116 |
44,548 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.save | public function save($objectID, $categoryConstant, array $attributes, $entryID = null) {
$params = [
'object' => $objectID,
'data' => $attributes,
'category' => $categoryConstant
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.save',
$params
);
if (!array_key_exists('entry', $result) ||
!is_int($result['entry']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $result['entry'];
} | php | public function save($objectID, $categoryConstant, array $attributes, $entryID = null) {
$params = [
'object' => $objectID,
'data' => $attributes,
'category' => $categoryConstant
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.save',
$params
);
if (!array_key_exists('entry', $result) ||
!is_int($result['entry']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $result['entry'];
} | [
"public",
"function",
"save",
"(",
"$",
"objectID",
",",
"$",
"categoryConstant",
",",
"array",
"$",
"attributes",
",",
"$",
"entryID",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'data'",
"=>",
"$",
"attrib... | Create new or update existing category entry for a specific object
Suitable for single- and multi-value categories
@param int $objectID Object identifier
@param string $categoryConstant Category constant
@param array $attributes Attributes as key-value pairs
@param int $entryID Entry identifier (only needed for multi-valued categories)
@return int Entry identifier
@throws Exception on error | [
"Create",
"new",
"or",
"update",
"existing",
"category",
"entry",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L49-L77 |
44,549 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.create | public function create($objectID, $categoryConst, array $attributes) {
$params = [
'objID' => $objectID,
'data' => $attributes,
'category' => $categoryConst
];
$result = $this->api->request(
'cmdb.category.create',
$params
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | php | public function create($objectID, $categoryConst, array $attributes) {
$params = [
'objID' => $objectID,
'data' => $attributes,
'category' => $categoryConst
];
$result = $this->api->request(
'cmdb.category.create',
$params
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | [
"public",
"function",
"create",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"params",
"=",
"[",
"'objID'",
"=>",
"$",
"objectID",
",",
"'data'",
"=>",
"$",
"attributes",
",",
"'category'",
"=>",
"$",
... | Create new category entry for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param array $attributes Attributes as key-value pairs
@return int Entry identifier
@throws Exception on error | [
"Create",
"new",
"category",
"entry",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L90-L114 |
44,550 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.update | public function update($objectID, $categoryConst, array $attributes, $entryID = null) {
if (isset($entryID)) {
$attributes['category_id'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.update',
[
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function update($objectID, $categoryConst, array $attributes, $entryID = null) {
if (isset($entryID)) {
$attributes['category_id'] = $entryID;
}
$result = $this->api->request(
'cmdb.category.update',
[
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
",",
"$",
"entryID",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"entryID",
")",
")",
"{",
"$",
"attributes",
"[",
"'category_id'... | Update category entry for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param array $attributes Attributes as key-value pairs
@param int $entryID Entry identifier (only needed for multi-value categories)
@return self Returns itself
@throws Exception on error | [
"Update",
"category",
"entry",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L220-L244 |
44,551 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.archive | public function archive($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.archive',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | php | public function archive($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.archive',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | [
"public",
"function",
"archive",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.archive'",
",",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>"... | Archive entry in a multi-value category for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Archive",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L257-L268 |
44,552 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.delete | public function delete($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.delete',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | php | public function delete($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.delete',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.delete'",
",",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>",
... | Marks entry in a multi-value category for a specific object as deleted
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Marks",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object",
"as",
"deleted"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L281-L292 |
44,553 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.purge | public function purge($objectID, $categoryConst, $entryID = null) {
$params = [
'object' => $objectID,
'category' => $categoryConst
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$this->api->request(
'cmdb.category.purge',
$params
);
return $this;
} | php | public function purge($objectID, $categoryConst, $entryID = null) {
$params = [
'object' => $objectID,
'category' => $categoryConst
];
if (isset($entryID)) {
$params['entry'] = $entryID;
}
$this->api->request(
'cmdb.category.purge',
$params
);
return $this;
} | [
"public",
"function",
"purge",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>",
"$",
"categoryConst",
"]",
";",
"if",
"(",
... | Purge entry in a single- or multi-value category for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier (only needed for multi-value categories)
@return self Returns itself
@throws Exception on error | [
"Purge",
"entry",
"in",
"a",
"single",
"-",
"or",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L305-L321 |
44,554 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.recycle | public function recycle($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.recycle',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | php | public function recycle($objectID, $categoryConst, $entryID) {
$this->api->request(
'cmdb.category.recycle',
[
'object' => $objectID,
'category' => $categoryConst,
'entry' => $entryID
]
);
return $this;
} | [
"public",
"function",
"recycle",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.recycle'",
",",
"[",
"'object'",
"=>",
"$",
"objectID",
",",
"'category'",
"=>"... | Restore entry in a multi-value category for a specific object to "normal" state
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Restore",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object",
"to",
"normal",
"state"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L334-L345 |
44,555 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.quickPurge | public function quickPurge($objectID, $categoryConst, $entryID) {
$result = $this->api->request(
'cmdb.category.quickpurge',
[
'objID' => $objectID,
'category' => $categoryConst,
'cateID' => $entryID
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function quickPurge($objectID, $categoryConst, $entryID) {
$result = $this->api->request(
'cmdb.category.quickpurge',
[
'objID' => $objectID,
'category' => $categoryConst,
'cateID' => $entryID
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"quickPurge",
"(",
"$",
"objectID",
",",
"$",
"categoryConst",
",",
"$",
"entryID",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.category.quickpurge'",
",",
"[",
"'objID'",
"=>",
"$",
"objectID"... | Purge entry in a multi-value category for a specific object
@param int $objectID Object identifier
@param string $categoryConst Category constant
@param int $entryID Entry identifier
@return self Returns itself
@throws Exception on error | [
"Purge",
"entry",
"in",
"a",
"multi",
"-",
"value",
"category",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L358-L378 |
44,556 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.batchCreate | public function batchCreate(array $objectIDs, $categoryConst, array $attributes) {
$entryIDs = [];
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($attributes as $data) {
$params = [
'objID' => $objectID,
'data' => $data,
'category' => $categoryConst
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => $params
];
}
}
$result = $this->api->batchRequest($requests);
foreach ($result as $entry) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $entry) ||
$entry['success'] !== true) {
if (array_key_exists('message', $entry)) {
throw new RuntimeException(sprintf('Bad result: %s', $entry['message']));
} else {
throw new RuntimeException('Bad result');
}
}
$entryIDs[] = (int) $entry['id'];
}
return $entryIDs;
} | php | public function batchCreate(array $objectIDs, $categoryConst, array $attributes) {
$entryIDs = [];
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($attributes as $data) {
$params = [
'objID' => $objectID,
'data' => $data,
'category' => $categoryConst
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => $params
];
}
}
$result = $this->api->batchRequest($requests);
foreach ($result as $entry) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $entry) ||
$entry['success'] !== true) {
if (array_key_exists('message', $entry)) {
throw new RuntimeException(sprintf('Bad result: %s', $entry['message']));
} else {
throw new RuntimeException('Bad result');
}
}
$entryIDs[] = (int) $entry['id'];
}
return $entryIDs;
} | [
"public",
"function",
"batchCreate",
"(",
"array",
"$",
"objectIDs",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"entryIDs",
"=",
"[",
"]",
";",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",... | Create multiple entries for a specific category and one or more objects
@param array $objectIDs List of object identifiers as integers
@param string $categoryConst Category constant
@param array $attributes Indexed array of attributes as key-value pairs
@return array List of entry identifiers as integers
@throws Exception on error | [
"Create",
"multiple",
"entries",
"for",
"a",
"specific",
"category",
"and",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L391-L428 |
44,557 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.batchRead | public function batchRead(array $objectIDs, array $categoryConsts, $status = 2) {
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($categoryConsts as $categoryConst) {
$requests[] = [
'method' => 'cmdb.category.read',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'status' => $status
]
];
}
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $objectIDs, array $categoryConsts, $status = 2) {
$requests = [];
foreach ($objectIDs as $objectID) {
foreach ($categoryConsts as $categoryConst) {
$requests[] = [
'method' => 'cmdb.category.read',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'status' => $status
]
];
}
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"objectIDs",
",",
"array",
"$",
"categoryConsts",
",",
"$",
"status",
"=",
"2",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"f... | Read one or more category entries for one or more objects
@param array $objectIDs List of object identifiers as integers
@param array $categoryConsts List of category constants as strings
@param int $status Filter entries by status:
2 = normal;
3 = archived;
4 = deleted,
-1 = combination of all;
defaults to: 2 = normal;
note: a status != 2 is only suitable for multi-value categories
@return array Indexed array of result sets (for both single- and multi-valued categories)
@throws Exception on error | [
"Read",
"one",
"or",
"more",
"category",
"entries",
"for",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L447-L464 |
44,558 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.batchUpdate | public function batchUpdate(array $objectIDs, $categoryConst, array $attributes) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.category.update',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
];
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | php | public function batchUpdate(array $objectIDs, $categoryConst, array $attributes) {
$requests = [];
foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.category.update',
'params' => [
'objID' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
];
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | [
"public",
"function",
"batchUpdate",
"(",
"array",
"$",
"objectIDs",
",",
"$",
"categoryConst",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"$",
"req... | Update single-value category for one or more objects
@param array $objectIDs List of object identifiers as integers
@param string $categoryConst Category constant
@param array $attributes Attributes as key-value pairs
@return self Returns itself
@throws Exception on error | [
"Update",
"single",
"-",
"value",
"category",
"for",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L477-L505 |
44,559 | bheisig/i-doit-api-client-php | src/CMDBCategory.php | CMDBCategory.clear | public function clear($objectID, array $categoryConsts) {
$batch = $this->batchRead([$objectID], $categoryConsts);
$requests = [];
$counter = 0;
$index = 0;
foreach ($batch as $entries) {
$categoryConst = $categoryConsts[$index];
foreach ($entries as $entry) {
$requests[] = [
'method' => 'cmdb.category.archive',
'params' => [
'object' => $objectID,
'category' => $categoryConst,
'entry' => (int) $entry['id']
]
];
$counter++;
}
$index++;
}
if ($counter === 0) {
return 0;
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $counter;
} | php | public function clear($objectID, array $categoryConsts) {
$batch = $this->batchRead([$objectID], $categoryConsts);
$requests = [];
$counter = 0;
$index = 0;
foreach ($batch as $entries) {
$categoryConst = $categoryConsts[$index];
foreach ($entries as $entry) {
$requests[] = [
'method' => 'cmdb.category.archive',
'params' => [
'object' => $objectID,
'category' => $categoryConst,
'entry' => (int) $entry['id']
]
];
$counter++;
}
$index++;
}
if ($counter === 0) {
return 0;
}
$results = $this->api->batchRequest($requests);
foreach ($results as $result) {
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $counter;
} | [
"public",
"function",
"clear",
"(",
"$",
"objectID",
",",
"array",
"$",
"categoryConsts",
")",
"{",
"$",
"batch",
"=",
"$",
"this",
"->",
"batchRead",
"(",
"[",
"$",
"objectID",
"]",
",",
"$",
"categoryConsts",
")",
";",
"$",
"requests",
"=",
"[",
"]... | Archive category entries for a specific object
@param int $objectID Object identifier
@param array $categoryConsts List of category constants as strings
@return int Number of purged category entries
@throws Exception on error | [
"Archive",
"category",
"entries",
"for",
"a",
"specific",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategory.php#L517-L561 |
44,560 | bheisig/i-doit-api-client-php | src/CMDBImpact.php | CMDBImpact.readByID | public function readByID($objectID, $relationType, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationType
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | php | public function readByID($objectID, $relationType, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationType
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | [
"public",
"function",
"readByID",
"(",
"$",
"objectID",
",",
"$",
"relationType",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
",",
"'relation_type'",
"=>",
"$",
"relationType",
"]",
";",
"if",
"(",... | Perform an impact analysis for a specific object by its relation type identifier
@param int $objectID Object identifier
@param int $relationType Relation type identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Perform",
"an",
"impact",
"analysis",
"for",
"a",
"specific",
"object",
"by",
"its",
"relation",
"type",
"identifier"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBImpact.php#L45-L59 |
44,561 | bheisig/i-doit-api-client-php | src/CMDBImpact.php | CMDBImpact.readByTypes | public function readByTypes($objectID, array $relationTypes, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationTypes
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | php | public function readByTypes($objectID, array $relationTypes, $status = null) {
$params = [
'id' => $objectID,
'relation_type' => $relationTypes
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.impact.read',
$params
);
} | [
"public",
"function",
"readByTypes",
"(",
"$",
"objectID",
",",
"array",
"$",
"relationTypes",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
",",
"'relation_type'",
"=>",
"$",
"relationTypes",
"]",
";"... | Perform an impact analysis for a specific object by one ore more relation type constant or identifiers
@param int $objectID Object identifier
@param array $relationTypes List of relation type constants as strings or identifiers as integers
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Perform",
"an",
"impact",
"analysis",
"for",
"a",
"specific",
"object",
"by",
"one",
"ore",
"more",
"relation",
"type",
"constant",
"or",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBImpact.php#L99-L113 |
44,562 | bheisig/i-doit-api-client-php | src/Select.php | Select.find | public function find($category, $attribute, $value) {
$cmdbObjects = new CMDBObjects($this->api);
$limit = 100;
$offset = 0;
$objectIDs = [];
while (true) {
$objects = $cmdbObjects->read([], $limit, $offset);
$count = count($objects);
if ($count === 0) {
break;
}
foreach ($objects as $object) {
$objectIDs[] = (int)$object['id'];
}
unset($objects);
$cmdbCategory = new CMDBCategory($this->api);
$result = $cmdbCategory->batchRead(
$objectIDs,
[$category]
);
$objectIDs = [];
foreach ($result as $categoryEntries) {
foreach ($categoryEntries as $categoryEntry) {
if (!array_key_exists($attribute, $categoryEntry)) {
continue;
}
$found = false;
if (is_array($categoryEntry[$attribute]) &&
array_key_exists('ref_title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['ref_title'] === $value
) {
$found = true;
} elseif (is_array($categoryEntry[$attribute]) &&
array_key_exists('title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['title'] === $value
) {
$found = true;
} elseif (is_numeric($categoryEntry[$attribute]) &&
is_int($value) &&
(int)$categoryEntry[$attribute] === $value
) {
$found = true;
} elseif (is_string($categoryEntry[$attribute]) &&
is_string($value) &&
$categoryEntry[$attribute] === $value
) {
$found = true;
}
if ($found === false) {
continue;
}
if (!array_key_exists('objID', $categoryEntry)) {
throw new RuntimeException('Found attribute for unknown object');
}
$objectIDs[] = (int)$categoryEntry['objID'];
}
}
if ($count < $limit) {
break;
}
$offset += $limit;
}
return $objectIDs;
} | php | public function find($category, $attribute, $value) {
$cmdbObjects = new CMDBObjects($this->api);
$limit = 100;
$offset = 0;
$objectIDs = [];
while (true) {
$objects = $cmdbObjects->read([], $limit, $offset);
$count = count($objects);
if ($count === 0) {
break;
}
foreach ($objects as $object) {
$objectIDs[] = (int)$object['id'];
}
unset($objects);
$cmdbCategory = new CMDBCategory($this->api);
$result = $cmdbCategory->batchRead(
$objectIDs,
[$category]
);
$objectIDs = [];
foreach ($result as $categoryEntries) {
foreach ($categoryEntries as $categoryEntry) {
if (!array_key_exists($attribute, $categoryEntry)) {
continue;
}
$found = false;
if (is_array($categoryEntry[$attribute]) &&
array_key_exists('ref_title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['ref_title'] === $value
) {
$found = true;
} elseif (is_array($categoryEntry[$attribute]) &&
array_key_exists('title', $categoryEntry[$attribute]) &&
$categoryEntry[$attribute]['title'] === $value
) {
$found = true;
} elseif (is_numeric($categoryEntry[$attribute]) &&
is_int($value) &&
(int)$categoryEntry[$attribute] === $value
) {
$found = true;
} elseif (is_string($categoryEntry[$attribute]) &&
is_string($value) &&
$categoryEntry[$attribute] === $value
) {
$found = true;
}
if ($found === false) {
continue;
}
if (!array_key_exists('objID', $categoryEntry)) {
throw new RuntimeException('Found attribute for unknown object');
}
$objectIDs[] = (int)$categoryEntry['objID'];
}
}
if ($count < $limit) {
break;
}
$offset += $limit;
}
return $objectIDs;
} | [
"public",
"function",
"find",
"(",
"$",
"category",
",",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"cmdbObjects",
"=",
"new",
"CMDBObjects",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"limit",
"=",
"100",
";",
"$",
"offset",
"=",
"0",
... | Find objects by attribute
@param string $category
@param string $attribute
@param mixed $value
@return array List of object identifiers as integers
@throws Exception on error | [
"Find",
"objects",
"by",
"attribute"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Select.php#L46-L128 |
44,563 | bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.createUNIXSocketConnection | public function createUNIXSocketConnection($title, $path, $active = true) {
$result = $this->api->request(
'monitoring.livestatus.create',
[
'data' => [
'connection' => 'unix',
'title' => $title,
'path' => $path,
'active' => $active
]
]
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | php | public function createUNIXSocketConnection($title, $path, $active = true) {
$result = $this->api->request(
'monitoring.livestatus.create',
[
'data' => [
'connection' => 'unix',
'title' => $title,
'path' => $path,
'active' => $active
]
]
);
if (!array_key_exists('id', $result) ||
!is_numeric($result['id']) ||
!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return (int) $result['id'];
} | [
"public",
"function",
"createUNIXSocketConnection",
"(",
"$",
"title",
",",
"$",
"path",
",",
"$",
"active",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.create'",
",",
"[",
"'data'",
"=... | Add a new monitoring instance listening on a UNIX socket
@param string $title Title
@param string $path Path to UNIX socket
@param bool $active Enable this instance? Defaults to true
@return int Identifier
@throws Exception on error | [
"Add",
"a",
"new",
"monitoring",
"instance",
"listening",
"on",
"a",
"UNIX",
"socket"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L86-L111 |
44,564 | bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.update | public function update($id, array $attributes) {
$result = $this->api->request(
'monitoring.livestatus.update',
[
'id' => $id,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function update($id, array $attributes) {
$result = $this->api->request(
'monitoring.livestatus.update',
[
'id' => $id,
'data' => $attributes
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.update'",
",",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'data'",
"=>",
"$"... | Update a monitoring instance by its identifier
@param int $id Identifier
@param array $attributes Attributes which can be altered:
"title", "connection", "address", "port", "path" and "active"
@return self Returns itself
@throws Exception on error | [
"Update",
"a",
"monitoring",
"instance",
"by",
"its",
"identifier"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L191-L210 |
44,565 | bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.deleteByID | public function deleteByID($id) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'id' => $id
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function deleteByID($id) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'id' => $id
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"deleteByID",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.delete'",
",",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(... | Delete a monitoring instance by its identifier
@param int $id Identifier
@return self Returns itself
@throws Exception on error | [
"Delete",
"a",
"monitoring",
"instance",
"by",
"its",
"identifier"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L221-L239 |
44,566 | bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.deleteByTitle | public function deleteByTitle($title) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'title' => $title
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | php | public function deleteByTitle($title) {
$result = $this->api->request(
'monitoring.livestatus.delete',
[
'title' => $title
]
);
if (!array_key_exists('success', $result) ||
$result['success'] !== true) {
if (array_key_exists('message', $result)) {
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
} else {
throw new RuntimeException('Bad result');
}
}
return $this;
} | [
"public",
"function",
"deleteByTitle",
"(",
"$",
"title",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'monitoring.livestatus.delete'",
",",
"[",
"'title'",
"=>",
"$",
"title",
"]",
")",
";",
"if",
"(",
"!",
"array_key_e... | Delete a monitoring instance by its title
@param string $title Title
@return self Returns itself
@throws Exception on error | [
"Delete",
"a",
"monitoring",
"instance",
"by",
"its",
"title"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L250-L268 |
44,567 | bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.batchDelete | public function batchDelete($ids) {
$requests = [];
foreach ($ids as $id) {
$requests[] = [
'method' => 'monitoring.livestatus.delete',
'params' => [
'id' => $id
]
];
}
$result = $this->api->batchRequest($requests);
foreach ($result as $tag) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $tag) ||
$tag['success'] !== true) {
if (array_key_exists('message', $tag)) {
throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | php | public function batchDelete($ids) {
$requests = [];
foreach ($ids as $id) {
$requests[] = [
'method' => 'monitoring.livestatus.delete',
'params' => [
'id' => $id
]
];
}
$result = $this->api->batchRequest($requests);
foreach ($result as $tag) {
// Do not check 'id' because in a batch request it is always NULL:
if (!array_key_exists('success', $tag) ||
$tag['success'] !== true) {
if (array_key_exists('message', $tag)) {
throw new RuntimeException(sprintf('Bad result: %s', $tag['message']));
} else {
throw new RuntimeException('Bad result');
}
}
}
return $this;
} | [
"public",
"function",
"batchDelete",
"(",
"$",
"ids",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'monitoring.livestatus.delete'",
",",
... | Delete one or more monitoring instances be their identifiers
@param array $ids List of identifiers as integers
@return self Returns itself
@throws Exception on error | [
"Delete",
"one",
"or",
"more",
"monitoring",
"instances",
"be",
"their",
"identifiers"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L279-L306 |
44,568 | bheisig/i-doit-api-client-php | src/MonitoringLivestatus.php | MonitoringLivestatus.deleteAll | public function deleteAll() {
$instances = $this->read();
$ids = [];
foreach ($instances as $instance) {
$ids[] = $instance['id'];
}
if (count($ids) > 0) {
$this->batchDelete($ids);
}
return $this;
} | php | public function deleteAll() {
$instances = $this->read();
$ids = [];
foreach ($instances as $instance) {
$ids[] = $instance['id'];
}
if (count($ids) > 0) {
$this->batchDelete($ids);
}
return $this;
} | [
"public",
"function",
"deleteAll",
"(",
")",
"{",
"$",
"instances",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"instances",
"as",
"$",
"instance",
")",
"{",
"$",
"ids",
"[",
"]",
"=",
"$"... | Delete all monitoring instances
@return self Returns itself
@throws Exception on error | [
"Delete",
"all",
"monitoring",
"instances"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/MonitoringLivestatus.php#L315-L329 |
44,569 | bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.load | public function load($objectID) {
$category = new CMDBCategory($this->api);
$netInfo = $category->read($objectID, 'C__CATS__NET');
if (count($netInfo) !== 1 ||
!array_key_exists(0, $netInfo) ||
!is_array($netInfo[0])) {
throw new RuntimeException(sprintf(
'Nothing found for object identifier %s',
$objectID
));
}
if (!array_key_exists('type', $netInfo[0]) ||
!is_array($netInfo[0]['type']) ||
!array_key_exists('const', $netInfo[0]['type']) ||
!is_string($netInfo[0]['type']['const']) ||
$netInfo[0]['type']['const'] !== 'C__CATS_NET_TYPE__IPV4') {
throw new RuntimeException('Works only for IPv4');
}
if (!array_key_exists('range_from', $netInfo[0]) ||
!is_string($netInfo[0]['range_from']) ||
!array_key_exists('range_to', $netInfo[0]) ||
!is_string($netInfo[0]['range_to'])) {
throw new RuntimeException(sprintf(
'Subnet #%s has no IP address range',
$objectID
));
}
$this->first = $this->convertIPv4Address($netInfo[0]['range_from']);
$this->last = $this->convertIPv4Address($netInfo[0]['range_to']);
$takenIPAddresses = $category->read($objectID, 'C__CATS__NET_IP_ADDRESSES');
foreach ($takenIPAddresses as $takenIPAddress) {
$this->taken[] = $takenIPAddress['title'];
}
$this->current = $this->first;
return $this;
} | php | public function load($objectID) {
$category = new CMDBCategory($this->api);
$netInfo = $category->read($objectID, 'C__CATS__NET');
if (count($netInfo) !== 1 ||
!array_key_exists(0, $netInfo) ||
!is_array($netInfo[0])) {
throw new RuntimeException(sprintf(
'Nothing found for object identifier %s',
$objectID
));
}
if (!array_key_exists('type', $netInfo[0]) ||
!is_array($netInfo[0]['type']) ||
!array_key_exists('const', $netInfo[0]['type']) ||
!is_string($netInfo[0]['type']['const']) ||
$netInfo[0]['type']['const'] !== 'C__CATS_NET_TYPE__IPV4') {
throw new RuntimeException('Works only for IPv4');
}
if (!array_key_exists('range_from', $netInfo[0]) ||
!is_string($netInfo[0]['range_from']) ||
!array_key_exists('range_to', $netInfo[0]) ||
!is_string($netInfo[0]['range_to'])) {
throw new RuntimeException(sprintf(
'Subnet #%s has no IP address range',
$objectID
));
}
$this->first = $this->convertIPv4Address($netInfo[0]['range_from']);
$this->last = $this->convertIPv4Address($netInfo[0]['range_to']);
$takenIPAddresses = $category->read($objectID, 'C__CATS__NET_IP_ADDRESSES');
foreach ($takenIPAddresses as $takenIPAddress) {
$this->taken[] = $takenIPAddress['title'];
}
$this->current = $this->first;
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"objectID",
")",
"{",
"$",
"category",
"=",
"new",
"CMDBCategory",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"netInfo",
"=",
"$",
"category",
"->",
"read",
"(",
"$",
"objectID",
",",
"'C__CATS__NET'",
")",
... | Fetches some information about subnet object
@param int $objectID Object identifier
@return self Returns itself
@throws Exception on error | [
"Fetches",
"some",
"information",
"about",
"subnet",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L73-L116 |
44,570 | bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.hasNext | public function hasNext() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
if ($this->isUsed($ipLong) === false) {
return true;
}
}
return false;
} | php | public function hasNext() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
if ($this->isUsed($ipLong) === false) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasNext",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You need to call method \"load()\" first.'",
")",
";",
"}",
"for",
"(",
"$",
"ipLong",... | Is there a free IP address?
@return bool
@throws Exception on error | [
"Is",
"there",
"a",
"free",
"IP",
"address?"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L125-L137 |
44,571 | bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.next | public function next() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
$this->current = $ipLong;
if ($this->isUsed($ipLong) === false) {
return long2ip($ipLong);
}
}
throw new RuntimeException('No free IP addresses left');
} | php | public function next() {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
for ($ipLong = $this->current; $ipLong <= $this->last; $ipLong++) {
$this->current = $ipLong;
if ($this->isUsed($ipLong) === false) {
return long2ip($ipLong);
}
}
throw new RuntimeException('No free IP addresses left');
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You need to call method \"load()\" first.'",
")",
";",
"}",
"for",
"(",
"$",
"ipLong",
... | Fetches next free IP address
@return string IPv4 address
@throws Exception on error | [
"Fetches",
"next",
"free",
"IP",
"address"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L146-L160 |
44,572 | bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.isFree | public function isFree($ipAddress) {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
$longIP = $this->convertIPv4Address($ipAddress);
return ! $this->isUsed($longIP);
} | php | public function isFree($ipAddress) {
if (!isset($this->current)) {
throw new BadMethodCallException('You need to call method "load()" first.');
}
$longIP = $this->convertIPv4Address($ipAddress);
return ! $this->isUsed($longIP);
} | [
"public",
"function",
"isFree",
"(",
"$",
"ipAddress",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"current",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'You need to call method \"load()\" first.'",
")",
";",
"}",
"$",
"lon... | Is IP address currently unused in subnet?
@param string $ipAddress IPv4 address
@return bool
@throws Exception on error | [
"Is",
"IP",
"address",
"currently",
"unused",
"in",
"subnet?"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L171-L179 |
44,573 | bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.isUsed | protected function isUsed($longIP) {
foreach ($this->taken as $taken) {
$takenIPLong = $this->convertIPv4Address($taken);
if ($takenIPLong === $longIP) {
return true;
}
}
return false;
} | php | protected function isUsed($longIP) {
foreach ($this->taken as $taken) {
$takenIPLong = $this->convertIPv4Address($taken);
if ($takenIPLong === $longIP) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isUsed",
"(",
"$",
"longIP",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"taken",
"as",
"$",
"taken",
")",
"{",
"$",
"takenIPLong",
"=",
"$",
"this",
"->",
"convertIPv4Address",
"(",
"$",
"taken",
")",
";",
"if",
"(",
"$",
... | Is IP address already taken in subnet?
@param int $longIP IPv4 address converted to long integer
@return bool
@throws Exception on error | [
"Is",
"IP",
"address",
"already",
"taken",
"in",
"subnet?"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L190-L200 |
44,574 | bheisig/i-doit-api-client-php | src/Subnet.php | Subnet.convertIPv4Address | protected function convertIPv4Address($ipv4Address) {
$longIP = ip2long($ipv4Address);
if (!is_int($longIP)) {
throw new RuntimeException(sprintf(
'Unable to convert IP address "%s"',
$ipv4Address
));
}
return $longIP;
} | php | protected function convertIPv4Address($ipv4Address) {
$longIP = ip2long($ipv4Address);
if (!is_int($longIP)) {
throw new RuntimeException(sprintf(
'Unable to convert IP address "%s"',
$ipv4Address
));
}
return $longIP;
} | [
"protected",
"function",
"convertIPv4Address",
"(",
"$",
"ipv4Address",
")",
"{",
"$",
"longIP",
"=",
"ip2long",
"(",
"$",
"ipv4Address",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"longIP",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"spr... | Convert IPv4 address to integer
@param string $ipv4Address IPv4 address
@return int
@throws Exception on error | [
"Convert",
"IPv4",
"address",
"to",
"integer"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Subnet.php#L211-L222 |
44,575 | bheisig/i-doit-api-client-php | src/Image.php | Image.add | public function add($objectID, $filePath, $caption = '') {
$imageAsString = $this->encode($filePath);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$objectID,
'C__CATG__IMAGES',
[
'name' => $caption,
'content' => $imageAsString
]
);
return $this;
} | php | public function add($objectID, $filePath, $caption = '') {
$imageAsString = $this->encode($filePath);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$objectID,
'C__CATG__IMAGES',
[
'name' => $caption,
'content' => $imageAsString
]
);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"objectID",
",",
"$",
"filePath",
",",
"$",
"caption",
"=",
"''",
")",
"{",
"$",
"imageAsString",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"filePath",
")",
";",
"$",
"cmdbCategory",
"=",
"new",
"CMDBCategory",
... | Add a new file to the image gallery.
@param int $objectID Object identifier
@param string $filePath Path to image file
@param string $caption (Optional) caption
@return self Returns itself
@throws Exception on error | [
"Add",
"a",
"new",
"file",
"to",
"the",
"image",
"gallery",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Image.php#L47-L62 |
44,576 | bheisig/i-doit-api-client-php | src/Image.php | Image.batchAdd | public function batchAdd($objectID, array $images) {
$objectIDs = [$objectID];
$categoryConst = 'C__CATG__IMAGES';
$attributes = [];
foreach ($images as $filePath => $caption) {
$imageAsString = $this->encode($filePath);
$attributes[] = [
'name' => $caption,
'content' => $imageAsString
];
}
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->batchCreate($objectIDs, $categoryConst, $attributes);
return $this;
} | php | public function batchAdd($objectID, array $images) {
$objectIDs = [$objectID];
$categoryConst = 'C__CATG__IMAGES';
$attributes = [];
foreach ($images as $filePath => $caption) {
$imageAsString = $this->encode($filePath);
$attributes[] = [
'name' => $caption,
'content' => $imageAsString
];
}
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->batchCreate($objectIDs, $categoryConst, $attributes);
return $this;
} | [
"public",
"function",
"batchAdd",
"(",
"$",
"objectID",
",",
"array",
"$",
"images",
")",
"{",
"$",
"objectIDs",
"=",
"[",
"$",
"objectID",
"]",
";",
"$",
"categoryConst",
"=",
"'C__CATG__IMAGES'",
";",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
... | Add new files to the image gallery.
@param int $objectID Object identifier
@param array $images Associative array (key: path to image file; value: caption)
@return self Returns itself
@throws Exception on error | [
"Add",
"new",
"files",
"to",
"the",
"image",
"gallery",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/Image.php#L74-L93 |
44,577 | bheisig/i-doit-api-client-php | src/File.php | File.add | public function add($objectID, $filePath, $description = '') {
$fileAsString = $this->encode($filePath);
$cmdbObject = new CMDBObject($this->api);
$fileObjectID = $cmdbObject->create(
'C__OBJTYPE__FILE',
$description
);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$fileObjectID,
'C__CATS__FILE_VERSIONS',
[
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
);
$cmdbCategory->create(
$objectID,
'C__CATG__FILE',
[
'file' => $fileObjectID
]
);
return $this;
} | php | public function add($objectID, $filePath, $description = '') {
$fileAsString = $this->encode($filePath);
$cmdbObject = new CMDBObject($this->api);
$fileObjectID = $cmdbObject->create(
'C__OBJTYPE__FILE',
$description
);
$cmdbCategory = new CMDBCategory($this->api);
$cmdbCategory->create(
$fileObjectID,
'C__CATS__FILE_VERSIONS',
[
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
);
$cmdbCategory->create(
$objectID,
'C__CATG__FILE',
[
'file' => $fileObjectID
]
);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"objectID",
",",
"$",
"filePath",
",",
"$",
"description",
"=",
"''",
")",
"{",
"$",
"fileAsString",
"=",
"$",
"this",
"->",
"encode",
"(",
"$",
"filePath",
")",
";",
"$",
"cmdbObject",
"=",
"new",
"CMDBObject",
... | Add a new file to a specific object. A new file object will be created and assigned to the specific object.
@param int $objectID Object identifier
@param string $filePath Path to file
@param string $description (Optional) description
@return self Returns itself
@throws Exception on error | [
"Add",
"a",
"new",
"file",
"to",
"a",
"specific",
"object",
".",
"A",
"new",
"file",
"object",
"will",
"be",
"created",
"and",
"assigned",
"to",
"the",
"specific",
"object",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/File.php#L47-L79 |
44,578 | bheisig/i-doit-api-client-php | src/File.php | File.batchAdd | public function batchAdd($objectID, array $files) {
$objects = [];
foreach ($files as $description) {
$objects[] = [
'type' => 'C__OBJTYPE__FILE',
'title' => $description
];
}
$cmdbObjects = new CMDBObjects($this->api);
$fileObjectIDs = $cmdbObjects->create($objects);
if (count($fileObjectIDs) !== count($files)) {
throw new RuntimeException(sprintf(
'Wanted to create %s file object(s) but got %s object identifiers',
count($files),
count($fileObjectIDs)
));
}
$requests = [];
$counter = 0;
foreach ($files as $filePath => $description) {
$fileAsString = $this->encode($filePath);
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $fileObjectIDs[$counter],
'catsID' => 'C__CATS__FILE_VERSIONS',
'data' => [
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
]
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $objectID,
'catgID' => 'C__CATG__FILE',
'data' => [
'file' => $fileObjectIDs[$counter]
]
]
];
$counter++;
}
$this->api->batchRequest($requests);
return $this;
} | php | public function batchAdd($objectID, array $files) {
$objects = [];
foreach ($files as $description) {
$objects[] = [
'type' => 'C__OBJTYPE__FILE',
'title' => $description
];
}
$cmdbObjects = new CMDBObjects($this->api);
$fileObjectIDs = $cmdbObjects->create($objects);
if (count($fileObjectIDs) !== count($files)) {
throw new RuntimeException(sprintf(
'Wanted to create %s file object(s) but got %s object identifiers',
count($files),
count($fileObjectIDs)
));
}
$requests = [];
$counter = 0;
foreach ($files as $filePath => $description) {
$fileAsString = $this->encode($filePath);
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $fileObjectIDs[$counter],
'catsID' => 'C__CATS__FILE_VERSIONS',
'data' => [
'file_content' => $fileAsString,
'file_physical' => basename($filePath),
'file_title' => $description,
'version_description' => $description
]
]
];
$requests[] = [
'method' => 'cmdb.category.create',
'params' => [
'objID' => $objectID,
'catgID' => 'C__CATG__FILE',
'data' => [
'file' => $fileObjectIDs[$counter]
]
]
];
$counter++;
}
$this->api->batchRequest($requests);
return $this;
} | [
"public",
"function",
"batchAdd",
"(",
"$",
"objectID",
",",
"array",
"$",
"files",
")",
"{",
"$",
"objects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"description",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"[",
"'type'",
"=>",
... | Add multiple new files to a specific object.
New file objects will be created and assigned to the specific object.
@param int $objectID Object identifier
@param array $files Associative array (key: path to file; value: description)
@return self Returns itself
@throws Exception on error | [
"Add",
"multiple",
"new",
"files",
"to",
"a",
"specific",
"object",
".",
"New",
"file",
"objects",
"will",
"be",
"created",
"and",
"assigned",
"to",
"the",
"specific",
"object",
"."
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/File.php#L92-L152 |
44,579 | bheisig/i-doit-api-client-php | src/File.php | File.encode | public function encode($filePath) {
if (!file_exists($filePath) ||
!is_readable($filePath)) {
throw new BadMethodCallException(sprintf(
'File "%s" not found or not readable',
$filePath
));
}
$fileContent = file_get_contents($filePath);
if (!is_string($fileContent)) {
throw new RuntimeException(sprintf(
'Unable to read from file "%s"',
$filePath
));
}
$fileAsString = base64_encode($fileContent);
return $fileAsString;
} | php | public function encode($filePath) {
if (!file_exists($filePath) ||
!is_readable($filePath)) {
throw new BadMethodCallException(sprintf(
'File "%s" not found or not readable',
$filePath
));
}
$fileContent = file_get_contents($filePath);
if (!is_string($fileContent)) {
throw new RuntimeException(sprintf(
'Unable to read from file "%s"',
$filePath
));
}
$fileAsString = base64_encode($fileContent);
return $fileAsString;
} | [
"public",
"function",
"encode",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filePath",
")",
"||",
"!",
"is_readable",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"sprintf",
"(",
"'File... | Encode an file to base64
@param string $filePath Path to file
@return string Base64 encoded string
@throws Exception on error | [
"Encode",
"an",
"file",
"to",
"base64"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/File.php#L163-L184 |
44,580 | bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.create | public function create($type, $title, array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
$result = $this->api->request(
'cmdb.object.create',
$attributes
);
if (array_key_exists('id', $result)) {
return $result['id'];
} else {
throw new RuntimeException('Unable to create object');
}
} | php | public function create($type, $title, array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
$result = $this->api->request(
'cmdb.object.create',
$attributes
);
if (array_key_exists('id', $result)) {
return $result['id'];
} else {
throw new RuntimeException('Unable to create object');
}
} | [
"public",
"function",
"create",
"(",
"$",
"type",
",",
"$",
"title",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"attributes",
"[",
"'title'",
"]",
"=",
"$",
"title",
... | Create new object
@param int|string $type Object type identifier or its constant
@param string $title Object title
@param array $attributes (Optional) additional common attributes:
string|int "category",
string|int "cmdb_status",
0|1 "defaultTemplate",
string "description",
string|int "purpose",
int "status",
string "sysid"
@return int Object identifier
@throws Exception on error | [
"Create",
"new",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L53-L67 |
44,581 | bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.createWithCategories | public function createWithCategories($type, $title, array $categories = [], array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
if (count($categories) > 0) {
$attributes['categories'] = $categories;
}
return $this->api->request(
'cmdb.object.create',
$attributes
);
} | php | public function createWithCategories($type, $title, array $categories = [], array $attributes = []) {
$attributes['type'] = $type;
$attributes['title'] = $title;
if (count($categories) > 0) {
$attributes['categories'] = $categories;
}
return $this->api->request(
'cmdb.object.create',
$attributes
);
} | [
"public",
"function",
"createWithCategories",
"(",
"$",
"type",
",",
"$",
"title",
",",
"array",
"$",
"categories",
"=",
"[",
"]",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",... | Create new object with category entries
@param int|string $type Object type identifier or its constant
@param string $title Object title
@param array $categories Also create category entries;
set category constant (string) as key and
one (array of attributes) entry or even several entries (array of arrays) as value
@param array $attributes (Optional) additional common attributes:
string|int "category",
string|int "cmdb_status",
0|1 "defaultTemplate",
string "description",
string|int "purpose",
int "status",
string "sysid"
@return array Result with object identifier ('id') and
key-value pairs of category constants and array of category entry identifiers as integers
@throws Exception on error | [
"Create",
"new",
"object",
"with",
"category",
"entries"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L91-L103 |
44,582 | bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.update | public function update($objectID, array $attributes = []) {
$params = [
'id' => $objectID
];
$supportedAttributes = [
'title'
];
foreach ($supportedAttributes as $supportedAttribute) {
if (array_key_exists($supportedAttribute, $attributes)) {
$params[$supportedAttribute] = $attributes[$supportedAttribute];
}
}
$result = $this->api->request(
'cmdb.object.update',
$params
);
if (!is_array($result) ||
!array_key_exists('success', $result) ||
$result['success'] === false) {
throw new RuntimeException(sprintf(
'Unable to archive object %s',
$objectID
));
}
return $this;
} | php | public function update($objectID, array $attributes = []) {
$params = [
'id' => $objectID
];
$supportedAttributes = [
'title'
];
foreach ($supportedAttributes as $supportedAttribute) {
if (array_key_exists($supportedAttribute, $attributes)) {
$params[$supportedAttribute] = $attributes[$supportedAttribute];
}
}
$result = $this->api->request(
'cmdb.object.update',
$params
);
if (!is_array($result) ||
!array_key_exists('success', $result) ||
$result['success'] === false) {
throw new RuntimeException(sprintf(
'Unable to archive object %s',
$objectID
));
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"objectID",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
"]",
";",
"$",
"supportedAttributes",
"=",
"[",
"'title'",
"]",
";",
"foreach",
"(... | Update existing object
@param int $objectID Object identifier
@param array $attributes (Optional) common attributes (only 'title' is supported at the moment)
@return self Returns itself
@throws Exception on error | [
"Update",
"existing",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L130-L160 |
44,583 | bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.load | public function load($objectID) {
$object = $this->read($objectID);
if (count($object) === 0) {
throw new RuntimeException('Object not found');
}
if (!array_key_exists('objecttype', $object)) {
throw new RuntimeException(sprintf(
'Object %s has no type',
$objectID
));
}
$cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);
$object += $cmdbObjectTypeCategories->readByID(
$object['objecttype']
);
$cmdbCategory = new CMDBCategory($this->api);
$categoryTypes = ['catg', 'cats', 'custom'];
$cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
$blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();
foreach ($categoryTypes as $categoryType) {
if (!array_key_exists($categoryType, $object)) {
continue;
}
$categoryConstants = [];
for ($i = 0; $i < count($object[$categoryType]); $i++) {
if (!array_key_exists('const', $object[$categoryType][$i])) {
throw new RuntimeException(
'Information about categories is broken. Constant is missing.'
);
}
$categoryConstant = $object[$categoryType][$i]['const'];
if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
continue;
}
$object[$categoryType][$i]['entries'] = [];
$categoryConstants[] = $categoryConstant;
}
$categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);
for ($i = 0; $i < count($categoryConstants); $i++) {
$index = -1;
$entries = [];
foreach ($object[$categoryType] as $key => $category) {
if ($category['const'] === $categoryConstants[$i]) {
$index = $key;
$entries = $categoryEntries[$i];
break;
}
}
$object[$categoryType][$index]['entries'] = $entries;
}
}
return $object;
} | php | public function load($objectID) {
$object = $this->read($objectID);
if (count($object) === 0) {
throw new RuntimeException('Object not found');
}
if (!array_key_exists('objecttype', $object)) {
throw new RuntimeException(sprintf(
'Object %s has no type',
$objectID
));
}
$cmdbObjectTypeCategories = new CMDBObjectTypeCategories($this->api);
$object += $cmdbObjectTypeCategories->readByID(
$object['objecttype']
);
$cmdbCategory = new CMDBCategory($this->api);
$categoryTypes = ['catg', 'cats', 'custom'];
$cmdbCategoryInfo = new CMDBCategoryInfo($this->api);
$blacklistedCategoryConstants = $cmdbCategoryInfo->getVirtualCategoryConstants();
foreach ($categoryTypes as $categoryType) {
if (!array_key_exists($categoryType, $object)) {
continue;
}
$categoryConstants = [];
for ($i = 0; $i < count($object[$categoryType]); $i++) {
if (!array_key_exists('const', $object[$categoryType][$i])) {
throw new RuntimeException(
'Information about categories is broken. Constant is missing.'
);
}
$categoryConstant = $object[$categoryType][$i]['const'];
if (in_array($categoryConstant, $blacklistedCategoryConstants)) {
continue;
}
$object[$categoryType][$i]['entries'] = [];
$categoryConstants[] = $categoryConstant;
}
$categoryEntries = $cmdbCategory->batchRead([$objectID], $categoryConstants);
for ($i = 0; $i < count($categoryConstants); $i++) {
$index = -1;
$entries = [];
foreach ($object[$categoryType] as $key => $category) {
if ($category['const'] === $categoryConstants[$i]) {
$index = $key;
$entries = $categoryEntries[$i];
break;
}
}
$object[$categoryType][$index]['entries'] = $entries;
}
}
return $object;
} | [
"public",
"function",
"load",
"(",
"$",
"objectID",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"objectID",
")",
";",
"if",
"(",
"count",
"(",
"$",
"object",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",... | Load all data about object
@param int $objectID Object identifier
@return array Multi-dimensional array
@throws Exception on error
@deprecated This method is pretty slow. Use readAll() instead! | [
"Load",
"all",
"data",
"about",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L299-L370 |
44,584 | bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.readAll | public function readAll($objectID) {
$objects = (new CMDBObjects($this->api))
->read(['ids' => [$objectID]], null, null, null, null, true);
switch (count($objects)) {
case 0:
throw new RuntimeException(sprintf(
'Object not found by identifier %s',
$objectID
));
case 1:
return end($objects);
default:
throw new RuntimeException(sprintf(
'Found multiple objects by identifier %s',
$objectID
));
}
} | php | public function readAll($objectID) {
$objects = (new CMDBObjects($this->api))
->read(['ids' => [$objectID]], null, null, null, null, true);
switch (count($objects)) {
case 0:
throw new RuntimeException(sprintf(
'Object not found by identifier %s',
$objectID
));
case 1:
return end($objects);
default:
throw new RuntimeException(sprintf(
'Found multiple objects by identifier %s',
$objectID
));
}
} | [
"public",
"function",
"readAll",
"(",
"$",
"objectID",
")",
"{",
"$",
"objects",
"=",
"(",
"new",
"CMDBObjects",
"(",
"$",
"this",
"->",
"api",
")",
")",
"->",
"read",
"(",
"[",
"'ids'",
"=>",
"[",
"$",
"objectID",
"]",
"]",
",",
"null",
",",
"nu... | Read all information about object including category entries
@param int $objectID Object identifier
@return array Multi-dimensional array
@throws Exception on error | [
"Read",
"all",
"information",
"about",
"object",
"including",
"category",
"entries"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L381-L399 |
44,585 | bheisig/i-doit-api-client-php | src/CMDBObject.php | CMDBObject.upsert | public function upsert($type, $title, array $attributes = []) {
$cmdbObjects = new CMDBObjects($this->api);
$filter = [
'title' => $title,
'type' => $type
];
$result = $cmdbObjects->read($filter);
switch (count($result)) {
case 0:
return $this->create($type, $title, $attributes);
case 1:
if (!array_key_exists(0, $result) ||
!array_key_exists('id', $result[0])) {
throw new RuntimeException('Bad result');
}
return $result[0]['id'];
default:
throw new RuntimeException(sprintf(
'Found %s objects',
count($result)
));
}
} | php | public function upsert($type, $title, array $attributes = []) {
$cmdbObjects = new CMDBObjects($this->api);
$filter = [
'title' => $title,
'type' => $type
];
$result = $cmdbObjects->read($filter);
switch (count($result)) {
case 0:
return $this->create($type, $title, $attributes);
case 1:
if (!array_key_exists(0, $result) ||
!array_key_exists('id', $result[0])) {
throw new RuntimeException('Bad result');
}
return $result[0]['id'];
default:
throw new RuntimeException(sprintf(
'Found %s objects',
count($result)
));
}
} | [
"public",
"function",
"upsert",
"(",
"$",
"type",
",",
"$",
"title",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"cmdbObjects",
"=",
"new",
"CMDBObjects",
"(",
"$",
"this",
"->",
"api",
")",
";",
"$",
"filter",
"=",
"[",
"'title'... | Create new object or fetch existing one based on its title and type
@param int|string $type Object type identifier or its constant
@param string $title Object title
@param array $attributes (Optional) additional common attributes
('category', 'purpose', 'cmdb_status', 'description')
@return int Object identifier
@throws Exception on error | [
"Create",
"new",
"object",
"or",
"fetch",
"existing",
"one",
"based",
"on",
"its",
"title",
"and",
"type"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBObject.php#L413-L439 |
44,586 | bheisig/i-doit-api-client-php | src/CheckMKTags.php | CheckMKTags.batchRead | public function batchRead(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
if (!is_int($objectID) || $objectID <= 0) {
throw new BadMethodCallException('Invalid object identifiers');
}
$requests[] = [
'method' => 'checkmk.tags.read',
'params' => [
'objID' => $objectID
]
];
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $objectIDs) {
$requests = [];
foreach ($objectIDs as $objectID) {
if (!is_int($objectID) || $objectID <= 0) {
throw new BadMethodCallException('Invalid object identifiers');
}
$requests[] = [
'method' => 'checkmk.tags.read',
'params' => [
'objID' => $objectID
]
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"objectIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectIDs",
"as",
"$",
"objectID",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"objectID",
")",
"||",
"$",
"ob... | Read host tags for one or more objects
@param array $objectIDs List of object identifiers as integers
@return array
@throws Exception on error | [
"Read",
"host",
"tags",
"for",
"one",
"or",
"more",
"objects"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CheckMKTags.php#L62-L79 |
44,587 | bheisig/i-doit-api-client-php | src/CMDBReports.php | CMDBReports.read | public function read($reportID) {
$result = $this->api->request(
'cmdb.reports',
[
'id' => $reportID
]
);
if (!is_array($result)) {
return [];
}
return $result;
} | php | public function read($reportID) {
$result = $this->api->request(
'cmdb.reports',
[
'id' => $reportID
]
);
if (!is_array($result)) {
return [];
}
return $result;
} | [
"public",
"function",
"read",
"(",
"$",
"reportID",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'cmdb.reports'",
",",
"[",
"'id'",
"=>",
"$",
"reportID",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"resul... | Fetches the result of a report
@param int $reportID Report identifier
@return array
@throws Exception on error | [
"Fetches",
"the",
"result",
"of",
"a",
"report"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBReports.php#L56-L69 |
44,588 | bheisig/i-doit-api-client-php | src/CMDBReports.php | CMDBReports.batchRead | public function batchRead(array $reportIDs) {
$requests = [];
foreach ($reportIDs as $reportID) {
$requests[] = [
'method' => 'cmdb.reports',
'params' => [
'id' => $reportID
]
];
}
$batchResults = $this->api->batchRequest($requests);
$results = [];
foreach ($batchResults as $result) {
if (is_array($result)) {
$results[] = $result;
} else {
$results[] = [];
}
}
return $results;
} | php | public function batchRead(array $reportIDs) {
$requests = [];
foreach ($reportIDs as $reportID) {
$requests[] = [
'method' => 'cmdb.reports',
'params' => [
'id' => $reportID
]
];
}
$batchResults = $this->api->batchRequest($requests);
$results = [];
foreach ($batchResults as $result) {
if (is_array($result)) {
$results[] = $result;
} else {
$results[] = [];
}
}
return $results;
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"reportIDs",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reportIDs",
"as",
"$",
"reportID",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.reports'"... | Fetches the result of one or more reports
@param array $reportIDs List of report identifiers as integers
@return array Indexed array of arrays
@throws Exception on error | [
"Fetches",
"the",
"result",
"of",
"one",
"or",
"more",
"reports"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBReports.php#L80-L104 |
44,589 | PrestaShop/welcome | OnBoarding/Configuration.php | Configuration.generateSfBaseUrl | protected function generateSfBaseUrl(Router $router, $controller, $fakeParameters = [])
{
$url = $router->getGenerator()->generate($controller, $fakeParameters);
$url = substr($url, strlen(basename(__PS_BASE_URI__)) + 1);
$url = str_replace('/' . basename(_PS_ADMIN_DIR_) . '/', '', $url);
$url = str_replace(array_values($fakeParameters), '.+', $url);
return $url;
} | php | protected function generateSfBaseUrl(Router $router, $controller, $fakeParameters = [])
{
$url = $router->getGenerator()->generate($controller, $fakeParameters);
$url = substr($url, strlen(basename(__PS_BASE_URI__)) + 1);
$url = str_replace('/' . basename(_PS_ADMIN_DIR_) . '/', '', $url);
$url = str_replace(array_values($fakeParameters), '.+', $url);
return $url;
} | [
"protected",
"function",
"generateSfBaseUrl",
"(",
"Router",
"$",
"router",
",",
"$",
"controller",
",",
"$",
"fakeParameters",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"router",
"->",
"getGenerator",
"(",
")",
"->",
"generate",
"(",
"$",
"controll... | generate url pattern to recognize the route as the current step url
here we replace the route specific parameters with wildcard to allow regexp matching
@param \PrestaShopBundle\Service\Routing\Router $router
@param $controller
@param array $fakeParameters
@return mixed|string | [
"generate",
"url",
"pattern",
"to",
"recognize",
"the",
"route",
"as",
"the",
"current",
"step",
"url",
"here",
"we",
"replace",
"the",
"route",
"specific",
"parameters",
"with",
"wildcard",
"to",
"allow",
"regexp",
"matching"
] | a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50 | https://github.com/PrestaShop/welcome/blob/a0ad26a5fdeb0311e1aea1a42be3d9c74e889a50/OnBoarding/Configuration.php#L285-L294 |
44,590 | bheisig/i-doit-api-client-php | src/API.php | API.login | public function login() {
if ($this->isLoggedIn()) {
throw new BadMethodCallException('Client is already logged-in.');
}
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$response = $this->request(
'idoit.login'
);
if (!array_key_exists('session-id', $response)) {
throw new RuntimeException('Failed to login because i-doit responded without a session ID');
}
$this->session = $response['session-id'];
return $this;
} | php | public function login() {
if ($this->isLoggedIn()) {
throw new BadMethodCallException('Client is already logged-in.');
}
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$response = $this->request(
'idoit.login'
);
if (!array_key_exists('session-id', $response)) {
throw new RuntimeException('Failed to login because i-doit responded without a session ID');
}
$this->session = $response['session-id'];
return $this;
} | [
"public",
"function",
"login",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Client is already logged-in.'",
")",
";",
"}",
"// Auto-connect:",
"if",
"(",
"$",
"this",
"->",
... | Logins to API
@return self Returns itself
@throws Exception on error | [
"Logins",
"to",
"API"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L365-L386 |
44,591 | bheisig/i-doit-api-client-php | src/API.php | API.logout | public function logout() {
if ($this->isLoggedIn() === false) {
throw new BadMethodCallException('Client is not logged-in.');
}
$this->request(
'idoit.logout'
);
$this->session = null;
return $this;
} | php | public function logout() {
if ($this->isLoggedIn() === false) {
throw new BadMethodCallException('Client is not logged-in.');
}
$this->request(
'idoit.logout'
);
$this->session = null;
return $this;
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Client is not logged-in.'",
")",
";",
"}",
"$",
"this",
"->",
"request",
"(",
... | Logouts from API
@return self Returns itself
@throws Exception on error | [
"Logouts",
"from",
"API"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L395-L407 |
44,592 | bheisig/i-doit-api-client-php | src/API.php | API.request | public function request($method, array $params = []) {
$data = [
'version' => '2.0',
'method' => $method,
'params' => $params,
'id' => $this->genID()
];
$data['params']['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config) &&
!array_key_exists(self::LANGUAGE, $params)) {
$data['params'][self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$response = $this->execute($data);
$this->evaluateResponse($response);
return $response['result'];
} | php | public function request($method, array $params = []) {
$data = [
'version' => '2.0',
'method' => $method,
'params' => $params,
'id' => $this->genID()
];
$data['params']['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config) &&
!array_key_exists(self::LANGUAGE, $params)) {
$data['params'][self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$response = $this->execute($data);
$this->evaluateResponse($response);
return $response['result'];
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'version'",
"=>",
"'2.0'",
",",
"'method'",
"=>",
"$",
"method",
",",
"'params'",
"=>",
"$",
"params",
",",
"'id'",
"... | Sends request to API
@param string $method JSON-RPC method
@param array $params Optional parameters
@return array Result of request
@throws Exception on error | [
"Sends",
"request",
"to",
"API"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L439-L459 |
44,593 | bheisig/i-doit-api-client-php | src/API.php | API.batchRequest | public function batchRequest(array $requests) {
$data = [];
foreach ($requests as $request) {
if (!array_key_exists('method', $request)) {
throw new BadMethodCallException(
'Missing method in one of the sub-requests of this batch request'
);
}
$params = [];
if (array_key_exists('params', $request)) {
$params = $request['params'];
}
$params['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config)) {
$params[self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$data[] = [
'version' => '2.0',
'method' => $request['method'],
'params' => $params,
'id' => $this->genID()
];
}
$responses = $this->execute($data);
$results = [];
foreach ($responses as $response) {
if (!is_array($response)) {
throw new RuntimeException(sprintf(
'Found invalid result for request in batch: %s',
$response
));
}
$this->evaluateResponse($response);
$results[] = $response['result'];
}
return $results;
} | php | public function batchRequest(array $requests) {
$data = [];
foreach ($requests as $request) {
if (!array_key_exists('method', $request)) {
throw new BadMethodCallException(
'Missing method in one of the sub-requests of this batch request'
);
}
$params = [];
if (array_key_exists('params', $request)) {
$params = $request['params'];
}
$params['apikey'] = $this->config[self::KEY];
if (array_key_exists(self::LANGUAGE, $this->config)) {
$params[self::LANGUAGE] = $this->config[self::LANGUAGE];
}
$data[] = [
'version' => '2.0',
'method' => $request['method'],
'params' => $params,
'id' => $this->genID()
];
}
$responses = $this->execute($data);
$results = [];
foreach ($responses as $response) {
if (!is_array($response)) {
throw new RuntimeException(sprintf(
'Found invalid result for request in batch: %s',
$response
));
}
$this->evaluateResponse($response);
$results[] = $response['result'];
}
return $results;
} | [
"public",
"function",
"batchRequest",
"(",
"array",
"$",
"requests",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"requests",
"as",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'method'",
",",
"$",
"request",
... | Performs multiple requests to API at once
@param array $requests Batch requests with 'method' and optional 'params'
@return array Result of request
@throws Exception on error | [
"Performs",
"multiple",
"requests",
"to",
"API",
"at",
"once"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L470-L518 |
44,594 | bheisig/i-doit-api-client-php | src/API.php | API.execute | protected function execute(array $data) {
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$this->lastRequestContent = $data;
$dataAsString = json_encode($data);
$options = $this->options;
$options[CURLOPT_POSTFIELDS] = $dataAsString;
if (isset($this->session)) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Session: ' . $this->session;
} elseif (array_key_exists(self::USERNAME, $this->config) &&
is_string($this->config[self::USERNAME]) &&
!empty($this->config[self::USERNAME]) &&
array_key_exists(self::PASSWORD, $this->config) &&
is_string($this->config[self::PASSWORD]) &&
!empty($this->config[self::PASSWORD])) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Username: ' . $this->config[self::USERNAME];
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Password: ' . $this->config[self::PASSWORD];
}
curl_setopt_array($this->resource, $options);
$responseString = curl_exec($this->resource);
$this->lastInfo = curl_getinfo($this->resource);
if ($responseString === false) {
switch ($this->lastInfo['http_code']) {
case 0:
$message = curl_error($this->resource);
if (strlen($message) === 0) {
$message = 'Connection to Web server failed';
}
throw new RuntimeException($message);
default:
throw new RuntimeException(sprintf(
'Web server responded with HTTP status code "%s"',
$this->lastInfo['http_code']
));
}
} elseif (!is_string($responseString)) {
throw new RuntimeException('No content from Web server');
}
$headerLength = curl_getinfo($this->resource, CURLINFO_HEADER_SIZE);
$this->lastResponseHeaders = substr($responseString, 0, $headerLength);
$body = substr($responseString, $headerLength);
$lastResponse = json_decode(trim($body), true);
if (!is_array($lastResponse)) {
if (is_string($body) && strlen($body) > 0) {
throw new RuntimeException(sprintf(
'i-doit responded with an unknown message: %s',
$body
));
} else {
throw new RuntimeException('i-doit responded with an invalid JSON string.');
}
}
$this->lastResponse = $lastResponse;
return $this->lastResponse;
} | php | protected function execute(array $data) {
// Auto-connect:
if ($this->isConnected() === false) {
$this->connect();
}
$this->lastRequestContent = $data;
$dataAsString = json_encode($data);
$options = $this->options;
$options[CURLOPT_POSTFIELDS] = $dataAsString;
if (isset($this->session)) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Session: ' . $this->session;
} elseif (array_key_exists(self::USERNAME, $this->config) &&
is_string($this->config[self::USERNAME]) &&
!empty($this->config[self::USERNAME]) &&
array_key_exists(self::PASSWORD, $this->config) &&
is_string($this->config[self::PASSWORD]) &&
!empty($this->config[self::PASSWORD])) {
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Username: ' . $this->config[self::USERNAME];
$options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Password: ' . $this->config[self::PASSWORD];
}
curl_setopt_array($this->resource, $options);
$responseString = curl_exec($this->resource);
$this->lastInfo = curl_getinfo($this->resource);
if ($responseString === false) {
switch ($this->lastInfo['http_code']) {
case 0:
$message = curl_error($this->resource);
if (strlen($message) === 0) {
$message = 'Connection to Web server failed';
}
throw new RuntimeException($message);
default:
throw new RuntimeException(sprintf(
'Web server responded with HTTP status code "%s"',
$this->lastInfo['http_code']
));
}
} elseif (!is_string($responseString)) {
throw new RuntimeException('No content from Web server');
}
$headerLength = curl_getinfo($this->resource, CURLINFO_HEADER_SIZE);
$this->lastResponseHeaders = substr($responseString, 0, $headerLength);
$body = substr($responseString, $headerLength);
$lastResponse = json_decode(trim($body), true);
if (!is_array($lastResponse)) {
if (is_string($body) && strlen($body) > 0) {
throw new RuntimeException(sprintf(
'i-doit responded with an unknown message: %s',
$body
));
} else {
throw new RuntimeException('i-doit responded with an invalid JSON string.');
}
}
$this->lastResponse = $lastResponse;
return $this->lastResponse;
} | [
"protected",
"function",
"execute",
"(",
"array",
"$",
"data",
")",
"{",
"// Auto-connect:",
"if",
"(",
"$",
"this",
"->",
"isConnected",
"(",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"lastRe... | Sends request to API with headers and receives response
@param array $data Payload
@return array Result of request
@throws Exception on error | [
"Sends",
"request",
"to",
"API",
"with",
"headers",
"and",
"receives",
"response"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L529-L602 |
44,595 | bheisig/i-doit-api-client-php | src/API.php | API.evaluateResponse | protected function evaluateResponse(array $response) {
if (array_key_exists('error', $response) &&
$response['error'] !== null) {
// Validate error object:
if (!is_array($response['error'])) {
throw new RuntimeException('Invalid error object');
}
if (!array_key_exists('code', $response['error']) ||
!is_int($response['error']['code']) ||
$response['error']['code'] >= 0) {
throw new RuntimeException('Invalid error code');
}
if (!array_key_exists('message', $response['error']) ||
!is_string($response['error']['message']) ||
strlen($response['error']['message']) === 0) {
throw new RuntimeException('Invalid error message');
}
$details = [];
if (array_key_exists('data', $response['error']) &&
is_array($response['error']['data'])) {
foreach ($response['error']['data'] as $topic => $description) {
$text = 'unknown';
switch (gettype($description)) {
case 'array':
$text = implode('; ', $description);
break;
case 'string':
$text = $description;
break;
}
$details[] = sprintf(
'%s: %s',
$topic,
$text
);
}
}
if (count($details) > 0) {
$message = sprintf(
'i-doit responded with an error: %s [%s]',
$response['error']['message'],
implode('; ', $details)
);
} else {
$message = sprintf(
'i-doit responded with an error: %s',
$response['error']['message']
);
}
throw new RuntimeException(
$message,
$response['error']['code']
);
}
if (!array_key_exists('result', $response)) {
throw new RuntimeException('i-doit forgot to add a result to its response.');
}
return $this;
} | php | protected function evaluateResponse(array $response) {
if (array_key_exists('error', $response) &&
$response['error'] !== null) {
// Validate error object:
if (!is_array($response['error'])) {
throw new RuntimeException('Invalid error object');
}
if (!array_key_exists('code', $response['error']) ||
!is_int($response['error']['code']) ||
$response['error']['code'] >= 0) {
throw new RuntimeException('Invalid error code');
}
if (!array_key_exists('message', $response['error']) ||
!is_string($response['error']['message']) ||
strlen($response['error']['message']) === 0) {
throw new RuntimeException('Invalid error message');
}
$details = [];
if (array_key_exists('data', $response['error']) &&
is_array($response['error']['data'])) {
foreach ($response['error']['data'] as $topic => $description) {
$text = 'unknown';
switch (gettype($description)) {
case 'array':
$text = implode('; ', $description);
break;
case 'string':
$text = $description;
break;
}
$details[] = sprintf(
'%s: %s',
$topic,
$text
);
}
}
if (count($details) > 0) {
$message = sprintf(
'i-doit responded with an error: %s [%s]',
$response['error']['message'],
implode('; ', $details)
);
} else {
$message = sprintf(
'i-doit responded with an error: %s',
$response['error']['message']
);
}
throw new RuntimeException(
$message,
$response['error']['code']
);
}
if (!array_key_exists('result', $response)) {
throw new RuntimeException('i-doit forgot to add a result to its response.');
}
return $this;
} | [
"protected",
"function",
"evaluateResponse",
"(",
"array",
"$",
"response",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'error'",
",",
"$",
"response",
")",
"&&",
"$",
"response",
"[",
"'error'",
"]",
"!==",
"null",
")",
"{",
"// Validate error object:",
... | Evaluates server response
@param array $response Server response
@return self Returns itself
@throws Exception on error | [
"Evaluates",
"server",
"response"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L613-L681 |
44,596 | bheisig/i-doit-api-client-php | src/API.php | API.rawRequest | public function rawRequest(array $data = [], array $headers = []) {
foreach ($headers as $header => $value) {
$this->options[CURLOPT_HTTPHEADER][] = $header . ': ' . $value;
}
return $this->execute($data);
} | php | public function rawRequest(array $data = [], array $headers = []) {
foreach ($headers as $header => $value) {
$this->options[CURLOPT_HTTPHEADER][] = $header . ': ' . $value;
}
return $this->execute($data);
} | [
"public",
"function",
"rawRequest",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"options",
... | Perform a low level API request
@param array $data JSON-RPC compatible payload
@param array $headers Additional headers as key-value pairs
@return array Raw response from
@throws Exception on error | [
"Perform",
"a",
"low",
"level",
"API",
"request"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/API.php#L692-L698 |
44,597 | bheisig/i-doit-api-client-php | src/CMDBLocationTree.php | CMDBLocationTree.read | public function read($objectID, $status = null) {
$params = [
'id' => $objectID
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.location_tree.read',
$params
);
} | php | public function read($objectID, $status = null) {
$params = [
'id' => $objectID
];
if (isset($status)) {
$params['status'] = $status;
}
return $this->api->request(
'cmdb.location_tree.read',
$params
);
} | [
"public",
"function",
"read",
"(",
"$",
"objectID",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'id'",
"=>",
"$",
"objectID",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"status",
")",
")",
"{",
"$",
"params",
"[",
"'status'"... | Reads objects located directly under an object
This method does not run recursively. Use readRecursively() instead.
@param int $objectID Object identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Reads",
"objects",
"located",
"directly",
"under",
"an",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLocationTree.php#L47-L60 |
44,598 | bheisig/i-doit-api-client-php | src/CMDBLocationTree.php | CMDBLocationTree.readRecursively | public function readRecursively($objectID, $status = null) {
$children = $this->read($objectID, $status);
$tree = [];
foreach ($children as $child) {
if (!array_key_exists('id', $child)) {
throw new RuntimeException('Broken result');
}
$node = $child;
$childChildren = $this->read((int) $child['id'], $status);
if (count($childChildren) > 0) {
$node['children'] = $childChildren;
}
$tree[] = $node;
}
return $tree;
} | php | public function readRecursively($objectID, $status = null) {
$children = $this->read($objectID, $status);
$tree = [];
foreach ($children as $child) {
if (!array_key_exists('id', $child)) {
throw new RuntimeException('Broken result');
}
$node = $child;
$childChildren = $this->read((int) $child['id'], $status);
if (count($childChildren) > 0) {
$node['children'] = $childChildren;
}
$tree[] = $node;
}
return $tree;
} | [
"public",
"function",
"readRecursively",
"(",
"$",
"objectID",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"objectID",
",",
"$",
"status",
")",
";",
"$",
"tree",
"=",
"[",
"]",
";",
"foreach... | Reads recursively objects located under an object
@param int $objectID Object identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted
@return array
@throws Exception on error | [
"Reads",
"recursively",
"objects",
"located",
"under",
"an",
"object"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBLocationTree.php#L72-L94 |
44,599 | bheisig/i-doit-api-client-php | src/CMDBCategoryInfo.php | CMDBCategoryInfo.batchRead | public function batchRead(array $categories) {
$requests = [];
foreach ($categories as $category) {
$requests[] = [
'method' => 'cmdb.category_info',
'params' => array(
'category' => $category
)
];
}
return $this->api->batchRequest($requests);
} | php | public function batchRead(array $categories) {
$requests = [];
foreach ($categories as $category) {
$requests[] = [
'method' => 'cmdb.category_info',
'params' => array(
'category' => $category
)
];
}
return $this->api->batchRequest($requests);
} | [
"public",
"function",
"batchRead",
"(",
"array",
"$",
"categories",
")",
"{",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"requests",
"[",
"]",
"=",
"[",
"'method'",
"=>",
"'cmdb.categor... | Fetches information about one or more categories
@param array $categories List of category constants as strings
@return array Indexed array of associative arrays
@throws Exception on error | [
"Fetches",
"information",
"about",
"one",
"or",
"more",
"categories"
] | 931ac20cfbe07fa330766d4516018bf7bc926efd | https://github.com/bheisig/i-doit-api-client-php/blob/931ac20cfbe07fa330766d4516018bf7bc926efd/src/CMDBCategoryInfo.php#L62-L75 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.