id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
230,800 | inetprocess/libsugarcrm | src/LogicHook.php | LogicHook.getModuleHooks | public function getModuleHooks($module)
{
$hooks = $this->getHooksDefinitionsFromSugar($module);
if (empty($hooks)) {
return array();
}
$sortedHooks = array();
$hooksDef = $this->getHooksDefinitionsFromFiles($module);
// Process hooks in a specific order
foreach ($this->modulesLogicHooksDef as $type => $hookDesc) {
if (!array_key_exists($type, $hooks) || empty($hooks[$type])) {
continue;
}
$i = 0;
foreach ($hooks[$type] as $hook) {
$num = str_pad($hook[0], 20, 0, \STR_PAD_LEFT) . '_' . $i;
$sortedHooks[$type][$num] = array(
'Weight' => $hook[0],
'Description' => $hook[1],
'File' => $hook[2],
'Class' => $hook[3],
'Method' => $hook[4],
'Defined In' => $this->findHookInDefinition($hooksDef, $type, $hook[2], $hook[3], $hook[4]),
);
$i++;
}
ksort($sortedHooks[$type]);
unset($hooks[$type]);
}
// Have I lost some hooks ?
if (!empty($hooks)) {
foreach ($hooks as $type => $hooks) {
foreach ($hooks as $hook) {
if (empty($hook)) {
continue;
}
$sortedHooks[$type][] = array(
'Weight' => $hook[0],
'Description' => $hook[1],
'File' => $hook[2],
'Class' => $hook[3],
'Method' => $hook[4],
'Defined In' => $this->findHookInDefinition($hooksDef, $type, $hook[2], $hook[3], $hook[4]),
);
}
}
}
return $sortedHooks;
} | php | public function getModuleHooks($module)
{
$hooks = $this->getHooksDefinitionsFromSugar($module);
if (empty($hooks)) {
return array();
}
$sortedHooks = array();
$hooksDef = $this->getHooksDefinitionsFromFiles($module);
// Process hooks in a specific order
foreach ($this->modulesLogicHooksDef as $type => $hookDesc) {
if (!array_key_exists($type, $hooks) || empty($hooks[$type])) {
continue;
}
$i = 0;
foreach ($hooks[$type] as $hook) {
$num = str_pad($hook[0], 20, 0, \STR_PAD_LEFT) . '_' . $i;
$sortedHooks[$type][$num] = array(
'Weight' => $hook[0],
'Description' => $hook[1],
'File' => $hook[2],
'Class' => $hook[3],
'Method' => $hook[4],
'Defined In' => $this->findHookInDefinition($hooksDef, $type, $hook[2], $hook[3], $hook[4]),
);
$i++;
}
ksort($sortedHooks[$type]);
unset($hooks[$type]);
}
// Have I lost some hooks ?
if (!empty($hooks)) {
foreach ($hooks as $type => $hooks) {
foreach ($hooks as $hook) {
if (empty($hook)) {
continue;
}
$sortedHooks[$type][] = array(
'Weight' => $hook[0],
'Description' => $hook[1],
'File' => $hook[2],
'Class' => $hook[3],
'Method' => $hook[4],
'Defined In' => $this->findHookInDefinition($hooksDef, $type, $hook[2], $hook[3], $hook[4]),
);
}
}
}
return $sortedHooks;
} | [
"public",
"function",
"getModuleHooks",
"(",
"$",
"module",
")",
"{",
"$",
"hooks",
"=",
"$",
"this",
"->",
"getHooksDefinitionsFromSugar",
"(",
"$",
"module",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"hooks",
")",
")",
"{",
"return",
"array",
"(",
")",... | Get a list of hooks, by type and sorted by weight for a specific module
@param string $module SugarCRM module name
@return array List of hooks | [
"Get",
"a",
"list",
"of",
"hooks",
"by",
"type",
"and",
"sorted",
"by",
"weight",
"for",
"a",
"specific",
"module"
] | 493bb105c29996dc583181431fcb0987fd1fed70 | https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LogicHook.php#L96-L149 |
230,801 | inetprocess/libsugarcrm | src/LogicHook.php | LogicHook.getHooksDefinitionsFromSugar | public function getHooksDefinitionsFromSugar($module)
{
$modulesList = array_keys($this->getEntryPoint()->getBeansList());
if (!in_array($module, $modulesList)) {
throw new BeanNotFoundException("$module is not a valid module name");
}
$beanManager = new Bean($this->getEntryPoint());
$bean = $beanManager->newBean($module);
// even if we have our own method, rely on sugar to identify hooks
$logicHook = new \LogicHook();
// @codeCoverageIgnoreStart
if (!method_exists($logicHook, 'loadHooks')) {
// Will fail on old sugar version.
throw new \BadMethodCallException('The loadHooks method does not exist. Is your SugarCRM too old ?');
}
// @codeCoverageIgnoreEnd
$logicHook->setBean($bean);
return $logicHook->loadHooks($beanManager->getModuleDirectory($module));
} | php | public function getHooksDefinitionsFromSugar($module)
{
$modulesList = array_keys($this->getEntryPoint()->getBeansList());
if (!in_array($module, $modulesList)) {
throw new BeanNotFoundException("$module is not a valid module name");
}
$beanManager = new Bean($this->getEntryPoint());
$bean = $beanManager->newBean($module);
// even if we have our own method, rely on sugar to identify hooks
$logicHook = new \LogicHook();
// @codeCoverageIgnoreStart
if (!method_exists($logicHook, 'loadHooks')) {
// Will fail on old sugar version.
throw new \BadMethodCallException('The loadHooks method does not exist. Is your SugarCRM too old ?');
}
// @codeCoverageIgnoreEnd
$logicHook->setBean($bean);
return $logicHook->loadHooks($beanManager->getModuleDirectory($module));
} | [
"public",
"function",
"getHooksDefinitionsFromSugar",
"(",
"$",
"module",
")",
"{",
"$",
"modulesList",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"getEntryPoint",
"(",
")",
"->",
"getBeansList",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
... | Get Hooks Definitions From SugarCRM
@param string $module
@return array | [
"Get",
"Hooks",
"Definitions",
"From",
"SugarCRM"
] | 493bb105c29996dc583181431fcb0987fd1fed70 | https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LogicHook.php#L156-L177 |
230,802 | inetprocess/libsugarcrm | src/LogicHook.php | LogicHook.getHooksDefinitionsFromFiles | public function getHooksDefinitionsFromFiles($module, $byFiles = true)
{
$modulesList = array_keys($this->getEntryPoint()->getBeansList());
if (!in_array($module, $modulesList)) {
throw new BeanNotFoundException("$module is not a valid module name");
}
$hooks = array();
// Create a new find to locate all the files where hooks could be defined
$beanManager = new Bean($this->getEntryPoint());
$bean = $beanManager->newBean($module);
$files = array();
// process the main file
$mainFile = 'custom/modules/' . $beanManager->getModuleDirectory($module) . '/logic_hooks.php';
if (file_exists($mainFile)) {
$files[] = $mainFile;
}
// find files in ExtDir
$customExtDir = 'custom/Extension/modules/' . $beanManager->getModuleDirectory($module) . '/Ext/LogicHooks/';
if (is_dir($customExtDir)) {
$finder = new Finder();
$finder->files()->in($customExtDir)->name('*.php');
foreach ($finder as $file) {
$files[] = $customExtDir . $file->getRelativePathname();
}
}
// read file and exit as soon as we find one
$hooksDefs = array();
foreach ($files as $file) {
if ($byFiles === true) {
$hook_array = array();
}
require($file);
$hooksDefs[$file] = $hook_array;
}
return ($byFiles === true ? $hooksDefs : $hook_array);
} | php | public function getHooksDefinitionsFromFiles($module, $byFiles = true)
{
$modulesList = array_keys($this->getEntryPoint()->getBeansList());
if (!in_array($module, $modulesList)) {
throw new BeanNotFoundException("$module is not a valid module name");
}
$hooks = array();
// Create a new find to locate all the files where hooks could be defined
$beanManager = new Bean($this->getEntryPoint());
$bean = $beanManager->newBean($module);
$files = array();
// process the main file
$mainFile = 'custom/modules/' . $beanManager->getModuleDirectory($module) . '/logic_hooks.php';
if (file_exists($mainFile)) {
$files[] = $mainFile;
}
// find files in ExtDir
$customExtDir = 'custom/Extension/modules/' . $beanManager->getModuleDirectory($module) . '/Ext/LogicHooks/';
if (is_dir($customExtDir)) {
$finder = new Finder();
$finder->files()->in($customExtDir)->name('*.php');
foreach ($finder as $file) {
$files[] = $customExtDir . $file->getRelativePathname();
}
}
// read file and exit as soon as we find one
$hooksDefs = array();
foreach ($files as $file) {
if ($byFiles === true) {
$hook_array = array();
}
require($file);
$hooksDefs[$file] = $hook_array;
}
return ($byFiles === true ? $hooksDefs : $hook_array);
} | [
"public",
"function",
"getHooksDefinitionsFromFiles",
"(",
"$",
"module",
",",
"$",
"byFiles",
"=",
"true",
")",
"{",
"$",
"modulesList",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"getEntryPoint",
"(",
")",
"->",
"getBeansList",
"(",
")",
")",
";",
"if",
... | Get, from the known files, the list of hooks defined in the system
@param string $module
@return array List of Hooks | [
"Get",
"from",
"the",
"known",
"files",
"the",
"list",
"of",
"hooks",
"defined",
"in",
"the",
"system"
] | 493bb105c29996dc583181431fcb0987fd1fed70 | https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LogicHook.php#L185-L226 |
230,803 | inetprocess/libsugarcrm | src/LogicHook.php | LogicHook.findHookInDefinition | public function findHookInDefinition(array $hooksDef, $type, $file, $class, $method)
{
foreach ($hooksDef as $defFile => $hooks) {
if (!array_key_exists($type, $hooks)) {
continue;
}
// Find a hook
foreach ($hooks[$type] as $hook) {
if ($hook[2] == $file && $hook[3] == $class && $hook[4] == $method) {
return $defFile;
}
}
}
} | php | public function findHookInDefinition(array $hooksDef, $type, $file, $class, $method)
{
foreach ($hooksDef as $defFile => $hooks) {
if (!array_key_exists($type, $hooks)) {
continue;
}
// Find a hook
foreach ($hooks[$type] as $hook) {
if ($hook[2] == $file && $hook[3] == $class && $hook[4] == $method) {
return $defFile;
}
}
}
} | [
"public",
"function",
"findHookInDefinition",
"(",
"array",
"$",
"hooksDef",
",",
"$",
"type",
",",
"$",
"file",
",",
"$",
"class",
",",
"$",
"method",
")",
"{",
"foreach",
"(",
"$",
"hooksDef",
"as",
"$",
"defFile",
"=>",
"$",
"hooks",
")",
"{",
"if... | Try to identify the file where a hook is defined
@param array $hooks
@param string $type
@param string $file
@param string $class
@param string $method
@return string File Name | [
"Try",
"to",
"identify",
"the",
"file",
"where",
"a",
"hook",
"is",
"defined"
] | 493bb105c29996dc583181431fcb0987fd1fed70 | https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LogicHook.php#L238-L252 |
230,804 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_compile_extends.php | Smarty_Internal_Compile_Extends.compileInclude | private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file)
{
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
$compiler->compileTag('include',
array($file,
array('scope' => 'parent'))));
} | php | private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file)
{
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
$compiler->compileTag('include',
array($file,
array('scope' => 'parent'))));
} | [
"private",
"function",
"compileInclude",
"(",
"Smarty_Internal_TemplateCompilerBase",
"$",
"compiler",
",",
"$",
"file",
")",
"{",
"$",
"compiler",
"->",
"parser",
"->",
"template_postfix",
"[",
"]",
"=",
"new",
"Smarty_Internal_ParseTree_Tag",
"(",
"$",
"compiler",... | Add code for including subtemplate to end of template
@param \Smarty_Internal_TemplateCompilerBase $compiler
@param string $file subtemplate name | [
"Add",
"code",
"for",
"including",
"subtemplate",
"to",
"end",
"of",
"template"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_compile_extends.php#L111-L117 |
230,805 | cygnite/framework | src/Cygnite/Pipeline/Pipeline.php | Pipeline.through | public function through(array $pipes, string $method = null) : PipelineInterface
{
$this->pipes = $pipes;
$this->method = !is_null($method) ? $method : $this->defaultMethod;
return $this;
} | php | public function through(array $pipes, string $method = null) : PipelineInterface
{
$this->pipes = $pipes;
$this->method = !is_null($method) ? $method : $this->defaultMethod;
return $this;
} | [
"public",
"function",
"through",
"(",
"array",
"$",
"pipes",
",",
"string",
"$",
"method",
"=",
"null",
")",
":",
"PipelineInterface",
"{",
"$",
"this",
"->",
"pipes",
"=",
"$",
"pipes",
";",
"$",
"this",
"->",
"method",
"=",
"!",
"is_null",
"(",
"$"... | Pass request through the pipeline.
@param array $pipes
@param string|null $method
@return $this | [
"Pass",
"request",
"through",
"the",
"pipeline",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Pipeline/Pipeline.php#L93-L99 |
230,806 | cygnite/framework | src/Cygnite/Pipeline/Pipeline.php | Pipeline.run | public function run()
{
return call_user_func(
array_reduce(
array_reverse($this->pipes),
$this->createPipelineCallback(),
function ($request) {
return ($this->callback === null) ? $request : call_user_func($this->callback, $request);
}
),
$this->request
);
} | php | public function run()
{
return call_user_func(
array_reduce(
array_reverse($this->pipes),
$this->createPipelineCallback(),
function ($request) {
return ($this->callback === null) ? $request : call_user_func($this->callback, $request);
}
),
$this->request
);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"return",
"call_user_func",
"(",
"array_reduce",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"pipes",
")",
",",
"$",
"this",
"->",
"createPipelineCallback",
"(",
")",
",",
"function",
"(",
"$",
"request",
")",
... | Run all pipeline requests.
@return mixed | [
"Run",
"all",
"pipeline",
"requests",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Pipeline/Pipeline.php#L116-L128 |
230,807 | cygnite/framework | src/Cygnite/Pipeline/Pipeline.php | Pipeline.createPipelineCallback | private function createPipelineCallback() : Closure
{
return function ($stack, $pipe) {
return function ($request) use ($stack, $pipe) {
if ($pipe instanceof Closure) {
return call_user_func($pipe, $request, $stack);
} elseif (!is_object($pipe)) {
list($callback, $parameters) = $this->createParameters($pipe, $request, $stack, true);
} else {
if (!method_exists($pipe, $this->method)) {
throw new PipelineException(sprintf("%s::%s doesn't exist", get_class($pipe), $this->method));
}
list($callback, $parameters) = $this->createParameters($pipe, $request, $stack);
}
return $this->call($callback, $parameters);
};
};
} | php | private function createPipelineCallback() : Closure
{
return function ($stack, $pipe) {
return function ($request) use ($stack, $pipe) {
if ($pipe instanceof Closure) {
return call_user_func($pipe, $request, $stack);
} elseif (!is_object($pipe)) {
list($callback, $parameters) = $this->createParameters($pipe, $request, $stack, true);
} else {
if (!method_exists($pipe, $this->method)) {
throw new PipelineException(sprintf("%s::%s doesn't exist", get_class($pipe), $this->method));
}
list($callback, $parameters) = $this->createParameters($pipe, $request, $stack);
}
return $this->call($callback, $parameters);
};
};
} | [
"private",
"function",
"createPipelineCallback",
"(",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"$",
"stack",
",",
"$",
"pipe",
")",
"{",
"return",
"function",
"(",
"$",
"request",
")",
"use",
"(",
"$",
"stack",
",",
"$",
"pipe",
")",
"{",
... | Create pipeline callback.
@throws PipelineException thrown if method doesn't exists
@return callable | [
"Create",
"pipeline",
"callback",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Pipeline/Pipeline.php#L137-L156 |
230,808 | cygnite/framework | src/Cygnite/Pipeline/Pipeline.php | Pipeline.createParameters | private function createParameters($pipe, $request, $stack, $isString = false)
{
if ($isString) {
list($name, $parameters) = $this->parsePipeString($pipe);
if (!is_object($this->container)) {
throw new PipelineException(sprintf('%s expects container instance', get_class($this)));
}
$pipe = ($this->container->has($name)) ? $this->container->get($name) : $this->container->make($name);
$parameters = array_merge([$request, $stack], $parameters);
} else {
$parameters = [$request, $stack];
}
return [[$pipe, $this->method], $parameters];
} | php | private function createParameters($pipe, $request, $stack, $isString = false)
{
if ($isString) {
list($name, $parameters) = $this->parsePipeString($pipe);
if (!is_object($this->container)) {
throw new PipelineException(sprintf('%s expects container instance', get_class($this)));
}
$pipe = ($this->container->has($name)) ? $this->container->get($name) : $this->container->make($name);
$parameters = array_merge([$request, $stack], $parameters);
} else {
$parameters = [$request, $stack];
}
return [[$pipe, $this->method], $parameters];
} | [
"private",
"function",
"createParameters",
"(",
"$",
"pipe",
",",
"$",
"request",
",",
"$",
"stack",
",",
"$",
"isString",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"isString",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"parameters",
")",
"=",
"$"... | Form a array of callback and parameters.
@param $pipe
@param $request
@param $stack
@param bool $isString
@throws PipelineException
@return array | [
"Form",
"a",
"array",
"of",
"callback",
"and",
"parameters",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Pipeline/Pipeline.php#L170-L186 |
230,809 | et-nik/binn-php | src/BinnList.php | BinnList.getBinnVal | public function getBinnVal()
{
$this->calculateSize();
$this->binnString = '';
$this->binnString .= $this->pack(self::BINN_UINT8, $this->binnType);
$this->binnString .= $this->packSize($this->size);
$count = count($this->binnArr);
$this->binnString .= $this->packSize($count);
foreach ($this->binnArr as &$arr) {
$type = $arr[self::KEY_TYPE];
$storageType = $this->storageType($type);
if ($type === self::BINN_BOOL) {
$this->binnString .= $arr[self::KEY_VAL]
? $this->packType(self::BINN_TRUE)
: $this->packType(self::BINN_FALSE);
continue;
}
if ($storageType === self::BINN_STORAGE_QWORD
|| $storageType === self::BINN_STORAGE_DWORD
|| $storageType === self::BINN_STORAGE_WORD
|| $storageType === self::BINN_STORAGE_BYTE
) {
$this->binnString .= $this->packType($arr[self::KEY_TYPE]);
$this->binnString .= $this->pack($arr[self::KEY_TYPE], $arr[self::KEY_VAL]);
} else if ($storageType === self::BINN_STORAGE_NOBYTES) {
$this->binnString .= $this->packType($arr[self::KEY_TYPE]);
} else if ($storageType === self::BINN_STORAGE_STRING) {
$this->binnString .= $this->packType(self::BINN_STRING);
$this->binnString .= $this->packSize($arr[self::KEY_SIZE]);
$this->binnString .= $this->pack(self::BINN_STRING, $arr[self::KEY_VAL]);
$this->binnString .= $this->pack(self::BINN_NULL);
} else if ($storageType === self::BINN_STORAGE_CONTAINER) {
$this->binnString .= $arr[self::KEY_VAL]->getBinnVal();
}
}
return $this->binnString;
} | php | public function getBinnVal()
{
$this->calculateSize();
$this->binnString = '';
$this->binnString .= $this->pack(self::BINN_UINT8, $this->binnType);
$this->binnString .= $this->packSize($this->size);
$count = count($this->binnArr);
$this->binnString .= $this->packSize($count);
foreach ($this->binnArr as &$arr) {
$type = $arr[self::KEY_TYPE];
$storageType = $this->storageType($type);
if ($type === self::BINN_BOOL) {
$this->binnString .= $arr[self::KEY_VAL]
? $this->packType(self::BINN_TRUE)
: $this->packType(self::BINN_FALSE);
continue;
}
if ($storageType === self::BINN_STORAGE_QWORD
|| $storageType === self::BINN_STORAGE_DWORD
|| $storageType === self::BINN_STORAGE_WORD
|| $storageType === self::BINN_STORAGE_BYTE
) {
$this->binnString .= $this->packType($arr[self::KEY_TYPE]);
$this->binnString .= $this->pack($arr[self::KEY_TYPE], $arr[self::KEY_VAL]);
} else if ($storageType === self::BINN_STORAGE_NOBYTES) {
$this->binnString .= $this->packType($arr[self::KEY_TYPE]);
} else if ($storageType === self::BINN_STORAGE_STRING) {
$this->binnString .= $this->packType(self::BINN_STRING);
$this->binnString .= $this->packSize($arr[self::KEY_SIZE]);
$this->binnString .= $this->pack(self::BINN_STRING, $arr[self::KEY_VAL]);
$this->binnString .= $this->pack(self::BINN_NULL);
} else if ($storageType === self::BINN_STORAGE_CONTAINER) {
$this->binnString .= $arr[self::KEY_VAL]->getBinnVal();
}
}
return $this->binnString;
} | [
"public",
"function",
"getBinnVal",
"(",
")",
"{",
"$",
"this",
"->",
"calculateSize",
"(",
")",
";",
"$",
"this",
"->",
"binnString",
"=",
"''",
";",
"$",
"this",
"->",
"binnString",
".=",
"$",
"this",
"->",
"pack",
"(",
"self",
"::",
"BINN_UINT8",
... | Get binary string
@return string | [
"Get",
"binary",
"string"
] | c493bc135c7ecdbbc7a8fb62c82625b7f1c6defb | https://github.com/et-nik/binn-php/blob/c493bc135c7ecdbbc7a8fb62c82625b7f1c6defb/src/BinnList.php#L93-L137 |
230,810 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_method_setdefaultmodifiers.php | Smarty_Internal_Method_SetDefaultModifiers.setDefaultModifiers | public function setDefaultModifiers(Smarty_Internal_TemplateBase $obj, $modifiers)
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
$smarty->default_modifiers = (array) $modifiers;
return $obj;
} | php | public function setDefaultModifiers(Smarty_Internal_TemplateBase $obj, $modifiers)
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
$smarty->default_modifiers = (array) $modifiers;
return $obj;
} | [
"public",
"function",
"setDefaultModifiers",
"(",
"Smarty_Internal_TemplateBase",
"$",
"obj",
",",
"$",
"modifiers",
")",
"{",
"$",
"smarty",
"=",
"isset",
"(",
"$",
"obj",
"->",
"smarty",
")",
"?",
"$",
"obj",
"->",
"smarty",
":",
"$",
"obj",
";",
"$",
... | Set default modifiers
@api Smarty::setDefaultModifiers()
@param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
@param array|string $modifiers modifier or list of modifiers
to set
@return \Smarty|\Smarty_Internal_Template | [
"Set",
"default",
"modifiers"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_setdefaultmodifiers.php#L32-L37 |
230,811 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_method_getdefaultmodifiers.php | Smarty_Internal_Method_GetDefaultModifiers.getDefaultModifiers | public function getDefaultModifiers(Smarty_Internal_TemplateBase $obj)
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
return $smarty->default_modifiers;
} | php | public function getDefaultModifiers(Smarty_Internal_TemplateBase $obj)
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
return $smarty->default_modifiers;
} | [
"public",
"function",
"getDefaultModifiers",
"(",
"Smarty_Internal_TemplateBase",
"$",
"obj",
")",
"{",
"$",
"smarty",
"=",
"isset",
"(",
"$",
"obj",
"->",
"smarty",
")",
"?",
"$",
"obj",
"->",
"smarty",
":",
"$",
"obj",
";",
"return",
"$",
"smarty",
"->... | Get default modifiers
@api Smarty::getDefaultModifiers()
@param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
@return array list of default modifiers | [
"Get",
"default",
"modifiers"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_getdefaultmodifiers.php#L30-L34 |
230,812 | cygnite/framework | src/Cygnite/Database/Migration.php | Migration.insert | public function insert($table, $attributes = [])
{
$this->tableName = $table;
$this->setAttributes($attributes);
if ($this->save()) {
return true;
} else {
return false;
}
} | php | public function insert($table, $attributes = [])
{
$this->tableName = $table;
$this->setAttributes($attributes);
if ($this->save()) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"tableName",
"=",
"$",
"table",
";",
"$",
"this",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"this"... | Seed a table using migration.
@param $table
@param array $attributes
@return bool | [
"Seed",
"a",
"table",
"using",
"migration",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Migration.php#L29-L39 |
230,813 | cygnite/framework | src/Cygnite/Database/Migration.php | Migration.delete | public function delete($table, $attribute)
{
$this->tableName = $table;
if (is_array($attribute)) {
return $this->trash($attribute, true);
} elseif (is_string($attribute) || is_int($attribute)) {
return $this->trash($attribute);
}
} | php | public function delete($table, $attribute)
{
$this->tableName = $table;
if (is_array($attribute)) {
return $this->trash($attribute, true);
} elseif (is_string($attribute) || is_int($attribute)) {
return $this->trash($attribute);
}
} | [
"public",
"function",
"delete",
"(",
"$",
"table",
",",
"$",
"attribute",
")",
"{",
"$",
"this",
"->",
"tableName",
"=",
"$",
"table",
";",
"if",
"(",
"is_array",
"(",
"$",
"attribute",
")",
")",
"{",
"return",
"$",
"this",
"->",
"trash",
"(",
"$",... | Delete rows using migration.
@param $table
@param array $attribute
@return bool | [
"Delete",
"rows",
"using",
"migration",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Migration.php#L49-L58 |
230,814 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_cacheresource_keyvaluestore.php | Smarty_CacheResource_KeyValueStore.process | public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
{
if (!$cached) {
$cached = $_template->cached;
}
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) {
return false;
}
}
if (isset($content)) {
/** @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
$_smarty_tpl = $_template;
eval("?>" . $content);
return true;
}
return false;
} | php | public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
{
if (!$cached) {
$cached = $_template->cached;
}
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) {
return false;
}
}
if (isset($content)) {
/** @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
$_smarty_tpl = $_template;
eval("?>" . $content);
return true;
}
return false;
} | [
"public",
"function",
"process",
"(",
"Smarty_Internal_Template",
"$",
"_template",
",",
"Smarty_Template_Cached",
"$",
"cached",
"=",
"null",
",",
"$",
"update",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"cached",
")",
"{",
"$",
"cached",
"=",
"$",
"... | Read the cached template and process the header
@param Smarty_Internal_Template $_template template object
@param Smarty_Template_Cached $cached cached object
@param bool $update flag if called because cache update
@return boolean true or false if the cached content does not exist | [
"Read",
"the",
"cached",
"template",
"and",
"process",
"the",
"header"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_cacheresource_keyvaluestore.php#L89-L112 |
230,815 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.create | public static function create(Closure $callback = null, $request = [])
{
return (is_callable($callback)) ?
$callback(new static(Security::create(), $request)) :
new static(Security::create(), $request);
} | php | public static function create(Closure $callback = null, $request = [])
{
return (is_callable($callback)) ?
$callback(new static(Security::create(), $request)) :
new static(Security::create(), $request);
} | [
"public",
"static",
"function",
"create",
"(",
"Closure",
"$",
"callback",
"=",
"null",
",",
"$",
"request",
"=",
"[",
"]",
")",
"{",
"return",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"?",
"$",
"callback",
"(",
"new",
"static",
"(",
"Secu... | Create Cookie Instance and return to user.
@param callable $callback
@param array $request
@return object | [
"Create",
"Cookie",
"Instance",
"and",
"return",
"to",
"user",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L75-L80 |
230,816 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.name | public function name($name)
{
if (is_null($name)) {
throw new \InvalidCookieException('Cookie name cannot be null');
return false;
}
$this->name = (string) $this->security->sanitize($name);
return $this;
} | php | public function name($name)
{
if (is_null($name)) {
throw new \InvalidCookieException('Cookie name cannot be null');
return false;
}
$this->name = (string) $this->security->sanitize($name);
return $this;
} | [
"public",
"function",
"name",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidCookieException",
"(",
"'Cookie name cannot be null'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->"... | Set cookie name.
@param string $name cookie name
@throws \InvalidCookieException
@return mixed obj or bool false | [
"Set",
"cookie",
"name",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L91-L102 |
230,817 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.value | public function value($value = null)
{
if (is_null($value)) {
throw new \InvalidCookieException('Cookie value cannot be null.');
}
if (is_array($value)) {
$value = json_encode($this->security->sanitize($value));
}
$length = (function_exists('mb_strlen') ? mb_strlen($value) : strlen($value));
if ($length > 4096) {
throw new \InvalidCookieException('Cookie maximum size exceeds 4kb');
return false;
}
$this->value = $this->security->sanitize($value);
return $this;
} | php | public function value($value = null)
{
if (is_null($value)) {
throw new \InvalidCookieException('Cookie value cannot be null.');
}
if (is_array($value)) {
$value = json_encode($this->security->sanitize($value));
}
$length = (function_exists('mb_strlen') ? mb_strlen($value) : strlen($value));
if ($length > 4096) {
throw new \InvalidCookieException('Cookie maximum size exceeds 4kb');
return false;
}
$this->value = $this->security->sanitize($value);
return $this;
} | [
"public",
"function",
"value",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidCookieException",
"(",
"'Cookie value cannot be null.'",
")",
";",
"}",
"if",
"(",
"is_array",
... | Set cookie value.
@param string $value cookie value
@throws \InvalidCookieException
@internal param bool $encrypt
@return bool whether the string was a string | [
"Set",
"cookie",
"value",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L115-L136 |
230,818 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.expire | public function expire($expire = 0)
{
$var = null;
$var = substr($expire, 0, 1);
if (in_array($var, ['+', '-'])) {
$this->expire = strtotime($expire);
if ($this->expire === false) {
throw new \InvalidCookieException(
'Cookie->setExpire was passed a string it could not parse - "'.$expire.'"'
);
}
return $this;
}
$this->expire = 0;
return $this;
} | php | public function expire($expire = 0)
{
$var = null;
$var = substr($expire, 0, 1);
if (in_array($var, ['+', '-'])) {
$this->expire = strtotime($expire);
if ($this->expire === false) {
throw new \InvalidCookieException(
'Cookie->setExpire was passed a string it could not parse - "'.$expire.'"'
);
}
return $this;
}
$this->expire = 0;
return $this;
} | [
"public",
"function",
"expire",
"(",
"$",
"expire",
"=",
"0",
")",
"{",
"$",
"var",
"=",
"null",
";",
"$",
"var",
"=",
"substr",
"(",
"$",
"expire",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"var",
",",
"[",
"'+'",
",",
... | Set cookie expire time.
@param int $expire
@throws \InvalidCookieException
@internal param string $time +1 day, etc.
@return bool whether the string was a string | [
"Set",
"cookie",
"expire",
"time",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L149-L169 |
230,819 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.get | public function get($name = null)
{
if (is_null($name)) {
$name = $this->security->sanitize($this->name);
}
$name = $this->security->sanitize($name);
if (!isset(static::$cookies[$name])) {
throw new InvalidCookieException('Cookie '.$name.' not found');
}
if (isset(static::$cookies[$name])) {
if (is_array(static::$cookies[$name])) {
return json_decode(static::$cookies[$name]);
}
return $this->security->sanitize(static::$cookies[$name]);
}
} | php | public function get($name = null)
{
if (is_null($name)) {
$name = $this->security->sanitize($this->name);
}
$name = $this->security->sanitize($name);
if (!isset(static::$cookies[$name])) {
throw new InvalidCookieException('Cookie '.$name.' not found');
}
if (isset(static::$cookies[$name])) {
if (is_array(static::$cookies[$name])) {
return json_decode(static::$cookies[$name]);
}
return $this->security->sanitize(static::$cookies[$name]);
}
} | [
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"security",
"->",
"sanitize",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"$",
... | Get a cookie's value.
@param string $name The cookie name
@return mixed string /bool - The value of the cookie name | [
"Get",
"a",
"cookie",
"s",
"value",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L236-L255 |
230,820 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.store | public function store()
{
if ($this->name && $this->setCookie == true) {
throw new InvalidCookieException('Cookies can only set once.');
}
$bool = setcookie(
$this->name,
$this->value,
$this->expire,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
);
if ($bool == true) {
$this->setCookie = true;
}
return $bool;
} | php | public function store()
{
if ($this->name && $this->setCookie == true) {
throw new InvalidCookieException('Cookies can only set once.');
}
$bool = setcookie(
$this->name,
$this->value,
$this->expire,
$this->path,
$this->domain,
$this->secure,
$this->httpOnly
);
if ($bool == true) {
$this->setCookie = true;
}
return $bool;
} | [
"public",
"function",
"store",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"&&",
"$",
"this",
"->",
"setCookie",
"==",
"true",
")",
"{",
"throw",
"new",
"InvalidCookieException",
"(",
"'Cookies can only set once.'",
")",
";",
"}",
"$",
"bool",
"... | Set the cookie.
@throws \Exceptions Cookies already set
@return bool | [
"Set",
"the",
"cookie",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L264-L285 |
230,821 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.has | public function has($cookie)
{
if (isset(static::$cookies[$cookie]) || $cookie == $this->name) {
return true;
}
return false;
} | php | public function has($cookie)
{
if (isset(static::$cookies[$cookie]) || $cookie == $this->name) {
return true;
}
return false;
} | [
"public",
"function",
"has",
"(",
"$",
"cookie",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"cookies",
"[",
"$",
"cookie",
"]",
")",
"||",
"$",
"cookie",
"==",
"$",
"this",
"->",
"name",
")",
"{",
"return",
"true",
";",
"}",
"return"... | Check cookie existance.
@param $cookie
@return bool|mixed | [
"Check",
"cookie",
"existance",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L294-L301 |
230,822 | cygnite/framework | src/Cygnite/Common/Input/CookieManager/Cookie.php | Cookie.destroy | public function destroy($name = null)
{
if (is_null($name)) {
$name = $this->name;
}
return setcookie($name, null, (time() - 1), $this->path, $this->domain);
} | php | public function destroy($name = null)
{
if (is_null($name)) {
$name = $this->name;
}
return setcookie($name, null, (time() - 1), $this->path, $this->domain);
} | [
"public",
"function",
"destroy",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
";",
"}",
"return",
"setcookie",
"(",
"$",
"name",
",",
"null",
",",
"... | Destroy the cookie.
@param null $name
@internal param string $cookieName to kill
@return bool true/false | [
"Destroy",
"the",
"cookie",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Input/CookieManager/Cookie.php#L312-L319 |
230,823 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php | Smarty_Internal_Method_RegisterDefaultTemplateHandler.registerDefaultTemplateHandler | public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback)
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
if (is_callable($callback)) {
$smarty->default_template_handler_func = $callback;
} else {
throw new SmartyException("Default template handler not callable");
}
return $obj;
} | php | public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback)
{
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
if (is_callable($callback)) {
$smarty->default_template_handler_func = $callback;
} else {
throw new SmartyException("Default template handler not callable");
}
return $obj;
} | [
"public",
"function",
"registerDefaultTemplateHandler",
"(",
"Smarty_Internal_TemplateBase",
"$",
"obj",
",",
"$",
"callback",
")",
"{",
"$",
"smarty",
"=",
"isset",
"(",
"$",
"obj",
"->",
"smarty",
")",
"?",
"$",
"obj",
"->",
"smarty",
":",
"$",
"obj",
";... | Register template default handler
@api Smarty::registerDefaultTemplateHandler()
@param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
@param callable $callback class/method name
@return \Smarty|\Smarty_Internal_Template
@throws SmartyException if $callback is not callable | [
"Register",
"template",
"default",
"handler"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php#L32-L41 |
230,824 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php | Smarty_Internal_Method_RegisterDefaultTemplateHandler._getDefaultTemplate | public static function _getDefaultTemplate(Smarty_Template_Source $source)
{
if ($source->isConfig) {
$default_handler = $source->smarty->default_config_handler_func;
} else {
$default_handler = $source->smarty->default_template_handler_func;
}
$_content = $_timestamp = null;
$_return = call_user_func_array($default_handler, array($source->type, $source->name, &$_content, &$_timestamp,
$source->smarty));
if (is_string($_return)) {
$source->exists = is_file($_return);
if ($source->exists) {
$source->timestamp = filemtime($_return);
}
$source->filepath = $_return;
} elseif ($_return === true) {
$source->content = $_content;
$source->timestamp = $_timestamp;
$source->exists = true;
$source->handler->recompiled = true;
$source->filepath = false;
}
} | php | public static function _getDefaultTemplate(Smarty_Template_Source $source)
{
if ($source->isConfig) {
$default_handler = $source->smarty->default_config_handler_func;
} else {
$default_handler = $source->smarty->default_template_handler_func;
}
$_content = $_timestamp = null;
$_return = call_user_func_array($default_handler, array($source->type, $source->name, &$_content, &$_timestamp,
$source->smarty));
if (is_string($_return)) {
$source->exists = is_file($_return);
if ($source->exists) {
$source->timestamp = filemtime($_return);
}
$source->filepath = $_return;
} elseif ($_return === true) {
$source->content = $_content;
$source->timestamp = $_timestamp;
$source->exists = true;
$source->handler->recompiled = true;
$source->filepath = false;
}
} | [
"public",
"static",
"function",
"_getDefaultTemplate",
"(",
"Smarty_Template_Source",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"->",
"isConfig",
")",
"{",
"$",
"default_handler",
"=",
"$",
"source",
"->",
"smarty",
"->",
"default_config_handler_func",
... | get default content from template or config resource handler
@param Smarty_Template_Source $source | [
"get",
"default",
"content",
"from",
"template",
"or",
"config",
"resource",
"handler"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php#L48-L71 |
230,825 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.initialize | public function initialize(array $query, array $post, array $cookie, array $server, array $files, array $env, $content = null)
{
$this->query = new Collection($query);
$this->post = new Collection($post);
$this->put = new Collection([]);
$this->patch = new Collection([]);
$this->delete = new Collection([]);
$this->env = new Collection($env);
$this->header = new Header($server);
$this->server = new Collection($server);
$this->cookie = new Collection($cookie);
$this->files = new Files($files);
$this->content = $content;
$this->method = null;
$this->setClientIPs();
$this->setPath();
$this->setUnsupportedMethodsIfExists();
return $this;
} | php | public function initialize(array $query, array $post, array $cookie, array $server, array $files, array $env, $content = null)
{
$this->query = new Collection($query);
$this->post = new Collection($post);
$this->put = new Collection([]);
$this->patch = new Collection([]);
$this->delete = new Collection([]);
$this->env = new Collection($env);
$this->header = new Header($server);
$this->server = new Collection($server);
$this->cookie = new Collection($cookie);
$this->files = new Files($files);
$this->content = $content;
$this->method = null;
$this->setClientIPs();
$this->setPath();
$this->setUnsupportedMethodsIfExists();
return $this;
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"query",
",",
"array",
"$",
"post",
",",
"array",
"$",
"cookie",
",",
"array",
"$",
"server",
",",
"array",
"$",
"files",
",",
"array",
"$",
"env",
",",
"$",
"content",
"=",
"null",
")",
"{",
"... | Initialize parameters for current request.
@param array $query
@param array $post
@param array $cookie
@param array $server
@param array $files
@param array $env
@param null $content | [
"Initialize",
"parameters",
"for",
"current",
"request",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L103-L123 |
230,826 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.createFromGlobals | public static function createFromGlobals(
array $query = null,
array $post = null,
array $cookie = null,
array $server = null,
array $files = null,
array $env = null,
$content = null
) {
$query = isset($query) ? $query : $_GET;
$post = isset($post) ? $post : $_POST;
$cookie = isset($cookie) ? $cookie : $_COOKIE;
$server = isset($server) ? $server : $_SERVER;
$files = isset($files) ? $files : $_FILES;
$env = isset($env) ? $env : $_ENV;
$server = self::setServerParam($server, [
'CONTENT_LENGTH' => 'HTTP_CONTENT_LENGTH',
'CONTENT_TYPE' => 'HTTP_CONTENT_TYPE',
]);
return new static($query, $post, $cookie, $server, $files, $env, $content);
} | php | public static function createFromGlobals(
array $query = null,
array $post = null,
array $cookie = null,
array $server = null,
array $files = null,
array $env = null,
$content = null
) {
$query = isset($query) ? $query : $_GET;
$post = isset($post) ? $post : $_POST;
$cookie = isset($cookie) ? $cookie : $_COOKIE;
$server = isset($server) ? $server : $_SERVER;
$files = isset($files) ? $files : $_FILES;
$env = isset($env) ? $env : $_ENV;
$server = self::setServerParam($server, [
'CONTENT_LENGTH' => 'HTTP_CONTENT_LENGTH',
'CONTENT_TYPE' => 'HTTP_CONTENT_TYPE',
]);
return new static($query, $post, $cookie, $server, $files, $env, $content);
} | [
"public",
"static",
"function",
"createFromGlobals",
"(",
"array",
"$",
"query",
"=",
"null",
",",
"array",
"$",
"post",
"=",
"null",
",",
"array",
"$",
"cookie",
"=",
"null",
",",
"array",
"$",
"server",
"=",
"null",
",",
"array",
"$",
"files",
"=",
... | Create a new request using PHP super global variables.
@param array $query
@param array $post
@param array $cookie
@param array $server
@param array $files
@param array $env
@param null $content
@return static | [
"Create",
"a",
"new",
"request",
"using",
"PHP",
"super",
"global",
"variables",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L138-L160 |
230,827 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.setServerParam | private static function setServerParam($server, $arr)
{
foreach ($arr as $key => $value) {
if (array_key_exists($value, $server)) {
$server[$key] = $server[$value];
}
}
return $server;
} | php | private static function setServerParam($server, $arr)
{
foreach ($arr as $key => $value) {
if (array_key_exists($value, $server)) {
$server[$key] = $server[$value];
}
}
return $server;
} | [
"private",
"static",
"function",
"setServerParam",
"(",
"$",
"server",
",",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"server",
")",
... | Set content parameter if exists in server array.
@param $server
@param $arr
@return mixed | [
"Set",
"content",
"parameter",
"if",
"exists",
"in",
"server",
"array",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L170-L179 |
230,828 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.create | public static function create(
$url,
$method = RequestMethods::GET,
array $parameters = [],
array $cookies = [],
array $server = [],
array $files = [],
array $env = [],
$rawBody = null
) {
// Define some basic server vars, but override them with the input on collision
$server = array_replace([
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_HOST' => 'localhost',
'REMOTE_ADDR' => '127.0.01',
'SCRIPT_FILENAME' => '',
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80,
'SERVER_PROTOCOL' => 'HTTP/1.1',
'HTTP_USER_AGENT' => 'Cygnite/3.x',
'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'REQUEST_TIME' => time(),
], $server);
$query = [];
$post = [];
// Set the content type for unsupported HTTP methods
switch (strtoupper($method)) {
case RequestMethods::GET:
$query = $parameters;
break;
case RequestMethods::PATCH:
case RequestMethods::PUT:
case RequestMethods::DELETE:
if (!isset($server['CONTENT_TYPE'])) {
$server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
}
// no break
case RequestMethods::POST:
$post = $parameters;
break;
}
$server['REQUEST_METHOD'] = strtoupper($method);
$urlParts = parse_url($url);
$server = static::setServerData($urlParts, [
'host' => 'HTTP_HOST',
'path' => 'REQUEST_URI',
'user' => 'PHP_AUTH_USER',
'pass' => 'PHP_AUTH_PW',
], $server);
if (isset($urlParts['scheme'])) {
if ($urlParts['scheme'] == 'https') {
$server['HTTPS'] = 'on';
$server['SERVER_PORT'] = 443;
} else {
unset($server['HTTPS']);
$server['SERVER_PORT'] = 80;
}
}
if (isset($urlParts['query'])) {
parse_str(html_entity_decode($urlParts['query']), $queryFromUrl);
$query = array_replace($queryFromUrl, $query);
}
if (!isset($urlParts['path'])) {
$urlParts['path'] = '/';
}
$qs = http_build_query($query, '', '&');
$server['QUERY_STRING'] = $qs;
$server['REQUEST_URI'] = $urlParts['path'].(count($query) > 0 ? '?'.$qs : '');
if (isset($urlParts['port'])) {
$server = static::setServerData($urlParts, [
'port' => 'SERVER_PORT',
":{$urlParts['port']}" => 'HTTP_HOST',
], $server);
}
return new static($query, $post, $cookies, $server, $files, $env, $rawBody);
} | php | public static function create(
$url,
$method = RequestMethods::GET,
array $parameters = [],
array $cookies = [],
array $server = [],
array $files = [],
array $env = [],
$rawBody = null
) {
// Define some basic server vars, but override them with the input on collision
$server = array_replace([
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_HOST' => 'localhost',
'REMOTE_ADDR' => '127.0.01',
'SCRIPT_FILENAME' => '',
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80,
'SERVER_PROTOCOL' => 'HTTP/1.1',
'HTTP_USER_AGENT' => 'Cygnite/3.x',
'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'REQUEST_TIME' => time(),
], $server);
$query = [];
$post = [];
// Set the content type for unsupported HTTP methods
switch (strtoupper($method)) {
case RequestMethods::GET:
$query = $parameters;
break;
case RequestMethods::PATCH:
case RequestMethods::PUT:
case RequestMethods::DELETE:
if (!isset($server['CONTENT_TYPE'])) {
$server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
}
// no break
case RequestMethods::POST:
$post = $parameters;
break;
}
$server['REQUEST_METHOD'] = strtoupper($method);
$urlParts = parse_url($url);
$server = static::setServerData($urlParts, [
'host' => 'HTTP_HOST',
'path' => 'REQUEST_URI',
'user' => 'PHP_AUTH_USER',
'pass' => 'PHP_AUTH_PW',
], $server);
if (isset($urlParts['scheme'])) {
if ($urlParts['scheme'] == 'https') {
$server['HTTPS'] = 'on';
$server['SERVER_PORT'] = 443;
} else {
unset($server['HTTPS']);
$server['SERVER_PORT'] = 80;
}
}
if (isset($urlParts['query'])) {
parse_str(html_entity_decode($urlParts['query']), $queryFromUrl);
$query = array_replace($queryFromUrl, $query);
}
if (!isset($urlParts['path'])) {
$urlParts['path'] = '/';
}
$qs = http_build_query($query, '', '&');
$server['QUERY_STRING'] = $qs;
$server['REQUEST_URI'] = $urlParts['path'].(count($query) > 0 ? '?'.$qs : '');
if (isset($urlParts['port'])) {
$server = static::setServerData($urlParts, [
'port' => 'SERVER_PORT',
":{$urlParts['port']}" => 'HTTP_HOST',
], $server);
}
return new static($query, $post, $cookies, $server, $files, $env, $rawBody);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"url",
",",
"$",
"method",
"=",
"RequestMethods",
"::",
"GET",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"cookies",
"=",
"[",
"]",
",",
"array",
"$",
"server",
"=",
"[",
"... | Create a request based on the uri given, populate
server information.
@param $url
@param $method
@param array $parameters
@param array $cookies
@param array $server
@param array $files
@param array $env
@param null $rawBody
@return static | [
"Create",
"a",
"request",
"based",
"on",
"the",
"uri",
"given",
"populate",
"server",
"information",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L196-L283 |
230,829 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.setServerData | private static function setServerData($parts, $params, $server)
{
foreach ($params as $key => $value) {
if (isset($parts[$key])) {
$server[$value] = $parts[$key];
}
}
return $server;
} | php | private static function setServerData($parts, $params, $server)
{
foreach ($params as $key => $value) {
if (isset($parts[$key])) {
$server[$value] = $parts[$key];
}
}
return $server;
} | [
"private",
"static",
"function",
"setServerData",
"(",
"$",
"parts",
",",
"$",
"params",
",",
"$",
"server",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"$",
... | Set param to server variable is exists in url parts.
@param $parts
@param $params
@param $server
@return mixed | [
"Set",
"param",
"to",
"server",
"variable",
"is",
"exists",
"in",
"url",
"parts",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L294-L303 |
230,830 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.setPath | public function setPath($path = null) : bool
{
if ($path === null) {
$uri = $this->server->get('REQUEST_URI');
if (!empty($uri)) {
$uriParts = explode('?', $uri);
$this->path = $uriParts[0];
return true;
}
// Default to a slash
$this->path = '/';
return true;
}
$this->path = $path;
return true;
} | php | public function setPath($path = null) : bool
{
if ($path === null) {
$uri = $this->server->get('REQUEST_URI');
if (!empty($uri)) {
$uriParts = explode('?', $uri);
$this->path = $uriParts[0];
return true;
}
// Default to a slash
$this->path = '/';
return true;
}
$this->path = $path;
return true;
} | [
"public",
"function",
"setPath",
"(",
"$",
"path",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"server",
"->",
"get",
"(",
"'REQUEST_URI'",
")",
";",
"if",
"(",
"!",
"... | Set the path of the current request. It doesn't include the query
string if no input specified and automatically set path using the header.
@param null $path
@return bool | [
"Set",
"the",
"path",
"of",
"the",
"current",
"request",
".",
"It",
"doesn",
"t",
"include",
"the",
"query",
"string",
"if",
"no",
"input",
"specified",
"and",
"automatically",
"set",
"path",
"using",
"the",
"header",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L313-L334 |
230,831 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.setClientIPs | private function setClientIPs()
{
if ($this->isUsingTrustedProxy()) {
$this->clientIps = [$this->server->get('REMOTE_ADDR')];
}
$clientIps = [];
if ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED])) {
$header = $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED]);
preg_match_all("/for=(?:\"?\[?)([a-z0-9:\.\-\/_]*)/", $header, $matches);
$clientIps = $matches[1];
} elseif ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP])) {
$clientIps = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP]));
$clientIps = array_map('trim', $clientIps);
}
$clientIps[] = $this->server->get('REMOTE_ADDR');
$fallbackClientIps = [$clientIps[0]];
foreach ($clientIps as $index => $clientIp) {
// Check for valid IPs
if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
unset($clientIps[$index]);
continue;
}
// Don't allow trusted proxies
if (in_array($clientIp, self::$trustedProxies)) {
unset($clientIps[$index]);
}
}
$this->clientIps = (count($clientIps) == 0) ? $fallbackClientIps : array_reverse($clientIps);
} | php | private function setClientIPs()
{
if ($this->isUsingTrustedProxy()) {
$this->clientIps = [$this->server->get('REMOTE_ADDR')];
}
$clientIps = [];
if ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED])) {
$header = $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::FORWARDED]);
preg_match_all("/for=(?:\"?\[?)([a-z0-9:\.\-\/_]*)/", $header, $matches);
$clientIps = $matches[1];
} elseif ($this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP])) {
$clientIps = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_IP]));
$clientIps = array_map('trim', $clientIps);
}
$clientIps[] = $this->server->get('REMOTE_ADDR');
$fallbackClientIps = [$clientIps[0]];
foreach ($clientIps as $index => $clientIp) {
// Check for valid IPs
if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
unset($clientIps[$index]);
continue;
}
// Don't allow trusted proxies
if (in_array($clientIp, self::$trustedProxies)) {
unset($clientIps[$index]);
}
}
$this->clientIps = (count($clientIps) == 0) ? $fallbackClientIps : array_reverse($clientIps);
} | [
"private",
"function",
"setClientIPs",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isUsingTrustedProxy",
"(",
")",
")",
"{",
"$",
"this",
"->",
"clientIps",
"=",
"[",
"$",
"this",
"->",
"server",
"->",
"get",
"(",
"'REMOTE_ADDR'",
")",
"]",
";",
"}... | Sets the client IP addresses. | [
"Sets",
"the",
"client",
"IP",
"addresses",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L368-L402 |
230,832 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.getFullUrl | public function getFullUrl()
{
$isSecure = $this->isSecure();
$srvProtocol = strtolower($this->server->get('SERVER_PROTOCOL'));
$protocol = substr($srvProtocol, 0, strpos($srvProtocol, '/')).(($isSecure) ? 's' : '');
$port = $this->getPort();
$port = ((!$isSecure && $port != '80') || ($isSecure && $port != '443')) ? ":$port" : '';
return $protocol.'://'.$this->getHost().$port.$this->server->get('REQUEST_URI');
} | php | public function getFullUrl()
{
$isSecure = $this->isSecure();
$srvProtocol = strtolower($this->server->get('SERVER_PROTOCOL'));
$protocol = substr($srvProtocol, 0, strpos($srvProtocol, '/')).(($isSecure) ? 's' : '');
$port = $this->getPort();
$port = ((!$isSecure && $port != '80') || ($isSecure && $port != '443')) ? ":$port" : '';
return $protocol.'://'.$this->getHost().$port.$this->server->get('REQUEST_URI');
} | [
"public",
"function",
"getFullUrl",
"(",
")",
"{",
"$",
"isSecure",
"=",
"$",
"this",
"->",
"isSecure",
"(",
")",
";",
"$",
"srvProtocol",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"server",
"->",
"get",
"(",
"'SERVER_PROTOCOL'",
")",
")",
";",
"$",
... | Get the full URL of the current request.
@return string | [
"Get",
"the",
"full",
"URL",
"of",
"the",
"current",
"request",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L526-L535 |
230,833 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.getHost | public function getHost()
{
if ($this->isUsingTrustedProxy() && $this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_HOST])) {
$hosts = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_HOST]));
$host = trim(end($hosts));
} else {
$host = $this->header->get('X_FORWARDED_FOR');
}
$host = $this->getHostIfNull($host);
// Remove the port number
$host = strtolower(preg_replace('/:\d+$/', '', trim($host)));
// Check for forbidden characters
if (!empty($host) && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) {
throw new \UnexpectedValueException("Invalid host $host");
}
return $host;
} | php | public function getHost()
{
if ($this->isUsingTrustedProxy() && $this->header->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_HOST])) {
$hosts = explode(',', $this->header->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_HOST]));
$host = trim(end($hosts));
} else {
$host = $this->header->get('X_FORWARDED_FOR');
}
$host = $this->getHostIfNull($host);
// Remove the port number
$host = strtolower(preg_replace('/:\d+$/', '', trim($host)));
// Check for forbidden characters
if (!empty($host) && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) {
throw new \UnexpectedValueException("Invalid host $host");
}
return $host;
} | [
"public",
"function",
"getHost",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isUsingTrustedProxy",
"(",
")",
"&&",
"$",
"this",
"->",
"header",
"->",
"has",
"(",
"self",
"::",
"$",
"trustedHeaderNames",
"[",
"RequestHeaderConstants",
"::",
"CLIENT_HOST",
... | Gets the host name.
@throws \UnexpectedValueException Thrown if the host name invalid
@return string | [
"Gets",
"the",
"host",
"name",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L544-L564 |
230,834 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.getHostIfNull | private function getHostIfNull($host)
{
if ($host === null) {
$host = $this->header->get('HOST');
}
if ($host === null) {
$host = $this->server->get('SERVER_NAME');
}
if ($host === null) {
// Return an empty string by default so we can do string operations on it later
$host = $this->server->get('SERVER_ADDR', '');
}
return $host;
} | php | private function getHostIfNull($host)
{
if ($host === null) {
$host = $this->header->get('HOST');
}
if ($host === null) {
$host = $this->server->get('SERVER_NAME');
}
if ($host === null) {
// Return an empty string by default so we can do string operations on it later
$host = $this->server->get('SERVER_ADDR', '');
}
return $host;
} | [
"private",
"function",
"getHostIfNull",
"(",
"$",
"host",
")",
"{",
"if",
"(",
"$",
"host",
"===",
"null",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"header",
"->",
"get",
"(",
"'HOST'",
")",
";",
"}",
"if",
"(",
"$",
"host",
"===",
"null",
... | Check if host variable is null then search
host name from different global variables.
@param $host
@return mixed | [
"Check",
"if",
"host",
"variable",
"is",
"null",
"then",
"search",
"host",
"name",
"from",
"different",
"global",
"variables",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L574-L590 |
230,835 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.isPath | public function isPath($path, $isRegex = false)
{
if ($isRegex) {
return preg_match('#^'.$path.'$#', $this->path) === 1;
} else {
return $this->path == $path;
}
} | php | public function isPath($path, $isRegex = false)
{
if ($isRegex) {
return preg_match('#^'.$path.'$#', $this->path) === 1;
} else {
return $this->path == $path;
}
} | [
"public",
"function",
"isPath",
"(",
"$",
"path",
",",
"$",
"isRegex",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"isRegex",
")",
"{",
"return",
"preg_match",
"(",
"'#^'",
".",
"$",
"path",
".",
"'$#'",
",",
"$",
"this",
"->",
"path",
")",
"===",
"1... | Check if the given path matches with input path.
@param $path
@param bool $isRegex
@return bool | [
"Check",
"if",
"the",
"given",
"path",
"matches",
"with",
"input",
"path",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L879-L886 |
230,836 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.getReferrerUrl | public function getReferrerUrl($fallBackToReferer = true)
{
if (!empty($this->refererUrl)) {
return $this->refererUrl;
}
if ($fallBackToReferer) {
return $this->header->get('REFERER', '');
}
return '';
} | php | public function getReferrerUrl($fallBackToReferer = true)
{
if (!empty($this->refererUrl)) {
return $this->refererUrl;
}
if ($fallBackToReferer) {
return $this->header->get('REFERER', '');
}
return '';
} | [
"public",
"function",
"getReferrerUrl",
"(",
"$",
"fallBackToReferer",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"refererUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"refererUrl",
";",
"}",
"if",
"(",
"$",
"fallBackTo... | The referrer URL, if set otherwise return the referrer header.
@param bool $fallBackToReferer
@return string | [
"The",
"referrer",
"URL",
"if",
"set",
"otherwise",
"return",
"the",
"referrer",
"header",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L895-L906 |
230,837 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.getBaseUrl | public function getBaseUrl() : string
{
// Current Request URI
$this->currentUrl = $this->server->get('REQUEST_URI');
// Remove rewrite base path (= allows one to run the router in a sub folder)
$basePath = implode('/', array_slice(explode('/', $this->server->get('SCRIPT_NAME')), 0, -1)).'/';
return $basePath;
} | php | public function getBaseUrl() : string
{
// Current Request URI
$this->currentUrl = $this->server->get('REQUEST_URI');
// Remove rewrite base path (= allows one to run the router in a sub folder)
$basePath = implode('/', array_slice(explode('/', $this->server->get('SCRIPT_NAME')), 0, -1)).'/';
return $basePath;
} | [
"public",
"function",
"getBaseUrl",
"(",
")",
":",
"string",
"{",
"// Current Request URI",
"$",
"this",
"->",
"currentUrl",
"=",
"$",
"this",
"->",
"server",
"->",
"get",
"(",
"'REQUEST_URI'",
")",
";",
"// Remove rewrite base path (= allows one to run the router in ... | Get the base url.
@return string | [
"Get",
"the",
"base",
"url",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L913-L922 |
230,838 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.isSecure | public function isSecure()
{
if ($this->isUsingTrustedProxy() && $this->server->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_PROTO])) {
$protocolString = $this->server->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_PROTO]);
$protocols = explode(',', $protocolString);
return count($protocols) > 0 && in_array(strtolower($protocols[0]), ['https', 'ssl', 'on']);
}
return $this->server->has('HTTPS') && strtolower($this->server->get('HTTPS')) !== 'off';
} | php | public function isSecure()
{
if ($this->isUsingTrustedProxy() && $this->server->has(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_PROTO])) {
$protocolString = $this->server->get(self::$trustedHeaderNames[RequestHeaderConstants::CLIENT_PROTO]);
$protocols = explode(',', $protocolString);
return count($protocols) > 0 && in_array(strtolower($protocols[0]), ['https', 'ssl', 'on']);
}
return $this->server->has('HTTPS') && strtolower($this->server->get('HTTPS')) !== 'off';
} | [
"public",
"function",
"isSecure",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isUsingTrustedProxy",
"(",
")",
"&&",
"$",
"this",
"->",
"server",
"->",
"has",
"(",
"self",
"::",
"$",
"trustedHeaderNames",
"[",
"RequestHeaderConstants",
"::",
"CLIENT_PROTO",... | Check whether the request is through HTTPS or not.
@return bool | [
"Check",
"whether",
"the",
"request",
"is",
"through",
"HTTPS",
"or",
"not",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L953-L963 |
230,839 | cygnite/framework | src/Cygnite/Http/Requests/Request.php | Request.isUrl | public function isUrl($url, $isRegex = false)
{
if ($isRegex) {
return preg_match('#^'.$url.'$#', $this->getFullUrl()) === 1;
}
return $this->getFullUrl() == $url;
} | php | public function isUrl($url, $isRegex = false)
{
if ($isRegex) {
return preg_match('#^'.$url.'$#', $this->getFullUrl()) === 1;
}
return $this->getFullUrl() == $url;
} | [
"public",
"function",
"isUrl",
"(",
"$",
"url",
",",
"$",
"isRegex",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"isRegex",
")",
"{",
"return",
"preg_match",
"(",
"'#^'",
".",
"$",
"url",
".",
"'$#'",
",",
"$",
"this",
"->",
"getFullUrl",
"(",
")",
"... | Check if current url matches the given url.
@param $url
@param bool $isRegex
@return bool | [
"Check",
"if",
"current",
"url",
"matches",
"the",
"given",
"url",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Requests/Request.php#L973-L980 |
230,840 | ARCANEDEV/GeoIP | src/Drivers/IpApiDriver.php | IpApiDriver.getHttpClientConfig | private function getHttpClientConfig()
{
$config = [
'base_uri' => 'http://ip-api.com/',
'headers' => [
'User-Agent' => 'Laravel-GeoIP',
],
'query' => [
'fields' => 16895,
],
];
// Using the Pro service
if ($this->getOption('key')) {
$config['base_uri'] = $this->isSecure() ? 'https://pro.ip-api.com/' : 'http://pro.ip-api.com/';
$config['query']['key'] = $this->getOption('key');
}
return $config;
} | php | private function getHttpClientConfig()
{
$config = [
'base_uri' => 'http://ip-api.com/',
'headers' => [
'User-Agent' => 'Laravel-GeoIP',
],
'query' => [
'fields' => 16895,
],
];
// Using the Pro service
if ($this->getOption('key')) {
$config['base_uri'] = $this->isSecure() ? 'https://pro.ip-api.com/' : 'http://pro.ip-api.com/';
$config['query']['key'] = $this->getOption('key');
}
return $config;
} | [
"private",
"function",
"getHttpClientConfig",
"(",
")",
"{",
"$",
"config",
"=",
"[",
"'base_uri'",
"=>",
"'http://ip-api.com/'",
",",
"'headers'",
"=>",
"[",
"'User-Agent'",
"=>",
"'Laravel-GeoIP'",
",",
"]",
",",
"'query'",
"=>",
"[",
"'fields'",
"=>",
"1689... | Get the http client config.
@return array | [
"Get",
"the",
"http",
"client",
"config",
"."
] | 2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318 | https://github.com/ARCANEDEV/GeoIP/blob/2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318/src/Drivers/IpApiDriver.php#L92-L111 |
230,841 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php | Smarty_Internal_Compile_Private_ForeachSection.scanForProperties | public function scanForProperties($attributes, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->propertyPreg = '~(';
$this->startOffset = 0;
$this->resultOffsets = array();
$this->matchResults = array('named' => array(), 'item' => array());
if ($this->isNamed) {
$this->buildPropertyPreg(true, $attributes);
}
if (isset($this->itemProperties)) {
if ($this->isNamed) {
$this->propertyPreg .= '|';
}
$this->buildPropertyPreg(false, $attributes);
}
$this->propertyPreg .= ')\W~i';
// Template source
$this->matchTemplateSource($compiler);
// Parent template source
$this->matchParentTemplateSource($compiler);
// {block} source
$this->matchBlockSource($compiler);
} | php | public function scanForProperties($attributes, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->propertyPreg = '~(';
$this->startOffset = 0;
$this->resultOffsets = array();
$this->matchResults = array('named' => array(), 'item' => array());
if ($this->isNamed) {
$this->buildPropertyPreg(true, $attributes);
}
if (isset($this->itemProperties)) {
if ($this->isNamed) {
$this->propertyPreg .= '|';
}
$this->buildPropertyPreg(false, $attributes);
}
$this->propertyPreg .= ')\W~i';
// Template source
$this->matchTemplateSource($compiler);
// Parent template source
$this->matchParentTemplateSource($compiler);
// {block} source
$this->matchBlockSource($compiler);
} | [
"public",
"function",
"scanForProperties",
"(",
"$",
"attributes",
",",
"Smarty_Internal_TemplateCompilerBase",
"$",
"compiler",
")",
"{",
"$",
"this",
"->",
"propertyPreg",
"=",
"'~('",
";",
"$",
"this",
"->",
"startOffset",
"=",
"0",
";",
"$",
"this",
"->",
... | Scan sources for used tag attributes
@param array $attributes
@param \Smarty_Internal_TemplateCompilerBase $compiler | [
"Scan",
"sources",
"for",
"used",
"tag",
"attributes"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php#L80-L102 |
230,842 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php | Smarty_Internal_Compile_Private_ForeachSection.buildPropertyPreg | public function buildPropertyPreg($named, $attributes)
{
if ($named) {
$this->resultOffsets['named'] = $this->startOffset + 3;
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
$properties = $this->nameProperties;
} else {
$this->resultOffsets['item'] = $this->startOffset + 3;
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
$properties = $this->itemProperties;
}
$this->startOffset += count($properties) + 2;
$propName = reset($properties);
while ($propName) {
$this->propertyPreg .= "({$propName})";
$propName = next($properties);
if ($propName) {
$this->propertyPreg .= '|';
}
}
$this->propertyPreg .= '))';
} | php | public function buildPropertyPreg($named, $attributes)
{
if ($named) {
$this->resultOffsets['named'] = $this->startOffset + 3;
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
$properties = $this->nameProperties;
} else {
$this->resultOffsets['item'] = $this->startOffset + 3;
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
$properties = $this->itemProperties;
}
$this->startOffset += count($properties) + 2;
$propName = reset($properties);
while ($propName) {
$this->propertyPreg .= "({$propName})";
$propName = next($properties);
if ($propName) {
$this->propertyPreg .= '|';
}
}
$this->propertyPreg .= '))';
} | [
"public",
"function",
"buildPropertyPreg",
"(",
"$",
"named",
",",
"$",
"attributes",
")",
"{",
"if",
"(",
"$",
"named",
")",
"{",
"$",
"this",
"->",
"resultOffsets",
"[",
"'named'",
"]",
"=",
"$",
"this",
"->",
"startOffset",
"+",
"3",
";",
"$",
"th... | Build property preg string
@param bool $named
@param array $attributes | [
"Build",
"property",
"preg",
"string"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php#L110-L131 |
230,843 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php | Smarty_Internal_Compile_Private_ForeachSection.matchProperty | public function matchProperty($source)
{
preg_match_all($this->propertyPreg, $source, $match, PREG_SET_ORDER);
foreach ($this->resultOffsets as $key => $offset) {
foreach ($match as $m) {
if (isset($m[$offset]) && !empty($m[$offset])) {
$this->matchResults[$key][strtolower($m[$offset])] = true;
}
}
}
} | php | public function matchProperty($source)
{
preg_match_all($this->propertyPreg, $source, $match, PREG_SET_ORDER);
foreach ($this->resultOffsets as $key => $offset) {
foreach ($match as $m) {
if (isset($m[$offset]) && !empty($m[$offset])) {
$this->matchResults[$key][strtolower($m[$offset])] = true;
}
}
}
} | [
"public",
"function",
"matchProperty",
"(",
"$",
"source",
")",
"{",
"preg_match_all",
"(",
"$",
"this",
"->",
"propertyPreg",
",",
"$",
"source",
",",
"$",
"match",
",",
"PREG_SET_ORDER",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"resultOffsets",
"as",... | Find matches in source string
@param string $source | [
"Find",
"matches",
"in",
"source",
"string"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php#L138-L148 |
230,844 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php | Smarty_Internal_Compile_Private_ForeachSection.matchParentTemplateSource | public function matchParentTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
{
// search parent compiler template source
$nextCompiler = $compiler;
while ($nextCompiler !== $nextCompiler->parent_compiler) {
$nextCompiler = $nextCompiler->parent_compiler;
if ($compiler !== $nextCompiler) {
// get template source
$_content = $nextCompiler->template->source->getContent();
if ($_content != '') {
// run pre filter if required
if ((isset($nextCompiler->smarty->autoload_filters['pre']) ||
isset($nextCompiler->smarty->registered_filters['pre']))) {
$_content = $nextCompiler->smarty->ext->_filter_Handler->runFilter('pre', $_content, $nextCompiler->template);
}
$this->matchProperty($_content);
}
}
}
} | php | public function matchParentTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
{
// search parent compiler template source
$nextCompiler = $compiler;
while ($nextCompiler !== $nextCompiler->parent_compiler) {
$nextCompiler = $nextCompiler->parent_compiler;
if ($compiler !== $nextCompiler) {
// get template source
$_content = $nextCompiler->template->source->getContent();
if ($_content != '') {
// run pre filter if required
if ((isset($nextCompiler->smarty->autoload_filters['pre']) ||
isset($nextCompiler->smarty->registered_filters['pre']))) {
$_content = $nextCompiler->smarty->ext->_filter_Handler->runFilter('pre', $_content, $nextCompiler->template);
}
$this->matchProperty($_content);
}
}
}
} | [
"public",
"function",
"matchParentTemplateSource",
"(",
"Smarty_Internal_TemplateCompilerBase",
"$",
"compiler",
")",
"{",
"// search parent compiler template source",
"$",
"nextCompiler",
"=",
"$",
"compiler",
";",
"while",
"(",
"$",
"nextCompiler",
"!==",
"$",
"nextComp... | Find matches in all parent template source
@param \Smarty_Internal_TemplateCompilerBase $compiler | [
"Find",
"matches",
"in",
"all",
"parent",
"template",
"source"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_compile_private_foreachsection.php#L165-L184 |
230,845 | ARCANEDEV/GeoIP | src/GeoIPServiceProvider.php | GeoIPServiceProvider.registerGeoIpManager | private function registerGeoIpManager()
{
$this->singleton(Contracts\DriverFactory::class, function ($app) {
return new DriverManager($app);
});
$this->singleton(Contracts\GeoIPDriver::class, function ($app) {
/** @var \Arcanedev\GeoIP\Contracts\DriverFactory $manager */
$manager = $app[Contracts\DriverFactory::class];
return $manager->driver();
});
} | php | private function registerGeoIpManager()
{
$this->singleton(Contracts\DriverFactory::class, function ($app) {
return new DriverManager($app);
});
$this->singleton(Contracts\GeoIPDriver::class, function ($app) {
/** @var \Arcanedev\GeoIP\Contracts\DriverFactory $manager */
$manager = $app[Contracts\DriverFactory::class];
return $manager->driver();
});
} | [
"private",
"function",
"registerGeoIpManager",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"DriverFactory",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"DriverManager",
"(",
"$",
"app",
")",
";",
... | Register the GeoIP manager. | [
"Register",
"the",
"GeoIP",
"manager",
"."
] | 2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318 | https://github.com/ARCANEDEV/GeoIP/blob/2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318/src/GeoIPServiceProvider.php#L88-L100 |
230,846 | ARCANEDEV/GeoIP | src/GeoIPServiceProvider.php | GeoIPServiceProvider.registerGeoIpCache | private function registerGeoIpCache()
{
$this->singleton(Contracts\GeoIPCache::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new Cache(
$app['cache.store'],
$config->get('geoip.cache.tags', []),
$config->get('geoip.cache.expires', 30)
);
});
} | php | private function registerGeoIpCache()
{
$this->singleton(Contracts\GeoIPCache::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new Cache(
$app['cache.store'],
$config->get('geoip.cache.tags', []),
$config->get('geoip.cache.expires', 30)
);
});
} | [
"private",
"function",
"registerGeoIpCache",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"GeoIPCache",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"/** @var \\Illuminate\\Contracts\\Config\\Repository $config */",
"$",
"conf... | Register the GeoIP Cache store. | [
"Register",
"the",
"GeoIP",
"Cache",
"store",
"."
] | 2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318 | https://github.com/ARCANEDEV/GeoIP/blob/2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318/src/GeoIPServiceProvider.php#L105-L117 |
230,847 | ARCANEDEV/GeoIP | src/GeoIPServiceProvider.php | GeoIPServiceProvider.registerGeoIp | private function registerGeoIp()
{
$this->singleton(Contracts\GeoIP::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new GeoIP(
$app[Contracts\GeoIPDriver::class],
$app[Contracts\GeoIPCache::class],
Arr::only($config->get('geoip', []), ['cache', 'location', 'currencies'])
);
});
} | php | private function registerGeoIp()
{
$this->singleton(Contracts\GeoIP::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new GeoIP(
$app[Contracts\GeoIPDriver::class],
$app[Contracts\GeoIPCache::class],
Arr::only($config->get('geoip', []), ['cache', 'location', 'currencies'])
);
});
} | [
"private",
"function",
"registerGeoIp",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"GeoIP",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"/** @var \\Illuminate\\Contracts\\Config\\Repository $config */",
"$",
"config",
"="... | Register the GeoIP. | [
"Register",
"the",
"GeoIP",
"."
] | 2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318 | https://github.com/ARCANEDEV/GeoIP/blob/2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318/src/GeoIPServiceProvider.php#L122-L134 |
230,848 | cygnite/framework | src/Cygnite/Common/SessionManager/Database/Session.php | Session.createTableIfNotExists | public function createTableIfNotExists()
{
Schema::make(
$this,
function ($table) {
$table->tableName = $this->getTable();
/*
| Check if table already exists
| if not we will create an table to store session info
*/
if (!$table->hasTable()->run()) {
$table->create(
[
[
'column' => 'id',
'type' => 'int',
'length' => 11,
'increment' => true,
'key' => 'primary',
],
['column' => 'access', 'type' => 'int', 'length' => 11],
['column' => 'data', 'type' => 'text'],
['column' => 'session_id', 'type' => 'string', 'length' => 128],
],
'InnoDB',
'latin1'
)->run();
}
}
);
} | php | public function createTableIfNotExists()
{
Schema::make(
$this,
function ($table) {
$table->tableName = $this->getTable();
/*
| Check if table already exists
| if not we will create an table to store session info
*/
if (!$table->hasTable()->run()) {
$table->create(
[
[
'column' => 'id',
'type' => 'int',
'length' => 11,
'increment' => true,
'key' => 'primary',
],
['column' => 'access', 'type' => 'int', 'length' => 11],
['column' => 'data', 'type' => 'text'],
['column' => 'session_id', 'type' => 'string', 'length' => 128],
],
'InnoDB',
'latin1'
)->run();
}
}
);
} | [
"public",
"function",
"createTableIfNotExists",
"(",
")",
"{",
"Schema",
"::",
"make",
"(",
"$",
"this",
",",
"function",
"(",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"tableName",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"/*\n ... | We will create session schema if not exists. | [
"We",
"will",
"create",
"session",
"schema",
"if",
"not",
"exists",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/SessionManager/Database/Session.php#L175-L206 |
230,849 | michaeljennings/feed | src/Store/Eloquent/Notification.php | Notification.getNotifications | public function getNotifications(array $types, array $ids, $read = false)
{
$query = $this->whereIn('notifiable_type', $types)
->whereIn('notifiable_id', $ids)
->where('read', $read)
->orderBy($this->orderBy, $this->orderByDirection);
if ($this->limit) {
$query->limit($this->limit);
}
if ($this->offset) {
$query->offset($this->offset);
}
foreach($this->filters as $filter) {
$filter($query);
}
if ($this->paginate) {
return $query->paginate($this->paginate);
}
return $query->get();
} | php | public function getNotifications(array $types, array $ids, $read = false)
{
$query = $this->whereIn('notifiable_type', $types)
->whereIn('notifiable_id', $ids)
->where('read', $read)
->orderBy($this->orderBy, $this->orderByDirection);
if ($this->limit) {
$query->limit($this->limit);
}
if ($this->offset) {
$query->offset($this->offset);
}
foreach($this->filters as $filter) {
$filter($query);
}
if ($this->paginate) {
return $query->paginate($this->paginate);
}
return $query->get();
} | [
"public",
"function",
"getNotifications",
"(",
"array",
"$",
"types",
",",
"array",
"$",
"ids",
",",
"$",
"read",
"=",
"false",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"whereIn",
"(",
"'notifiable_type'",
",",
"$",
"types",
")",
"->",
"whereIn"... | Get all of the unread notifications where their notifiable type
is in the array of types, and their notifiable id is in the
array of ids.
@param array $types
@param array $ids
@param bool $read
@return \Michaeljennings\Feed\Contracts\Notification[] | [
"Get",
"all",
"of",
"the",
"unread",
"notifications",
"where",
"their",
"notifiable",
"type",
"is",
"in",
"the",
"array",
"of",
"types",
"and",
"their",
"notifiable",
"id",
"is",
"in",
"the",
"array",
"of",
"ids",
"."
] | 687cae75dae7ce6cbf81678ffe1615faf6cbe0d6 | https://github.com/michaeljennings/feed/blob/687cae75dae7ce6cbf81678ffe1615faf6cbe0d6/src/Store/Eloquent/Notification.php#L88-L112 |
230,850 | michaeljennings/feed | src/Store/Eloquent/Notification.php | Notification.getIds | public function getIds($notifications)
{
return array_map(function($notification) {
if ($notification instanceof NotificationContract) {
return $notification->getKey();
} else {
return $notification;
}
}, $notifications);
} | php | public function getIds($notifications)
{
return array_map(function($notification) {
if ($notification instanceof NotificationContract) {
return $notification->getKey();
} else {
return $notification;
}
}, $notifications);
} | [
"public",
"function",
"getIds",
"(",
"$",
"notifications",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"notification",
")",
"{",
"if",
"(",
"$",
"notification",
"instanceof",
"NotificationContract",
")",
"{",
"return",
"$",
"notification",
"->"... | Get the primary of all of the notifications.
@param array $notifications
@return array | [
"Get",
"the",
"primary",
"of",
"all",
"of",
"the",
"notifications",
"."
] | 687cae75dae7ce6cbf81678ffe1615faf6cbe0d6 | https://github.com/michaeljennings/feed/blob/687cae75dae7ce6cbf81678ffe1615faf6cbe0d6/src/Store/Eloquent/Notification.php#L230-L239 |
230,851 | cygnite/framework | src/Cygnite/Common/Encrypt.php | Encrypt.setSaltKey | private function setSaltKey($key)
{
$this->setKey($key);
if (!function_exists('mcrypt_create_iv')) {
throw new \BadFunctionCallException('Mcrypt extension library not loaded');
}
$this->iv = mcrypt_create_iv(32);
} | php | private function setSaltKey($key)
{
$this->setKey($key);
if (!function_exists('mcrypt_create_iv')) {
throw new \BadFunctionCallException('Mcrypt extension library not loaded');
}
$this->iv = mcrypt_create_iv(32);
} | [
"private",
"function",
"setSaltKey",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"setKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"function_exists",
"(",
"'mcrypt_create_iv'",
")",
")",
"{",
"throw",
"new",
"\\",
"BadFunctionCallException",
"(",
"'... | We will set the Encryption key.
@param $key
@throws \BadFunctionCallException | [
"We",
"will",
"set",
"the",
"Encryption",
"key",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Encrypt.php#L81-L90 |
230,852 | cygnite/framework | src/Cygnite/Common/Encrypt.php | Encrypt.encode | public function encode($input)
{
$this->value = base64_encode(
mcrypt_encrypt(
MCRYPT_RIJNDAEL_256,
$this->secureKey,
$input,
MCRYPT_MODE_ECB,
$this->iv
)
);
return $this->value;
} | php | public function encode($input)
{
$this->value = base64_encode(
mcrypt_encrypt(
MCRYPT_RIJNDAEL_256,
$this->secureKey,
$input,
MCRYPT_MODE_ECB,
$this->iv
)
);
return $this->value;
} | [
"public",
"function",
"encode",
"(",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"base64_encode",
"(",
"mcrypt_encrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"$",
"this",
"->",
"secureKey",
",",
"$",
"input",
",",
"MCRYPT_MODE_ECB",
",",
"$",
"thi... | This function is to encrypt string.
@param string
@return encrypted hash | [
"This",
"function",
"is",
"to",
"encrypt",
"string",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Encrypt.php#L117-L130 |
230,853 | cygnite/framework | src/Cygnite/Common/Encrypt.php | Encrypt.decode | public function decode($input)
{
$this->value = trim(
mcrypt_decrypt(
MCRYPT_RIJNDAEL_256,
$this->secureKey,
base64_decode($input),
MCRYPT_MODE_ECB,
$this->iv
)
);
return $this->value;
} | php | public function decode($input)
{
$this->value = trim(
mcrypt_decrypt(
MCRYPT_RIJNDAEL_256,
$this->secureKey,
base64_decode($input),
MCRYPT_MODE_ECB,
$this->iv
)
);
return $this->value;
} | [
"public",
"function",
"decode",
"(",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"trim",
"(",
"mcrypt_decrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"$",
"this",
"->",
"secureKey",
",",
"base64_decode",
"(",
"$",
"input",
")",
",",
"MCRYPT_MODE_EC... | This function is to decrypt the encoded string.
@param string
@return decrypted string | [
"This",
"function",
"is",
"to",
"decrypt",
"the",
"encoded",
"string",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Encrypt.php#L139-L152 |
230,854 | franzliedke/lti | src/OAuth/DataStore.php | DataStore.lookupConsumer | public function lookupConsumer($consumer_key)
{
return new Consumer(
$this->tool_provider->consumer->getKey(),
$this->tool_provider->consumer->secret
);
} | php | public function lookupConsumer($consumer_key)
{
return new Consumer(
$this->tool_provider->consumer->getKey(),
$this->tool_provider->consumer->secret
);
} | [
"public",
"function",
"lookupConsumer",
"(",
"$",
"consumer_key",
")",
"{",
"return",
"new",
"Consumer",
"(",
"$",
"this",
"->",
"tool_provider",
"->",
"consumer",
"->",
"getKey",
"(",
")",
",",
"$",
"this",
"->",
"tool_provider",
"->",
"consumer",
"->",
"... | Create an Consumer object for the tool consumer.
@param string $consumer_key Consumer key value
@return Consumer Consumer object | [
"Create",
"an",
"Consumer",
"object",
"for",
"the",
"tool",
"consumer",
"."
] | 131cf331f2cb87fcc29049ac739c8751e9e5133b | https://github.com/franzliedke/lti/blob/131cf331f2cb87fcc29049ac739c8751e9e5133b/src/OAuth/DataStore.php#L39-L45 |
230,855 | DevGroup-ru/yii2-jstree-widget | src/widgets/TreeWidget.php | TreeWidget.prepareJs | private function prepareJs()
{
switch ($this->treeType) {
case self::TREE_TYPE_ADJACENCY :
return $this->adjacencyJs();
case self::TREE_TYPE_NESTED_SET :
return $this->nestedSetJs();
}
} | php | private function prepareJs()
{
switch ($this->treeType) {
case self::TREE_TYPE_ADJACENCY :
return $this->adjacencyJs();
case self::TREE_TYPE_NESTED_SET :
return $this->nestedSetJs();
}
} | [
"private",
"function",
"prepareJs",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"treeType",
")",
"{",
"case",
"self",
"::",
"TREE_TYPE_ADJACENCY",
":",
"return",
"$",
"this",
"->",
"adjacencyJs",
"(",
")",
";",
"case",
"self",
"::",
"TREE_TYPE_NESTED_... | Prepares js according to given tree type
@return string | [
"Prepares",
"js",
"according",
"to",
"given",
"tree",
"type"
] | 6ae0311254eb757a13fc5c318d6a15544d84b105 | https://github.com/DevGroup-ru/yii2-jstree-widget/blob/6ae0311254eb757a13fc5c318d6a15544d84b105/src/widgets/TreeWidget.php#L239-L247 |
230,856 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_runtime_tplfunction.php | Smarty_Internal_Runtime_TplFunction.callTemplateFunction | public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
{
if (isset($tpl->tpl_function[$name])) {
if (!$tpl->caching || ($tpl->caching && $nocache)) {
$function = $tpl->tpl_function[$name]['call_name'];
} else {
if (isset($tpl->tpl_function[$name]['call_name_caching'])) {
$function = $tpl->tpl_function[$name]['call_name_caching'];
} else {
$function = $tpl->tpl_function[$name]['call_name'];
}
}
if (function_exists($function)) {
$function ($tpl, $params);
return;
}
// try to load template function dynamically
if ($this->addTplFuncToCache($tpl, $name, $function)) {
$function ($tpl, $params);
return;
}
}
throw new SmartyException("Unable to find template function '{$name}'");
} | php | public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
{
if (isset($tpl->tpl_function[$name])) {
if (!$tpl->caching || ($tpl->caching && $nocache)) {
$function = $tpl->tpl_function[$name]['call_name'];
} else {
if (isset($tpl->tpl_function[$name]['call_name_caching'])) {
$function = $tpl->tpl_function[$name]['call_name_caching'];
} else {
$function = $tpl->tpl_function[$name]['call_name'];
}
}
if (function_exists($function)) {
$function ($tpl, $params);
return;
}
// try to load template function dynamically
if ($this->addTplFuncToCache($tpl, $name, $function)) {
$function ($tpl, $params);
return;
}
}
throw new SmartyException("Unable to find template function '{$name}'");
} | [
"public",
"function",
"callTemplateFunction",
"(",
"Smarty_Internal_Template",
"$",
"tpl",
",",
"$",
"name",
",",
"$",
"params",
",",
"$",
"nocache",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"tpl",
"->",
"tpl_function",
"[",
"$",
"name",
"]",
")",
")",
... | Call template function
@param \Smarty_Internal_Template $tpl template object
@param string $name template function name
@param array $params parameter array
@param bool $nocache true if called nocache
@throws \SmartyException | [
"Call",
"template",
"function"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_runtime_tplfunction.php#L23-L46 |
230,857 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_method_getconfigvars.php | Smarty_Internal_Method_GetConfigVars.getConfigVars | public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true)
{
$_ptr = $data;
$var_array = array();
while ($_ptr !== null) {
if (isset($varname)) {
if (isset($_ptr->config_vars[$varname])) {
return $_ptr->config_vars[$varname];
}
} else {
$var_array = array_merge($_ptr->config_vars, $var_array);
}
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
} else {
$_ptr = null;
}
}
if (isset($varname)) {
return '';
} else {
return $var_array;
}
} | php | public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true)
{
$_ptr = $data;
$var_array = array();
while ($_ptr !== null) {
if (isset($varname)) {
if (isset($_ptr->config_vars[$varname])) {
return $_ptr->config_vars[$varname];
}
} else {
$var_array = array_merge($_ptr->config_vars, $var_array);
}
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
} else {
$_ptr = null;
}
}
if (isset($varname)) {
return '';
} else {
return $var_array;
}
} | [
"public",
"function",
"getConfigVars",
"(",
"Smarty_Internal_Data",
"$",
"data",
",",
"$",
"varname",
"=",
"null",
",",
"$",
"search_parents",
"=",
"true",
")",
"{",
"$",
"_ptr",
"=",
"$",
"data",
";",
"$",
"var_array",
"=",
"array",
"(",
")",
";",
"wh... | Returns a single or all config variables
@api Smarty::getConfigVars()
@link http://www.smarty.net/docs/en/api.get.config.vars.tpl
@param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
@param string $varname variable name or null
@param bool $search_parents include parent templates?
@return mixed variable value or or array of variables | [
"Returns",
"a",
"single",
"or",
"all",
"config",
"variables"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_getconfigvars.php#L33-L57 |
230,858 | cygnite/framework | src/Cygnite/Router/Controller/ResourceController.php | ResourceController.resourceController | public function resourceController($router, $name, $controller)
{
$this->setRouter($router);
foreach ($this->resourceRoutes as $key => $action) {
$this->{'setResource' . ucfirst($action)}($name, $controller, $action);
}
return $this;
} | php | public function resourceController($router, $name, $controller)
{
$this->setRouter($router);
foreach ($this->resourceRoutes as $key => $action) {
$this->{'setResource' . ucfirst($action)}($name, $controller, $action);
}
return $this;
} | [
"public",
"function",
"resourceController",
"(",
"$",
"router",
",",
"$",
"name",
",",
"$",
"controller",
")",
"{",
"$",
"this",
"->",
"setRouter",
"(",
"$",
"router",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"resourceRoutes",
"as",
"$",
"key",
"=>... | Set the controller as Resource Controller
Cygnite Router knows how to respond to resource controller
request automatically.
@param $router
@param $name
@param $controller
@return $this | [
"Set",
"the",
"controller",
"as",
"Resource",
"Controller",
"Cygnite",
"Router",
"knows",
"how",
"to",
"respond",
"to",
"resource",
"controller",
"request",
"automatically",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Router/Controller/ResourceController.php#L46-L55 |
230,859 | tapestry-cloud/tapestry | src/Entities/File.php | File.getUid | public function getUid()
{
if (is_null($this->uid)) {
$pathName = (! empty($this->getFileInfo()->getRelativePathname())) ? $this->getFileInfo()->getRelativePathname() : $this->getFileInfo()->getPathname();
$this->uid = $this->cleanUid($pathName);
}
return $this->uid;
} | php | public function getUid()
{
if (is_null($this->uid)) {
$pathName = (! empty($this->getFileInfo()->getRelativePathname())) ? $this->getFileInfo()->getRelativePathname() : $this->getFileInfo()->getPathname();
$this->uid = $this->cleanUid($pathName);
}
return $this->uid;
} | [
"public",
"function",
"getUid",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"uid",
")",
")",
"{",
"$",
"pathName",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getFileInfo",
"(",
")",
"->",
"getRelativePathname",
"(",
")",
")",... | Get identifier for this file, the relative pathname is unique to each file so that should be good enough.
@return string | [
"Get",
"identifier",
"for",
"this",
"file",
"the",
"relative",
"pathname",
"is",
"unique",
"to",
"each",
"file",
"so",
"that",
"should",
"be",
"good",
"enough",
"."
] | f3fc980b2484ccbe609a7f811c65b91254e8720e | https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Entities/File.php#L137-L145 |
230,860 | tapestry-cloud/tapestry | src/Entities/File.php | File.getCompiledPermalink | public function getCompiledPermalink()
{
$pretty = $this->getData('pretty_permalink', true);
if ($this->hasData('permalink')) {
$pretty = false;
}
return $this->permalink->getCompiled($this, $pretty);
} | php | public function getCompiledPermalink()
{
$pretty = $this->getData('pretty_permalink', true);
if ($this->hasData('permalink')) {
$pretty = false;
}
return $this->permalink->getCompiled($this, $pretty);
} | [
"public",
"function",
"getCompiledPermalink",
"(",
")",
"{",
"$",
"pretty",
"=",
"$",
"this",
"->",
"getData",
"(",
"'pretty_permalink'",
",",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasData",
"(",
"'permalink'",
")",
")",
"{",
"$",
"pretty",
... | Pretty Permalinks are disabled on all files that have their
permalink structure configured via front matter.
@return mixed|string
@throws \Exception | [
"Pretty",
"Permalinks",
"are",
"disabled",
"on",
"all",
"files",
"that",
"have",
"their",
"permalink",
"structure",
"configured",
"via",
"front",
"matter",
"."
] | f3fc980b2484ccbe609a7f811c65b91254e8720e | https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Entities/File.php#L230-L238 |
230,861 | cygnite/framework | src/Cygnite/Foundation/Collection.php | Collection.add | public function add(string $name, $value)
{
if (is_array($name)) {
foreach ($name as $key => $value) {
$this->data[$key] = $value;
}
return $this;
}
$this->data[$name] = $value;
return $this;
} | php | public function add(string $name, $value)
{
if (is_array($name)) {
foreach ($name as $key => $value) {
$this->data[$key] = $value;
}
return $this;
}
$this->data[$name] = $value;
return $this;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data"... | Add additional arguments in the given collection.
@param $name
@param $value
@return $this | [
"Add",
"additional",
"arguments",
"in",
"the",
"given",
"collection",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Collection.php#L79-L92 |
230,862 | cygnite/framework | src/Cygnite/Foundation/Collection.php | Collection.unserialize | public function unserialize($serialized = null)
{
if (is_null($serialized)) {
return unserialize($this->serialize);
}
return unserialize($serialized);
} | php | public function unserialize($serialized = null)
{
if (is_null($serialized)) {
return unserialize($this->serialize);
}
return unserialize($serialized);
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"serialized",
")",
")",
"{",
"return",
"unserialize",
"(",
"$",
"this",
"->",
"serialize",
")",
";",
"}",
"return",
"unserialize",
"(",
... | Un serialize the data.
@param string $serialized
@return array | [
"Un",
"serialize",
"the",
"data",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Collection.php#L235-L242 |
230,863 | cygnite/framework | src/Cygnite/Foundation/Collection.php | Collection.filter | public function filter(\Closure $callback = null) : Collection
{
if ($callback) {
return static::create(array_filter($this->data, $callback));
}
return static::create(array_filter($this->data));
} | php | public function filter(\Closure $callback = null) : Collection
{
if ($callback) {
return static::create(array_filter($this->data, $callback));
}
return static::create(array_filter($this->data));
} | [
"public",
"function",
"filter",
"(",
"\\",
"Closure",
"$",
"callback",
"=",
"null",
")",
":",
"Collection",
"{",
"if",
"(",
"$",
"callback",
")",
"{",
"return",
"static",
"::",
"create",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"data",
",",
"$",
... | Filter over array element.
@param \Closure|null $callback
@return Collection | [
"Filter",
"over",
"array",
"element",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Collection.php#L250-L257 |
230,864 | cygnite/framework | src/Cygnite/Foundation/Collection.php | Collection.map | public function map(\Closure $callback) : Collection
{
$keys = array_keys($this->data);
$values = array_map($callback, $this->data, $keys);
return static::create(array_combine($keys, $values));
} | php | public function map(\Closure $callback) : Collection
{
$keys = array_keys($this->data);
$values = array_map($callback, $this->data, $keys);
return static::create(array_combine($keys, $values));
} | [
"public",
"function",
"map",
"(",
"\\",
"Closure",
"$",
"callback",
")",
":",
"Collection",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"values",
"=",
"array_map",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
... | Map array elements and return as Collection object.
@param \Closure $callback
@return Collection | [
"Map",
"array",
"elements",
"and",
"return",
"as",
"Collection",
"object",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Collection.php#L344-L350 |
230,865 | cygnite/framework | src/Cygnite/Foundation/Collection.php | Collection.merge | public function merge($data) : Collection
{
return static::create(array_merge($this->data, $this->convertToArray($data)));
} | php | public function merge($data) : Collection
{
return static::create(array_merge($this->data, $this->convertToArray($data)));
} | [
"public",
"function",
"merge",
"(",
"$",
"data",
")",
":",
"Collection",
"{",
"return",
"static",
"::",
"create",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"convertToArray",
"(",
"$",
"data",
")",
")",
")",
";",
"}"
... | Merge the collection with the given array.
@param $data
@return Collection | [
"Merge",
"the",
"collection",
"with",
"the",
"given",
"array",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Collection.php#L358-L361 |
230,866 | cygnite/framework | src/Cygnite/Foundation/Collection.php | Collection.sort | public function sort(callable $callback = null) : Collection
{
$data = $this->data;
!is_null($callback) ? uasort($data, $callback) : asort($data);
return static::create($data);
} | php | public function sort(callable $callback = null) : Collection
{
$data = $this->data;
!is_null($callback) ? uasort($data, $callback) : asort($data);
return static::create($data);
} | [
"public",
"function",
"sort",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
":",
"Collection",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"!",
"is_null",
"(",
"$",
"callback",
")",
"?",
"uasort",
"(",
"$",
"data",
",",
"$",
"callb... | Sort each element with callback.
We will sort using ussort if callback given otherwise
we will sort the original collection using arsort.
@reference https://github.com/laravel/framework/blob/5.4/src/Illuminate/Support/Collection.php
@param callable $callback
@return Collection | [
"Sort",
"each",
"element",
"with",
"callback",
".",
"We",
"will",
"sort",
"using",
"ussort",
"if",
"callback",
"given",
"otherwise",
"we",
"will",
"sort",
"the",
"original",
"collection",
"using",
"arsort",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Collection.php#L381-L387 |
230,867 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_method_createdata.php | Smarty_Internal_Method_CreateData.createData | public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
{
/* @var Smarty $smarty */
$smarty = isset($this->smarty) ? $this->smarty : $obj;
$dataObj = new Smarty_Data($parent, $smarty, $name);
if ($smarty->debugging) {
Smarty_Internal_Debug::register_data($dataObj);
}
return $dataObj;
} | php | public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
{
/* @var Smarty $smarty */
$smarty = isset($this->smarty) ? $this->smarty : $obj;
$dataObj = new Smarty_Data($parent, $smarty, $name);
if ($smarty->debugging) {
Smarty_Internal_Debug::register_data($dataObj);
}
return $dataObj;
} | [
"public",
"function",
"createData",
"(",
"Smarty_Internal_TemplateBase",
"$",
"obj",
",",
"Smarty_Internal_Data",
"$",
"parent",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"/* @var Smarty $smarty */",
"$",
"smarty",
"=",
"isset",
"(",
"$",
"this",
"... | creates a data object
@api Smarty::createData()
@link http://www.smarty.net/docs/en/api.create.data.tpl
@param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
@param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
variables
@param string $name optional data block name
@returns Smarty_Data data object | [
"creates",
"a",
"data",
"object"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_createdata.php#L34-L43 |
230,868 | thrace-project/datagrid-bundle | Controller/DataGridController.php | DataGridController.sortableAction | public function sortableAction ($name)
{
$event = new RowPositionChangeEvent(
$name, $this->getRequest()->get('row_id'),
$this->getRequest()->get('row_position')
);
$this->container->get('event_dispatcher')->dispatch(DataGridEvents::onRowPositionChange, $event);
return new JsonResponse($event->getExtraData());
} | php | public function sortableAction ($name)
{
$event = new RowPositionChangeEvent(
$name, $this->getRequest()->get('row_id'),
$this->getRequest()->get('row_position')
);
$this->container->get('event_dispatcher')->dispatch(DataGridEvents::onRowPositionChange, $event);
return new JsonResponse($event->getExtraData());
} | [
"public",
"function",
"sortableAction",
"(",
"$",
"name",
")",
"{",
"$",
"event",
"=",
"new",
"RowPositionChangeEvent",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'row_id'",
")",
",",
"$",
"this",
"->",
"getReq... | This action dispatch onRowPositionChange
@param string $name
@return \Symfony\Component\HttpFoundation\Response | [
"This",
"action",
"dispatch",
"onRowPositionChange"
] | 07b39d6494336870933756276d6af1ef7039d700 | https://github.com/thrace-project/datagrid-bundle/blob/07b39d6494336870933756276d6af1ef7039d700/Controller/DataGridController.php#L66-L76 |
230,869 | tapestry-cloud/tapestry | src/Modules/Renderers/ContentRendererFactory.php | ContentRendererFactory.renderFile | public function renderFile(File &$file)
{
if ($file->isRendered()) {
return;
}
$fileRenderer = $this->get($file->getExt());
$file->setContent($fileRenderer->render($file));
$file->setExt($fileRenderer->getDestinationExtension($file->getExt()));
$file->setRendered(true);
$fileRenderer->mutateFile($file);
} | php | public function renderFile(File &$file)
{
if ($file->isRendered()) {
return;
}
$fileRenderer = $this->get($file->getExt());
$file->setContent($fileRenderer->render($file));
$file->setExt($fileRenderer->getDestinationExtension($file->getExt()));
$file->setRendered(true);
$fileRenderer->mutateFile($file);
} | [
"public",
"function",
"renderFile",
"(",
"File",
"&",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isRendered",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"fileRenderer",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"file",
"->",
"getExt",
... | Identify which Renderer to be used and then execute it upon the file in question.
@param File $file | [
"Identify",
"which",
"Renderer",
"to",
"be",
"used",
"and",
"then",
"execute",
"it",
"upon",
"the",
"file",
"in",
"question",
"."
] | f3fc980b2484ccbe609a7f811c65b91254e8720e | https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Modules/Renderers/ContentRendererFactory.php#L107-L117 |
230,870 | cygnite/framework | src/Cygnite/Exception/ExceptionHandler.php | ExceptionHandler.run | public function run()
{
$handler = $this;
$this->setCollapsePaths();
//Add new panel to debug bar
$this->addPanel(function ($e) use ($handler) {
if (!is_null($path = $handler->assetsPath())) {
$contents = $handler->includeAssets($path);
}
if (!is_null($e)) {
if ($handler->isLoggerEnabled()) {
$handler->log($e);
}
return [
'tab' => $handler->name,
'panel' => '<h1>
<p class="heading-blue">
<a href="http://www.cygniteframework.com">'.$handler->name.' </a>
</p>
</h1>
<p> Version : '.Application::version().' </p>
<style type="text/css" class="tracy-debug">'.$contents.'</style>',
];
}
});
$this->addPanel(function ($e) {
if (!$e instanceof \PDOException) {
return;
}
if (isset($e->queryString)) {
$sql = $e->queryString;
}
return isset($sql) ? ['tab' => 'SQL', 'panel' => $sql] : null;
});
} | php | public function run()
{
$handler = $this;
$this->setCollapsePaths();
//Add new panel to debug bar
$this->addPanel(function ($e) use ($handler) {
if (!is_null($path = $handler->assetsPath())) {
$contents = $handler->includeAssets($path);
}
if (!is_null($e)) {
if ($handler->isLoggerEnabled()) {
$handler->log($e);
}
return [
'tab' => $handler->name,
'panel' => '<h1>
<p class="heading-blue">
<a href="http://www.cygniteframework.com">'.$handler->name.' </a>
</p>
</h1>
<p> Version : '.Application::version().' </p>
<style type="text/css" class="tracy-debug">'.$contents.'</style>',
];
}
});
$this->addPanel(function ($e) {
if (!$e instanceof \PDOException) {
return;
}
if (isset($e->queryString)) {
$sql = $e->queryString;
}
return isset($sql) ? ['tab' => 'SQL', 'panel' => $sql] : null;
});
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"setCollapsePaths",
"(",
")",
";",
"//Add new panel to debug bar",
"$",
"this",
"->",
"addPanel",
"(",
"function",
"(",
"$",
"e",
")",
"use",
"(",
"$"... | Run the debugger to handle all exception and
display stack trace. | [
"Run",
"the",
"debugger",
"to",
"handle",
"all",
"exception",
"and",
"display",
"stack",
"trace",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Exception/ExceptionHandler.php#L214-L253 |
230,871 | cygnite/framework | src/Cygnite/Exception/ExceptionHandler.php | ExceptionHandler.handleException | public function handleException()
{
/*
| Exception handler registered here. So it will handle all
| exceptions and thrown as pretty format
|-----------------------------------
| Enable pretty exception handler and
| do necessary configuration
|-----------------------------------
*/
$config = Config::get('global.config');
$this->enable($config['logs']['activate'], $config['logs']['path'])
->setTitle()
->setDebugger(Debugger::getBlueScreen())
->setEmailAddress(
$config['logs']['email'],
$config['logs']['error.emailing']
)->run();
} | php | public function handleException()
{
/*
| Exception handler registered here. So it will handle all
| exceptions and thrown as pretty format
|-----------------------------------
| Enable pretty exception handler and
| do necessary configuration
|-----------------------------------
*/
$config = Config::get('global.config');
$this->enable($config['logs']['activate'], $config['logs']['path'])
->setTitle()
->setDebugger(Debugger::getBlueScreen())
->setEmailAddress(
$config['logs']['email'],
$config['logs']['error.emailing']
)->run();
} | [
"public",
"function",
"handleException",
"(",
")",
"{",
"/*\n | Exception handler registered here. So it will handle all\n | exceptions and thrown as pretty format\n |-----------------------------------\n | Enable pretty exception handler and\n | do necessary configura... | Enable and set configuration to Tracy Handler
Event will Trigger this method on runtime when any exception
occurs. | [
"Enable",
"and",
"set",
"configuration",
"to",
"Tracy",
"Handler",
"Event",
"will",
"Trigger",
"this",
"method",
"on",
"runtime",
"when",
"any",
"exception",
"occurs",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Exception/ExceptionHandler.php#L328-L347 |
230,872 | cygnite/framework | src/Cygnite/Exception/ExceptionHandler.php | ExceptionHandler.importCustomErrorPage | public function importCustomErrorPage($e = null)
{
$path = CYGNITE_BASE.DS.toPath(APPPATH.'/Views/errors/');
if ($e == null) {
Debugger::$errorTemplate = include $path.'500.view'.EXT;
}
$statusCode = 500;
if (method_exists($e, 'getStatusCode')) {
$statusCode = $e->getStatusCode();
} else {
if (method_exists($e, 'getCode')) {
$statusCode = $e->getCode();
}
}
if ($statusCode == 0) {
$statusCode = 500;
}
if (file_exists($path.$statusCode.'.view'.EXT)) {
$error = ['error.code' => $statusCode, 'message' => $e->getMessage()];
extract($error);
Debugger::$errorTemplate = include $path.$statusCode.'.view'.EXT;
} else {
throw new \Exception('Error view file not exists '.$path.$e->getStatusCode().'.view'.EXT);
}
} | php | public function importCustomErrorPage($e = null)
{
$path = CYGNITE_BASE.DS.toPath(APPPATH.'/Views/errors/');
if ($e == null) {
Debugger::$errorTemplate = include $path.'500.view'.EXT;
}
$statusCode = 500;
if (method_exists($e, 'getStatusCode')) {
$statusCode = $e->getStatusCode();
} else {
if (method_exists($e, 'getCode')) {
$statusCode = $e->getCode();
}
}
if ($statusCode == 0) {
$statusCode = 500;
}
if (file_exists($path.$statusCode.'.view'.EXT)) {
$error = ['error.code' => $statusCode, 'message' => $e->getMessage()];
extract($error);
Debugger::$errorTemplate = include $path.$statusCode.'.view'.EXT;
} else {
throw new \Exception('Error view file not exists '.$path.$e->getStatusCode().'.view'.EXT);
}
} | [
"public",
"function",
"importCustomErrorPage",
"(",
"$",
"e",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"CYGNITE_BASE",
".",
"DS",
".",
"toPath",
"(",
"APPPATH",
".",
"'/Views/errors/'",
")",
";",
"if",
"(",
"$",
"e",
"==",
"null",
")",
"{",
"Debugger",... | We will display custom error page in production mode.
@param null $e
@throws \Exception | [
"We",
"will",
"display",
"custom",
"error",
"page",
"in",
"production",
"mode",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Exception/ExceptionHandler.php#L365-L392 |
230,873 | cygnite/framework | src/Cygnite/Http/Header.php | Header.get | public function get(string $name, $default = null, $onlyReturnFirst = true)
{
if ($this->has($name)) {
$value = $this->data[$this->normalizeName($name)];
if ($onlyReturnFirst) {
return $value[0];
}
} else {
$value = $default;
}
return $value;
} | php | public function get(string $name, $default = null, $onlyReturnFirst = true)
{
if ($this->has($name)) {
$value = $this->data[$this->normalizeName($name)];
if ($onlyReturnFirst) {
return $value[0];
}
} else {
$value = $default;
}
return $value;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
",",
"$",
"default",
"=",
"null",
",",
"$",
"onlyReturnFirst",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
... | Return only first header values if exists otherwise
return all header information.
@param mixed $name
@param null $default
@param bool $onlyReturnFirst
@return mixed|null | [
"Return",
"only",
"first",
"header",
"values",
"if",
"exists",
"otherwise",
"return",
"all",
"header",
"information",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Header.php#L72-L85 |
230,874 | cygnite/framework | src/Cygnite/Http/Header.php | Header.set | public function set($name, $value, $shouldReplace = true)
{
$name = $this->normalizeName($name);
$value = (array) $value;
if ($shouldReplace || !$this->has($name)) {
parent::add($name, $value);
} else {
parent::add($name, array_merge($this->data[$name], $value));
}
} | php | public function set($name, $value, $shouldReplace = true)
{
$name = $this->normalizeName($name);
$value = (array) $value;
if ($shouldReplace || !$this->has($name)) {
parent::add($name, $value);
} else {
parent::add($name, array_merge($this->data[$name], $value));
}
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"shouldReplace",
"=",
"true",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"normalizeName",
"(",
"$",
"name",
")",
";",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"valu... | Set header information.
@param $name
@param $value
@param bool $shouldReplace | [
"Set",
"header",
"information",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Header.php#L118-L128 |
230,875 | cygnite/framework | src/Cygnite/Http/Header.php | Header.normalizeName | protected function normalizeName($name)
{
$name = strtr(strtolower($name), '_', '-');
if (strpos($name, 'http-') === 0) {
$name = substr($name, 5);
}
return $name;
} | php | protected function normalizeName($name)
{
$name = strtr(strtolower($name), '_', '-');
if (strpos($name, 'http-') === 0) {
$name = substr($name, 5);
}
return $name;
} | [
"protected",
"function",
"normalizeName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtr",
"(",
"strtolower",
"(",
"$",
"name",
")",
",",
"'_'",
",",
"'-'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'http-'",
")",
"===",
"0",
"... | Normalizes a key string.
@param $name
@return string | [
"Normalizes",
"a",
"key",
"string",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Header.php#L137-L146 |
230,876 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_debug.php | Smarty_Internal_Debug.start_template | public function start_template(Smarty_Internal_Template $template, $mode = null)
{
if (isset($mode)) {
$this->index ++;
$this->offset ++;
$this->template_data[$this->index] = null;
}
$key = $this->get_key($template);
$this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
} | php | public function start_template(Smarty_Internal_Template $template, $mode = null)
{
if (isset($mode)) {
$this->index ++;
$this->offset ++;
$this->template_data[$this->index] = null;
}
$key = $this->get_key($template);
$this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
} | [
"public",
"function",
"start_template",
"(",
"Smarty_Internal_Template",
"$",
"template",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"mode",
")",
")",
"{",
"$",
"this",
"->",
"index",
"++",
";",
"$",
"this",
"->",
"offset",
... | Start logging template
@param \Smarty_Internal_Template $template template
@param null $mode true: display false: fetch null: subtemplate | [
"Start",
"logging",
"template"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_debug.php#L53-L62 |
230,877 | ctbsea/phalapi-smarty | src/Smarty/sysplugins/smarty_internal_debug.php | Smarty_Internal_Debug.debugUrl | public function debugUrl(Smarty $smarty)
{
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $smarty->smarty_debug_id)) {
if (false !== strpos($_query_string, $smarty->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$smarty->debugging = true;
} elseif (false !== strpos($_query_string, $smarty->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$smarty->debugging = false;
} else {
// enable debugging for this page
$smarty->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$smarty->debugging = true;
}
}
} | php | public function debugUrl(Smarty $smarty)
{
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $smarty->smarty_debug_id)) {
if (false !== strpos($_query_string, $smarty->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$smarty->debugging = true;
} elseif (false !== strpos($_query_string, $smarty->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$smarty->debugging = false;
} else {
// enable debugging for this page
$smarty->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$smarty->debugging = true;
}
}
} | [
"public",
"function",
"debugUrl",
"(",
"Smarty",
"$",
"smarty",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
")",
")",
"{",
"$",
"_query_string",
"=",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
";",
"}",
"else",
"{",
... | handle 'URL' debugging mode
@param Smarty $smarty | [
"handle",
"URL",
"debugging",
"mode"
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_debug.php#L404-L429 |
230,878 | kaliop-uk/ezworkflowenginebundle | Command/GenerateCommand.php | GenerateCommand.generateWorkflowFile | protected function generateWorkflowFile($path, $fileType, $parameters = array())
{
$warning = '';
// Generate workflow file by template
$template = 'Workflow.' . $fileType . '.twig';
$templatePath = $this->getApplication()->getKernel()->getBundle($this->thisBundle)->getPath() . '/Resources/views/WorkflowTemplate/';
if (!is_file($templatePath . $template)) {
throw new \Exception("Generation of a workflow example is not supported with format '$fileType'");
}
$code = $this->getContainer()->get('twig')->render($this->thisBundle . ':WorkflowTemplate:' . $template, $parameters);
file_put_contents($path, $code);
return $warning;
} | php | protected function generateWorkflowFile($path, $fileType, $parameters = array())
{
$warning = '';
// Generate workflow file by template
$template = 'Workflow.' . $fileType . '.twig';
$templatePath = $this->getApplication()->getKernel()->getBundle($this->thisBundle)->getPath() . '/Resources/views/WorkflowTemplate/';
if (!is_file($templatePath . $template)) {
throw new \Exception("Generation of a workflow example is not supported with format '$fileType'");
}
$code = $this->getContainer()->get('twig')->render($this->thisBundle . ':WorkflowTemplate:' . $template, $parameters);
file_put_contents($path, $code);
return $warning;
} | [
"protected",
"function",
"generateWorkflowFile",
"(",
"$",
"path",
",",
"$",
"fileType",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"warning",
"=",
"''",
";",
"// Generate workflow file by template",
"$",
"template",
"=",
"'Workflow.'",
"."... | Generates a workflow definition file.
@param string $path filename to file to generate (full path)
@param string $fileType The type of workflow file to generate
@param array $parameters
@return string A warning message in case file generation was OK but there was something weird
@throws \Exception | [
"Generates",
"a",
"workflow",
"definition",
"file",
"."
] | 1540eff00b64b6db692ec865c9d25b0179b4b638 | https://github.com/kaliop-uk/ezworkflowenginebundle/blob/1540eff00b64b6db692ec865c9d25b0179b4b638/Command/GenerateCommand.php#L106-L122 |
230,879 | cygnite/framework | src/Cygnite/Cache/Storage/ApcWrapper.php | ApcWrapper.store | public function store($key, $value, $minute = null)
{
if (is_null($key) || $key == '') {
throw new \InvalidArgumentException("Key shouldn't be empty");
}
$time = (is_null($minute)) ? $this->getLifeTime() : $minute * 60;
return ($this->isApcUEnabled) ? apcu_store($key, $value, $time) : apc_store($key, $value, $time);
} | php | public function store($key, $value, $minute = null)
{
if (is_null($key) || $key == '') {
throw new \InvalidArgumentException("Key shouldn't be empty");
}
$time = (is_null($minute)) ? $this->getLifeTime() : $minute * 60;
return ($this->isApcUEnabled) ? apcu_store($key, $value, $time) : apc_store($key, $value, $time);
} | [
"public",
"function",
"store",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"minute",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
"||",
"$",
"key",
"==",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",... | Store the value in the apc memory.
@false string $key
@false mix $value
@param $key
@param $value
@param null $minute
@throws \InvalidArgumentException
@return bool | [
"Store",
"the",
"value",
"in",
"the",
"apc",
"memory",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/ApcWrapper.php#L68-L77 |
230,880 | cygnite/framework | src/Cygnite/Hash/BCrypt.php | BCrypt.create | public function create($string, array $arguments = [])
{
$cost = isset($arguments['cost']) ? $arguments['cost'] : $this->cost;
if (isset($arguments['salt'])) {
$hash = password_hash($string, PASSWORD_BCRYPT, ['cost' => $cost, 'salt' => $arguments['salt']]);
} else {
$hash = password_hash($string, PASSWORD_BCRYPT, ['cost' => $cost]);
}
if ($hash === false) {
throw new \RuntimeException('BCrypt hashing support not available.');
}
return $hash;
} | php | public function create($string, array $arguments = [])
{
$cost = isset($arguments['cost']) ? $arguments['cost'] : $this->cost;
if (isset($arguments['salt'])) {
$hash = password_hash($string, PASSWORD_BCRYPT, ['cost' => $cost, 'salt' => $arguments['salt']]);
} else {
$hash = password_hash($string, PASSWORD_BCRYPT, ['cost' => $cost]);
}
if ($hash === false) {
throw new \RuntimeException('BCrypt hashing support not available.');
}
return $hash;
} | [
"public",
"function",
"create",
"(",
"$",
"string",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"cost",
"=",
"isset",
"(",
"$",
"arguments",
"[",
"'cost'",
"]",
")",
"?",
"$",
"arguments",
"[",
"'cost'",
"]",
":",
"$",
"this",
"... | We will creating hash for the given string and return it.
@param string $string
@param array $arguments
@throws \RuntimeException
@return string | [
"We",
"will",
"creating",
"hash",
"for",
"the",
"given",
"string",
"and",
"return",
"it",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Hash/BCrypt.php#L55-L70 |
230,881 | cygnite/framework | src/Cygnite/Hash/BCrypt.php | BCrypt.needReHash | public function needReHash($hashedString, array $arguments = [])
{
$cost = isset($arguments['cost']) ? $arguments['cost'] : $this->cost;
return password_needs_rehash($hashedString, PASSWORD_BCRYPT, ['cost' => $cost]);
} | php | public function needReHash($hashedString, array $arguments = [])
{
$cost = isset($arguments['cost']) ? $arguments['cost'] : $this->cost;
return password_needs_rehash($hashedString, PASSWORD_BCRYPT, ['cost' => $cost]);
} | [
"public",
"function",
"needReHash",
"(",
"$",
"hashedString",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"cost",
"=",
"isset",
"(",
"$",
"arguments",
"[",
"'cost'",
"]",
")",
"?",
"$",
"arguments",
"[",
"'cost'",
"]",
":",
"$",
"... | We will check if given hashed string has been
hashed using the given options.
@param string $hashedString
@param array $arguments
@return bool | [
"We",
"will",
"check",
"if",
"given",
"hashed",
"string",
"has",
"been",
"hashed",
"using",
"the",
"given",
"options",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Hash/BCrypt.php#L95-L100 |
230,882 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.generateFormElements | private function generateFormElements($value)
{
$form = $label = '';
$label = Inflector::underscoreToSpace($value['COLUMN_NAME']);
$form .= "\t\t".'->addElement("label", "'.$label.'", ["class" => "col-sm-2 control-label","style" => "width:100%;"])'.PHP_EOL;
$form .= "\t\t".'->addElement("text", "'.$value['COLUMN_NAME'].'", ["value" => (isset($this->model->'.$value['COLUMN_NAME'].')) ? $this->model->'.$value['COLUMN_NAME'].' : "", "class" => "form-control"])'.PHP_EOL;
return $form;
} | php | private function generateFormElements($value)
{
$form = $label = '';
$label = Inflector::underscoreToSpace($value['COLUMN_NAME']);
$form .= "\t\t".'->addElement("label", "'.$label.'", ["class" => "col-sm-2 control-label","style" => "width:100%;"])'.PHP_EOL;
$form .= "\t\t".'->addElement("text", "'.$value['COLUMN_NAME'].'", ["value" => (isset($this->model->'.$value['COLUMN_NAME'].')) ? $this->model->'.$value['COLUMN_NAME'].' : "", "class" => "form-control"])'.PHP_EOL;
return $form;
} | [
"private",
"function",
"generateFormElements",
"(",
"$",
"value",
")",
"{",
"$",
"form",
"=",
"$",
"label",
"=",
"''",
";",
"$",
"label",
"=",
"Inflector",
"::",
"underscoreToSpace",
"(",
"$",
"value",
"[",
"'COLUMN_NAME'",
"]",
")",
";",
"$",
"form",
... | Generate Form Elements.
@param $value
@return string | [
"Generate",
"Form",
"Elements",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L130-L139 |
230,883 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.generateDbCode | private function generateDbCode($value)
{
$code = '';
$code .=
"\t\t\t\t".'$'.Inflector::tabilize($this->model).'->'.$value['COLUMN_NAME'].' = $postArray["'.$value['COLUMN_NAME'].'"];'.PHP_EOL;
return $code;
} | php | private function generateDbCode($value)
{
$code = '';
$code .=
"\t\t\t\t".'$'.Inflector::tabilize($this->model).'->'.$value['COLUMN_NAME'].' = $postArray["'.$value['COLUMN_NAME'].'"];'.PHP_EOL;
return $code;
} | [
"private",
"function",
"generateDbCode",
"(",
"$",
"value",
")",
"{",
"$",
"code",
"=",
"''",
";",
"$",
"code",
".=",
"\"\\t\\t\\t\\t\"",
".",
"'$'",
".",
"Inflector",
"::",
"tabilize",
"(",
"$",
"this",
"->",
"model",
")",
".",
"'->'",
".",
"$",
"va... | Generate database code.
@param $value
@return string | [
"Generate",
"database",
"code",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L164-L171 |
230,884 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.updateTemplate | public function updateTemplate()
{
$codeDb = $validationCode = $form = '';
$form = $this->buildFormOpen();
foreach ($this->columns as $key => $value) {
if ($value['COLUMN_NAME'] !== 'id') {
if ($this->isFormGenerator == false) {
$codeDb .= $this->generateDbCode($value);
}
$form .= $this->generateFormElements($value);
}
}
$form .= $this->buildFormCloseTags();
$this->setForm($form);
$this->setDbCode($codeDb);
} | php | public function updateTemplate()
{
$codeDb = $validationCode = $form = '';
$form = $this->buildFormOpen();
foreach ($this->columns as $key => $value) {
if ($value['COLUMN_NAME'] !== 'id') {
if ($this->isFormGenerator == false) {
$codeDb .= $this->generateDbCode($value);
}
$form .= $this->generateFormElements($value);
}
}
$form .= $this->buildFormCloseTags();
$this->setForm($form);
$this->setDbCode($codeDb);
} | [
"public",
"function",
"updateTemplate",
"(",
")",
"{",
"$",
"codeDb",
"=",
"$",
"validationCode",
"=",
"$",
"form",
"=",
"''",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"buildFormOpen",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as... | Update the template code. | [
"Update",
"the",
"template",
"code",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L176-L196 |
230,885 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.replaceControllerName | private function replaceControllerName($content)
{
$content = str_replace('{%ControllerClassName%}', $this->controller, $content);
$content = str_replace('%ControllerName%', $this->controller, $content);
$content = str_replace('%controllerName%', Inflector::deCamelize($this->controller), $content);
return $content;
} | php | private function replaceControllerName($content)
{
$content = str_replace('{%ControllerClassName%}', $this->controller, $content);
$content = str_replace('%ControllerName%', $this->controller, $content);
$content = str_replace('%controllerName%', Inflector::deCamelize($this->controller), $content);
return $content;
} | [
"private",
"function",
"replaceControllerName",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"str_replace",
"(",
"'{%ControllerClassName%}'",
",",
"$",
"this",
"->",
"controller",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"str_replace",
"(",
... | Replace the controller name with original name.
@param $content
@return mixed | [
"Replace",
"the",
"controller",
"name",
"with",
"original",
"name",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L234-L241 |
230,886 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.replaceModelName | private function replaceModelName($content)
{
$newContent = '';
$content = str_replace('new %modelName%', 'new '.$this->model, $content);
$content = str_replace('%StaticModelName%', $this->model, $content);
$content = str_replace('new %StaticModelName%()', $this->model, $content);
$newContent = str_replace('%modelName%', Inflector::tabilize($this->model), $content);
return $newContent;
} | php | private function replaceModelName($content)
{
$newContent = '';
$content = str_replace('new %modelName%', 'new '.$this->model, $content);
$content = str_replace('%StaticModelName%', $this->model, $content);
$content = str_replace('new %StaticModelName%()', $this->model, $content);
$newContent = str_replace('%modelName%', Inflector::tabilize($this->model), $content);
return $newContent;
} | [
"private",
"function",
"replaceModelName",
"(",
"$",
"content",
")",
"{",
"$",
"newContent",
"=",
"''",
";",
"$",
"content",
"=",
"str_replace",
"(",
"'new %modelName%'",
",",
"'new '",
".",
"$",
"this",
"->",
"model",
",",
"$",
"content",
")",
";",
"$",... | Replace the model name with original model name.
@param $content
@return mixed | [
"Replace",
"the",
"model",
"name",
"with",
"original",
"model",
"name",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L250-L259 |
230,887 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.generateControllerTemplate | public function generateControllerTemplate()
{
$controllerTemplate = ($this->viewType == 'php') ?
'Php'.DS.'Controller'.EXT :
$this->controllerTemplateName();
$file = $this->getControllerTemplatePath().$controllerTemplate;
$this->formPath = str_replace('Controllers\\', '', $this->getControllerTemplatePath()).DS.'Form'.DS;
file_exists($file) or die('Controller Template not Exists');
//file_exists($modelFl ) or die("No Model Exists");
/*read operation ->*/
$this->filePointer = fopen($file, 'r');
$content = fread($this->filePointer, filesize($file));
//fclose($tmp);
$content = $this->replaceControllerName($content);
$content = str_replace('{%Apps%}', APP_NS, $content);
$primaryKey = $this->controllerCommand->table()->getPrimaryKey();
$content = str_replace('{%primaryKey%}', $primaryKey, $content);
$content = str_replace('%modelColumns%', $this->getDbCode().PHP_EOL, $content);
$content = str_replace('%ControllerName%Form', $this->controller.'Form', $content);
$formTemplatePath = null;
$formTemplatePath = str_replace('Controllers', '', $this->formPath);
if (file_exists($formTemplatePath.'Form'.EXT)) {
//We will generate Form Component
$formContent = file_get_contents($formTemplatePath.'Form'.EXT, true);
} else {
die("Form template doesn't exists in ".$formTemplatePath.'Form'.EXT.' directory.');
}
$formContent = str_replace('%controllerName%', $this->controller, $formContent);
$formContent = str_replace('{%formElements%}', $this->getForm().PHP_EOL, $formContent);
$this->generateFormComponent($formContent);
$newContent = $this->replaceModelName($content);
$content = null;
$this->replacedContent = $newContent;
} | php | public function generateControllerTemplate()
{
$controllerTemplate = ($this->viewType == 'php') ?
'Php'.DS.'Controller'.EXT :
$this->controllerTemplateName();
$file = $this->getControllerTemplatePath().$controllerTemplate;
$this->formPath = str_replace('Controllers\\', '', $this->getControllerTemplatePath()).DS.'Form'.DS;
file_exists($file) or die('Controller Template not Exists');
//file_exists($modelFl ) or die("No Model Exists");
/*read operation ->*/
$this->filePointer = fopen($file, 'r');
$content = fread($this->filePointer, filesize($file));
//fclose($tmp);
$content = $this->replaceControllerName($content);
$content = str_replace('{%Apps%}', APP_NS, $content);
$primaryKey = $this->controllerCommand->table()->getPrimaryKey();
$content = str_replace('{%primaryKey%}', $primaryKey, $content);
$content = str_replace('%modelColumns%', $this->getDbCode().PHP_EOL, $content);
$content = str_replace('%ControllerName%Form', $this->controller.'Form', $content);
$formTemplatePath = null;
$formTemplatePath = str_replace('Controllers', '', $this->formPath);
if (file_exists($formTemplatePath.'Form'.EXT)) {
//We will generate Form Component
$formContent = file_get_contents($formTemplatePath.'Form'.EXT, true);
} else {
die("Form template doesn't exists in ".$formTemplatePath.'Form'.EXT.' directory.');
}
$formContent = str_replace('%controllerName%', $this->controller, $formContent);
$formContent = str_replace('{%formElements%}', $this->getForm().PHP_EOL, $formContent);
$this->generateFormComponent($formContent);
$newContent = $this->replaceModelName($content);
$content = null;
$this->replacedContent = $newContent;
} | [
"public",
"function",
"generateControllerTemplate",
"(",
")",
"{",
"$",
"controllerTemplate",
"=",
"(",
"$",
"this",
"->",
"viewType",
"==",
"'php'",
")",
"?",
"'Php'",
".",
"DS",
".",
"'Controller'",
".",
"EXT",
":",
"$",
"this",
"->",
"controllerTemplateNa... | Generate Controller template with original content. | [
"Generate",
"Controller",
"template",
"with",
"original",
"content",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L269-L313 |
230,888 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.generateFormComponent | public function generateFormComponent($formContent)
{
/*write operation ->*/
$writeTmp = fopen($this->applicationDir.DS.'Form'.DS.$this->controller.'Form'.EXT, 'w')
or die('Unable to generate controller');
$contentAppendWith = '';
$contentAppendWith = '<?php '.PHP_EOL;
$formContent = str_replace('{%Apps%}', APP_NS, $formContent);
fwrite($writeTmp, $contentAppendWith.$formContent);
fclose($writeTmp);
return true;
} | php | public function generateFormComponent($formContent)
{
/*write operation ->*/
$writeTmp = fopen($this->applicationDir.DS.'Form'.DS.$this->controller.'Form'.EXT, 'w')
or die('Unable to generate controller');
$contentAppendWith = '';
$contentAppendWith = '<?php '.PHP_EOL;
$formContent = str_replace('{%Apps%}', APP_NS, $formContent);
fwrite($writeTmp, $contentAppendWith.$formContent);
fclose($writeTmp);
return true;
} | [
"public",
"function",
"generateFormComponent",
"(",
"$",
"formContent",
")",
"{",
"/*write operation ->*/",
"$",
"writeTmp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"applicationDir",
".",
"DS",
".",
"'Form'",
".",
"DS",
".",
"$",
"this",
"->",
"controller",
".... | Generate form component.
@param $formContent
@return bool | [
"Generate",
"form",
"component",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L322-L335 |
230,889 | cygnite/framework | src/Cygnite/Console/Generator/Controller.php | Controller.generate | public function generate()
{
/*write operation ->*/
$writeTmp = fopen(
$this->applicationDir.DS.'Controllers'.DS.$this->controller.'Controller'.EXT,
'w'
) or die('Unable to generate controller');
$contentAppendWith = '<?php '.PHP_EOL;
fwrite($writeTmp, $contentAppendWith.$this->replacedContent);
fclose($writeTmp);
fclose($this->filePointer);
} | php | public function generate()
{
/*write operation ->*/
$writeTmp = fopen(
$this->applicationDir.DS.'Controllers'.DS.$this->controller.'Controller'.EXT,
'w'
) or die('Unable to generate controller');
$contentAppendWith = '<?php '.PHP_EOL;
fwrite($writeTmp, $contentAppendWith.$this->replacedContent);
fclose($writeTmp);
fclose($this->filePointer);
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"/*write operation ->*/",
"$",
"writeTmp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"applicationDir",
".",
"DS",
".",
"'Controllers'",
".",
"DS",
".",
"$",
"this",
"->",
"controller",
".",
"'Controller'",
".",
... | Generate the controller with updated template. | [
"Generate",
"the",
"controller",
"with",
"updated",
"template",
"."
] | 58d0cc1c946415eb0867d76218bd35166e999093 | https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Controller.php#L350-L363 |
230,890 | franzliedke/lti | src/User.php | User.delete | public function delete()
{
return
is_null($this->resourceLink) ||
$this->resourceLink->getConsumer()->getStorage()->User_delete($this);
} | php | public function delete()
{
return
is_null($this->resourceLink) ||
$this->resourceLink->getConsumer()->getStorage()->User_delete($this);
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"return",
"is_null",
"(",
"$",
"this",
"->",
"resourceLink",
")",
"||",
"$",
"this",
"->",
"resourceLink",
"->",
"getConsumer",
"(",
")",
"->",
"getStorage",
"(",
")",
"->",
"User_delete",
"(",
"$",
"this",
... | Delete the user from the database.
@return boolean True if the user object was successfully deleted | [
"Delete",
"the",
"user",
"from",
"the",
"database",
"."
] | 131cf331f2cb87fcc29049ac739c8751e9e5133b | https://github.com/franzliedke/lti/blob/131cf331f2cb87fcc29049ac739c8751e9e5133b/src/User.php#L155-L160 |
230,891 | franzliedke/lti | src/User.php | User.setEmail | public function setEmail($email, $defaultEmail = null)
{
if (!empty($email)) {
$this->email = $email;
} else if (!empty($defaultEmail)) {
$this->email = $defaultEmail;
if (substr($this->email, 0, 1) == '@') {
$this->email = $this->getId() . $this->email;
}
} else {
$this->email = '';
}
} | php | public function setEmail($email, $defaultEmail = null)
{
if (!empty($email)) {
$this->email = $email;
} else if (!empty($defaultEmail)) {
$this->email = $defaultEmail;
if (substr($this->email, 0, 1) == '@') {
$this->email = $this->getId() . $this->email;
}
} else {
$this->email = '';
}
} | [
"public",
"function",
"setEmail",
"(",
"$",
"email",
",",
"$",
"defaultEmail",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"email",
")",
")",
"{",
"$",
"this",
"->",
"email",
"=",
"$",
"email",
";",
"}",
"else",
"if",
"(",
"!",
"e... | Set the user's email address.
@param string $email Email address value
@param string $defaultEmail Value to use if no email is provided (optional, default is none) | [
"Set",
"the",
"user",
"s",
"email",
"address",
"."
] | 131cf331f2cb87fcc29049ac739c8751e9e5133b | https://github.com/franzliedke/lti/blob/131cf331f2cb87fcc29049ac739c8751e9e5133b/src/User.php#L255-L267 |
230,892 | franzliedke/lti | src/ToolConsumer.php | ToolConsumer.isAvailable | public function isAvailable()
{
$ok = $this->enabled;
$now = time();
if ($ok && !is_null($this->enableFrom)) {
$ok = $this->enableFrom <= $now;
}
if ($ok && !is_null($this->enableUntil)) {
$ok = $this->enableUntil > $now;
}
return $ok;
} | php | public function isAvailable()
{
$ok = $this->enabled;
$now = time();
if ($ok && !is_null($this->enableFrom)) {
$ok = $this->enableFrom <= $now;
}
if ($ok && !is_null($this->enableUntil)) {
$ok = $this->enableUntil > $now;
}
return $ok;
} | [
"public",
"function",
"isAvailable",
"(",
")",
"{",
"$",
"ok",
"=",
"$",
"this",
"->",
"enabled",
";",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"ok",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"enableFrom",
")",
")",
"{",
"$",... | Is the consumer key available to accept launch requests?
@return boolean True if the consumer key is enabled and within any date constraints | [
"Is",
"the",
"consumer",
"key",
"available",
"to",
"accept",
"launch",
"requests?"
] | 131cf331f2cb87fcc29049ac739c8751e9e5133b | https://github.com/franzliedke/lti/blob/131cf331f2cb87fcc29049ac739c8751e9e5133b/src/ToolConsumer.php#L231-L244 |
230,893 | ARCANEDEV/GeoIP | src/Drivers/MaxmindDatabaseDriver.php | MaxmindDatabaseDriver.checkDatabaseFile | private function checkDatabaseFile()
{
if ($this->isDatabaseExists()) return;
$pathinfo = pathinfo($path = $this->getDatabasePath());
if ( ! file_exists($pathinfo['dirname'])) {
mkdir($pathinfo['dirname'], 0777, true);
}
copy(realpath(__DIR__ . '/../../data/geoip.mmdb'), $path);
} | php | private function checkDatabaseFile()
{
if ($this->isDatabaseExists()) return;
$pathinfo = pathinfo($path = $this->getDatabasePath());
if ( ! file_exists($pathinfo['dirname'])) {
mkdir($pathinfo['dirname'], 0777, true);
}
copy(realpath(__DIR__ . '/../../data/geoip.mmdb'), $path);
} | [
"private",
"function",
"checkDatabaseFile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDatabaseExists",
"(",
")",
")",
"return",
";",
"$",
"pathinfo",
"=",
"pathinfo",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"getDatabasePath",
"(",
")",
")",
";"... | Check if database file exists, otherwise copy the dummy one. | [
"Check",
"if",
"database",
"file",
"exists",
"otherwise",
"copy",
"the",
"dummy",
"one",
"."
] | 2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318 | https://github.com/ARCANEDEV/GeoIP/blob/2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318/src/Drivers/MaxmindDatabaseDriver.php#L128-L139 |
230,894 | ARCANEDEV/GeoIP | src/Tasks/DownloadMaxmindDatabaseTask.php | DownloadMaxmindDatabaseTask.checkUrl | private static function checkUrl($url)
{
$headers = get_headers($url);
if ( ! Str::contains($headers[0], '200 OK')) {
throw new Exception('Unable to download Maxmind\'s database. ('.substr($headers[0], 13).')');
}
} | php | private static function checkUrl($url)
{
$headers = get_headers($url);
if ( ! Str::contains($headers[0], '200 OK')) {
throw new Exception('Unable to download Maxmind\'s database. ('.substr($headers[0], 13).')');
}
} | [
"private",
"static",
"function",
"checkUrl",
"(",
"$",
"url",
")",
"{",
"$",
"headers",
"=",
"get_headers",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"Str",
"::",
"contains",
"(",
"$",
"headers",
"[",
"0",
"]",
",",
"'200 OK'",
")",
")",
"{",
"t... | Check the url status.
@param string $url
@throws \Exception | [
"Check",
"the",
"url",
"status",
"."
] | 2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318 | https://github.com/ARCANEDEV/GeoIP/blob/2b7b5590cbbbb99e9d1a3a2c85ce9e39dd39b318/src/Tasks/DownloadMaxmindDatabaseTask.php#L68-L75 |
230,895 | pedro-teixeira/grid-bundle | Grid/GridAbstract.php | GridAbstract.render | public function render()
{
if ($this->isAjax()) {
if ($this->isExport()) {
if (!$this->getExportable()) {
throw new \Exception('Export not allowed');
}
$data = $this->processExport();
} else {
$data = $this->processGrid();
}
$json = json_encode($data);
$response = new Response();
$response->headers->set('Content-Type', 'application/json');
$response->setContent($json);
return $response;
} else {
if ($this->isExport()) {
if (!$this->getExportable()) {
throw new \Exception('Export not allowed');
}
$exportFile = $this->getExportFileName();
$response = new Response();
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($exportFile) . '"');
$response->setContent(file_get_contents($exportFile));
return $response;
} else {
return new GridView($this, $this->container);
}
}
} | php | public function render()
{
if ($this->isAjax()) {
if ($this->isExport()) {
if (!$this->getExportable()) {
throw new \Exception('Export not allowed');
}
$data = $this->processExport();
} else {
$data = $this->processGrid();
}
$json = json_encode($data);
$response = new Response();
$response->headers->set('Content-Type', 'application/json');
$response->setContent($json);
return $response;
} else {
if ($this->isExport()) {
if (!$this->getExportable()) {
throw new \Exception('Export not allowed');
}
$exportFile = $this->getExportFileName();
$response = new Response();
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($exportFile) . '"');
$response->setContent(file_get_contents($exportFile));
return $response;
} else {
return new GridView($this, $this->container);
}
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAjax",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExport",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getExportable",
"(",
")",
")",
"{",
"... | Returns the an array with a GridView instance for normal requests and json for AJAX requests
@throws \Exception
@return GridView | \Symfony\Component\HttpFoundation\Response | [
"Returns",
"the",
"an",
"array",
"with",
"a",
"GridView",
"instance",
"for",
"normal",
"requests",
"and",
"json",
"for",
"AJAX",
"requests"
] | 9b81736133061e70364365e4f3fe5cd95b3070cb | https://github.com/pedro-teixeira/grid-bundle/blob/9b81736133061e70364365e4f3fe5cd95b3070cb/Grid/GridAbstract.php#L470-L510 |
230,896 | ctbsea/phalapi-smarty | src/Smarty/Autoloader.php | Smarty_Autoloader.registerBC | public static function registerBC($prepend = false)
{
/**
* register the class autoloader
*/
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
if (SMARTY_SPL_AUTOLOAD &&
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
spl_autoload_register();
}
} else {
self::register($prepend);
}
} | php | public static function registerBC($prepend = false)
{
/**
* register the class autoloader
*/
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
if (SMARTY_SPL_AUTOLOAD &&
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
spl_autoload_register();
}
} else {
self::register($prepend);
}
} | [
"public",
"static",
"function",
"registerBC",
"(",
"$",
"prepend",
"=",
"false",
")",
"{",
"/**\n * register the class autoloader\n */",
"if",
"(",
"!",
"defined",
"(",
"'SMARTY_SPL_AUTOLOAD'",
")",
")",
"{",
"define",
"(",
"'SMARTY_SPL_AUTOLOAD'",
","... | Registers Smarty_Autoloader backward compatible to older installations.
@param bool $prepend Whether to prepend the autoloader or not. | [
"Registers",
"Smarty_Autoloader",
"backward",
"compatible",
"to",
"older",
"installations",
"."
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/Autoloader.php#L48-L66 |
230,897 | ctbsea/phalapi-smarty | src/Smarty/Autoloader.php | Smarty_Autoloader.register | public static function register($prepend = false)
{
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
if (version_compare(phpversion(), '5.3.0', '>=')) {
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
} else {
spl_autoload_register(array(__CLASS__, 'autoload'));
}
} | php | public static function register($prepend = false)
{
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
if (version_compare(phpversion(), '5.3.0', '>=')) {
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
} else {
spl_autoload_register(array(__CLASS__, 'autoload'));
}
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"prepend",
"=",
"false",
")",
"{",
"self",
"::",
"$",
"SMARTY_DIR",
"=",
"defined",
"(",
"'SMARTY_DIR'",
")",
"?",
"SMARTY_DIR",
":",
"dirname",
"(",
"__FILE__",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"s... | Registers Smarty_Autoloader as an SPL autoloader.
@param bool $prepend Whether to prepend the autoloader or not. | [
"Registers",
"Smarty_Autoloader",
"as",
"an",
"SPL",
"autoloader",
"."
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/Autoloader.php#L73-L83 |
230,898 | ctbsea/phalapi-smarty | src/Smarty/Autoloader.php | Smarty_Autoloader.autoload | public static function autoload($class)
{
$_class = strtolower($class);
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
if (strpos($_class, 'smarty_internal_') === 0) {
if (strpos($_class, 'smarty_internal_compile_') === 0) {
if (is_file($file)) {
require $file;
}
return;
}
@include $file;
return;
}
if (preg_match('/^(smarty_(((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/',
$_class, $match)) {
if (!empty($match[3])) {
@include $file;
return;
} elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) {
$file = self::$rootClasses[$_class];
require $file;
return;
}
}
if (0 !== strpos($_class, 'smarty')) {
return;
}
if (is_file($file)) {
require $file;
return;
}
return;
} | php | public static function autoload($class)
{
$_class = strtolower($class);
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
if (strpos($_class, 'smarty_internal_') === 0) {
if (strpos($_class, 'smarty_internal_compile_') === 0) {
if (is_file($file)) {
require $file;
}
return;
}
@include $file;
return;
}
if (preg_match('/^(smarty_(((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/',
$_class, $match)) {
if (!empty($match[3])) {
@include $file;
return;
} elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) {
$file = self::$rootClasses[$_class];
require $file;
return;
}
}
if (0 !== strpos($_class, 'smarty')) {
return;
}
if (is_file($file)) {
require $file;
return;
}
return;
} | [
"public",
"static",
"function",
"autoload",
"(",
"$",
"class",
")",
"{",
"$",
"_class",
"=",
"strtolower",
"(",
"$",
"class",
")",
";",
"$",
"file",
"=",
"self",
"::",
"$",
"SMARTY_SYSPLUGINS_DIR",
".",
"$",
"_class",
".",
"'.php'",
";",
"if",
"(",
"... | Handles auto loading of classes.
@param string $class A class name. | [
"Handles",
"auto",
"loading",
"of",
"classes",
"."
] | 4d40da3e4482c0749f3cfd1605265a109a1c495f | https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/Autoloader.php#L90-L123 |
230,899 | DevGroup-ru/yii2-jstree-widget | src/actions/nestedset/NodeMoveAction.php | NodeMoveAction.getLr | protected function getLr($ids)
{
$class = $this->className;
return $class::find()
->select(['id', $this->leftAttribute, $this->rightAttribute])
->where(['id' => $ids])
->indexBy('id')
->asArray(true)
->all();
} | php | protected function getLr($ids)
{
$class = $this->className;
return $class::find()
->select(['id', $this->leftAttribute, $this->rightAttribute])
->where(['id' => $ids])
->indexBy('id')
->asArray(true)
->all();
} | [
"protected",
"function",
"getLr",
"(",
"$",
"ids",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"className",
";",
"return",
"$",
"class",
"::",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'id'",
",",
"$",
"this",
"->",
"leftAttribute",
",",
"$"... | Returns field set of rows to be modified while reordering
@param array $ids
@return array|\yii\db\ActiveRecord[] | [
"Returns",
"field",
"set",
"of",
"rows",
"to",
"be",
"modified",
"while",
"reordering"
] | 6ae0311254eb757a13fc5c318d6a15544d84b105 | https://github.com/DevGroup-ru/yii2-jstree-widget/blob/6ae0311254eb757a13fc5c318d6a15544d84b105/src/actions/nestedset/NodeMoveAction.php#L479-L488 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.