repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
WyriHaximus/TwigView | src/Lib/Scanner.php | Scanner.plugin | public static function plugin($plugin)
{
$templates = [];
foreach (App::path('Template', $plugin) as $path) {
$templates = array_merge($templates, static::iteratePath($path));
}
return $templates;
} | php | public static function plugin($plugin)
{
$templates = [];
foreach (App::path('Template', $plugin) as $path) {
$templates = array_merge($templates, static::iteratePath($path));
}
return $templates;
} | [
"public",
"static",
"function",
"plugin",
"(",
"$",
"plugin",
")",
"{",
"$",
"templates",
"=",
"[",
"]",
";",
"foreach",
"(",
"App",
"::",
"path",
"(",
"'Template'",
",",
"$",
"plugin",
")",
"as",
"$",
"path",
")",
"{",
"$",
"templates",
"=",
"arra... | Return all templates for a given plugin.
@param string $plugin The plugin to find all templates for.
@return mixed | [
"Return",
"all",
"templates",
"for",
"a",
"given",
"plugin",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L55-L64 | train |
WyriHaximus/TwigView | src/Lib/Scanner.php | Scanner.clearEmptySections | protected static function clearEmptySections(array $sections): array
{
array_walk($sections, function ($templates, $index) use (&$sections) {
if (count($templates) == 0) {
unset($sections[$index]);
}
});
return $sections;
} | php | protected static function clearEmptySections(array $sections): array
{
array_walk($sections, function ($templates, $index) use (&$sections) {
if (count($templates) == 0) {
unset($sections[$index]);
}
});
return $sections;
} | [
"protected",
"static",
"function",
"clearEmptySections",
"(",
"array",
"$",
"sections",
")",
":",
"array",
"{",
"array_walk",
"(",
"$",
"sections",
",",
"function",
"(",
"$",
"templates",
",",
"$",
"index",
")",
"use",
"(",
"&",
"$",
"sections",
")",
"{"... | Check sections a remove the ones without anything in them.
@param array $sections Sections to check.
@return array | [
"Check",
"sections",
"a",
"remove",
"the",
"ones",
"without",
"anything",
"in",
"them",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L73-L82 | train |
WyriHaximus/TwigView | src/Lib/Scanner.php | Scanner.pluginsWithTemplates | protected static function pluginsWithTemplates(): array
{
$plugins = Plugin::loaded();
array_walk($plugins, function ($plugin, $index) use (&$plugins) {
$paths = App::path('Template', $plugin);
array_walk($paths, function ($path, $index) use (&$paths) {
if (!is_dir($path)) {
unset($paths[$index]);
}
});
});
return $plugins;
} | php | protected static function pluginsWithTemplates(): array
{
$plugins = Plugin::loaded();
array_walk($plugins, function ($plugin, $index) use (&$plugins) {
$paths = App::path('Template', $plugin);
array_walk($paths, function ($path, $index) use (&$paths) {
if (!is_dir($path)) {
unset($paths[$index]);
}
});
});
return $plugins;
} | [
"protected",
"static",
"function",
"pluginsWithTemplates",
"(",
")",
":",
"array",
"{",
"$",
"plugins",
"=",
"Plugin",
"::",
"loaded",
"(",
")",
";",
"array_walk",
"(",
"$",
"plugins",
",",
"function",
"(",
"$",
"plugin",
",",
"$",
"index",
")",
"use",
... | Finds all plugins with a Template directory.
@return array | [
"Finds",
"all",
"plugins",
"with",
"a",
"Template",
"directory",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L89-L104 | train |
WyriHaximus/TwigView | src/Lib/Scanner.php | Scanner.setupIterator | protected static function setupIterator($path): Iterator
{
return new RegexIterator(new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
$path,
FilesystemIterator::KEY_AS_PATHNAME |
FilesystemIterator::CURRENT_AS_FILEINFO |
FilesystemIterator::SKIP_DOTS
),
RecursiveIteratorIterator::CHILD_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD
), '/.*?' . TwigView::EXT . '$/', RegexIterator::GET_MATCH);
} | php | protected static function setupIterator($path): Iterator
{
return new RegexIterator(new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
$path,
FilesystemIterator::KEY_AS_PATHNAME |
FilesystemIterator::CURRENT_AS_FILEINFO |
FilesystemIterator::SKIP_DOTS
),
RecursiveIteratorIterator::CHILD_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD
), '/.*?' . TwigView::EXT . '$/', RegexIterator::GET_MATCH);
} | [
"protected",
"static",
"function",
"setupIterator",
"(",
"$",
"path",
")",
":",
"Iterator",
"{",
"return",
"new",
"RegexIterator",
"(",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"path",
",",
"FilesystemIterator",
"::",
... | Setup iterator for given path.
@param string $path Path to setup iterator for.
@return \Iterator | [
"Setup",
"iterator",
"for",
"given",
"path",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L125-L137 | train |
WyriHaximus/TwigView | src/Lib/Scanner.php | Scanner.walkIterator | protected static function walkIterator(Iterator $iterator): array
{
$items = [];
$array = iterator_to_array($iterator);
uasort($array, function ($a, $b) {
if ($a == $b) {
return 0;
}
return $a < $b ? -1 : 1;
});
foreach ($array as $paths) {
foreach ($paths as $path) {
$items[] = $path;
}
}
return $items;
} | php | protected static function walkIterator(Iterator $iterator): array
{
$items = [];
$array = iterator_to_array($iterator);
uasort($array, function ($a, $b) {
if ($a == $b) {
return 0;
}
return $a < $b ? -1 : 1;
});
foreach ($array as $paths) {
foreach ($paths as $path) {
$items[] = $path;
}
}
return $items;
} | [
"protected",
"static",
"function",
"walkIterator",
"(",
"Iterator",
"$",
"iterator",
")",
":",
"array",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"$",
"array",
"=",
"iterator_to_array",
"(",
"$",
"iterator",
")",
";",
"uasort",
"(",
"$",
"array",
",",
"fu... | Walk over the iterator and compile all templates.
@param \Iterator $iterator Iterator to walk.
@return array | [
"Walk",
"over",
"the",
"iterator",
"and",
"compile",
"all",
"templates",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Scanner.php#L146-L166 | train |
WyriHaximus/TwigView | src/Lib/RelativeScanner.php | RelativeScanner.stripAbsolutePath | protected static function stripAbsolutePath(array $paths, $plugin = null): array
{
foreach (App::path('Template', $plugin) as $templatesPath) {
array_walk($paths, function (&$path) use ($templatesPath) {
if (substr($path, 0, strlen($templatesPath)) == $templatesPath) {
$path = substr($path, strlen($templatesPath));
}
});
}
return $paths;
} | php | protected static function stripAbsolutePath(array $paths, $plugin = null): array
{
foreach (App::path('Template', $plugin) as $templatesPath) {
array_walk($paths, function (&$path) use ($templatesPath) {
if (substr($path, 0, strlen($templatesPath)) == $templatesPath) {
$path = substr($path, strlen($templatesPath));
}
});
}
return $paths;
} | [
"protected",
"static",
"function",
"stripAbsolutePath",
"(",
"array",
"$",
"paths",
",",
"$",
"plugin",
"=",
"null",
")",
":",
"array",
"{",
"foreach",
"(",
"App",
"::",
"path",
"(",
"'Template'",
",",
"$",
"plugin",
")",
"as",
"$",
"templatesPath",
")",... | Strip the absolute path of template's paths.
@param array $paths Paths to strip.
@param string|null $plugin Hold plugin name or null for App.
@return array | [
"Strip",
"the",
"absolute",
"path",
"of",
"template",
"s",
"paths",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/RelativeScanner.php#L61-L72 | train |
WyriHaximus/TwigView | src/View/TwigView.php | TwigView.initialize | public function initialize(): void
{
$this->twig = new Environment($this->getLoader(), $this->resolveConfig());
$this->getEventManager()->dispatch(ConstructEvent::create($this, $this->twig));
$this->_ext = self::EXT;
parent::initialize();
} | php | public function initialize(): void
{
$this->twig = new Environment($this->getLoader(), $this->resolveConfig());
$this->getEventManager()->dispatch(ConstructEvent::create($this, $this->twig));
$this->_ext = self::EXT;
parent::initialize();
} | [
"public",
"function",
"initialize",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"twig",
"=",
"new",
"Environment",
"(",
"$",
"this",
"->",
"getLoader",
"(",
")",
",",
"$",
"this",
"->",
"resolveConfig",
"(",
")",
")",
";",
"$",
"this",
"->",
"ge... | Initialize view. | [
"Initialize",
"view",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/View/TwigView.php#L69-L78 | train |
WyriHaximus/TwigView | src/View/TwigView.php | TwigView.getLoader | protected function getLoader(): Loader
{
$event = LoaderEvent::create(new Loader());
$this->getEventManager()->dispatch($event);
return $event->getResultLoader();
} | php | protected function getLoader(): Loader
{
$event = LoaderEvent::create(new Loader());
$this->getEventManager()->dispatch($event);
return $event->getResultLoader();
} | [
"protected",
"function",
"getLoader",
"(",
")",
":",
"Loader",
"{",
"$",
"event",
"=",
"LoaderEvent",
"::",
"create",
"(",
"new",
"Loader",
"(",
")",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
... | Create the template loader.
@return \WyriHaximus\TwigView\Lib\Twig\Loader | [
"Create",
"the",
"template",
"loader",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/View/TwigView.php#L156-L162 | train |
WyriHaximus/TwigView | src/Lib/Twig/Loader.php | Loader.isFresh | public function isFresh($name, $time): bool
{
$name = $this->resolveFileName($name);
return filemtime($name) < $time;
} | php | public function isFresh($name, $time): bool
{
$name = $this->resolveFileName($name);
return filemtime($name) < $time;
} | [
"public",
"function",
"isFresh",
"(",
"$",
"name",
",",
"$",
"time",
")",
":",
"bool",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"resolveFileName",
"(",
"$",
"name",
")",
";",
"return",
"filemtime",
"(",
"$",
"name",
")",
"<",
"$",
"time",
";",
"... | Check if template is still fresh.
@param string $name Template.
@param int $time Timestamp.
@return bool | [
"Check",
"if",
"template",
"is",
"still",
"fresh",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Loader.php#L80-L85 | train |
WyriHaximus/TwigView | src/Lib/Twig/Loader.php | Loader.resolveFileName | private function resolveFileName($name): string
{
$filename = $this->getFilename($name);
if ($filename === false) {
throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
}
return $filename;
} | php | private function resolveFileName($name): string
{
$filename = $this->getFilename($name);
if ($filename === false) {
throw new LoaderError(sprintf('Template "%s" is not defined.', $name));
}
return $filename;
} | [
"private",
"function",
"resolveFileName",
"(",
"$",
"name",
")",
":",
"string",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFilename",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"filename",
"===",
"false",
")",
"{",
"throw",
"new",
"LoaderError"... | Resolve template name to filename.
@param string $name Template.
@throws \Twig\Error\LoaderError Thrown when template file isn't found.
@return string | [
"Resolve",
"template",
"name",
"to",
"filename",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Loader.php#L113-L121 | train |
WyriHaximus/TwigView | src/Lib/Twig/Loader.php | Loader.getFilename | private function getFilename($name)
{
if (file_exists($name)) {
return $name;
}
[$plugin, $file] = pluginSplit($name);
foreach ([null, $plugin] as $scope) {
$paths = $this->getPaths($scope);
foreach ($paths as $path) {
$filePath = $path . $file;
if (is_file($filePath)) {
return $filePath;
}
$filePath = $path . $file . TwigView::EXT;
if (is_file($filePath)) {
return $filePath;
}
}
}
return false;
} | php | private function getFilename($name)
{
if (file_exists($name)) {
return $name;
}
[$plugin, $file] = pluginSplit($name);
foreach ([null, $plugin] as $scope) {
$paths = $this->getPaths($scope);
foreach ($paths as $path) {
$filePath = $path . $file;
if (is_file($filePath)) {
return $filePath;
}
$filePath = $path . $file . TwigView::EXT;
if (is_file($filePath)) {
return $filePath;
}
}
}
return false;
} | [
"private",
"function",
"getFilename",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"name",
";",
"}",
"[",
"$",
"plugin",
",",
"$",
"file",
"]",
"=",
"pluginSplit",
"(",
"$",
"name",
")",
";... | Get template filename.
@param string $name Template.
@return string|false | [
"Get",
"template",
"filename",
"."
] | 65527d6a7828086f7d16c73e95afce11c96a49f2 | https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Loader.php#L131-L154 | train |
TransbankDevelopers/transbank-sdk-php | lib/onepay/OnepayBase.php | OnepayBase.setCurrentIntegrationType | public static function setCurrentIntegrationType($type)
{
if (!self::integrationTypes()[$type]) {
$integrationTypes = array_keys(self::integrationTypes());
$integrationTypesAsString = join($integrationTypes, ", ");
throw new \Exception('Invalid integration type, valid values are: ' . $integrationTypesAsString);
}
self::$integrationType = $type;
} | php | public static function setCurrentIntegrationType($type)
{
if (!self::integrationTypes()[$type]) {
$integrationTypes = array_keys(self::integrationTypes());
$integrationTypesAsString = join($integrationTypes, ", ");
throw new \Exception('Invalid integration type, valid values are: ' . $integrationTypesAsString);
}
self::$integrationType = $type;
} | [
"public",
"static",
"function",
"setCurrentIntegrationType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"integrationTypes",
"(",
")",
"[",
"$",
"type",
"]",
")",
"{",
"$",
"integrationTypes",
"=",
"array_keys",
"(",
"self",
"::",
"integratio... | Set the integration type | [
"Set",
"the",
"integration",
"type"
] | d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8 | https://github.com/TransbankDevelopers/transbank-sdk-php/blob/d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8/lib/onepay/OnepayBase.php#L192-L200 | train |
TransbankDevelopers/transbank-sdk-php | lib/onepay/Item.php | Item.setQuantity | public function setQuantity($quantity) {
if (!is_integer($quantity)) {
throw new \Exception ("quantity must be an Integer");
}
if ($quantity < 0) {
throw new \Exception ("quantity cannot be less than zero");
}
$this->quantity = $quantity;
} | php | public function setQuantity($quantity) {
if (!is_integer($quantity)) {
throw new \Exception ("quantity must be an Integer");
}
if ($quantity < 0) {
throw new \Exception ("quantity cannot be less than zero");
}
$this->quantity = $quantity;
} | [
"public",
"function",
"setQuantity",
"(",
"$",
"quantity",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"quantity",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"quantity must be an Integer\"",
")",
";",
"}",
"if",
"(",
"$",
"quantity",
... | Set the quantity for an instance of Item | [
"Set",
"the",
"quantity",
"for",
"an",
"instance",
"of",
"Item"
] | d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8 | https://github.com/TransbankDevelopers/transbank-sdk-php/blob/d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8/lib/onepay/Item.php#L53-L61 | train |
TransbankDevelopers/transbank-sdk-php | lib/onepay/Item.php | Item.setAdditionalData | public function setAdditionalData($additionalData) {
if (is_null($additionalData)) {
$additionalData = "";
}
if (!is_string($additionalData)) {
throw new \Exception ("Additional Data must be a String");
}
$this->additionalData = $additionalData;
} | php | public function setAdditionalData($additionalData) {
if (is_null($additionalData)) {
$additionalData = "";
}
if (!is_string($additionalData)) {
throw new \Exception ("Additional Data must be a String");
}
$this->additionalData = $additionalData;
} | [
"public",
"function",
"setAdditionalData",
"(",
"$",
"additionalData",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"additionalData",
")",
")",
"{",
"$",
"additionalData",
"=",
"\"\"",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"additionalData",
")",
... | Set the additional data for an instance of Item | [
"Set",
"the",
"additional",
"data",
"for",
"an",
"instance",
"of",
"Item"
] | d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8 | https://github.com/TransbankDevelopers/transbank-sdk-php/blob/d78a320a6ced0d95aaaa7a5fd9ead1325ea70ca8/lib/onepay/Item.php#L87-L95 | train |
yangqi/Htmldom | src/Yangqi/Htmldom/Htmldom.php | Htmldom.load_file | public function load_file()
{
$args = func_get_args();
$this->load(call_user_func_array('file_get_contents', $args), true);
// Throw an error if we can't properly load the dom.
if (($error=error_get_last())!==null) {
$this->clear();
return false;
}
} | php | public function load_file()
{
$args = func_get_args();
$this->load(call_user_func_array('file_get_contents', $args), true);
// Throw an error if we can't properly load the dom.
if (($error=error_get_last())!==null) {
$this->clear();
return false;
}
} | [
"public",
"function",
"load_file",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"load",
"(",
"call_user_func_array",
"(",
"'file_get_contents'",
",",
"$",
"args",
")",
",",
"true",
")",
";",
"// Throw an error if we can... | load html from file | [
"load",
"html",
"from",
"file"
] | e6c0c6eb3c5c5855708ae155569fab7f7fba95c2 | https://github.com/yangqi/Htmldom/blob/e6c0c6eb3c5c5855708ae155569fab7f7fba95c2/src/Yangqi/Htmldom/Htmldom.php#L178-L187 | train |
yangqi/Htmldom | src/Yangqi/Htmldom/Htmldom.php | Htmldom.find | public function find($selector, $idx=null, $lowercase=false)
{
return $this->root->find($selector, $idx, $lowercase);
} | php | public function find($selector, $idx=null, $lowercase=false)
{
return $this->root->find($selector, $idx, $lowercase);
} | [
"public",
"function",
"find",
"(",
"$",
"selector",
",",
"$",
"idx",
"=",
"null",
",",
"$",
"lowercase",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"root",
"->",
"find",
"(",
"$",
"selector",
",",
"$",
"idx",
",",
"$",
"lowercase",
")",
... | Paperg - allow us to specify that we want case insensitive testing of the value of the selector. | [
"Paperg",
"-",
"allow",
"us",
"to",
"specify",
"that",
"we",
"want",
"case",
"insensitive",
"testing",
"of",
"the",
"value",
"of",
"the",
"selector",
"."
] | e6c0c6eb3c5c5855708ae155569fab7f7fba95c2 | https://github.com/yangqi/Htmldom/blob/e6c0c6eb3c5c5855708ae155569fab7f7fba95c2/src/Yangqi/Htmldom/Htmldom.php#L273-L276 | train |
yangqi/Htmldom | src/Yangqi/Htmldom/Htmldom.php | Htmldom.as_text_node | protected function as_text_node($tag)
{
$node = new Htmldomnode($this);
++$this->cursor;
$node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
$this->link_nodes($node, false);
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
return true;
} | php | protected function as_text_node($tag)
{
$node = new Htmldomnode($this);
++$this->cursor;
$node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
$this->link_nodes($node, false);
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
return true;
} | [
"protected",
"function",
"as_text_node",
"(",
"$",
"tag",
")",
"{",
"$",
"node",
"=",
"new",
"Htmldomnode",
"(",
"$",
"this",
")",
";",
"++",
"$",
"this",
"->",
"cursor",
";",
"$",
"node",
"->",
"_",
"[",
"HDOM_INFO_TEXT",
"]",
"=",
"'</'",
".",
"$... | as a text node | [
"as",
"a",
"text",
"node"
] | e6c0c6eb3c5c5855708ae155569fab7f7fba95c2 | https://github.com/yangqi/Htmldom/blob/e6c0c6eb3c5c5855708ae155569fab7f7fba95c2/src/Yangqi/Htmldom/Htmldom.php#L698-L706 | train |
craftcms/commerce-stripe | src/services/Invoices.php | Invoices.getSubscriptionInvoices | public function getSubscriptionInvoices(int $subscriptionId): array
{
$results = $this->_createInvoiceQuery()
->where(['subscriptionId' => $subscriptionId])
->orderBy(['dateCreated' => SORT_DESC])
->all();
$invoices = [];
foreach ($results as $result) {
$result['invoiceData'] = Json::decodeIfJson($result['invoiceData']);
$invoices[] = new Invoice($result);
}
return $invoices;
} | php | public function getSubscriptionInvoices(int $subscriptionId): array
{
$results = $this->_createInvoiceQuery()
->where(['subscriptionId' => $subscriptionId])
->orderBy(['dateCreated' => SORT_DESC])
->all();
$invoices = [];
foreach ($results as $result) {
$result['invoiceData'] = Json::decodeIfJson($result['invoiceData']);
$invoices[] = new Invoice($result);
}
return $invoices;
} | [
"public",
"function",
"getSubscriptionInvoices",
"(",
"int",
"$",
"subscriptionId",
")",
":",
"array",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"_createInvoiceQuery",
"(",
")",
"->",
"where",
"(",
"[",
"'subscriptionId'",
"=>",
"$",
"subscriptionId",
"]",
... | Returns a customer by gateway and user id.
@param int $subscriptionId The subscription id.
@return Invoice[] | [
"Returns",
"a",
"customer",
"by",
"gateway",
"and",
"user",
"id",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Invoices.php#L76-L91 | train |
craftcms/commerce-stripe | src/services/Invoices.php | Invoices.getInvoiceByReference | public function getInvoiceByReference(string $reference)
{
$invoiceRow = $this->_createInvoiceQuery()
->where(['reference' => $reference])
->one();
if ($invoiceRow) {
return new Invoice($invoiceRow);
}
return null;
} | php | public function getInvoiceByReference(string $reference)
{
$invoiceRow = $this->_createInvoiceQuery()
->where(['reference' => $reference])
->one();
if ($invoiceRow) {
return new Invoice($invoiceRow);
}
return null;
} | [
"public",
"function",
"getInvoiceByReference",
"(",
"string",
"$",
"reference",
")",
"{",
"$",
"invoiceRow",
"=",
"$",
"this",
"->",
"_createInvoiceQuery",
"(",
")",
"->",
"where",
"(",
"[",
"'reference'",
"=>",
"$",
"reference",
"]",
")",
"->",
"one",
"("... | Get an invoice from the database by the invoice reference number. Returns null if not found.
@param string $reference
@return Invoice|null | [
"Get",
"an",
"invoice",
"from",
"the",
"database",
"by",
"the",
"invoice",
"reference",
"number",
".",
"Returns",
"null",
"if",
"not",
"found",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Invoices.php#L99-L110 | train |
craftcms/commerce-stripe | src/services/Customers.php | Customers.getCustomer | public function getCustomer(int $gatewayId, User $user): Customer
{
$result = $this->_createCustomerQuery()
->where(['userId' => $user->id, 'gatewayId' => $gatewayId])
->one();
if ($result !== null) {
return new Customer($result);
}
Stripe::setApiKey(Craft::parseEnv(Commerce::getInstance()->getGateways()->getGatewayById($gatewayId)->apiKey));
Stripe::setAppInfo(StripePlugin::getInstance()->name, StripePlugin::getInstance()->version, StripePlugin::getInstance()->documentationUrl);
Stripe::setApiVersion(Gateway::STRIPE_API_VERSION);
/** @var StripeCustomer $stripeCustomer */
$stripeCustomer = StripeCustomer::create([
'description' => Craft::t('commerce-stripe', 'Customer for Craft user with ID {id}', ['id' => $user->id]),
'email' => $user->email
]);
$customer = new Customer([
'userId' => $user->id,
'gatewayId' => $gatewayId,
'reference' => $stripeCustomer->id,
'response' => $stripeCustomer->jsonSerialize()
]);
if (!$this->saveCustomer($customer)) {
throw new CustomerException('Could not save customer: ' . implode(', ', $customer->getErrorSummary(true)));
}
return $customer;
} | php | public function getCustomer(int $gatewayId, User $user): Customer
{
$result = $this->_createCustomerQuery()
->where(['userId' => $user->id, 'gatewayId' => $gatewayId])
->one();
if ($result !== null) {
return new Customer($result);
}
Stripe::setApiKey(Craft::parseEnv(Commerce::getInstance()->getGateways()->getGatewayById($gatewayId)->apiKey));
Stripe::setAppInfo(StripePlugin::getInstance()->name, StripePlugin::getInstance()->version, StripePlugin::getInstance()->documentationUrl);
Stripe::setApiVersion(Gateway::STRIPE_API_VERSION);
/** @var StripeCustomer $stripeCustomer */
$stripeCustomer = StripeCustomer::create([
'description' => Craft::t('commerce-stripe', 'Customer for Craft user with ID {id}', ['id' => $user->id]),
'email' => $user->email
]);
$customer = new Customer([
'userId' => $user->id,
'gatewayId' => $gatewayId,
'reference' => $stripeCustomer->id,
'response' => $stripeCustomer->jsonSerialize()
]);
if (!$this->saveCustomer($customer)) {
throw new CustomerException('Could not save customer: ' . implode(', ', $customer->getErrorSummary(true)));
}
return $customer;
} | [
"public",
"function",
"getCustomer",
"(",
"int",
"$",
"gatewayId",
",",
"User",
"$",
"user",
")",
":",
"Customer",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_createCustomerQuery",
"(",
")",
"->",
"where",
"(",
"[",
"'userId'",
"=>",
"$",
"user",
"->... | Returns a customer by gateway and user
@param int $gatewayId The stripe gateway
@param User $user The user
@return Customer
@throws CustomerException | [
"Returns",
"a",
"customer",
"by",
"gateway",
"and",
"user"
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Customers.php#L44-L76 | train |
craftcms/commerce-stripe | src/services/Customers.php | Customers.deleteCustomerById | public function deleteCustomerById($id): bool
{
$record = CustomerRecord::findOne($id);
if ($record) {
return (bool)$record->delete();
}
return false;
} | php | public function deleteCustomerById($id): bool
{
$record = CustomerRecord::findOne($id);
if ($record) {
return (bool)$record->delete();
}
return false;
} | [
"public",
"function",
"deleteCustomerById",
"(",
"$",
"id",
")",
":",
"bool",
"{",
"$",
"record",
"=",
"CustomerRecord",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"record",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"record",
"->",
... | Delete a customer by it's id.
@param int $id The id
@return bool
@throws \Throwable in case something went wrong when deleting. | [
"Delete",
"a",
"customer",
"by",
"it",
"s",
"id",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/services/Customers.php#L126-L135 | train |
craftcms/commerce-stripe | src/models/Plan.php | Plan.isOnSamePaymentCycleAs | public function isOnSamePaymentCycleAs(Plan $plan): bool
{
$thisPlanData = Json::decode($this->planData);
$otherPlanData = Json::decode($plan->planData);
return $thisPlanData['plan']['interval'] === $otherPlanData['plan']['interval'] && $thisPlanData['plan']['interval_count'] === $otherPlanData['plan']['interval_count'];
} | php | public function isOnSamePaymentCycleAs(Plan $plan): bool
{
$thisPlanData = Json::decode($this->planData);
$otherPlanData = Json::decode($plan->planData);
return $thisPlanData['plan']['interval'] === $otherPlanData['plan']['interval'] && $thisPlanData['plan']['interval_count'] === $otherPlanData['plan']['interval_count'];
} | [
"public",
"function",
"isOnSamePaymentCycleAs",
"(",
"Plan",
"$",
"plan",
")",
":",
"bool",
"{",
"$",
"thisPlanData",
"=",
"Json",
"::",
"decode",
"(",
"$",
"this",
"->",
"planData",
")",
";",
"$",
"otherPlanData",
"=",
"Json",
"::",
"decode",
"(",
"$",
... | Returns true if this plan is on the same payment cycle as another plan.
@param Plan $plan
@return bool | [
"Returns",
"true",
"if",
"this",
"plan",
"is",
"on",
"the",
"same",
"payment",
"cycle",
"as",
"another",
"plan",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/models/Plan.php#L37-L43 | train |
craftcms/commerce-stripe | src/migrations/Install.php | Install._convertGateways | private function _convertGateways()
{
$gateways = (new Query())
->select(['id', 'settings'])
->where(['type' => 'craft\\commerce\\gateways\\Stripe'])
->from(['{{%commerce_gateways}}'])
->all();
$dbConnection = Craft::$app->getDb();
foreach ($gateways as $gateway) {
$settings = Json::decodeIfJson($gateway['settings']);
if ($settings && isset($settings['includeReceiptEmailInRequests'])) {
$settings['sendReceiptEmail'] = $settings['includeReceiptEmailInRequests'];
unset($settings['includeReceiptEmailInRequests']);
} else {
$settings = [];
}
$settings = Json::encode($settings);
$values = [
'type' => Gateway::class,
'settings' => $settings
];
$dbConnection->createCommand()
->update('{{%commerce_gateways}}', $values, ['id' => $gateway['id']])
->execute();
}
} | php | private function _convertGateways()
{
$gateways = (new Query())
->select(['id', 'settings'])
->where(['type' => 'craft\\commerce\\gateways\\Stripe'])
->from(['{{%commerce_gateways}}'])
->all();
$dbConnection = Craft::$app->getDb();
foreach ($gateways as $gateway) {
$settings = Json::decodeIfJson($gateway['settings']);
if ($settings && isset($settings['includeReceiptEmailInRequests'])) {
$settings['sendReceiptEmail'] = $settings['includeReceiptEmailInRequests'];
unset($settings['includeReceiptEmailInRequests']);
} else {
$settings = [];
}
$settings = Json::encode($settings);
$values = [
'type' => Gateway::class,
'settings' => $settings
];
$dbConnection->createCommand()
->update('{{%commerce_gateways}}', $values, ['id' => $gateway['id']])
->execute();
}
} | [
"private",
"function",
"_convertGateways",
"(",
")",
"{",
"$",
"gateways",
"=",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'id'",
",",
"'settings'",
"]",
")",
"->",
"where",
"(",
"[",
"'type'",
"=>",
"'craft\\\\commerce\\\\gateways\\\\S... | Converts any old school Stripe gateways to this one | [
"Converts",
"any",
"old",
"school",
"Stripe",
"gateways",
"to",
"this",
"one"
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/migrations/Install.php#L90-L122 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._buildRequestPaymentSource | private function _buildRequestPaymentSource(Transaction $transaction, Payment $paymentForm, array $request): Source
{
// For 3D secure, make sure to set the redirect URL and the metadata flag, so we can catch it later.
if ($paymentForm->threeDSecure) {
unset($request['description'], $request['receipt_email']);
$request['type'] = 'three_d_secure';
$request['three_d_secure'] = [
'card' => $paymentForm->token
];
$request['redirect'] = [
'return_url' => UrlHelper::actionUrl('commerce/payments/complete-payment', ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash])
];
$request['metadata']['three_d_secure_flow'] = true;
return Source::create($request);
}
if ($paymentForm->token) {
$paymentForm->token = $this->_normalizePaymentToken((string)$paymentForm->token);
/** @var Source $source */
$source = Source::retrieve($paymentForm->token);
// If this required 3D secure, let's set the flag for it and repeat
if (!empty($source->card->three_d_secure) && $source->card->three_d_secure == 'required') {
$paymentForm->threeDSecure = true;
return $this->_buildRequestPaymentSource($transaction, $paymentForm, $request);
}
return $source;
}
throw new PaymentException(Craft::t('commerce-stripe', 'Cannot process the payment at this time'));
} | php | private function _buildRequestPaymentSource(Transaction $transaction, Payment $paymentForm, array $request): Source
{
// For 3D secure, make sure to set the redirect URL and the metadata flag, so we can catch it later.
if ($paymentForm->threeDSecure) {
unset($request['description'], $request['receipt_email']);
$request['type'] = 'three_d_secure';
$request['three_d_secure'] = [
'card' => $paymentForm->token
];
$request['redirect'] = [
'return_url' => UrlHelper::actionUrl('commerce/payments/complete-payment', ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash])
];
$request['metadata']['three_d_secure_flow'] = true;
return Source::create($request);
}
if ($paymentForm->token) {
$paymentForm->token = $this->_normalizePaymentToken((string)$paymentForm->token);
/** @var Source $source */
$source = Source::retrieve($paymentForm->token);
// If this required 3D secure, let's set the flag for it and repeat
if (!empty($source->card->three_d_secure) && $source->card->three_d_secure == 'required') {
$paymentForm->threeDSecure = true;
return $this->_buildRequestPaymentSource($transaction, $paymentForm, $request);
}
return $source;
}
throw new PaymentException(Craft::t('commerce-stripe', 'Cannot process the payment at this time'));
} | [
"private",
"function",
"_buildRequestPaymentSource",
"(",
"Transaction",
"$",
"transaction",
",",
"Payment",
"$",
"paymentForm",
",",
"array",
"$",
"request",
")",
":",
"Source",
"{",
"// For 3D secure, make sure to set the redirect URL and the metadata flag, so we can catch it... | Build a payment source for request.
@param Transaction $transaction the transaction to be used as base
@param Payment $paymentForm the payment form
@param array $request the request data
@return Source
@throws PaymentException if unexpected payment information encountered | [
"Build",
"a",
"payment",
"source",
"for",
"request",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1001-L1039 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._createPaymentResponseFromError | private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse
{
if ($exception instanceof CardError) {
$body = $exception->getJsonBody();
$data = $body;
$data['code'] = $body['error']['code'];
$data['message'] = $body['error']['message'];
$data['id'] = $body['error']['charge'];
} else if ($exception instanceof Base) {
// So it's not a card being declined but something else. ¯\_(ツ)_/¯
$body = $exception->getJsonBody();
$data = $body;
$data['id'] = null;
$data['message'] = $body['error']['message'] ?? $exception->getMessage();
$data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode();
} else {
throw $exception;
}
return new PaymentResponse($data);
} | php | private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse
{
if ($exception instanceof CardError) {
$body = $exception->getJsonBody();
$data = $body;
$data['code'] = $body['error']['code'];
$data['message'] = $body['error']['message'];
$data['id'] = $body['error']['charge'];
} else if ($exception instanceof Base) {
// So it's not a card being declined but something else. ¯\_(ツ)_/¯
$body = $exception->getJsonBody();
$data = $body;
$data['id'] = null;
$data['message'] = $body['error']['message'] ?? $exception->getMessage();
$data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode();
} else {
throw $exception;
}
return new PaymentResponse($data);
} | [
"private",
"function",
"_createPaymentResponseFromError",
"(",
"\\",
"Exception",
"$",
"exception",
")",
":",
"PaymentResponse",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"CardError",
")",
"{",
"$",
"body",
"=",
"$",
"exception",
"->",
"getJsonBody",
"(",
... | Create a Response object from an Exception.
@param \Exception $exception
@return PaymentResponse
@throws \Exception if not a Stripe exception | [
"Create",
"a",
"Response",
"object",
"from",
"an",
"Exception",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1063-L1083 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._createSubscriptionPayment | private function _createSubscriptionPayment(array $data, Currency $currency): SubscriptionPayment
{
$payment = new SubscriptionPayment([
'paymentAmount' => $data['amount_due'] / (10 ** $currency->minorUnit),
'paymentCurrency' => $currency,
'paymentDate' => $data['date'],
'paymentReference' => $data['charge'],
'paid' => $data['paid'],
'response' => Json::encode($data)
]);
return $payment;
} | php | private function _createSubscriptionPayment(array $data, Currency $currency): SubscriptionPayment
{
$payment = new SubscriptionPayment([
'paymentAmount' => $data['amount_due'] / (10 ** $currency->minorUnit),
'paymentCurrency' => $currency,
'paymentDate' => $data['date'],
'paymentReference' => $data['charge'],
'paid' => $data['paid'],
'response' => Json::encode($data)
]);
return $payment;
} | [
"private",
"function",
"_createSubscriptionPayment",
"(",
"array",
"$",
"data",
",",
"Currency",
"$",
"currency",
")",
":",
"SubscriptionPayment",
"{",
"$",
"payment",
"=",
"new",
"SubscriptionPayment",
"(",
"[",
"'paymentAmount'",
"=>",
"$",
"data",
"[",
"'amou... | Create a subscription payment model from invoice.
@param array $data
@param Currency $currency the currency used for payment
@return SubscriptionPayment | [
"Create",
"a",
"subscription",
"payment",
"model",
"from",
"invoice",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1093-L1105 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._handleInvoiceCreated | private function _handleInvoiceCreated(array $data)
{
$stripeInvoice = $data['data']['object'];
if ($this->hasEventHandlers(self::EVENT_CREATE_INVOICE)) {
$this->trigger(self::EVENT_CREATE_INVOICE, new CreateInvoiceEvent([
'invoiceData' => $stripeInvoice
]));
}
$canBePaid = empty($stripeInvoice['paid']) && $stripeInvoice['billing'] === 'charge_automatically';
if (StripePlugin::getInstance()->getSettings()->chargeInvoicesImmediately && $canBePaid) {
/** @var StripeInvoice $invoice */
$invoice = StripeInvoice::retrieve($stripeInvoice['id']);
$invoice->pay();
}
} | php | private function _handleInvoiceCreated(array $data)
{
$stripeInvoice = $data['data']['object'];
if ($this->hasEventHandlers(self::EVENT_CREATE_INVOICE)) {
$this->trigger(self::EVENT_CREATE_INVOICE, new CreateInvoiceEvent([
'invoiceData' => $stripeInvoice
]));
}
$canBePaid = empty($stripeInvoice['paid']) && $stripeInvoice['billing'] === 'charge_automatically';
if (StripePlugin::getInstance()->getSettings()->chargeInvoicesImmediately && $canBePaid) {
/** @var StripeInvoice $invoice */
$invoice = StripeInvoice::retrieve($stripeInvoice['id']);
$invoice->pay();
}
} | [
"private",
"function",
"_handleInvoiceCreated",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"stripeInvoice",
"=",
"$",
"data",
"[",
"'data'",
"]",
"[",
"'object'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasEventHandlers",
"(",
"self",
"::",
"EVENT_CREATE_I... | Handle a created invoice.
@param array $data | [
"Handle",
"a",
"created",
"invoice",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1210-L1227 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._handlePlanEvent | private function _handlePlanEvent(array $data)
{
$planService = Commerce::getInstance()->getPlans();
if ($data['type'] == 'plan.deleted') {
$plan = $planService->getPlanByReference($data['data']['object']['id']);
if ($plan) {
$planService->archivePlanById($plan->id);
Craft::warning($plan->name . ' was archived because the corresponding plan was deleted on Stripe. (event "' . $data['id'] . '")', 'stripe');
}
}
} | php | private function _handlePlanEvent(array $data)
{
$planService = Commerce::getInstance()->getPlans();
if ($data['type'] == 'plan.deleted') {
$plan = $planService->getPlanByReference($data['data']['object']['id']);
if ($plan) {
$planService->archivePlanById($plan->id);
Craft::warning($plan->name . ' was archived because the corresponding plan was deleted on Stripe. (event "' . $data['id'] . '")', 'stripe');
}
}
} | [
"private",
"function",
"_handlePlanEvent",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"planService",
"=",
"Commerce",
"::",
"getInstance",
"(",
")",
"->",
"getPlans",
"(",
")",
";",
"if",
"(",
"$",
"data",
"[",
"'type'",
"]",
"==",
"'plan.deleted'",
")",
... | Handle Plan events
@param array $data
@throws \yii\base\InvalidConfigException If plan not | [
"Handle",
"Plan",
"events"
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1276-L1288 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._getStripeCustomer | private function _getStripeCustomer(int $userId): Customer
{
try {
$user = Craft::$app->getUsers()->getUserById($userId);
$customers = StripePlugin::getInstance()->getCustomers();
$customer = $customers->getCustomer($this->id, $user);
return Customer::retrieve($customer->reference);
} catch (\Exception $exception) {
throw new CustomerException('Could not fetch Stripe customer: ' . $exception->getMessage());
}
} | php | private function _getStripeCustomer(int $userId): Customer
{
try {
$user = Craft::$app->getUsers()->getUserById($userId);
$customers = StripePlugin::getInstance()->getCustomers();
$customer = $customers->getCustomer($this->id, $user);
return Customer::retrieve($customer->reference);
} catch (\Exception $exception) {
throw new CustomerException('Could not fetch Stripe customer: ' . $exception->getMessage());
}
} | [
"private",
"function",
"_getStripeCustomer",
"(",
"int",
"$",
"userId",
")",
":",
"Customer",
"{",
"try",
"{",
"$",
"user",
"=",
"Craft",
"::",
"$",
"app",
"->",
"getUsers",
"(",
")",
"->",
"getUserById",
"(",
"$",
"userId",
")",
";",
"$",
"customers",... | Get the Stripe customer for a User.
@param int $userId
@return Customer
@throws CustomerException if wasn't able to create or retrieve Stripe Customer. | [
"Get",
"the",
"Stripe",
"customer",
"for",
"a",
"User",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1360-L1370 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._normalizePaymentToken | private function _normalizePaymentToken(string $token = ''): string
{
if (StringHelper::substr($token, 0, 4) === 'tok_') {
try {
/** @var Source $tokenSource */
$tokenSource = Source::create([
'type' => 'card',
'token' => $token
]);
return $tokenSource->id;
} catch (\Exception $exception) {
Craft::error('Unable to normalize payment token: ' . $token . ', because ' . $exception->getMessage());
}
}
return $token;
} | php | private function _normalizePaymentToken(string $token = ''): string
{
if (StringHelper::substr($token, 0, 4) === 'tok_') {
try {
/** @var Source $tokenSource */
$tokenSource = Source::create([
'type' => 'card',
'token' => $token
]);
return $tokenSource->id;
} catch (\Exception $exception) {
Craft::error('Unable to normalize payment token: ' . $token . ', because ' . $exception->getMessage());
}
}
return $token;
} | [
"private",
"function",
"_normalizePaymentToken",
"(",
"string",
"$",
"token",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"StringHelper",
"::",
"substr",
"(",
"$",
"token",
",",
"0",
",",
"4",
")",
"===",
"'tok_'",
")",
"{",
"try",
"{",
"/** @var So... | Normalize one-time payment token to a source token, that may or may not be multi-use.
@param string $token
@return string | [
"Normalize",
"one",
"-",
"time",
"payment",
"token",
"to",
"a",
"source",
"token",
"that",
"may",
"or",
"may",
"not",
"be",
"multi",
"-",
"use",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1378-L1395 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._authorizeOrPurchase | private function _authorizeOrPurchase(Transaction $transaction, BasePaymentForm $form, bool $capture = true): RequestResponseInterface
{
/** @var Payment $form */
$requestData = $this->_buildRequestData($transaction);
$paymentSource = $this->_buildRequestPaymentSource($transaction, $form, $requestData);
if ($paymentSource instanceof Source && $paymentSource->status === 'pending' && $paymentSource->flow === 'redirect') {
// This should only happen for 3D secure payments.
$response = $this->_createPaymentResponseFromApiResource($paymentSource);
$response->setRedirectUrl($paymentSource->redirect->url);
return $response;
}
$requestData['source'] = $paymentSource;
if ($form->customer) {
$requestData['customer'] = $form->customer;
}
$requestData['capture'] = $capture;
try {
$charge = Charge::create($requestData, ['idempotency_key' => $transaction->hash]);
return $this->_createPaymentResponseFromApiResource($charge);
} catch (\Exception $exception) {
return $this->_createPaymentResponseFromError($exception);
}
} | php | private function _authorizeOrPurchase(Transaction $transaction, BasePaymentForm $form, bool $capture = true): RequestResponseInterface
{
/** @var Payment $form */
$requestData = $this->_buildRequestData($transaction);
$paymentSource = $this->_buildRequestPaymentSource($transaction, $form, $requestData);
if ($paymentSource instanceof Source && $paymentSource->status === 'pending' && $paymentSource->flow === 'redirect') {
// This should only happen for 3D secure payments.
$response = $this->_createPaymentResponseFromApiResource($paymentSource);
$response->setRedirectUrl($paymentSource->redirect->url);
return $response;
}
$requestData['source'] = $paymentSource;
if ($form->customer) {
$requestData['customer'] = $form->customer;
}
$requestData['capture'] = $capture;
try {
$charge = Charge::create($requestData, ['idempotency_key' => $transaction->hash]);
return $this->_createPaymentResponseFromApiResource($charge);
} catch (\Exception $exception) {
return $this->_createPaymentResponseFromError($exception);
}
} | [
"private",
"function",
"_authorizeOrPurchase",
"(",
"Transaction",
"$",
"transaction",
",",
"BasePaymentForm",
"$",
"form",
",",
"bool",
"$",
"capture",
"=",
"true",
")",
":",
"RequestResponseInterface",
"{",
"/** @var Payment $form */",
"$",
"requestData",
"=",
"$"... | Make an authorize or purchase request to Stripe
@param Transaction $transaction the transaction on which this request is based
@param BasePaymentForm $form payment form parameters
@param bool $capture whether funds should be captured immediately, defaults to true.
@return RequestResponseInterface
@throws NotSupportedException if unrecognized currency specified for transaction
@throws PaymentException if unexpected payment information provided.
@throws \Exception if reasons | [
"Make",
"an",
"authorize",
"or",
"purchase",
"request",
"to",
"Stripe"
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1409-L1438 | train |
craftcms/commerce-stripe | src/gateways/Gateway.php | Gateway._saveSubscriptionInvoice | private function _saveSubscriptionInvoice(array $stripeInvoice, Subscription $subscription): Invoice
{
$invoiceService = StripePlugin::getInstance()->getInvoices();
$invoice = $invoiceService->getInvoiceByReference($stripeInvoice['id']) ?: new Invoice();
$invoice->subscriptionId = $subscription->id;
$invoice->reference = $stripeInvoice['id'];
$invoice->invoiceData = $stripeInvoice;
$invoiceService->saveInvoice($invoice);
return $invoice;
} | php | private function _saveSubscriptionInvoice(array $stripeInvoice, Subscription $subscription): Invoice
{
$invoiceService = StripePlugin::getInstance()->getInvoices();
$invoice = $invoiceService->getInvoiceByReference($stripeInvoice['id']) ?: new Invoice();
$invoice->subscriptionId = $subscription->id;
$invoice->reference = $stripeInvoice['id'];
$invoice->invoiceData = $stripeInvoice;
$invoiceService->saveInvoice($invoice);
return $invoice;
} | [
"private",
"function",
"_saveSubscriptionInvoice",
"(",
"array",
"$",
"stripeInvoice",
",",
"Subscription",
"$",
"subscription",
")",
":",
"Invoice",
"{",
"$",
"invoiceService",
"=",
"StripePlugin",
"::",
"getInstance",
"(",
")",
"->",
"getInvoices",
"(",
")",
"... | Save a subscription invoice.
@param $stripeInvoice
@param $subscription
@return Invoice | [
"Save",
"a",
"subscription",
"invoice",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/gateways/Gateway.php#L1447-L1457 | train |
craftcms/commerce-stripe | src/models/Customer.php | Customer.getGateway | public function getGateway()
{
if (null === $this->_gateway) {
$this->_gateway = Commerce::getInstance()->getGateways()->getGatewayById($this->gatewayId);
}
return $this->_gateway;
} | php | public function getGateway()
{
if (null === $this->_gateway) {
$this->_gateway = Commerce::getInstance()->getGateways()->getGatewayById($this->gatewayId);
}
return $this->_gateway;
} | [
"public",
"function",
"getGateway",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_gateway",
")",
"{",
"$",
"this",
"->",
"_gateway",
"=",
"Commerce",
"::",
"getInstance",
"(",
")",
"->",
"getGateways",
"(",
")",
"->",
"getGatewayById",
... | Returns the gateway associated with this customer.
@return GatewayInterface|null | [
"Returns",
"the",
"gateway",
"associated",
"with",
"this",
"customer",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/models/Customer.php#L98-L105 | train |
craftcms/commerce-stripe | src/controllers/DefaultController.php | DefaultController.actionFetchPlans | public function actionFetchPlans()
{
try {
$this->requirePostRequest();
$this->requireAcceptsJson();
$request = Craft::$app->getRequest();
$gatewayId = $request->getRequiredBodyParam('gatewayId');
$gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId);
if (!$gateway || !$gateway instanceof Gateway) {
throw new BadRequestHttpException('That is not a valid gateway id.');
}
return $this->asJson($gateway->getSubscriptionPlans());
} catch (\Throwable $e) {
return $this->asErrorJson($e->getMessage());
}
} | php | public function actionFetchPlans()
{
try {
$this->requirePostRequest();
$this->requireAcceptsJson();
$request = Craft::$app->getRequest();
$gatewayId = $request->getRequiredBodyParam('gatewayId');
$gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId);
if (!$gateway || !$gateway instanceof Gateway) {
throw new BadRequestHttpException('That is not a valid gateway id.');
}
return $this->asJson($gateway->getSubscriptionPlans());
} catch (\Throwable $e) {
return $this->asErrorJson($e->getMessage());
}
} | [
"public",
"function",
"actionFetchPlans",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"requirePostRequest",
"(",
")",
";",
"$",
"this",
"->",
"requireAcceptsJson",
"(",
")",
";",
"$",
"request",
"=",
"Craft",
"::",
"$",
"app",
"->",
"getRequest",
"(",
... | Load Stripe Subscription plans for a gateway.
@return Response | [
"Load",
"Stripe",
"Subscription",
"plans",
"for",
"a",
"gateway",
"."
] | 95795f5997cd4d57e3652ca12bfc3c15f182fb02 | https://github.com/craftcms/commerce-stripe/blob/95795f5997cd4d57e3652ca12bfc3c15f182fb02/src/controllers/DefaultController.php#L39-L57 | train |
rips/php-connector | src/Requests/BaseRequest.php | BaseRequest.handleResponse | protected function handleResponse(ResponseInterface $response)
{
$responseWrapper = new Response($response);
$statusCode = (int) floor($response->getStatusCode() / 100);
if ($statusCode === 4) {
throw new ClientException($responseWrapper);
} elseif ($statusCode === 5) {
throw new ServerException($responseWrapper);
}
return $responseWrapper;
} | php | protected function handleResponse(ResponseInterface $response)
{
$responseWrapper = new Response($response);
$statusCode = (int) floor($response->getStatusCode() / 100);
if ($statusCode === 4) {
throw new ClientException($responseWrapper);
} elseif ($statusCode === 5) {
throw new ServerException($responseWrapper);
}
return $responseWrapper;
} | [
"protected",
"function",
"handleResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"responseWrapper",
"=",
"new",
"Response",
"(",
"$",
"response",
")",
";",
"$",
"statusCode",
"=",
"(",
"int",
")",
"floor",
"(",
"$",
"response",
"->",
"g... | Handle response returned by Guzzle
@param ResponseInterface $response
@return Response
@throws ClientException if status code starts with 4
@throws ServerException if status code starts with 5 | [
"Handle",
"response",
"returned",
"by",
"Guzzle"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/BaseRequest.php#L34-L46 | train |
rips/php-connector | src/Requests/MaintenanceRequests.php | MaintenanceRequests.deleteCode | public function deleteCode(array $queryParams = [])
{
$response = $this->client->delete('/maintenance/code', [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function deleteCode(array $queryParams = [])
{
$response = $this->client->delete('/maintenance/code', [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"deleteCode",
"(",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"'/maintenance/code'",
",",
"[",
"'query'",
"=>",
"$",
"queryParams",
",",
"]",
")",
... | Remove old and unused code from cloud.
@param array $queryParams
@return Response | [
"Remove",
"old",
"and",
"unused",
"code",
"from",
"cloud",
"."
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/MaintenanceRequests.php#L15-L22 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.deleteById | public function deleteById($appId, $scanId, array $queryParams = [])
{
if (is_null($appId) || is_null($scanId)) {
throw new LibException('appId or scanId is null');
}
$response = $this->client->delete("{$this->uri($appId)}/{$scanId}", [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function deleteById($appId, $scanId, array $queryParams = [])
{
if (is_null($appId) || is_null($scanId)) {
throw new LibException('appId or scanId is null');
}
$response = $this->client->delete("{$this->uri($appId)}/{$scanId}", [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"deleteById",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"appId",
")",
"||",
"is_null",
"(",
"$",
"scanId",
")",
")",
"{",
"throw",
"new",
... | Delete a scan by id
@param int $appId
@param int $scanId
@param array $queryParams
@return Response | [
"Delete",
"a",
"scan",
"by",
"id"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L223-L234 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.blockUntilDone | public function blockUntilDone(
$appId,
$scanId,
$waitTime = 0,
$sleepTime = 5,
array $queryParams = []
) {
for ($iteration = 0;; $iteration++) {
$scanResponse = $this->getById($appId, $scanId, $queryParams);
$scan = $scanResponse->getDecodedData();
if ((int) $scan->phase === 0 && (int) $scan->percent === 100) {
return $scanResponse;
} else if ($waitTime > 0 && $iteration > ($waitTime / $sleepTime)) {
throw new \Exception('Scan did not finish before the defined wait time.');
}
sleep($sleepTime);
}
throw new \Exception('blockUntilDone unexpected state');
} | php | public function blockUntilDone(
$appId,
$scanId,
$waitTime = 0,
$sleepTime = 5,
array $queryParams = []
) {
for ($iteration = 0;; $iteration++) {
$scanResponse = $this->getById($appId, $scanId, $queryParams);
$scan = $scanResponse->getDecodedData();
if ((int) $scan->phase === 0 && (int) $scan->percent === 100) {
return $scanResponse;
} else if ($waitTime > 0 && $iteration > ($waitTime / $sleepTime)) {
throw new \Exception('Scan did not finish before the defined wait time.');
}
sleep($sleepTime);
}
throw new \Exception('blockUntilDone unexpected state');
} | [
"public",
"function",
"blockUntilDone",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"$",
"waitTime",
"=",
"0",
",",
"$",
"sleepTime",
"=",
"5",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"for",
"(",
"$",
"iteration",
"=",
"0",
";",
... | Block until scan is finished
@param int $appId
@param int $scanId
@param int $waitTime - Optional time to wait, will wait indefinitely if 0 (default: 0)
@param int $sleepTime - Time to wait between scan completion checks (default: 5)
@param array $queryParams
@return Response
@throws \Exception if scan does not finish in time | [
"Block",
"until",
"scan",
"is",
"finished"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L247-L268 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.classes | public function classes()
{
if (is_null($this->classRequests)) {
$this->classRequests = new ClassRequests($this->client);
}
return $this->classRequests;
} | php | public function classes()
{
if (is_null($this->classRequests)) {
$this->classRequests = new ClassRequests($this->client);
}
return $this->classRequests;
} | [
"public",
"function",
"classes",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"classRequests",
")",
")",
"{",
"$",
"this",
"->",
"classRequests",
"=",
"new",
"ClassRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
... | Class requests accessor
@return ClassRequests | [
"Class",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L275-L282 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.comparisons | public function comparisons()
{
if (is_null($this->comparisonRequests)) {
$this->comparisonRequests = new ComparisonRequests($this->client);
}
return $this->comparisonRequests;
} | php | public function comparisons()
{
if (is_null($this->comparisonRequests)) {
$this->comparisonRequests = new ComparisonRequests($this->client);
}
return $this->comparisonRequests;
} | [
"public",
"function",
"comparisons",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"comparisonRequests",
")",
")",
"{",
"$",
"this",
"->",
"comparisonRequests",
"=",
"new",
"ComparisonRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
... | Comparison requests accessor
@return ComparisonRequests | [
"Comparison",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L289-L296 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.concats | public function concats()
{
if (is_null($this->concatRequests)) {
$this->concatRequests = new ConcatRequests($this->client);
}
return $this->concatRequests;
} | php | public function concats()
{
if (is_null($this->concatRequests)) {
$this->concatRequests = new ConcatRequests($this->client);
}
return $this->concatRequests;
} | [
"public",
"function",
"concats",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"concatRequests",
")",
")",
"{",
"$",
"this",
"->",
"concatRequests",
"=",
"new",
"ConcatRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Concat requests accessor
@return ConcatRequests | [
"Concat",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L303-L310 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.exports | public function exports()
{
if (is_null($this->exportRequests)) {
$this->exportRequests = new ExportRequests($this->client);
}
return $this->exportRequests;
} | php | public function exports()
{
if (is_null($this->exportRequests)) {
$this->exportRequests = new ExportRequests($this->client);
}
return $this->exportRequests;
} | [
"public",
"function",
"exports",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"exportRequests",
")",
")",
"{",
"$",
"this",
"->",
"exportRequests",
"=",
"new",
"ExportRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Export requests accessor
@return ExportRequests | [
"Export",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L317-L324 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.files | public function files()
{
if (is_null($this->fileRequests)) {
$this->fileRequests = new FileRequests($this->client);
}
return $this->fileRequests;
} | php | public function files()
{
if (is_null($this->fileRequests)) {
$this->fileRequests = new FileRequests($this->client);
}
return $this->fileRequests;
} | [
"public",
"function",
"files",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"fileRequests",
")",
")",
"{",
"$",
"this",
"->",
"fileRequests",
"=",
"new",
"FileRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
"$",
... | File requests accessor
@return FileRequests | [
"File",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L331-L338 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.functions | public function functions()
{
if (is_null($this->functionRequests)) {
$this->functionRequests = new FunctionRequests($this->client);
}
return $this->functionRequests;
} | php | public function functions()
{
if (is_null($this->functionRequests)) {
$this->functionRequests = new FunctionRequests($this->client);
}
return $this->functionRequests;
} | [
"public",
"function",
"functions",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"functionRequests",
")",
")",
"{",
"$",
"this",
"->",
"functionRequests",
"=",
"new",
"FunctionRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"... | Function requests accessor
@return FunctionRequests | [
"Function",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L345-L352 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.issues | public function issues()
{
if (is_null($this->issueRequests)) {
$this->issueRequests = new IssueRequests($this->client);
}
return $this->issueRequests;
} | php | public function issues()
{
if (is_null($this->issueRequests)) {
$this->issueRequests = new IssueRequests($this->client);
}
return $this->issueRequests;
} | [
"public",
"function",
"issues",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"issueRequests",
")",
")",
"{",
"$",
"this",
"->",
"issueRequests",
"=",
"new",
"IssueRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
"... | Issue requests accessor
@return IssueRequests | [
"Issue",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L359-L366 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.processes | public function processes()
{
if (is_null($this->processRequests)) {
$this->processRequests = new ProcessRequests($this->client);
}
return $this->processRequests;
} | php | public function processes()
{
if (is_null($this->processRequests)) {
$this->processRequests = new ProcessRequests($this->client);
}
return $this->processRequests;
} | [
"public",
"function",
"processes",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"processRequests",
")",
")",
"{",
"$",
"this",
"->",
"processRequests",
"=",
"new",
"ProcessRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"ret... | Process requests accessor
@return ProcessRequests | [
"Process",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L373-L380 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.sinks | public function sinks()
{
if (is_null($this->sinkRequests)) {
$this->sinkRequests = new SinkRequests($this->client);
}
return $this->sinkRequests;
} | php | public function sinks()
{
if (is_null($this->sinkRequests)) {
$this->sinkRequests = new SinkRequests($this->client);
}
return $this->sinkRequests;
} | [
"public",
"function",
"sinks",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"sinkRequests",
")",
")",
"{",
"$",
"this",
"->",
"sinkRequests",
"=",
"new",
"SinkRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
"$",
... | Sink requests accessor
@return SinkRequests | [
"Sink",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L387-L394 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.sources | public function sources()
{
if (is_null($this->sourceRequests)) {
$this->sourceRequests = new SourceRequests($this->client);
}
return $this->sourceRequests;
} | php | public function sources()
{
if (is_null($this->sourceRequests)) {
$this->sourceRequests = new SourceRequests($this->client);
}
return $this->sourceRequests;
} | [
"public",
"function",
"sources",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"sourceRequests",
")",
")",
"{",
"$",
"this",
"->",
"sourceRequests",
"=",
"new",
"SourceRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Source requests accessor
@return SourceRequests | [
"Source",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L401-L408 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.entrypoints | public function entrypoints()
{
if (is_null($this->entrypointRequests)) {
$this->entrypointRequests = new EntrypointRequests($this->client);
}
return $this->entrypointRequests;
} | php | public function entrypoints()
{
if (is_null($this->entrypointRequests)) {
$this->entrypointRequests = new EntrypointRequests($this->client);
}
return $this->entrypointRequests;
} | [
"public",
"function",
"entrypoints",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"entrypointRequests",
")",
")",
"{",
"$",
"this",
"->",
"entrypointRequests",
"=",
"new",
"EntrypointRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
... | Entrypoint requests accessor
@return EntrypointRequests | [
"Entrypoint",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L415-L422 | train |
rips/php-connector | src/Requests/Application/ScanRequests.php | ScanRequests.libraries | public function libraries()
{
if (is_null($this->libraryRequests)) {
$this->libraryRequests = new LibraryRequests($this->client);
}
return $this->libraryRequests;
} | php | public function libraries()
{
if (is_null($this->libraryRequests)) {
$this->libraryRequests = new LibraryRequests($this->client);
}
return $this->libraryRequests;
} | [
"public",
"function",
"libraries",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"libraryRequests",
")",
")",
"{",
"$",
"this",
"->",
"libraryRequests",
"=",
"new",
"LibraryRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"ret... | Libraries requests accessor
@return LibraryRequests | [
"Libraries",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ScanRequests.php#L429-L436 | train |
rips/php-connector | src/Requests/StatusRequests.php | StatusRequests.getStatus | public function getStatus(array $queryParams = [])
{
$response = $this->client->get($this->uri(), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function getStatus(array $queryParams = [])
{
$response = $this->client->get($this->uri(), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"getStatus",
"(",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"uri",
"(",
")",
",",
"[",
"'query'",
"=>",
"$",
"queryParams",
",... | Get status info for the current session and API env.
@param array $queryParams
@return Response | [
"Get",
"status",
"info",
"for",
"the",
"current",
"session",
"and",
"API",
"env",
"."
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/StatusRequests.php#L26-L33 | train |
rips/php-connector | src/Requests/StatusRequests.php | StatusRequests.isLoggedIn | public function isLoggedIn()
{
$response = $this->client->get($this->uri());
try {
$body = $this->handleResponse($response)->getDecodedData();
} catch (ClientException $exception) {
return false;
}
return property_exists(
$body,
'user'
);
} | php | public function isLoggedIn()
{
$response = $this->client->get($this->uri());
try {
$body = $this->handleResponse($response)->getDecodedData();
} catch (ClientException $exception) {
return false;
}
return property_exists(
$body,
'user'
);
} | [
"public",
"function",
"isLoggedIn",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"uri",
"(",
")",
")",
";",
"try",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"handleResponse",
"(",
"$",
"re... | Checks if the user is logged with the given credentials
@return boolean | [
"Checks",
"if",
"the",
"user",
"is",
"logged",
"with",
"the",
"given",
"credentials"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/StatusRequests.php#L40-L54 | train |
rips/php-connector | src/Requests/Application/Scan/Issue/ReviewRequests.php | ReviewRequests.uri | protected function uri($appId, $scanId, $issueId = null, $reviewId = null)
{
if (is_null($issueId)) {
return "/applications/{$appId}/scans/{$scanId}/issues/reviews/batches";
}
return is_null($reviewId)
? "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews"
: "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews/{$reviewId}";
} | php | protected function uri($appId, $scanId, $issueId = null, $reviewId = null)
{
if (is_null($issueId)) {
return "/applications/{$appId}/scans/{$scanId}/issues/reviews/batches";
}
return is_null($reviewId)
? "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews"
: "/applications/{$appId}/scans/{$scanId}/issues/{$issueId}/reviews/{$reviewId}";
} | [
"protected",
"function",
"uri",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"$",
"issueId",
"=",
"null",
",",
"$",
"reviewId",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"issueId",
")",
")",
"{",
"return",
"\"/applications/{$appId}/scans/{$sc... | Build a uri for the request
@param int $appId
@param int $scanId
@param int $issueId
@param int $reviewId
@return string | [
"Build",
"a",
"uri",
"for",
"the",
"request"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/Issue/ReviewRequests.php#L26-L35 | train |
rips/php-connector | src/Requests/Application/Scan/Issue/ReviewRequests.php | ReviewRequests.types | public function types()
{
if (is_null($this->typeRequests)) {
$this->typeRequests = new TypeRequests($this->client);
}
return $this->typeRequests;
} | php | public function types()
{
if (is_null($this->typeRequests)) {
$this->typeRequests = new TypeRequests($this->client);
}
return $this->typeRequests;
} | [
"public",
"function",
"types",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"typeRequests",
")",
")",
"{",
"$",
"this",
"->",
"typeRequests",
"=",
"new",
"TypeRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
"$",
... | Type requests accessor
@return TypeRequests | [
"Type",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/Issue/ReviewRequests.php#L118-L125 | train |
rips/php-connector | src/Requests/Application/Scan/ExportRequests.php | ExportRequests.queuePdf | public function queuePdf($appId, $scanId, array $queryParams = [])
{
$response = $this->client->post($this->uri($appId, $scanId, 'pdfs') . '/queues', [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function queuePdf($appId, $scanId, array $queryParams = [])
{
$response = $this->client->post($this->uri($appId, $scanId, 'pdfs') . '/queues', [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"queuePdf",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"uri",
"(",
"$",
"appId",
... | Create a new pdf export on the queue
@param int $appId
@param int $scanId
@param array $queryParams
@return Response | [
"Create",
"a",
"new",
"pdf",
"export",
"on",
"the",
"queue"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/ExportRequests.php#L69-L76 | train |
rips/php-connector | src/Requests/Application/Scan/ExportRequests.php | ExportRequests.getQueuedPdf | public function getQueuedPdf($appId, $scanId, $queueId, array $queryParams = [])
{
$response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId, [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function getQueuedPdf($appId, $scanId, $queueId, array $queryParams = [])
{
$response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId, [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"getQueuedPdf",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"$",
"queueId",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"ur... | Get information about pdf export on queue
@param $appId
@param $scanId
@param $queueId
@param array $queryParams
@return Response | [
"Get",
"information",
"about",
"pdf",
"export",
"on",
"queue"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/ExportRequests.php#L87-L94 | train |
rips/php-connector | src/Requests/Application/Scan/ExportRequests.php | ExportRequests.downloadQueuedPdf | public function downloadQueuedPdf($appId, $scanId, $queueId, $outFile, array $queryParams = [])
{
$response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId . '/downloads', [
'sink' => $outFile,
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function downloadQueuedPdf($appId, $scanId, $queueId, $outFile, array $queryParams = [])
{
$response = $this->client->get($this->uri($appId, $scanId, 'pdfs') . '/queues/' . $queueId . '/downloads', [
'sink' => $outFile,
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"downloadQueuedPdf",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"$",
"queueId",
",",
"$",
"outFile",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"("... | Download pdf export from queue
@param $appId
@param $scanId
@param $queueId
@param $outFile
@param array $queryParams
@return Response | [
"Download",
"pdf",
"export",
"from",
"queue"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/ExportRequests.php#L106-L114 | train |
rips/php-connector | src/Requests/ApplicationRequests.php | ApplicationRequests.acls | public function acls()
{
if (is_null($this->aclRequests)) {
$this->aclRequests = new AclRequests($this->client);
}
return $this->aclRequests;
} | php | public function acls()
{
if (is_null($this->aclRequests)) {
$this->aclRequests = new AclRequests($this->client);
}
return $this->aclRequests;
} | [
"public",
"function",
"acls",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"aclRequests",
")",
")",
"{",
"$",
"this",
"->",
"aclRequests",
"=",
"new",
"AclRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
"$",
"t... | ACL requests accessor
@return Application\AclRequests | [
"ACL",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L152-L159 | train |
rips/php-connector | src/Requests/ApplicationRequests.php | ApplicationRequests.profiles | public function profiles()
{
if (is_null($this->profileRequests)) {
$this->profileRequests = new ProfileRequests($this->client);
}
return $this->profileRequests;
} | php | public function profiles()
{
if (is_null($this->profileRequests)) {
$this->profileRequests = new ProfileRequests($this->client);
}
return $this->profileRequests;
} | [
"public",
"function",
"profiles",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"profileRequests",
")",
")",
"{",
"$",
"this",
"->",
"profileRequests",
"=",
"new",
"ProfileRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"retu... | Profile requests accessor
@return ProfileRequests | [
"Profile",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L166-L173 | train |
rips/php-connector | src/Requests/ApplicationRequests.php | ApplicationRequests.scans | public function scans()
{
if (is_null($this->scanRequests)) {
$this->scanRequests = new ScanRequests($this->client);
}
return $this->scanRequests;
} | php | public function scans()
{
if (is_null($this->scanRequests)) {
$this->scanRequests = new ScanRequests($this->client);
}
return $this->scanRequests;
} | [
"public",
"function",
"scans",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"scanRequests",
")",
")",
"{",
"$",
"this",
"->",
"scanRequests",
"=",
"new",
"ScanRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
"$",
... | Scan requests accessor
@return ScanRequests | [
"Scan",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L180-L187 | train |
rips/php-connector | src/Requests/ApplicationRequests.php | ApplicationRequests.uploads | public function uploads()
{
if (is_null($this->uploadRequests)) {
$this->uploadRequests = new UploadRequests($this->client);
}
return $this->uploadRequests;
} | php | public function uploads()
{
if (is_null($this->uploadRequests)) {
$this->uploadRequests = new UploadRequests($this->client);
}
return $this->uploadRequests;
} | [
"public",
"function",
"uploads",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"uploadRequests",
")",
")",
"{",
"$",
"this",
"->",
"uploadRequests",
"=",
"new",
"UploadRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Upload requests accessor
@return UploadRequests | [
"Upload",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/ApplicationRequests.php#L194-L201 | train |
rips/php-connector | src/Requests/OAuth2Requests.php | OAuth2Requests.clients | public function clients()
{
if (is_null($this->clientRequests)) {
$this->clientRequests = new ClientRequests($this->client);
}
return $this->clientRequests;
} | php | public function clients()
{
if (is_null($this->clientRequests)) {
$this->clientRequests = new ClientRequests($this->client);
}
return $this->clientRequests;
} | [
"public",
"function",
"clients",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"clientRequests",
")",
")",
"{",
"$",
"this",
"->",
"clientRequests",
"=",
"new",
"ClientRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Client request accessor
@return ClientRequests | [
"Client",
"request",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/OAuth2Requests.php#L25-L32 | train |
rips/php-connector | src/Requests/OAuth2Requests.php | OAuth2Requests.accessTokens | public function accessTokens()
{
if (is_null($this->accessTokenRequests)) {
$this->accessTokenRequests = new AccessTokenRequest($this->client);
}
return $this->accessTokenRequests;
} | php | public function accessTokens()
{
if (is_null($this->accessTokenRequests)) {
$this->accessTokenRequests = new AccessTokenRequest($this->client);
}
return $this->accessTokenRequests;
} | [
"public",
"function",
"accessTokens",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"accessTokenRequests",
")",
")",
"{",
"$",
"this",
"->",
"accessTokenRequests",
"=",
"new",
"AccessTokenRequest",
"(",
"$",
"this",
"->",
"client",
")",
";",... | Access token request accessor
@return AccessTokenRequest | [
"Access",
"token",
"request",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/OAuth2Requests.php#L39-L46 | train |
rips/php-connector | src/Requests/Application/Scan/IssueRequests.php | IssueRequests.comments | public function comments()
{
if (is_null($this->commentRequests)) {
$this->commentRequests = new CommentRequests($this->client);
}
return $this->commentRequests;
} | php | public function comments()
{
if (is_null($this->commentRequests)) {
$this->commentRequests = new CommentRequests($this->client);
}
return $this->commentRequests;
} | [
"public",
"function",
"comments",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"commentRequests",
")",
")",
"{",
"$",
"this",
"->",
"commentRequests",
"=",
"new",
"CommentRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"retu... | Accessor for comment requests
@return CommentRequests | [
"Accessor",
"for",
"comment",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/IssueRequests.php#L151-L158 | train |
rips/php-connector | src/Requests/Application/Scan/IssueRequests.php | IssueRequests.contexts | public function contexts()
{
if (is_null($this->contextRequests)) {
$this->contextRequests = new ContextRequests($this->client);
}
return $this->contextRequests;
} | php | public function contexts()
{
if (is_null($this->contextRequests)) {
$this->contextRequests = new ContextRequests($this->client);
}
return $this->contextRequests;
} | [
"public",
"function",
"contexts",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"contextRequests",
")",
")",
"{",
"$",
"this",
"->",
"contextRequests",
"=",
"new",
"ContextRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"retu... | Accessor for context requests
@return ContextRequests | [
"Accessor",
"for",
"context",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/IssueRequests.php#L165-L172 | train |
rips/php-connector | src/Requests/Application/Scan/IssueRequests.php | IssueRequests.origins | public function origins()
{
if (is_null($this->originRequests)) {
$this->originRequests = new OriginRequests($this->client);
}
return $this->originRequests;
} | php | public function origins()
{
if (is_null($this->originRequests)) {
$this->originRequests = new OriginRequests($this->client);
}
return $this->originRequests;
} | [
"public",
"function",
"origins",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"originRequests",
")",
")",
"{",
"$",
"this",
"->",
"originRequests",
"=",
"new",
"OriginRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Origin requests accessor
@return OriginRequests | [
"Origin",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/IssueRequests.php#L179-L186 | train |
rips/php-connector | src/Requests/Application/Scan/IssueRequests.php | IssueRequests.reviews | public function reviews()
{
if (is_null($this->reviewRequests)) {
$this->reviewRequests = new ReviewRequests($this->client);
}
return $this->reviewRequests;
} | php | public function reviews()
{
if (is_null($this->reviewRequests)) {
$this->reviewRequests = new ReviewRequests($this->client);
}
return $this->reviewRequests;
} | [
"public",
"function",
"reviews",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"reviewRequests",
")",
")",
"{",
"$",
"this",
"->",
"reviewRequests",
"=",
"new",
"ReviewRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",... | Accessor for review requests
@return ReviewRequests | [
"Accessor",
"for",
"review",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/IssueRequests.php#L193-L200 | train |
rips/php-connector | src/Requests/Application/Scan/IssueRequests.php | IssueRequests.summaries | public function summaries()
{
if (is_null($this->summaryRequests)) {
$this->summaryRequests = new SummaryRequests($this->client);
}
return $this->summaryRequests;
} | php | public function summaries()
{
if (is_null($this->summaryRequests)) {
$this->summaryRequests = new SummaryRequests($this->client);
}
return $this->summaryRequests;
} | [
"public",
"function",
"summaries",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"summaryRequests",
")",
")",
"{",
"$",
"this",
"->",
"summaryRequests",
"=",
"new",
"SummaryRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"ret... | Accessor for summary requests
@return SummaryRequests | [
"Accessor",
"for",
"summary",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/IssueRequests.php#L207-L214 | train |
rips/php-connector | src/Requests/Application/Scan/IssueRequests.php | IssueRequests.patches | public function patches()
{
if (is_null($this->patchRequests)) {
$this->patchRequests = new PatchRequests($this->client);
}
return $this->patchRequests;
} | php | public function patches()
{
if (is_null($this->patchRequests)) {
$this->patchRequests = new PatchRequests($this->client);
}
return $this->patchRequests;
} | [
"public",
"function",
"patches",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"patchRequests",
")",
")",
"{",
"$",
"this",
"->",
"patchRequests",
"=",
"new",
"PatchRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"return",
... | Accessor for patch requests
@return PatchRequests | [
"Accessor",
"for",
"patch",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/IssueRequests.php#L221-L228 | train |
rips/php-connector | src/Requests/Application/Scan/LibraryRequests.php | LibraryRequests.deleteAll | public function deleteAll($appId, $scanId, array $queryParams = [])
{
$response = $this->client->delete($this->uri($appId, $scanId), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function deleteAll($appId, $scanId, array $queryParams = [])
{
$response = $this->client->delete($this->uri($appId, $scanId), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"deleteAll",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"uri",
"(",
"$",
"appId"... | Delete all libraries
@param int $appId
@param int $scanId
@param array $queryParams
@return Response | [
"Delete",
"all",
"libraries"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/LibraryRequests.php#L108-L115 | train |
rips/php-connector | src/Requests/Application/Scan/LibraryRequests.php | LibraryRequests.deleteById | public function deleteById($appId, $scanId, $libraryId, array $queryParams = [])
{
if (is_null($appId) || is_null($scanId) || is_null($libraryId)) {
throw new LibException('appId, scanId, or libraryId is null');
}
$response = $this->client->delete($this->uri($appId, $scanId, $libraryId), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function deleteById($appId, $scanId, $libraryId, array $queryParams = [])
{
if (is_null($appId) || is_null($scanId) || is_null($libraryId)) {
throw new LibException('appId, scanId, or libraryId is null');
}
$response = $this->client->delete($this->uri($appId, $scanId, $libraryId), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"deleteById",
"(",
"$",
"appId",
",",
"$",
"scanId",
",",
"$",
"libraryId",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"appId",
")",
"||",
"is_null",
"(",
"$",
"scanId",
")",
"||... | Delete a library by id
@param int $appId
@param int $scanId
@param int $libraryId
@param array $queryParams
@return Response | [
"Delete",
"a",
"library",
"by",
"id"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/Scan/LibraryRequests.php#L126-L137 | train |
rips/php-connector | src/API.php | API.initialize | public function initialize($email, $password, array $clientConfig = [])
{
$mergedConfig = array_merge(
$this->clientConfig,
$clientConfig,
[
'headers' => [
'User-Agent' => "RIPS-API-Connector/{$this->version}",
],
],
[
'headers' => $this->getAuthHeaders($email, $password, $clientConfig)
]
);
$client = new Client($mergedConfig);
$this->callbacks = new CallbackRequests($client);
$this->applications = new ApplicationRequests($client);
$this->licenses = new LicenseRequests($client);
$this->logs = new LogRequests($client);
$this->orgs = new OrgRequests($client);
$this->quotas = new QuotaRequests($client);
$this->settings = new SettingRequests($client);
$this->sources = new SourceRequests($client);
$this->status = new StatusRequests($client);
$this->teams = new TeamRequests($client);
$this->users = new UserRequests($client);
$this->oauth2 = new OAuth2Requests($client);
$this->activities = new ActivityRequests($client);
$this->maintenance = new MaintenanceRequests($client);
$this->languages = new LanguageRequests($client);
$this->systems = new SystemRequests($client);
} | php | public function initialize($email, $password, array $clientConfig = [])
{
$mergedConfig = array_merge(
$this->clientConfig,
$clientConfig,
[
'headers' => [
'User-Agent' => "RIPS-API-Connector/{$this->version}",
],
],
[
'headers' => $this->getAuthHeaders($email, $password, $clientConfig)
]
);
$client = new Client($mergedConfig);
$this->callbacks = new CallbackRequests($client);
$this->applications = new ApplicationRequests($client);
$this->licenses = new LicenseRequests($client);
$this->logs = new LogRequests($client);
$this->orgs = new OrgRequests($client);
$this->quotas = new QuotaRequests($client);
$this->settings = new SettingRequests($client);
$this->sources = new SourceRequests($client);
$this->status = new StatusRequests($client);
$this->teams = new TeamRequests($client);
$this->users = new UserRequests($client);
$this->oauth2 = new OAuth2Requests($client);
$this->activities = new ActivityRequests($client);
$this->maintenance = new MaintenanceRequests($client);
$this->languages = new LanguageRequests($client);
$this->systems = new SystemRequests($client);
} | [
"public",
"function",
"initialize",
"(",
"$",
"email",
",",
"$",
"password",
",",
"array",
"$",
"clientConfig",
"=",
"[",
"]",
")",
"{",
"$",
"mergedConfig",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"clientConfig",
",",
"$",
"clientConfig",
",",
"[",
... | Initialize new API
Separation from the constructor is required because in some cases the information are not yet known when
the object is constructed.
@param string $email
@param string $password
@param array $clientConfig
@throws Exception | [
"Initialize",
"new",
"API",
"Separation",
"from",
"the",
"constructor",
"is",
"required",
"because",
"in",
"some",
"cases",
"the",
"information",
"are",
"not",
"yet",
"known",
"when",
"the",
"object",
"is",
"constructed",
"."
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/API.php#L147-L179 | train |
rips/php-connector | src/API.php | API.getAuthHeaders | private function getAuthHeaders($email, $password, $clientConfig)
{
if (!$email || !$password) {
return [];
}
if (!isset($clientConfig['oauth2']['enabled']) || !$clientConfig['oauth2']['enabled']) {
return [
'X-API-Email-Enc' => base64_encode($email),
'X-API-Password-Enc' => base64_encode($password),
'X-API-Email' => $email,
'X-API-Password' => $password
];
}
$oauth2Config = $clientConfig['oauth2'];
$accessToken = array_key_exists('access_token', $oauth2Config) ? $oauth2Config["access_token"] : "";
if (empty($accessToken)) {
$accessToken = $this->getAccessToken($email, $password, $clientConfig);
}
if (!$accessToken) {
throw new Exception('Cannot find/create valid token');
}
return [
'Authorization' => "Bearer {$accessToken}"
];
} | php | private function getAuthHeaders($email, $password, $clientConfig)
{
if (!$email || !$password) {
return [];
}
if (!isset($clientConfig['oauth2']['enabled']) || !$clientConfig['oauth2']['enabled']) {
return [
'X-API-Email-Enc' => base64_encode($email),
'X-API-Password-Enc' => base64_encode($password),
'X-API-Email' => $email,
'X-API-Password' => $password
];
}
$oauth2Config = $clientConfig['oauth2'];
$accessToken = array_key_exists('access_token', $oauth2Config) ? $oauth2Config["access_token"] : "";
if (empty($accessToken)) {
$accessToken = $this->getAccessToken($email, $password, $clientConfig);
}
if (!$accessToken) {
throw new Exception('Cannot find/create valid token');
}
return [
'Authorization' => "Bearer {$accessToken}"
];
} | [
"private",
"function",
"getAuthHeaders",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"clientConfig",
")",
"{",
"if",
"(",
"!",
"$",
"email",
"||",
"!",
"$",
"password",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
... | Get the authentication headers
@param string $email
@param string $password
@param array $clientConfig
@return array
@throws Exception | [
"Get",
"the",
"authentication",
"headers"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/API.php#L200-L228 | train |
rips/php-connector | src/API.php | API.getAccessToken | private function getAccessToken($email, $password, $clientConfig)
{
$oauth2Config = $clientConfig['oauth2'];
$accessToken = null;
// If there is a token file, try to read it and test the found token
try {
$filePath = array_key_exists('token_file_path', $oauth2Config) && !empty($oauth2Config['token_file_path'])
? $oauth2Config['token_file_path'] : '';
if (file_exists($filePath)) {
$data = file_get_contents($filePath);
if (!empty($data)) {
$decodedData = json_decode($data);
$accessToken = $decodedData->access_token;
return $accessToken;
}
}
} catch (\Exception $e) {
}
return $this->createAccessToken($email, $password, $clientConfig);
} | php | private function getAccessToken($email, $password, $clientConfig)
{
$oauth2Config = $clientConfig['oauth2'];
$accessToken = null;
// If there is a token file, try to read it and test the found token
try {
$filePath = array_key_exists('token_file_path', $oauth2Config) && !empty($oauth2Config['token_file_path'])
? $oauth2Config['token_file_path'] : '';
if (file_exists($filePath)) {
$data = file_get_contents($filePath);
if (!empty($data)) {
$decodedData = json_decode($data);
$accessToken = $decodedData->access_token;
return $accessToken;
}
}
} catch (\Exception $e) {
}
return $this->createAccessToken($email, $password, $clientConfig);
} | [
"private",
"function",
"getAccessToken",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"clientConfig",
")",
"{",
"$",
"oauth2Config",
"=",
"$",
"clientConfig",
"[",
"'oauth2'",
"]",
";",
"$",
"accessToken",
"=",
"null",
";",
"// If there is a token file, ... | Gets an access token either from config, from disk or by requesting a new one
@param $email
@param $password
@param $clientConfig
@return string|null
@throws Exception | [
"Gets",
"an",
"access",
"token",
"either",
"from",
"config",
"from",
"disk",
"or",
"by",
"requesting",
"a",
"new",
"one"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/API.php#L239-L263 | train |
rips/php-connector | src/API.php | API.createAccessToken | private function createAccessToken($email, $password, $clientConfig)
{
$oauth2Config = $clientConfig['oauth2'];
if (!array_key_exists('client_id', $oauth2Config)) {
throw new Exception('Cannot create new oauth token without client id');
}
$mergedConfig = array_merge($this->clientConfig, $clientConfig, [
'headers' => [
'User-Agent' => "RIPS-API-Connector/{$this->version}",
],
RequestOptions::JSON => [
'grant_type' => 'password',
'client_id' => $oauth2Config['client_id'],
'username' => $email,
'password' => $password
]
]);
$request = new AccessTokenRequest(new Client($mergedConfig));
$tokens = $request->getTokens()->getDecodedData();
if (isset($oauth2Config['store_token']) && $oauth2Config['store_token'] === true) {
if (!array_key_exists('token_file_path', $oauth2Config) || empty($oauth2Config['token_file_path'])) {
throw new Exception('Token path is needed to store token');
}
$filePath = $oauth2Config['token_file_path'];
file_put_contents($filePath, json_encode($tokens));
}
return $tokens->access_token;
} | php | private function createAccessToken($email, $password, $clientConfig)
{
$oauth2Config = $clientConfig['oauth2'];
if (!array_key_exists('client_id', $oauth2Config)) {
throw new Exception('Cannot create new oauth token without client id');
}
$mergedConfig = array_merge($this->clientConfig, $clientConfig, [
'headers' => [
'User-Agent' => "RIPS-API-Connector/{$this->version}",
],
RequestOptions::JSON => [
'grant_type' => 'password',
'client_id' => $oauth2Config['client_id'],
'username' => $email,
'password' => $password
]
]);
$request = new AccessTokenRequest(new Client($mergedConfig));
$tokens = $request->getTokens()->getDecodedData();
if (isset($oauth2Config['store_token']) && $oauth2Config['store_token'] === true) {
if (!array_key_exists('token_file_path', $oauth2Config) || empty($oauth2Config['token_file_path'])) {
throw new Exception('Token path is needed to store token');
}
$filePath = $oauth2Config['token_file_path'];
file_put_contents($filePath, json_encode($tokens));
}
return $tokens->access_token;
} | [
"private",
"function",
"createAccessToken",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"clientConfig",
")",
"{",
"$",
"oauth2Config",
"=",
"$",
"clientConfig",
"[",
"'oauth2'",
"]",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'client_id'",
",",
... | Creates an access token by requesting it from the server
@param $email
@param $password
@param $clientConfig
@return string
@throws Exception | [
"Creates",
"an",
"access",
"token",
"by",
"requesting",
"it",
"from",
"the",
"server"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/API.php#L274-L305 | train |
rips/php-connector | src/Requests/System/LdapRequests.php | LdapRequests.get | public function get(array $queryParams = [])
{
$response = $this->client->get("{$this->uri()}", [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function get(array $queryParams = [])
{
$response = $this->client->get("{$this->uri()}", [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"get",
"(",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"\"{$this->uri()}\"",
",",
"[",
"'query'",
"=>",
"$",
"queryParams",
",",
"]",
")",
";",
"ret... | Get a scan by application ID and scan ID
@param array $queryParams
@return Response | [
"Get",
"a",
"scan",
"by",
"application",
"ID",
"and",
"scan",
"ID"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/System/LdapRequests.php#L27-L34 | train |
rips/php-connector | src/Requests/System/LdapRequests.php | LdapRequests.sync | public function sync(array $queryParams = [])
{
$response = $this->client->post("{$this->uri()}/sync", [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function sync(array $queryParams = [])
{
$response = $this->client->post("{$this->uri()}/sync", [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"sync",
"(",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"\"{$this->uri()}/sync\"",
",",
"[",
"'query'",
"=>",
"$",
"queryParams",
",",
"]",
")",
";",... | Force LDAP synchronization
@param array $queryParams
@return Response | [
"Force",
"LDAP",
"synchronization"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/System/LdapRequests.php#L59-L66 | train |
rips/php-connector | src/Requests/UserRequests.php | UserRequests.reset | public function reset(array $input, array $queryParams = [])
{
$response = $this->client->post("{$this->uri()}/reset/ui", [
RequestOptions::JSON => ['reset' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function reset(array $input, array $queryParams = [])
{
$response = $this->client->post("{$this->uri()}/reset/ui", [
RequestOptions::JSON => ['reset' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"reset",
"(",
"array",
"$",
"input",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"\"{$this->uri()}/reset/ui\"",
",",
"[",
"RequestOptions",
"::",
"... | Request a reset e-mail
@param array $input
@param array $queryParams
@return Response | [
"Request",
"a",
"reset",
"e",
"-",
"mail"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/UserRequests.php#L147-L155 | train |
rips/php-connector | src/Requests/OAuth2/AccessTokenRequest.php | AccessTokenRequest.getTokens | public function getTokens()
{
$response = $this->client->post($this->uri());
return $this->handleResponse($response);
} | php | public function getTokens()
{
$response = $this->client->post($this->uri());
return $this->handleResponse($response);
} | [
"public",
"function",
"getTokens",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"uri",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"handleResponse",
"(",
"$",
"response",
")",
";",
"}"... | Get status info for the current session and API env
@return Response | [
"Get",
"status",
"info",
"for",
"the",
"current",
"session",
"and",
"API",
"env"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/OAuth2/AccessTokenRequest.php#L25-L30 | train |
rips/php-connector | src/Requests/SettingRequests.php | SettingRequests.getByKey | public function getByKey($key, array $queryParams = [])
{
$response = $this->client->get($this->uri($key), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function getByKey($key, array $queryParams = [])
{
$response = $this->client->get($this->uri($key), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"getByKey",
"(",
"$",
"key",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"uri",
"(",
"$",
"key",
")",
",",
"[",
"'query'"... | Get a setting by key
@param string $key
@param array $queryParams
@return Response | [
"Get",
"a",
"setting",
"by",
"key"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/SettingRequests.php#L43-L50 | train |
rips/php-connector | src/Requests/SettingRequests.php | SettingRequests.createOrUpdate | public function createOrUpdate($key, array $input, array $queryParams = [])
{
$response = $this->client->put($this->uri($key), [
RequestOptions::JSON => ['setting' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function createOrUpdate($key, array $input, array $queryParams = [])
{
$response = $this->client->put($this->uri($key), [
RequestOptions::JSON => ['setting' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"createOrUpdate",
"(",
"$",
"key",
",",
"array",
"$",
"input",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"put",
"(",
"$",
"this",
"->",
"uri",
"(",
"$",... | Create or update a setting
@param string $key
@param array $input
@param array $queryParams
@return Response | [
"Create",
"or",
"update",
"a",
"setting"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/SettingRequests.php#L60-L68 | train |
rips/php-connector | src/Requests/SettingRequests.php | SettingRequests.deleteByKey | public function deleteByKey($key, array $queryParams = [])
{
$response = $this->client->delete($this->uri($key), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function deleteByKey($key, array $queryParams = [])
{
$response = $this->client->delete($this->uri($key), [
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"deleteByKey",
"(",
"$",
"key",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"uri",
"(",
"$",
"key",
")",
",",
"[",
"'q... | Delete setting by key
@param string $key
@param array $queryParams
@return Response | [
"Delete",
"setting",
"by",
"key"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/SettingRequests.php#L92-L99 | train |
rips/php-connector | src/Requests/SystemRequests.php | SystemRequests.ldap | public function ldap()
{
if (is_null($this->ldapRequests)) {
$this->ldapRequests = new System\LdapRequests($this->client);
}
return $this->ldapRequests;
} | php | public function ldap()
{
if (is_null($this->ldapRequests)) {
$this->ldapRequests = new System\LdapRequests($this->client);
}
return $this->ldapRequests;
} | [
"public",
"function",
"ldap",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"ldapRequests",
")",
")",
"{",
"$",
"this",
"->",
"ldapRequests",
"=",
"new",
"System",
"\\",
"LdapRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
... | LDAP requests accessor
@return System\LdapRequests | [
"LDAP",
"requests",
"accessor"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/SystemRequests.php#L17-L24 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.uri | protected function uri($appId = null, $profileId = null, $clone = false)
{
if (is_null($appId)) {
return '/applications/profiles/all';
}
if (is_null($profileId)) {
return "/applications/{$appId}/profiles";
}
if (!$clone) {
return "/applications/{$appId}/profiles/{$profileId}";
}
return "/applications/{$appId}/profiles/{$profileId}/clone";
} | php | protected function uri($appId = null, $profileId = null, $clone = false)
{
if (is_null($appId)) {
return '/applications/profiles/all';
}
if (is_null($profileId)) {
return "/applications/{$appId}/profiles";
}
if (!$clone) {
return "/applications/{$appId}/profiles/{$profileId}";
}
return "/applications/{$appId}/profiles/{$profileId}/clone";
} | [
"protected",
"function",
"uri",
"(",
"$",
"appId",
"=",
"null",
",",
"$",
"profileId",
"=",
"null",
",",
"$",
"clone",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"appId",
")",
")",
"{",
"return",
"'/applications/profiles/all'",
";",
"}",
... | Build the URI for the requests
@param int $appId
@param int $profileId
@param bool $clone
@return string | [
"Build",
"the",
"URI",
"for",
"the",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L68-L83 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.cloneById | public function cloneById($appId, $profileId, $input, array $queryParams = [])
{
$response = $this->client->post($this->uri($appId, $profileId, true), [
RequestOptions::JSON => ['profile' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function cloneById($appId, $profileId, $input, array $queryParams = [])
{
$response = $this->client->post($this->uri($appId, $profileId, true), [
RequestOptions::JSON => ['profile' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"cloneById",
"(",
"$",
"appId",
",",
"$",
"profileId",
",",
"$",
"input",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"uri... | Clone a existing profile
@param int $appId
@param int $profileId
@param array $input
@param array $queryParams
@return Response | [
"Clone",
"a",
"existing",
"profile"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L145-L153 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.update | public function update($appId, $profileId, array $input, array $queryParams = [])
{
$response = $this->client->patch($this->uri($appId, $profileId), [
RequestOptions::JSON => ['profile' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | php | public function update($appId, $profileId, array $input, array $queryParams = [])
{
$response = $this->client->patch($this->uri($appId, $profileId), [
RequestOptions::JSON => ['profile' => $input],
'query' => $queryParams,
]);
return $this->handleResponse($response);
} | [
"public",
"function",
"update",
"(",
"$",
"appId",
",",
"$",
"profileId",
",",
"array",
"$",
"input",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->... | Update an existing profile
@param int $appId
@param int $profileId
@param array $input
@param array $queryParams
@return Response | [
"Update",
"an",
"existing",
"profile"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L164-L172 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.ignoredCodes | public function ignoredCodes()
{
if (is_null($this->ignoredCodeRequests)) {
$this->ignoredCodeRequests = new IgnoredCodeRequests($this->client);
}
return $this->ignoredCodeRequests;
} | php | public function ignoredCodes()
{
if (is_null($this->ignoredCodeRequests)) {
$this->ignoredCodeRequests = new IgnoredCodeRequests($this->client);
}
return $this->ignoredCodeRequests;
} | [
"public",
"function",
"ignoredCodes",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"ignoredCodeRequests",
")",
")",
"{",
"$",
"this",
"->",
"ignoredCodeRequests",
"=",
"new",
"IgnoredCodeRequests",
"(",
"$",
"this",
"->",
"client",
")",
";"... | Accessor to ignored code requests
@return IgnoredCodeRequests | [
"Accessor",
"to",
"ignored",
"code",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L216-L223 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.ignoredLocations | public function ignoredLocations()
{
if (is_null($this->ignoredLocationRequests)) {
$this->ignoredLocationRequests = new IgnoredLocationRequests($this->client);
}
return $this->ignoredLocationRequests;
} | php | public function ignoredLocations()
{
if (is_null($this->ignoredLocationRequests)) {
$this->ignoredLocationRequests = new IgnoredLocationRequests($this->client);
}
return $this->ignoredLocationRequests;
} | [
"public",
"function",
"ignoredLocations",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"ignoredLocationRequests",
")",
")",
"{",
"$",
"this",
"->",
"ignoredLocationRequests",
"=",
"new",
"IgnoredLocationRequests",
"(",
"$",
"this",
"->",
"clien... | Accessor to ignored location requests
@return IgnoredLocationRequests | [
"Accessor",
"to",
"ignored",
"location",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L230-L237 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.sanitizers | public function sanitizers()
{
if (is_null($this->sanitizerRequests)) {
$this->sanitizerRequests = new SanitizerRequests($this->client);
}
return $this->sanitizerRequests;
} | php | public function sanitizers()
{
if (is_null($this->sanitizerRequests)) {
$this->sanitizerRequests = new SanitizerRequests($this->client);
}
return $this->sanitizerRequests;
} | [
"public",
"function",
"sanitizers",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"sanitizerRequests",
")",
")",
"{",
"$",
"this",
"->",
"sanitizerRequests",
"=",
"new",
"SanitizerRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",... | Accessor to sanitizer requests
@return SanitizerRequests | [
"Accessor",
"to",
"sanitizer",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L244-L251 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.settings | public function settings()
{
if (is_null($this->settingRequests)) {
$this->settingRequests = new SettingRequests($this->client);
}
return $this->settingRequests;
} | php | public function settings()
{
if (is_null($this->settingRequests)) {
$this->settingRequests = new SettingRequests($this->client);
}
return $this->settingRequests;
} | [
"public",
"function",
"settings",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"settingRequests",
")",
")",
"{",
"$",
"this",
"->",
"settingRequests",
"=",
"new",
"SettingRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",
"retu... | Accessor to setting requests
@return SettingRequests | [
"Accessor",
"to",
"setting",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L258-L265 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.validators | public function validators()
{
if (is_null($this->validatorRequests)) {
$this->validatorRequests = new ValidatorRequests($this->client);
}
return $this->validatorRequests;
} | php | public function validators()
{
if (is_null($this->validatorRequests)) {
$this->validatorRequests = new ValidatorRequests($this->client);
}
return $this->validatorRequests;
} | [
"public",
"function",
"validators",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"validatorRequests",
")",
")",
"{",
"$",
"this",
"->",
"validatorRequests",
"=",
"new",
"ValidatorRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
"}",... | Accessor to validator requests
@return ValidatorRequests | [
"Accessor",
"to",
"validator",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L300-L307 | train |
rips/php-connector | src/Requests/Application/ProfileRequests.php | ProfileRequests.controllers | public function controllers()
{
if (is_null($this->controllerRequests)) {
$this->controllerRequests = new ControllerRequests($this->client);
}
return $this->controllerRequests;
} | php | public function controllers()
{
if (is_null($this->controllerRequests)) {
$this->controllerRequests = new ControllerRequests($this->client);
}
return $this->controllerRequests;
} | [
"public",
"function",
"controllers",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"controllerRequests",
")",
")",
"{",
"$",
"this",
"->",
"controllerRequests",
"=",
"new",
"ControllerRequests",
"(",
"$",
"this",
"->",
"client",
")",
";",
... | Accessor to controller requests
@return ControllerRequests | [
"Accessor",
"to",
"controller",
"requests"
] | 8a6cbd600ca164f4f65248dad8d6af7a579cc2d9 | https://github.com/rips/php-connector/blob/8a6cbd600ca164f4f65248dad8d6af7a579cc2d9/src/Requests/Application/ProfileRequests.php#L314-L321 | train |
silverstripe/cwp-core | src/Control/InitialisationMiddleware.php | InitialisationMiddleware.configureEgressProxy | protected function configureEgressProxy()
{
if (!Environment::getEnv('SS_OUTBOUND_PROXY')
|| !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
) {
return;
}
$proxy = Environment::getEnv('SS_OUTBOUND_PROXY');
$proxyPort = Environment::getEnv('SS_OUTBOUND_PROXY_PORT');
/*
* This sets the environment variables so they are available in
* external calls executed by exec() such as curl.
* Environment::setEnv() would only availabe in context of SilverStripe.
* Environment::getEnv() will fallback to getenv() and will therefore
* fetch the variables
*/
putenv('http_proxy=' . $proxy . ':' . $proxyPort);
putenv('https_proxy=' . $proxy . ':' . $proxyPort);
} | php | protected function configureEgressProxy()
{
if (!Environment::getEnv('SS_OUTBOUND_PROXY')
|| !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
) {
return;
}
$proxy = Environment::getEnv('SS_OUTBOUND_PROXY');
$proxyPort = Environment::getEnv('SS_OUTBOUND_PROXY_PORT');
/*
* This sets the environment variables so they are available in
* external calls executed by exec() such as curl.
* Environment::setEnv() would only availabe in context of SilverStripe.
* Environment::getEnv() will fallback to getenv() and will therefore
* fetch the variables
*/
putenv('http_proxy=' . $proxy . ':' . $proxyPort);
putenv('https_proxy=' . $proxy . ':' . $proxyPort);
} | [
"protected",
"function",
"configureEgressProxy",
"(",
")",
"{",
"if",
"(",
"!",
"Environment",
"::",
"getEnv",
"(",
"'SS_OUTBOUND_PROXY'",
")",
"||",
"!",
"Environment",
"::",
"getEnv",
"(",
"'SS_OUTBOUND_PROXY_PORT'",
")",
")",
"{",
"return",
";",
"}",
"$",
... | If the outbound egress proxy details have been defined in environment variables, configure the proxy
variables that are used to configure it. | [
"If",
"the",
"outbound",
"egress",
"proxy",
"details",
"have",
"been",
"defined",
"in",
"environment",
"variables",
"configure",
"the",
"proxy",
"variables",
"that",
"are",
"used",
"to",
"configure",
"it",
"."
] | fee3f1abbc6f5464e85a7d6af3b30dab02053829 | https://github.com/silverstripe/cwp-core/blob/fee3f1abbc6f5464e85a7d6af3b30dab02053829/src/Control/InitialisationMiddleware.php#L72-L92 | train |
silverstripe/cwp-core | src/Control/InitialisationMiddleware.php | InitialisationMiddleware.configureProxyDomainExclusions | protected function configureProxyDomainExclusions()
{
$noProxy = $this->config()->get('egress_proxy_exclude_domains');
if (empty($noProxy)) {
return;
}
if (!is_array($noProxy)) {
$noProxy = [$noProxy];
}
// Merge with exsiting if needed.
if (Environment::getEnv('NO_PROXY')) {
$noProxy = array_merge(explode(',', Environment::getEnv('NO_PROXY')), $noProxy);
}
/*
* Set the environment varial for NO_PROXY the same way the
* proxy variables are set above
*/
putenv('NO_PROXY=' . implode(',', array_unique($noProxy)));
} | php | protected function configureProxyDomainExclusions()
{
$noProxy = $this->config()->get('egress_proxy_exclude_domains');
if (empty($noProxy)) {
return;
}
if (!is_array($noProxy)) {
$noProxy = [$noProxy];
}
// Merge with exsiting if needed.
if (Environment::getEnv('NO_PROXY')) {
$noProxy = array_merge(explode(',', Environment::getEnv('NO_PROXY')), $noProxy);
}
/*
* Set the environment varial for NO_PROXY the same way the
* proxy variables are set above
*/
putenv('NO_PROXY=' . implode(',', array_unique($noProxy)));
} | [
"protected",
"function",
"configureProxyDomainExclusions",
"(",
")",
"{",
"$",
"noProxy",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'egress_proxy_exclude_domains'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"noProxy",
")",
")",
"{",
"ret... | Configure any domains that should be excluded from egress proxy rules and provide them to the environment | [
"Configure",
"any",
"domains",
"that",
"should",
"be",
"excluded",
"from",
"egress",
"proxy",
"rules",
"and",
"provide",
"them",
"to",
"the",
"environment"
] | fee3f1abbc6f5464e85a7d6af3b30dab02053829 | https://github.com/silverstripe/cwp-core/blob/fee3f1abbc6f5464e85a7d6af3b30dab02053829/src/Control/InitialisationMiddleware.php#L97-L118 | train |
silverstripe/cwp-core | src/Control/CwpBasicAuthMiddleware.php | CwpBasicAuthMiddleware.ipMatchesWhitelist | protected function ipMatchesWhitelist()
{
$whitelist = $this->getWhitelistedIps();
// Continue if no whitelist is defined
if (empty($whitelist)) {
return false;
}
$userIp = $_SERVER['REMOTE_ADDR'];
if (in_array($userIp, $whitelist)) {
return true;
}
return false;
} | php | protected function ipMatchesWhitelist()
{
$whitelist = $this->getWhitelistedIps();
// Continue if no whitelist is defined
if (empty($whitelist)) {
return false;
}
$userIp = $_SERVER['REMOTE_ADDR'];
if (in_array($userIp, $whitelist)) {
return true;
}
return false;
} | [
"protected",
"function",
"ipMatchesWhitelist",
"(",
")",
"{",
"$",
"whitelist",
"=",
"$",
"this",
"->",
"getWhitelistedIps",
"(",
")",
";",
"// Continue if no whitelist is defined",
"if",
"(",
"empty",
"(",
"$",
"whitelist",
")",
")",
"{",
"return",
"false",
"... | Check whether the current user's IP address is in the IP whitelist
@return bool | [
"Check",
"whether",
"the",
"current",
"user",
"s",
"IP",
"address",
"is",
"in",
"the",
"IP",
"whitelist"
] | fee3f1abbc6f5464e85a7d6af3b30dab02053829 | https://github.com/silverstripe/cwp-core/blob/fee3f1abbc6f5464e85a7d6af3b30dab02053829/src/Control/CwpBasicAuthMiddleware.php#L74-L88 | train |
silverstripe/cwp-core | src/Feed/CwpAtomFeed.php | CwpAtomFeed.outputToBrowser | public function outputToBrowser()
{
$output = parent::outputToBrowser();
$response = Controller::curr()->getResponse();
$response->addHeader("Content-Type", "application/atom+xml");
return $output;
} | php | public function outputToBrowser()
{
$output = parent::outputToBrowser();
$response = Controller::curr()->getResponse();
$response->addHeader("Content-Type", "application/atom+xml");
return $output;
} | [
"public",
"function",
"outputToBrowser",
"(",
")",
"{",
"$",
"output",
"=",
"parent",
"::",
"outputToBrowser",
"(",
")",
";",
"$",
"response",
"=",
"Controller",
"::",
"curr",
"(",
")",
"->",
"getResponse",
"(",
")",
";",
"$",
"response",
"->",
"addHeade... | Output the feed to the browser
@return DBHTMLText | [
"Output",
"the",
"feed",
"to",
"the",
"browser"
] | fee3f1abbc6f5464e85a7d6af3b30dab02053829 | https://github.com/silverstripe/cwp-core/blob/fee3f1abbc6f5464e85a7d6af3b30dab02053829/src/Feed/CwpAtomFeed.php#L66-L73 | train |
silverstripe/vendor-plugin | src/VendorPlugin.php | VendorPlugin.getLibrary | public function getLibrary(PackageEvent $event)
{
// Ensure package is the valid type
$package = $this->getOperationPackage($event);
if (!$package) {
return null;
}
// Get appropriate installer and query install path
$installer = $event->getComposer()->getInstallationManager()->getInstaller($package->getType());
$path = $installer->getInstallPath($package);
// Build module
return new Library($this->getProjectPath(), $path);
} | php | public function getLibrary(PackageEvent $event)
{
// Ensure package is the valid type
$package = $this->getOperationPackage($event);
if (!$package) {
return null;
}
// Get appropriate installer and query install path
$installer = $event->getComposer()->getInstallationManager()->getInstaller($package->getType());
$path = $installer->getInstallPath($package);
// Build module
return new Library($this->getProjectPath(), $path);
} | [
"public",
"function",
"getLibrary",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"// Ensure package is the valid type",
"$",
"package",
"=",
"$",
"this",
"->",
"getOperationPackage",
"(",
"$",
"event",
")",
";",
"if",
"(",
"!",
"$",
"package",
")",
"{",
"ret... | Gets library being installed
@param PackageEvent $event
@return Library|null | [
"Gets",
"library",
"being",
"installed"
] | 87769ad5770921428e74cc7de6ba4f217399b005 | https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorPlugin.php#L114-L128 | train |
silverstripe/vendor-plugin | src/VendorPlugin.php | VendorPlugin.installRootPackage | public function installRootPackage(Event $event)
{
// Build library in base path
$basePath = $this->getProjectPath();
$library = new Library($basePath, $basePath);
// Pass to library installer
$this->installLibrary($event->getIO(), $library);
} | php | public function installRootPackage(Event $event)
{
// Build library in base path
$basePath = $this->getProjectPath();
$library = new Library($basePath, $basePath);
// Pass to library installer
$this->installLibrary($event->getIO(), $library);
} | [
"public",
"function",
"installRootPackage",
"(",
"Event",
"$",
"event",
")",
"{",
"// Build library in base path",
"$",
"basePath",
"=",
"$",
"this",
"->",
"getProjectPath",
"(",
")",
";",
"$",
"library",
"=",
"new",
"Library",
"(",
"$",
"basePath",
",",
"$"... | Install resources from the root package
@param Event $event | [
"Install",
"resources",
"from",
"the",
"root",
"package"
] | 87769ad5770921428e74cc7de6ba4f217399b005 | https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorPlugin.php#L152-L160 | train |
silverstripe/vendor-plugin | src/VendorPlugin.php | VendorPlugin.installLibrary | protected function installLibrary(IOInterface $IO, Library $library)
{
if (!$library || !$library->requiresExpose()) {
return;
}
// Create exposure task
$task = new VendorExposeTask(
$this->getProjectPath(),
$this->filesystem,
$library->getBasePublicPath()
);
$task->process($IO, [$library]);
} | php | protected function installLibrary(IOInterface $IO, Library $library)
{
if (!$library || !$library->requiresExpose()) {
return;
}
// Create exposure task
$task = new VendorExposeTask(
$this->getProjectPath(),
$this->filesystem,
$library->getBasePublicPath()
);
$task->process($IO, [$library]);
} | [
"protected",
"function",
"installLibrary",
"(",
"IOInterface",
"$",
"IO",
",",
"Library",
"$",
"library",
")",
"{",
"if",
"(",
"!",
"$",
"library",
"||",
"!",
"$",
"library",
"->",
"requiresExpose",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Create expo... | Expose the given Library object
@param IOInterface $IO
@param Library $library | [
"Expose",
"the",
"given",
"Library",
"object"
] | 87769ad5770921428e74cc7de6ba4f217399b005 | https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorPlugin.php#L237-L250 | train |
silverstripe/vendor-plugin | src/VendorModule.php | VendorModule.getModulePath | public function getModulePath($base = self::DEFAULT_SOURCE)
{
if ($base === self::DEFAULT_TARGET) {
return $this->getPublicPath();
} else {
return $this->getPath();
}
} | php | public function getModulePath($base = self::DEFAULT_SOURCE)
{
if ($base === self::DEFAULT_TARGET) {
return $this->getPublicPath();
} else {
return $this->getPath();
}
} | [
"public",
"function",
"getModulePath",
"(",
"$",
"base",
"=",
"self",
"::",
"DEFAULT_SOURCE",
")",
"{",
"if",
"(",
"$",
"base",
"===",
"self",
"::",
"DEFAULT_TARGET",
")",
"{",
"return",
"$",
"this",
"->",
"getPublicPath",
"(",
")",
";",
"}",
"else",
"... | Get full path to the root install for this project
@deprecated 1.3..2.0 use getPath() instead
@param string $base Rewrite root (or 'vendor' for actual module path)
@return string Path for this module | [
"Get",
"full",
"path",
"to",
"the",
"root",
"install",
"for",
"this",
"project"
] | 87769ad5770921428e74cc7de6ba4f217399b005 | https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorModule.php#L45-L52 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.