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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
10,500 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.presenter | public function presenter($view, $method = 'view', $auto_filter = null)
{
return \Presenter::forge($view, $method, $auto_filter, $this->find_file($view));
} | php | public function presenter($view, $method = 'view', $auto_filter = null)
{
return \Presenter::forge($view, $method, $auto_filter, $this->find_file($view));
} | [
"public",
"function",
"presenter",
"(",
"$",
"view",
",",
"$",
"method",
"=",
"'view'",
",",
"$",
"auto_filter",
"=",
"null",
")",
"{",
"return",
"\\",
"Presenter",
"::",
"forge",
"(",
"$",
"view",
",",
"$",
"method",
",",
"$",
"auto_filter",
",",
"$",
"this",
"->",
"find_file",
"(",
"$",
"view",
")",
")",
";",
"}"
] | Loads a presenter, and have it use the view from the currently active theme,
the fallback theme, or the standard FuelPHP cascading file system
@param string Presenter classname without Presenter_ prefix or full classname
@param string Method to execute
@param bool $auto_filter Auto filter the view data
@return View New View object | [
"Loads",
"a",
"presenter",
"and",
"have",
"it",
"use",
"the",
"view",
"from",
"the",
"currently",
"active",
"theme",
"the",
"fallback",
"theme",
"or",
"the",
"standard",
"FuelPHP",
"cascading",
"file",
"system"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L239-L242 |
10,501 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.asset_path | public function asset_path($path)
{
if ($this->active['path'] === null)
{
throw new \ThemeException('You must set an active theme.');
}
if ($this->active['asset_base'])
{
return $this->active['asset_base'].$path;
}
else
{
return $this->active['path'].$path;
}
} | php | public function asset_path($path)
{
if ($this->active['path'] === null)
{
throw new \ThemeException('You must set an active theme.');
}
if ($this->active['asset_base'])
{
return $this->active['asset_base'].$path;
}
else
{
return $this->active['path'].$path;
}
} | [
"public",
"function",
"asset_path",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"active",
"[",
"'path'",
"]",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"ThemeException",
"(",
"'You must set an active theme.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"active",
"[",
"'asset_base'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"active",
"[",
"'asset_base'",
"]",
".",
"$",
"path",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"active",
"[",
"'path'",
"]",
".",
"$",
"path",
";",
"}",
"}"
] | Loads an asset from the currently loaded theme.
@param string $path Relative path to the asset
@return string Full asset URL or path if outside docroot | [
"Loads",
"an",
"asset",
"from",
"the",
"currently",
"loaded",
"theme",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L250-L265 |
10,502 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.set_template | public function set_template($template)
{
// make sure the template is a View
if (is_string($template))
{
$this->template = $this->view($template);
}
else
{
$this->template = $template;
}
// return the template view for chaining
return $this->template;
} | php | public function set_template($template)
{
// make sure the template is a View
if (is_string($template))
{
$this->template = $this->view($template);
}
else
{
$this->template = $template;
}
// return the template view for chaining
return $this->template;
} | [
"public",
"function",
"set_template",
"(",
"$",
"template",
")",
"{",
"// make sure the template is a View",
"if",
"(",
"is_string",
"(",
"$",
"template",
")",
")",
"{",
"$",
"this",
"->",
"template",
"=",
"$",
"this",
"->",
"view",
"(",
"$",
"template",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"template",
"=",
"$",
"template",
";",
"}",
"// return the template view for chaining",
"return",
"$",
"this",
"->",
"template",
";",
"}"
] | Sets a template for a theme
@param string $template Name of the template view
@return View | [
"Sets",
"a",
"template",
"for",
"a",
"theme"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L273-L287 |
10,503 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.render | public function render()
{
// make sure the template to be rendered is defined
if (empty($this->template))
{
throw new \ThemeException('No valid template could be found. Use set_template() to define a page template.');
}
// storage for rendered results
$rendered = array();
// pre-process all defined partials
foreach ($this->partials as $key => $partials)
{
$output = '';
foreach ($partials as $index => $partial)
{
// render the partial
$output .= $partial->render();
}
// store the rendered output
if ( ! empty($output) and array_key_exists($key, $this->chrome))
{
// encapsulate the partial in the chrome template
$rendered[$key] = $this->chrome[$key]['view']->set($this->chrome[$key]['var'], $output, false);
}
else
{
// store the partial output
$rendered[$key] = $output;
}
}
// assign the partials to the template
$this->template->set('partials', $rendered, false);
// return the template
return $this->template;
} | php | public function render()
{
// make sure the template to be rendered is defined
if (empty($this->template))
{
throw new \ThemeException('No valid template could be found. Use set_template() to define a page template.');
}
// storage for rendered results
$rendered = array();
// pre-process all defined partials
foreach ($this->partials as $key => $partials)
{
$output = '';
foreach ($partials as $index => $partial)
{
// render the partial
$output .= $partial->render();
}
// store the rendered output
if ( ! empty($output) and array_key_exists($key, $this->chrome))
{
// encapsulate the partial in the chrome template
$rendered[$key] = $this->chrome[$key]['view']->set($this->chrome[$key]['var'], $output, false);
}
else
{
// store the partial output
$rendered[$key] = $output;
}
}
// assign the partials to the template
$this->template->set('partials', $rendered, false);
// return the template
return $this->template;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// make sure the template to be rendered is defined",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"template",
")",
")",
"{",
"throw",
"new",
"\\",
"ThemeException",
"(",
"'No valid template could be found. Use set_template() to define a page template.'",
")",
";",
"}",
"// storage for rendered results",
"$",
"rendered",
"=",
"array",
"(",
")",
";",
"// pre-process all defined partials",
"foreach",
"(",
"$",
"this",
"->",
"partials",
"as",
"$",
"key",
"=>",
"$",
"partials",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"partials",
"as",
"$",
"index",
"=>",
"$",
"partial",
")",
"{",
"// render the partial",
"$",
"output",
".=",
"$",
"partial",
"->",
"render",
"(",
")",
";",
"}",
"// store the rendered output",
"if",
"(",
"!",
"empty",
"(",
"$",
"output",
")",
"and",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"chrome",
")",
")",
"{",
"// encapsulate the partial in the chrome template",
"$",
"rendered",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"chrome",
"[",
"$",
"key",
"]",
"[",
"'view'",
"]",
"->",
"set",
"(",
"$",
"this",
"->",
"chrome",
"[",
"$",
"key",
"]",
"[",
"'var'",
"]",
",",
"$",
"output",
",",
"false",
")",
";",
"}",
"else",
"{",
"// store the partial output",
"$",
"rendered",
"[",
"$",
"key",
"]",
"=",
"$",
"output",
";",
"}",
"}",
"// assign the partials to the template",
"$",
"this",
"->",
"template",
"->",
"set",
"(",
"'partials'",
",",
"$",
"rendered",
",",
"false",
")",
";",
"// return the template",
"return",
"$",
"this",
"->",
"template",
";",
"}"
] | Render the partials and the theme template
@return string|View
@throws \ThemeException | [
"Render",
"the",
"partials",
"and",
"the",
"theme",
"template"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L313-L352 |
10,504 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.set_partial | public function set_partial($section, $view, $overwrite = false)
{
// make sure the partial entry exists
array_key_exists($section, $this->partials) or $this->partials[$section] = array();
// make sure the partial is a view
if (is_string($view))
{
$name = $view;
$view = $this->view($view);
}
else
{
$name = 'partial_'.count($this->partials[$section]);
}
// store the partial
if ($overwrite)
{
$this->partials[$section] = array($name => $view);
}
else
{
$this->partials[$section][$name] = $view;
}
// return the partial view object for chaining
return $this->partials[$section][$name];
} | php | public function set_partial($section, $view, $overwrite = false)
{
// make sure the partial entry exists
array_key_exists($section, $this->partials) or $this->partials[$section] = array();
// make sure the partial is a view
if (is_string($view))
{
$name = $view;
$view = $this->view($view);
}
else
{
$name = 'partial_'.count($this->partials[$section]);
}
// store the partial
if ($overwrite)
{
$this->partials[$section] = array($name => $view);
}
else
{
$this->partials[$section][$name] = $view;
}
// return the partial view object for chaining
return $this->partials[$section][$name];
} | [
"public",
"function",
"set_partial",
"(",
"$",
"section",
",",
"$",
"view",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"// make sure the partial entry exists",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"partials",
")",
"or",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
"=",
"array",
"(",
")",
";",
"// make sure the partial is a view",
"if",
"(",
"is_string",
"(",
"$",
"view",
")",
")",
"{",
"$",
"name",
"=",
"$",
"view",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"view",
"(",
"$",
"view",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"'partial_'",
".",
"count",
"(",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
")",
";",
"}",
"// store the partial",
"if",
"(",
"$",
"overwrite",
")",
"{",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
"=",
"array",
"(",
"$",
"name",
"=>",
"$",
"view",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"view",
";",
"}",
"// return the partial view object for chaining",
"return",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
"[",
"$",
"name",
"]",
";",
"}"
] | Sets a partial for the current template
@param string $section Name of the partial section in the template
@param string|View|ViewModel|Presenter $view View, or name of the view
@param bool $overwrite If true overwrite any already defined partials for this section
@return View | [
"Sets",
"a",
"partial",
"for",
"the",
"current",
"template"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L362-L390 |
10,505 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.get_partial | public function get_partial($section, $view)
{
// make sure the partial entry exists
if ( ! array_key_exists($section, $this->partials) or ! array_key_exists($view, $this->partials[$section]))
{
throw new \ThemeException(sprintf('No partial named "%s" can be found in the "%s" section.', $view, $section));
}
return $this->partials[$section][$view];
} | php | public function get_partial($section, $view)
{
// make sure the partial entry exists
if ( ! array_key_exists($section, $this->partials) or ! array_key_exists($view, $this->partials[$section]))
{
throw new \ThemeException(sprintf('No partial named "%s" can be found in the "%s" section.', $view, $section));
}
return $this->partials[$section][$view];
} | [
"public",
"function",
"get_partial",
"(",
"$",
"section",
",",
"$",
"view",
")",
"{",
"// make sure the partial entry exists",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"partials",
")",
"or",
"!",
"array_key_exists",
"(",
"$",
"view",
",",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"ThemeException",
"(",
"sprintf",
"(",
"'No partial named \"%s\" can be found in the \"%s\" section.'",
",",
"$",
"view",
",",
"$",
"section",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
"[",
"$",
"view",
"]",
";",
"}"
] | Get a partial so it can be manipulated
@param string $section Name of the partial section in the template
@param string $view name of the view
@return View
@throws \ThemeException | [
"Get",
"a",
"partial",
"so",
"it",
"can",
"be",
"manipulated"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L400-L409 |
10,506 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.partial_count | public function partial_count($section)
{
// return the defined partial count
return array_key_exists($section, $this->partials) ? count($this->partials[$section]) : 0;
} | php | public function partial_count($section)
{
// return the defined partial count
return array_key_exists($section, $this->partials) ? count($this->partials[$section]) : 0;
} | [
"public",
"function",
"partial_count",
"(",
"$",
"section",
")",
"{",
"// return the defined partial count",
"return",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"partials",
")",
"?",
"count",
"(",
"$",
"this",
"->",
"partials",
"[",
"$",
"section",
"]",
")",
":",
"0",
";",
"}"
] | Returns the number of partials defined for a section
@param string $section Name of the partial section in the template
@return int | [
"Returns",
"the",
"number",
"of",
"partials",
"defined",
"for",
"a",
"section"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L428-L432 |
10,507 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.set_chrome | public function set_chrome($section, $view, $var = 'content')
{
// make sure the chrome is a view
if (is_string($view))
{
$view = $this->view($view);
}
$this->chrome[$section] = array('var' => $var, 'view' => $view);
return $view;
} | php | public function set_chrome($section, $view, $var = 'content')
{
// make sure the chrome is a view
if (is_string($view))
{
$view = $this->view($view);
}
$this->chrome[$section] = array('var' => $var, 'view' => $view);
return $view;
} | [
"public",
"function",
"set_chrome",
"(",
"$",
"section",
",",
"$",
"view",
",",
"$",
"var",
"=",
"'content'",
")",
"{",
"// make sure the chrome is a view",
"if",
"(",
"is_string",
"(",
"$",
"view",
")",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"view",
"(",
"$",
"view",
")",
";",
"}",
"$",
"this",
"->",
"chrome",
"[",
"$",
"section",
"]",
"=",
"array",
"(",
"'var'",
"=>",
"$",
"var",
",",
"'view'",
"=>",
"$",
"view",
")",
";",
"return",
"$",
"view",
";",
"}"
] | Sets a chrome for a partial
@param string $section Name of the partial section in the template
@param string|View|ViewModel|Presenter $view chrome View, or name of the view
@param string $var Name of the variable in the chome that will output the partial
@return View|ViewModel|Presenter, the view partial | [
"Sets",
"a",
"chrome",
"for",
"a",
"partial"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L443-L454 |
10,508 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.get_chrome | public function get_chrome($section)
{
// make sure the partial entry exists
if ( ! array_key_exists($section, $this->chrome))
{
throw new \ThemeException(sprintf('No chrome for a partial named "%s" can be found.', $section));
}
return $this->chrome[$section]['view'];
} | php | public function get_chrome($section)
{
// make sure the partial entry exists
if ( ! array_key_exists($section, $this->chrome))
{
throw new \ThemeException(sprintf('No chrome for a partial named "%s" can be found.', $section));
}
return $this->chrome[$section]['view'];
} | [
"public",
"function",
"get_chrome",
"(",
"$",
"section",
")",
"{",
"// make sure the partial entry exists",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"chrome",
")",
")",
"{",
"throw",
"new",
"\\",
"ThemeException",
"(",
"sprintf",
"(",
"'No chrome for a partial named \"%s\" can be found.'",
",",
"$",
"section",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"chrome",
"[",
"$",
"section",
"]",
"[",
"'view'",
"]",
";",
"}"
] | Get a set chrome view
@param string $section Name of the partial section in the template
@param string|View|ViewModel|Presenter $view chrome View, or name of the view
@param string $var Name of the variable in the chome that will output the partial
@return void | [
"Get",
"a",
"set",
"chrome",
"view"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L465-L474 |
10,509 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.find | public function find($theme)
{
foreach ($this->paths as $path)
{
if (is_dir($path.$theme))
{
return $path.$theme.DS;
}
}
return false;
} | php | public function find($theme)
{
foreach ($this->paths as $path)
{
if (is_dir($path.$theme))
{
return $path.$theme.DS;
}
}
return false;
} | [
"public",
"function",
"find",
"(",
"$",
"theme",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
".",
"$",
"theme",
")",
")",
"{",
"return",
"$",
"path",
".",
"$",
"theme",
".",
"DS",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Finds the given theme by searching through all of the theme paths. If
found it will return the path, else it will return `false`.
@param string $theme Theme to find
@return string|false Path or false if not found | [
"Finds",
"the",
"given",
"theme",
"by",
"searching",
"through",
"all",
"of",
"the",
"theme",
"paths",
".",
"If",
"found",
"it",
"will",
"return",
"the",
"path",
"else",
"it",
"will",
"return",
"false",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L505-L516 |
10,510 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.all | public function all()
{
$themes = array();
foreach ($this->paths as $path)
{
$iterator = new \GlobIterator($path.'*');
foreach($iterator as $theme)
{
$themes[] = $theme->getFilename();
}
}
sort($themes);
return $themes;
} | php | public function all()
{
$themes = array();
foreach ($this->paths as $path)
{
$iterator = new \GlobIterator($path.'*');
foreach($iterator as $theme)
{
$themes[] = $theme->getFilename();
}
}
sort($themes);
return $themes;
} | [
"public",
"function",
"all",
"(",
")",
"{",
"$",
"themes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"GlobIterator",
"(",
"$",
"path",
".",
"'*'",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"theme",
")",
"{",
"$",
"themes",
"[",
"]",
"=",
"$",
"theme",
"->",
"getFilename",
"(",
")",
";",
"}",
"}",
"sort",
"(",
"$",
"themes",
")",
";",
"return",
"$",
"themes",
";",
"}"
] | Gets an array of all themes in all theme paths, sorted alphabetically.
@return array | [
"Gets",
"an",
"array",
"of",
"all",
"themes",
"in",
"all",
"theme",
"paths",
"sorted",
"alphabetically",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L523-L537 |
10,511 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.get_info | public function get_info($var = null, $default = null, $theme = null)
{
// if no theme is given
if ($theme === null)
{
// if no var to search is given return the entire active info array
if ($var === null)
{
return $this->active['info'];
}
// find the value in the active theme info
if (($value = \Arr::get($this->active['info'], $var, null)) !== null)
{
return $value;
}
// and if not found, check the fallback
elseif (($value = \Arr::get($this->fallback['info'], $var, null)) !== null)
{
return $value;
}
}
// or if we have a specific theme
else
{
// fetch the info from that theme
$info = $this->load_info($theme);
// and return the requested value
return $var === null ? $info : \Arr::get($info, $var, $default);
}
// not found, return the given default value
return $default;
} | php | public function get_info($var = null, $default = null, $theme = null)
{
// if no theme is given
if ($theme === null)
{
// if no var to search is given return the entire active info array
if ($var === null)
{
return $this->active['info'];
}
// find the value in the active theme info
if (($value = \Arr::get($this->active['info'], $var, null)) !== null)
{
return $value;
}
// and if not found, check the fallback
elseif (($value = \Arr::get($this->fallback['info'], $var, null)) !== null)
{
return $value;
}
}
// or if we have a specific theme
else
{
// fetch the info from that theme
$info = $this->load_info($theme);
// and return the requested value
return $var === null ? $info : \Arr::get($info, $var, $default);
}
// not found, return the given default value
return $default;
} | [
"public",
"function",
"get_info",
"(",
"$",
"var",
"=",
"null",
",",
"$",
"default",
"=",
"null",
",",
"$",
"theme",
"=",
"null",
")",
"{",
"// if no theme is given",
"if",
"(",
"$",
"theme",
"===",
"null",
")",
"{",
"// if no var to search is given return the entire active info array",
"if",
"(",
"$",
"var",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"active",
"[",
"'info'",
"]",
";",
"}",
"// find the value in the active theme info",
"if",
"(",
"(",
"$",
"value",
"=",
"\\",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"active",
"[",
"'info'",
"]",
",",
"$",
"var",
",",
"null",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"// and if not found, check the fallback",
"elseif",
"(",
"(",
"$",
"value",
"=",
"\\",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"fallback",
"[",
"'info'",
"]",
",",
"$",
"var",
",",
"null",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"// or if we have a specific theme",
"else",
"{",
"// fetch the info from that theme",
"$",
"info",
"=",
"$",
"this",
"->",
"load_info",
"(",
"$",
"theme",
")",
";",
"// and return the requested value",
"return",
"$",
"var",
"===",
"null",
"?",
"$",
"info",
":",
"\\",
"Arr",
"::",
"get",
"(",
"$",
"info",
",",
"$",
"var",
",",
"$",
"default",
")",
";",
"}",
"// not found, return the given default value",
"return",
"$",
"default",
";",
"}"
] | Get a value from the info array
@return mixed | [
"Get",
"a",
"value",
"from",
"the",
"info",
"array"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L544-L580 |
10,512 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.set_info | public function set_info($var, $value = null, $type = 'active')
{
if ($type == 'active')
{
\Arr::set($this->active['info'], $var, $value);
}
elseif ($type == 'fallback')
{
\Arr::set($this->fallback['info'], $var, $value);
}
// return for chaining
return $this;
} | php | public function set_info($var, $value = null, $type = 'active')
{
if ($type == 'active')
{
\Arr::set($this->active['info'], $var, $value);
}
elseif ($type == 'fallback')
{
\Arr::set($this->fallback['info'], $var, $value);
}
// return for chaining
return $this;
} | [
"public",
"function",
"set_info",
"(",
"$",
"var",
",",
"$",
"value",
"=",
"null",
",",
"$",
"type",
"=",
"'active'",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'active'",
")",
"{",
"\\",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"active",
"[",
"'info'",
"]",
",",
"$",
"var",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'fallback'",
")",
"{",
"\\",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"fallback",
"[",
"'info'",
"]",
",",
"$",
"var",
",",
"$",
"value",
")",
";",
"}",
"// return for chaining",
"return",
"$",
"this",
";",
"}"
] | Set a value in the info array
@return Theme | [
"Set",
"a",
"value",
"in",
"the",
"info",
"array"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L587-L600 |
10,513 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.set_theme | protected function set_theme($theme = null, $type = 'active')
{
// set the theme if given
if ($theme !== null)
{
// remove the defined theme asset paths from the asset instance
empty($this->active['asset_path']) or $this->asset->remove_path($this->active['asset_path']);
empty($this->fallback['asset_path']) or $this->asset->remove_path($this->fallback['asset_path']);
$this->{$type} = $this->create_theme_array($theme);
// add the asset paths to the asset instance
empty($this->fallback['asset_path']) or $this->asset->add_path($this->fallback['asset_path']);
empty($this->active['asset_path']) or $this->asset->add_path($this->active['asset_path']);
}
// and return the theme config
return $this->{$type};
} | php | protected function set_theme($theme = null, $type = 'active')
{
// set the theme if given
if ($theme !== null)
{
// remove the defined theme asset paths from the asset instance
empty($this->active['asset_path']) or $this->asset->remove_path($this->active['asset_path']);
empty($this->fallback['asset_path']) or $this->asset->remove_path($this->fallback['asset_path']);
$this->{$type} = $this->create_theme_array($theme);
// add the asset paths to the asset instance
empty($this->fallback['asset_path']) or $this->asset->add_path($this->fallback['asset_path']);
empty($this->active['asset_path']) or $this->asset->add_path($this->active['asset_path']);
}
// and return the theme config
return $this->{$type};
} | [
"protected",
"function",
"set_theme",
"(",
"$",
"theme",
"=",
"null",
",",
"$",
"type",
"=",
"'active'",
")",
"{",
"// set the theme if given",
"if",
"(",
"$",
"theme",
"!==",
"null",
")",
"{",
"// remove the defined theme asset paths from the asset instance",
"empty",
"(",
"$",
"this",
"->",
"active",
"[",
"'asset_path'",
"]",
")",
"or",
"$",
"this",
"->",
"asset",
"->",
"remove_path",
"(",
"$",
"this",
"->",
"active",
"[",
"'asset_path'",
"]",
")",
";",
"empty",
"(",
"$",
"this",
"->",
"fallback",
"[",
"'asset_path'",
"]",
")",
"or",
"$",
"this",
"->",
"asset",
"->",
"remove_path",
"(",
"$",
"this",
"->",
"fallback",
"[",
"'asset_path'",
"]",
")",
";",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"=",
"$",
"this",
"->",
"create_theme_array",
"(",
"$",
"theme",
")",
";",
"// add the asset paths to the asset instance",
"empty",
"(",
"$",
"this",
"->",
"fallback",
"[",
"'asset_path'",
"]",
")",
"or",
"$",
"this",
"->",
"asset",
"->",
"add_path",
"(",
"$",
"this",
"->",
"fallback",
"[",
"'asset_path'",
"]",
")",
";",
"empty",
"(",
"$",
"this",
"->",
"active",
"[",
"'asset_path'",
"]",
")",
"or",
"$",
"this",
"->",
"asset",
"->",
"add_path",
"(",
"$",
"this",
"->",
"active",
"[",
"'asset_path'",
"]",
")",
";",
"}",
"// and return the theme config",
"return",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
";",
"}"
] | Sets a theme.
@param string $theme Theme name to set active
@param string $type name of the internal theme array to set
@return array The theme array
@throws \ThemeException | [
"Sets",
"a",
"theme",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L775-L793 |
10,514 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/theme.php | Theme.create_theme_array | protected function create_theme_array($theme)
{
if ( ! is_array($theme))
{
if ( ! $path = $this->find($theme))
{
throw new \ThemeException(sprintf('Theme "%s" could not be found.', $theme));
}
$theme = array(
'name' => $theme,
'path' => $path,
);
}
else
{
if ( ! isset($theme['name']) or ! isset($theme['path']))
{
throw new \ThemeException('Theme name and path must be given in array config.');
}
}
// load the theme info file
if ( ! isset($theme['info']))
{
$theme['info'] = $this->load_info($theme);
}
if ( ! isset($theme['asset_base']))
{
// determine the asset location and base URL
$assets_folder = rtrim($this->config['assets_folder'], DS).'/';
// all theme files are inside the docroot
if (strpos($path, DOCROOT) === 0 and is_dir($path.$assets_folder))
{
$theme['asset_path'] = $path.$assets_folder;
$theme['asset_base'] = str_replace(DOCROOT, '', $theme['asset_path']);
}
// theme views and templates are outside the docroot
else
{
$theme['asset_base'] = $assets_folder.$theme['name'].'/';
}
}
if ( ! isset($theme['asset_path']) and strpos($theme['asset_base'], '://') === false)
{
$theme['asset_path'] = DOCROOT.$theme['asset_base'];
}
// always uses forward slashes (DS is a backslash on Windows)
$theme['asset_base'] = str_replace(DS, '/', $theme['asset_base']);
return $theme;
} | php | protected function create_theme_array($theme)
{
if ( ! is_array($theme))
{
if ( ! $path = $this->find($theme))
{
throw new \ThemeException(sprintf('Theme "%s" could not be found.', $theme));
}
$theme = array(
'name' => $theme,
'path' => $path,
);
}
else
{
if ( ! isset($theme['name']) or ! isset($theme['path']))
{
throw new \ThemeException('Theme name and path must be given in array config.');
}
}
// load the theme info file
if ( ! isset($theme['info']))
{
$theme['info'] = $this->load_info($theme);
}
if ( ! isset($theme['asset_base']))
{
// determine the asset location and base URL
$assets_folder = rtrim($this->config['assets_folder'], DS).'/';
// all theme files are inside the docroot
if (strpos($path, DOCROOT) === 0 and is_dir($path.$assets_folder))
{
$theme['asset_path'] = $path.$assets_folder;
$theme['asset_base'] = str_replace(DOCROOT, '', $theme['asset_path']);
}
// theme views and templates are outside the docroot
else
{
$theme['asset_base'] = $assets_folder.$theme['name'].'/';
}
}
if ( ! isset($theme['asset_path']) and strpos($theme['asset_base'], '://') === false)
{
$theme['asset_path'] = DOCROOT.$theme['asset_base'];
}
// always uses forward slashes (DS is a backslash on Windows)
$theme['asset_base'] = str_replace(DS, '/', $theme['asset_base']);
return $theme;
} | [
"protected",
"function",
"create_theme_array",
"(",
"$",
"theme",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"theme",
")",
")",
"{",
"if",
"(",
"!",
"$",
"path",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"theme",
")",
")",
"{",
"throw",
"new",
"\\",
"ThemeException",
"(",
"sprintf",
"(",
"'Theme \"%s\" could not be found.'",
",",
"$",
"theme",
")",
")",
";",
"}",
"$",
"theme",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"theme",
",",
"'path'",
"=>",
"$",
"path",
",",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"theme",
"[",
"'name'",
"]",
")",
"or",
"!",
"isset",
"(",
"$",
"theme",
"[",
"'path'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"ThemeException",
"(",
"'Theme name and path must be given in array config.'",
")",
";",
"}",
"}",
"// load the theme info file",
"if",
"(",
"!",
"isset",
"(",
"$",
"theme",
"[",
"'info'",
"]",
")",
")",
"{",
"$",
"theme",
"[",
"'info'",
"]",
"=",
"$",
"this",
"->",
"load_info",
"(",
"$",
"theme",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"theme",
"[",
"'asset_base'",
"]",
")",
")",
"{",
"// determine the asset location and base URL",
"$",
"assets_folder",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"config",
"[",
"'assets_folder'",
"]",
",",
"DS",
")",
".",
"'/'",
";",
"// all theme files are inside the docroot",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"DOCROOT",
")",
"===",
"0",
"and",
"is_dir",
"(",
"$",
"path",
".",
"$",
"assets_folder",
")",
")",
"{",
"$",
"theme",
"[",
"'asset_path'",
"]",
"=",
"$",
"path",
".",
"$",
"assets_folder",
";",
"$",
"theme",
"[",
"'asset_base'",
"]",
"=",
"str_replace",
"(",
"DOCROOT",
",",
"''",
",",
"$",
"theme",
"[",
"'asset_path'",
"]",
")",
";",
"}",
"// theme views and templates are outside the docroot",
"else",
"{",
"$",
"theme",
"[",
"'asset_base'",
"]",
"=",
"$",
"assets_folder",
".",
"$",
"theme",
"[",
"'name'",
"]",
".",
"'/'",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"theme",
"[",
"'asset_path'",
"]",
")",
"and",
"strpos",
"(",
"$",
"theme",
"[",
"'asset_base'",
"]",
",",
"'://'",
")",
"===",
"false",
")",
"{",
"$",
"theme",
"[",
"'asset_path'",
"]",
"=",
"DOCROOT",
".",
"$",
"theme",
"[",
"'asset_base'",
"]",
";",
"}",
"// always uses forward slashes (DS is a backslash on Windows)",
"$",
"theme",
"[",
"'asset_base'",
"]",
"=",
"str_replace",
"(",
"DS",
",",
"'/'",
",",
"$",
"theme",
"[",
"'asset_base'",
"]",
")",
";",
"return",
"$",
"theme",
";",
"}"
] | Creates a theme array by locating the given theme and setting all of the
option. It will throw a \ThemeException if it cannot locate the theme.
@param string $theme Theme name to set active
@return array The theme array
@throws \ThemeException | [
"Creates",
"a",
"theme",
"array",
"by",
"locating",
"the",
"given",
"theme",
"and",
"setting",
"all",
"of",
"the",
"option",
".",
"It",
"will",
"throw",
"a",
"\\",
"ThemeException",
"if",
"it",
"cannot",
"locate",
"the",
"theme",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/theme.php#L803-L859 |
10,515 | ellipsephp/http | src/Exceptions/Inspector.php | Inspector.linearize | private function linearize(Throwable $e): array
{
$previous = $e->getPrevious();
if (is_null($previous)) return [$e];
return array_merge($this->linearize($previous), [$e]);
} | php | private function linearize(Throwable $e): array
{
$previous = $e->getPrevious();
if (is_null($previous)) return [$e];
return array_merge($this->linearize($previous), [$e]);
} | [
"private",
"function",
"linearize",
"(",
"Throwable",
"$",
"e",
")",
":",
"array",
"{",
"$",
"previous",
"=",
"$",
"e",
"->",
"getPrevious",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"previous",
")",
")",
"return",
"[",
"$",
"e",
"]",
";",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"linearize",
"(",
"$",
"previous",
")",
",",
"[",
"$",
"e",
"]",
")",
";",
"}"
] | Return an array containing the given exception and all its previous
exceptions.
@param \Throwable $e
@return array | [
"Return",
"an",
"array",
"containing",
"the",
"given",
"exception",
"and",
"all",
"its",
"previous",
"exceptions",
"."
] | 20a2b0ae1d3a149a905b93ae0993203eb7d414e1 | https://github.com/ellipsephp/http/blob/20a2b0ae1d3a149a905b93ae0993203eb7d414e1/src/Exceptions/Inspector.php#L63-L70 |
10,516 | Niirrty/Niirrty.DB | src/Driver/Attribute/Support.php | Support.getAttributes | protected function getAttributes( array $attributes ) : array
{
$result = [];
foreach ( $attributes as $attribute )
{
if ( ! ( $attribute instanceof Descriptor ) )
{
continue;
}
$result[ $attribute->getName() ] = $attribute;
}
return $result;
} | php | protected function getAttributes( array $attributes ) : array
{
$result = [];
foreach ( $attributes as $attribute )
{
if ( ! ( $attribute instanceof Descriptor ) )
{
continue;
}
$result[ $attribute->getName() ] = $attribute;
}
return $result;
} | [
"protected",
"function",
"getAttributes",
"(",
"array",
"$",
"attributes",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"attribute",
"instanceof",
"Descriptor",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"attribute",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"attribute",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Results array of items.
@param array $attributes
@return \Niirrty\DB\Driver\Attribute\Descriptor[] | [
"Results",
"array",
"of",
"items",
"."
] | 72741fc06293f9f0ee408ebb1ccc18af53a35330 | https://github.com/Niirrty/Niirrty.DB/blob/72741fc06293f9f0ee408ebb1ccc18af53a35330/src/Driver/Attribute/Support.php#L79-L95 |
10,517 | Niirrty/Niirrty.DB | src/Driver/Attribute/Support.php | Support.add | public function add( Descriptor $argDescriptor ) : Support
{
$this->_attributes[ $argDescriptor->getName() ] = $argDescriptor;
return $this;
} | php | public function add( Descriptor $argDescriptor ) : Support
{
$this->_attributes[ $argDescriptor->getName() ] = $argDescriptor;
return $this;
} | [
"public",
"function",
"add",
"(",
"Descriptor",
"$",
"argDescriptor",
")",
":",
"Support",
"{",
"$",
"this",
"->",
"_attributes",
"[",
"$",
"argDescriptor",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"argDescriptor",
";",
"return",
"$",
"this",
";",
"}"
] | Adds or overwrites a argument descriptor.
@param \Niirrty\DB\Driver\Attribute\Descriptor $argDescriptor
@return \Niirrty\DB\Driver\Attribute\Support | [
"Adds",
"or",
"overwrites",
"a",
"argument",
"descriptor",
"."
] | 72741fc06293f9f0ee408ebb1ccc18af53a35330 | https://github.com/Niirrty/Niirrty.DB/blob/72741fc06293f9f0ee408ebb1ccc18af53a35330/src/Driver/Attribute/Support.php#L147-L154 |
10,518 | Niirrty/Niirrty.DB | src/Driver/Attribute/Support.php | Support.remove | public function remove( string $argName ) : Support
{
if ( ! $this->has( $argName ) )
{
return $this;
}
unset( $this->_attributes[ $argName ] );
return $this;
} | php | public function remove( string $argName ) : Support
{
if ( ! $this->has( $argName ) )
{
return $this;
}
unset( $this->_attributes[ $argName ] );
return $this;
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"argName",
")",
":",
"Support",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"argName",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"_attributes",
"[",
"$",
"argName",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes the DSN argument descriptor with defined name
@param string $argName
@return \Niirrty\DB\Driver\Attribute\Support | [
"Removes",
"the",
"DSN",
"argument",
"descriptor",
"with",
"defined",
"name"
] | 72741fc06293f9f0ee408ebb1ccc18af53a35330 | https://github.com/Niirrty/Niirrty.DB/blob/72741fc06293f9f0ee408ebb1ccc18af53a35330/src/Driver/Attribute/Support.php#L162-L174 |
10,519 | Niirrty/Niirrty.DB | src/Driver/Attribute/Support.php | Support.getSQLParamNames | public function getSQLParamNames() : array
{
$out = [];
foreach ( $this->_attributes as $attributeName => $attribute )
{
if ( Type::INIT_SQL === $attribute->getType() )
{
$out[] = $attributeName;
}
}
return $out;
} | php | public function getSQLParamNames() : array
{
$out = [];
foreach ( $this->_attributes as $attributeName => $attribute )
{
if ( Type::INIT_SQL === $attribute->getType() )
{
$out[] = $attributeName;
}
}
return $out;
} | [
"public",
"function",
"getSQLParamNames",
"(",
")",
":",
"array",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_attributes",
"as",
"$",
"attributeName",
"=>",
"$",
"attribute",
")",
"{",
"if",
"(",
"Type",
"::",
"INIT_SQL",
"===",
"$",
"attribute",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"attributeName",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] | Gets the names of the parameters that should be used as SQL queries, called after connection open.
@return array | [
"Gets",
"the",
"names",
"of",
"the",
"parameters",
"that",
"should",
"be",
"used",
"as",
"SQL",
"queries",
"called",
"after",
"connection",
"open",
"."
] | 72741fc06293f9f0ee408ebb1ccc18af53a35330 | https://github.com/Niirrty/Niirrty.DB/blob/72741fc06293f9f0ee408ebb1ccc18af53a35330/src/Driver/Attribute/Support.php#L377-L392 |
10,520 | Niirrty/Niirrty.DB | src/Driver/Attribute/Support.php | Support.validate | public function validate( string $attributeName, $attributeValue ) : ValidationResult
{
$result = new ValidationResult();
if ( false === $this->has( $attributeName ) )
{
// Unknown argument name
return $result
->setErrorMessage( 'Unknown Driver attribute name "' . $attributeName . '"!' );
}
if ( $this->_attributes[ $attributeName ]->validateValue( $attributeValue ) )
{
// The value is valid we are done here
return $result
->setIsKnown( true )
->setIsValidValue( true )
->setValue( $attributeValue );
}
if ( $this->_attributes[ $attributeName ]->hasDefaultValue() )
{
// The defined value is not valid, but a default value is defined, that is used now
return $result
->setIsKnown( true )
->setValue( $this->_attributes[ $attributeName ]->getDefaultValue() );
}
return $result
->setIsKnown( true )
->setErrorMessage( 'Unknown Driver argument "' . $attributeName . '" value "' . $attributeValue . '"!' );
} | php | public function validate( string $attributeName, $attributeValue ) : ValidationResult
{
$result = new ValidationResult();
if ( false === $this->has( $attributeName ) )
{
// Unknown argument name
return $result
->setErrorMessage( 'Unknown Driver attribute name "' . $attributeName . '"!' );
}
if ( $this->_attributes[ $attributeName ]->validateValue( $attributeValue ) )
{
// The value is valid we are done here
return $result
->setIsKnown( true )
->setIsValidValue( true )
->setValue( $attributeValue );
}
if ( $this->_attributes[ $attributeName ]->hasDefaultValue() )
{
// The defined value is not valid, but a default value is defined, that is used now
return $result
->setIsKnown( true )
->setValue( $this->_attributes[ $attributeName ]->getDefaultValue() );
}
return $result
->setIsKnown( true )
->setErrorMessage( 'Unknown Driver argument "' . $attributeName . '" value "' . $attributeValue . '"!' );
} | [
"public",
"function",
"validate",
"(",
"string",
"$",
"attributeName",
",",
"$",
"attributeValue",
")",
":",
"ValidationResult",
"{",
"$",
"result",
"=",
"new",
"ValidationResult",
"(",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"has",
"(",
"$",
"attributeName",
")",
")",
"{",
"// Unknown argument name",
"return",
"$",
"result",
"->",
"setErrorMessage",
"(",
"'Unknown Driver attribute name \"'",
".",
"$",
"attributeName",
".",
"'\"!'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_attributes",
"[",
"$",
"attributeName",
"]",
"->",
"validateValue",
"(",
"$",
"attributeValue",
")",
")",
"{",
"// The value is valid we are done here",
"return",
"$",
"result",
"->",
"setIsKnown",
"(",
"true",
")",
"->",
"setIsValidValue",
"(",
"true",
")",
"->",
"setValue",
"(",
"$",
"attributeValue",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_attributes",
"[",
"$",
"attributeName",
"]",
"->",
"hasDefaultValue",
"(",
")",
")",
"{",
"// The defined value is not valid, but a default value is defined, that is used now",
"return",
"$",
"result",
"->",
"setIsKnown",
"(",
"true",
")",
"->",
"setValue",
"(",
"$",
"this",
"->",
"_attributes",
"[",
"$",
"attributeName",
"]",
"->",
"getDefaultValue",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
"->",
"setIsKnown",
"(",
"true",
")",
"->",
"setErrorMessage",
"(",
"'Unknown Driver argument \"'",
".",
"$",
"attributeName",
".",
"'\" value \"'",
".",
"$",
"attributeValue",
".",
"'\"!'",
")",
";",
"}"
] | Validates a Driver argument with defined name and value. At least it checks if the Driver knows the
argument and if the value is valid.
@param string $attributeName
@param $attributeValue
@return \Niirrty\DB\Driver\Attribute\ValidationResult | [
"Validates",
"a",
"Driver",
"argument",
"with",
"defined",
"name",
"and",
"value",
".",
"At",
"least",
"it",
"checks",
"if",
"the",
"Driver",
"knows",
"the",
"argument",
"and",
"if",
"the",
"value",
"is",
"valid",
"."
] | 72741fc06293f9f0ee408ebb1ccc18af53a35330 | https://github.com/Niirrty/Niirrty.DB/blob/72741fc06293f9f0ee408ebb1ccc18af53a35330/src/Driver/Attribute/Support.php#L402-L435 |
10,521 | ManifestWebDesign/dabl-adapter | src/Propel/Model/Database.php | Database.addTable | public function addTable($data)
{
if ($data instanceof Table) {
$tbl = $data; // alias
$tbl->setDatabase($this);
if ($tbl->getSchema() === null) $tbl->setSchema($this->getSchema());
if (isset($this->tablesByName[$tbl->getName()])) {
return;
// throw new EngineException("Duplicate table declared: " . $tbl->getName());
}
$this->tableList[] = $tbl;
$this->tablesByName[$tbl->getName()] = $tbl;
$this->tablesByLowercaseName[strtolower($tbl->getName())] = $tbl;
$this->tablesByPhpName[ $tbl->getPhpName() ] = $tbl;
if (strpos($tbl->getNamespace(), '\\') === 0) {
$tbl->setNamespace(substr($tbl->getNamespace(), 1));
} elseif ($namespace = $this->getNamespace()) {
if ($tbl->getNamespace() === null) {
$tbl->setNamespace($namespace);
} else {
$tbl->setNamespace($namespace . '\\' . $tbl->getNamespace());
}
}
if ($tbl->getPackage() === null) {
$tbl->setPackage($this->getPackage());
}
return $tbl;
} else {
$tbl = new Table();
$tbl->setDatabase($this);
$tbl->setSchema($this->getSchema());
$tbl->loadFromXML($data);
return $this->addTable($tbl); // call self w/ different param
}
} | php | public function addTable($data)
{
if ($data instanceof Table) {
$tbl = $data; // alias
$tbl->setDatabase($this);
if ($tbl->getSchema() === null) $tbl->setSchema($this->getSchema());
if (isset($this->tablesByName[$tbl->getName()])) {
return;
// throw new EngineException("Duplicate table declared: " . $tbl->getName());
}
$this->tableList[] = $tbl;
$this->tablesByName[$tbl->getName()] = $tbl;
$this->tablesByLowercaseName[strtolower($tbl->getName())] = $tbl;
$this->tablesByPhpName[ $tbl->getPhpName() ] = $tbl;
if (strpos($tbl->getNamespace(), '\\') === 0) {
$tbl->setNamespace(substr($tbl->getNamespace(), 1));
} elseif ($namespace = $this->getNamespace()) {
if ($tbl->getNamespace() === null) {
$tbl->setNamespace($namespace);
} else {
$tbl->setNamespace($namespace . '\\' . $tbl->getNamespace());
}
}
if ($tbl->getPackage() === null) {
$tbl->setPackage($this->getPackage());
}
return $tbl;
} else {
$tbl = new Table();
$tbl->setDatabase($this);
$tbl->setSchema($this->getSchema());
$tbl->loadFromXML($data);
return $this->addTable($tbl); // call self w/ different param
}
} | [
"public",
"function",
"addTable",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Table",
")",
"{",
"$",
"tbl",
"=",
"$",
"data",
";",
"// alias",
"$",
"tbl",
"->",
"setDatabase",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"tbl",
"->",
"getSchema",
"(",
")",
"===",
"null",
")",
"$",
"tbl",
"->",
"setSchema",
"(",
"$",
"this",
"->",
"getSchema",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"tablesByName",
"[",
"$",
"tbl",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"return",
";",
"//\t\t\t\tthrow new EngineException(\"Duplicate table declared: \" . $tbl->getName());",
"}",
"$",
"this",
"->",
"tableList",
"[",
"]",
"=",
"$",
"tbl",
";",
"$",
"this",
"->",
"tablesByName",
"[",
"$",
"tbl",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"tbl",
";",
"$",
"this",
"->",
"tablesByLowercaseName",
"[",
"strtolower",
"(",
"$",
"tbl",
"->",
"getName",
"(",
")",
")",
"]",
"=",
"$",
"tbl",
";",
"$",
"this",
"->",
"tablesByPhpName",
"[",
"$",
"tbl",
"->",
"getPhpName",
"(",
")",
"]",
"=",
"$",
"tbl",
";",
"if",
"(",
"strpos",
"(",
"$",
"tbl",
"->",
"getNamespace",
"(",
")",
",",
"'\\\\'",
")",
"===",
"0",
")",
"{",
"$",
"tbl",
"->",
"setNamespace",
"(",
"substr",
"(",
"$",
"tbl",
"->",
"getNamespace",
"(",
")",
",",
"1",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"namespace",
"=",
"$",
"this",
"->",
"getNamespace",
"(",
")",
")",
"{",
"if",
"(",
"$",
"tbl",
"->",
"getNamespace",
"(",
")",
"===",
"null",
")",
"{",
"$",
"tbl",
"->",
"setNamespace",
"(",
"$",
"namespace",
")",
";",
"}",
"else",
"{",
"$",
"tbl",
"->",
"setNamespace",
"(",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"tbl",
"->",
"getNamespace",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"tbl",
"->",
"getPackage",
"(",
")",
"===",
"null",
")",
"{",
"$",
"tbl",
"->",
"setPackage",
"(",
"$",
"this",
"->",
"getPackage",
"(",
")",
")",
";",
"}",
"return",
"$",
"tbl",
";",
"}",
"else",
"{",
"$",
"tbl",
"=",
"new",
"Table",
"(",
")",
";",
"$",
"tbl",
"->",
"setDatabase",
"(",
"$",
"this",
")",
";",
"$",
"tbl",
"->",
"setSchema",
"(",
"$",
"this",
"->",
"getSchema",
"(",
")",
")",
";",
"$",
"tbl",
"->",
"loadFromXML",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"addTable",
"(",
"$",
"tbl",
")",
";",
"// call self w/ different param",
"}",
"}"
] | An utility method to add a new table from an xml attribute. | [
"An",
"utility",
"method",
"to",
"add",
"a",
"new",
"table",
"from",
"an",
"xml",
"attribute",
"."
] | 98579ed23bec832d764e762ee2f93f0a88ef9cd3 | https://github.com/ManifestWebDesign/dabl-adapter/blob/98579ed23bec832d764e762ee2f93f0a88ef9cd3/src/Propel/Model/Database.php#L366-L400 |
10,522 | bariew/yii2-notice-cms-module | controllers/EmailConfigController.php | EmailConfigController.actionEvents | public function actionEvents()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$result = ($post = Yii::$app->request->post('depdrop_parents'))
? array_flip(ClassCrawler::getEventNames($post[0]))
: [];
$output = [];
foreach ($result as $id => $name) {
$output[] = compact('id', 'name');
}
echo Json::encode(['output' => $output, 'selected' => '']);
} | php | public function actionEvents()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$result = ($post = Yii::$app->request->post('depdrop_parents'))
? array_flip(ClassCrawler::getEventNames($post[0]))
: [];
$output = [];
foreach ($result as $id => $name) {
$output[] = compact('id', 'name');
}
echo Json::encode(['output' => $output, 'selected' => '']);
} | [
"public",
"function",
"actionEvents",
"(",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"$",
"result",
"=",
"(",
"$",
"post",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'depdrop_parents'",
")",
")",
"?",
"array_flip",
"(",
"ClassCrawler",
"::",
"getEventNames",
"(",
"$",
"post",
"[",
"0",
"]",
")",
")",
":",
"[",
"]",
";",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"id",
"=>",
"$",
"name",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"compact",
"(",
"'id'",
",",
"'name'",
")",
";",
"}",
"echo",
"Json",
"::",
"encode",
"(",
"[",
"'output'",
"=>",
"$",
"output",
",",
"'selected'",
"=>",
"''",
"]",
")",
";",
"}"
] | Returns json event list for form DepDrop widget. | [
"Returns",
"json",
"event",
"list",
"for",
"form",
"DepDrop",
"widget",
"."
] | 1dc9798b3ed2c511937e9d3e44867412c9f5a7b6 | https://github.com/bariew/yii2-notice-cms-module/blob/1dc9798b3ed2c511937e9d3e44867412c9f5a7b6/controllers/EmailConfigController.php#L100-L111 |
10,523 | ppetermann/knight23 | src/Knight23.php | Knight23.run | public function run($argc, $argv)
{
$this->addDefaultCommands();
// @todo place better command parser here
if ($argc == 1) {
$run = $this->getDefaultCommand();
$argv = [];
} else {
$run = $argv[1];
$argv = array_slice($argv, 2);
}
$found = false;
/** @var CommandInterface $command */
foreach ($this->commands as $command) {
// @todo prevent multiple commands having the same name (why?)
if ($command->getName() == $run) {
$command->run([], $argv);
$found = true;
}
}
// @todo more graceful end
if (!$found) {
echo "command unknown\n";
// exit with error
exit(1);
}
// this is running the react event loop, maybe this should run the actual commands too?
$this->loop->run();
} | php | public function run($argc, $argv)
{
$this->addDefaultCommands();
// @todo place better command parser here
if ($argc == 1) {
$run = $this->getDefaultCommand();
$argv = [];
} else {
$run = $argv[1];
$argv = array_slice($argv, 2);
}
$found = false;
/** @var CommandInterface $command */
foreach ($this->commands as $command) {
// @todo prevent multiple commands having the same name (why?)
if ($command->getName() == $run) {
$command->run([], $argv);
$found = true;
}
}
// @todo more graceful end
if (!$found) {
echo "command unknown\n";
// exit with error
exit(1);
}
// this is running the react event loop, maybe this should run the actual commands too?
$this->loop->run();
} | [
"public",
"function",
"run",
"(",
"$",
"argc",
",",
"$",
"argv",
")",
"{",
"$",
"this",
"->",
"addDefaultCommands",
"(",
")",
";",
"// @todo place better command parser here",
"if",
"(",
"$",
"argc",
"==",
"1",
")",
"{",
"$",
"run",
"=",
"$",
"this",
"->",
"getDefaultCommand",
"(",
")",
";",
"$",
"argv",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"run",
"=",
"$",
"argv",
"[",
"1",
"]",
";",
"$",
"argv",
"=",
"array_slice",
"(",
"$",
"argv",
",",
"2",
")",
";",
"}",
"$",
"found",
"=",
"false",
";",
"/** @var CommandInterface $command */",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"command",
")",
"{",
"// @todo prevent multiple commands having the same name (why?)",
"if",
"(",
"$",
"command",
"->",
"getName",
"(",
")",
"==",
"$",
"run",
")",
"{",
"$",
"command",
"->",
"run",
"(",
"[",
"]",
",",
"$",
"argv",
")",
";",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"// @todo more graceful end",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"echo",
"\"command unknown\\n\"",
";",
"// exit with error",
"exit",
"(",
"1",
")",
";",
"}",
"// this is running the react event loop, maybe this should run the actual commands too?",
"$",
"this",
"->",
"loop",
"->",
"run",
"(",
")",
";",
"}"
] | execute the actuall run | [
"execute",
"the",
"actuall",
"run"
] | 890cae845b45df9d8c7c6dc0b5b334974fb5bd76 | https://github.com/ppetermann/knight23/blob/890cae845b45df9d8c7c6dc0b5b334974fb5bd76/src/Knight23.php#L62-L95 |
10,524 | FiveLab/Transactional | src/Proxy/Generator/ProxyCodeGenerator.php | ProxyCodeGenerator.getProxyMethods | private function getProxyMethods(): array
{
if (null !== $this->reflectionProxyMethods) {
return $this->reflectionProxyMethods;
}
$proxyMethods = [];
$methods = $this->getClassMethods();
foreach ($methods as $method) {
$docComment = $method->getDocComment();
if (\strpos($docComment, 'Transactional') !== false) {
$annotation = $this->annotationReader->getMethodAnnotation(
$method,
Transactional::class
);
if ($annotation) {
$proxyMethods[] = $method;
}
}
}
$this->reflectionProxyMethods = $proxyMethods;
return $proxyMethods;
} | php | private function getProxyMethods(): array
{
if (null !== $this->reflectionProxyMethods) {
return $this->reflectionProxyMethods;
}
$proxyMethods = [];
$methods = $this->getClassMethods();
foreach ($methods as $method) {
$docComment = $method->getDocComment();
if (\strpos($docComment, 'Transactional') !== false) {
$annotation = $this->annotationReader->getMethodAnnotation(
$method,
Transactional::class
);
if ($annotation) {
$proxyMethods[] = $method;
}
}
}
$this->reflectionProxyMethods = $proxyMethods;
return $proxyMethods;
} | [
"private",
"function",
"getProxyMethods",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"reflectionProxyMethods",
")",
"{",
"return",
"$",
"this",
"->",
"reflectionProxyMethods",
";",
"}",
"$",
"proxyMethods",
"=",
"[",
"]",
";",
"$",
"methods",
"=",
"$",
"this",
"->",
"getClassMethods",
"(",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"docComment",
"=",
"$",
"method",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"docComment",
",",
"'Transactional'",
")",
"!==",
"false",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"annotationReader",
"->",
"getMethodAnnotation",
"(",
"$",
"method",
",",
"Transactional",
"::",
"class",
")",
";",
"if",
"(",
"$",
"annotation",
")",
"{",
"$",
"proxyMethods",
"[",
"]",
"=",
"$",
"method",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"reflectionProxyMethods",
"=",
"$",
"proxyMethods",
";",
"return",
"$",
"proxyMethods",
";",
"}"
] | Get proxy methods
@return array|\ReflectionMethod[] | [
"Get",
"proxy",
"methods"
] | d2a406543f9eab35ad618d7f4436090487508fc9 | https://github.com/FiveLab/Transactional/blob/d2a406543f9eab35ad618d7f4436090487508fc9/src/Proxy/Generator/ProxyCodeGenerator.php#L99-L126 |
10,525 | FiveLab/Transactional | src/Proxy/Generator/ProxyCodeGenerator.php | ProxyCodeGenerator.getClassMethods | private function getClassMethods(): array
{
if (null !== $this->reflectionMethods) {
return $this->reflectionMethods;
}
$this->reflectionMethods = [];
$class = $this->reflectionClass;
do {
$this->reflectionMethods = \array_merge(
$this->reflectionMethods,
$class->getMethods()
);
} while ($class = $class->getParentClass());
return $this->reflectionMethods;
} | php | private function getClassMethods(): array
{
if (null !== $this->reflectionMethods) {
return $this->reflectionMethods;
}
$this->reflectionMethods = [];
$class = $this->reflectionClass;
do {
$this->reflectionMethods = \array_merge(
$this->reflectionMethods,
$class->getMethods()
);
} while ($class = $class->getParentClass());
return $this->reflectionMethods;
} | [
"private",
"function",
"getClassMethods",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"reflectionMethods",
")",
"{",
"return",
"$",
"this",
"->",
"reflectionMethods",
";",
"}",
"$",
"this",
"->",
"reflectionMethods",
"=",
"[",
"]",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"reflectionClass",
";",
"do",
"{",
"$",
"this",
"->",
"reflectionMethods",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"reflectionMethods",
",",
"$",
"class",
"->",
"getMethods",
"(",
")",
")",
";",
"}",
"while",
"(",
"$",
"class",
"=",
"$",
"class",
"->",
"getParentClass",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"reflectionMethods",
";",
"}"
] | Get all methods from class
@return \ReflectionMethod[] | [
"Get",
"all",
"methods",
"from",
"class"
] | d2a406543f9eab35ad618d7f4436090487508fc9 | https://github.com/FiveLab/Transactional/blob/d2a406543f9eab35ad618d7f4436090487508fc9/src/Proxy/Generator/ProxyCodeGenerator.php#L133-L151 |
10,526 | FiveLab/Transactional | src/Proxy/Generator/ProxyCodeGenerator.php | ProxyCodeGenerator.getAllUseStatementsMarkedAsAnnotation | private function getAllUseStatementsMarkedAsAnnotation(\ReflectionClass $class): array
{
$tokens = \token_get_all(\file_get_contents($class->getFileName()));
$uses = [];
$buffer = '';
$startUseParse = false;
foreach ($tokens as $token) {
if (\is_scalar($token)) {
// Single element
if ($token == ';' || $token = ',') {
if ($startUseParse) {
// Add "use" statement to collection
$uses[] = trim($buffer);
// Clear buffer
$buffer = ''; // Clear buffer
if ($token == ';') {
// Stop parse "use"
$startUseParse = false;
}
}
}
continue;
}
$type = $token[0];
$value = $token[1];
if (\in_array($type, [T_ABSTRACT, T_CLASS, T_INTERFACE, T_TRAIT])) {
// Start class or interface or trait
break;
}
if ($type == T_USE) {
$startUseParse = true;
continue;
}
if ($startUseParse) {
$buffer .= $value;
}
}
$useFiltering = function ($class, $searchChild = true) use (&$useFiltering) {
if (!$class) {
return false;
}
$parts = \explode(' as ', $class, 2);
$class = $parts[0];
try {
$reflection = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
if ($searchChild) {
foreach (\get_declared_classes() as $declaredClass) {
if (\strpos($declaredClass, $class) === 0) {
if (true === $useFiltering($declaredClass, false)) {
return true;
}
}
}
}
return false;
}
if ($reflection->getName() == Transactional::class) {
return false;
}
return \strpos($reflection->getDocComment(), '@Annotation') !== false;
};
$uses = \array_filter($uses, $useFiltering);
return $uses;
} | php | private function getAllUseStatementsMarkedAsAnnotation(\ReflectionClass $class): array
{
$tokens = \token_get_all(\file_get_contents($class->getFileName()));
$uses = [];
$buffer = '';
$startUseParse = false;
foreach ($tokens as $token) {
if (\is_scalar($token)) {
// Single element
if ($token == ';' || $token = ',') {
if ($startUseParse) {
// Add "use" statement to collection
$uses[] = trim($buffer);
// Clear buffer
$buffer = ''; // Clear buffer
if ($token == ';') {
// Stop parse "use"
$startUseParse = false;
}
}
}
continue;
}
$type = $token[0];
$value = $token[1];
if (\in_array($type, [T_ABSTRACT, T_CLASS, T_INTERFACE, T_TRAIT])) {
// Start class or interface or trait
break;
}
if ($type == T_USE) {
$startUseParse = true;
continue;
}
if ($startUseParse) {
$buffer .= $value;
}
}
$useFiltering = function ($class, $searchChild = true) use (&$useFiltering) {
if (!$class) {
return false;
}
$parts = \explode(' as ', $class, 2);
$class = $parts[0];
try {
$reflection = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
if ($searchChild) {
foreach (\get_declared_classes() as $declaredClass) {
if (\strpos($declaredClass, $class) === 0) {
if (true === $useFiltering($declaredClass, false)) {
return true;
}
}
}
}
return false;
}
if ($reflection->getName() == Transactional::class) {
return false;
}
return \strpos($reflection->getDocComment(), '@Annotation') !== false;
};
$uses = \array_filter($uses, $useFiltering);
return $uses;
} | [
"private",
"function",
"getAllUseStatementsMarkedAsAnnotation",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
":",
"array",
"{",
"$",
"tokens",
"=",
"\\",
"token_get_all",
"(",
"\\",
"file_get_contents",
"(",
"$",
"class",
"->",
"getFileName",
"(",
")",
")",
")",
";",
"$",
"uses",
"=",
"[",
"]",
";",
"$",
"buffer",
"=",
"''",
";",
"$",
"startUseParse",
"=",
"false",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"\\",
"is_scalar",
"(",
"$",
"token",
")",
")",
"{",
"// Single element",
"if",
"(",
"$",
"token",
"==",
"';'",
"||",
"$",
"token",
"=",
"','",
")",
"{",
"if",
"(",
"$",
"startUseParse",
")",
"{",
"// Add \"use\" statement to collection",
"$",
"uses",
"[",
"]",
"=",
"trim",
"(",
"$",
"buffer",
")",
";",
"// Clear buffer",
"$",
"buffer",
"=",
"''",
";",
"// Clear buffer",
"if",
"(",
"$",
"token",
"==",
"';'",
")",
"{",
"// Stop parse \"use\"",
"$",
"startUseParse",
"=",
"false",
";",
"}",
"}",
"}",
"continue",
";",
"}",
"$",
"type",
"=",
"$",
"token",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"token",
"[",
"1",
"]",
";",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"type",
",",
"[",
"T_ABSTRACT",
",",
"T_CLASS",
",",
"T_INTERFACE",
",",
"T_TRAIT",
"]",
")",
")",
"{",
"// Start class or interface or trait",
"break",
";",
"}",
"if",
"(",
"$",
"type",
"==",
"T_USE",
")",
"{",
"$",
"startUseParse",
"=",
"true",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"startUseParse",
")",
"{",
"$",
"buffer",
".=",
"$",
"value",
";",
"}",
"}",
"$",
"useFiltering",
"=",
"function",
"(",
"$",
"class",
",",
"$",
"searchChild",
"=",
"true",
")",
"use",
"(",
"&",
"$",
"useFiltering",
")",
"{",
"if",
"(",
"!",
"$",
"class",
")",
"{",
"return",
"false",
";",
"}",
"$",
"parts",
"=",
"\\",
"explode",
"(",
"' as '",
",",
"$",
"class",
",",
"2",
")",
";",
"$",
"class",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"try",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"searchChild",
")",
"{",
"foreach",
"(",
"\\",
"get_declared_classes",
"(",
")",
"as",
"$",
"declaredClass",
")",
"{",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"declaredClass",
",",
"$",
"class",
")",
"===",
"0",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"useFiltering",
"(",
"$",
"declaredClass",
",",
"false",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"reflection",
"->",
"getName",
"(",
")",
"==",
"Transactional",
"::",
"class",
")",
"{",
"return",
"false",
";",
"}",
"return",
"\\",
"strpos",
"(",
"$",
"reflection",
"->",
"getDocComment",
"(",
")",
",",
"'@Annotation'",
")",
"!==",
"false",
";",
"}",
";",
"$",
"uses",
"=",
"\\",
"array_filter",
"(",
"$",
"uses",
",",
"$",
"useFiltering",
")",
";",
"return",
"$",
"uses",
";",
"}"
] | Get all use statements from class
@param \ReflectionClass $class
@return array | [
"Get",
"all",
"use",
"statements",
"from",
"class"
] | d2a406543f9eab35ad618d7f4436090487508fc9 | https://github.com/FiveLab/Transactional/blob/d2a406543f9eab35ad618d7f4436090487508fc9/src/Proxy/Generator/ProxyCodeGenerator.php#L160-L240 |
10,527 | FiveLab/Transactional | src/Proxy/Generator/ProxyCodeGenerator.php | ProxyCodeGenerator.generateProxyClass | private function generateProxyClass(): string
{
$class = $this->reflectionClass;
if ($class->isFinal()) {
throw new \RuntimeException(sprintf(
'Can not generate proxy for final class "%s".',
$class->getName()
));
}
if ($class->isAbstract()) {
throw new \RuntimeException(sprintf(
'Can not generate proxy for abstract class "%s".',
$class->getName()
));
}
$methodCodes = [];
$uses = $this->getAllUseStatementsMarkedAsAnnotation($class);
$uses[] = 'FiveLab\Component\Transactional\Proxy\ProxyInterface as FiveLabTransactionalProxyInterface';
$uses = \array_map(function ($use) {
return 'use '.$use.';';
}, $uses);
$interfaces = [
'FiveLabTransactionalProxyInterface',
];
foreach ($this->getProxyMethods() as $method) {
$methodCodes[] = $this->generateProxyMethod($method);
}
$docComment = $class->getDocComment();
$templateVariables = [
'uses' => \implode("\n", $uses),
'namespace' => $class->getNamespaceName(),
'docComment' => $docComment,
'proxyClassName' => $class->getShortName().'Proxy',
'className' => '\\'.$class->getName(),
'proxyMethods' => \implode("\n\n", $methodCodes),
'interfaces' => \implode(', ', $interfaces),
'realClassName' => $class->getName(),
];
$template = $this->getTemplateForProxyClass();
$code = $this->replaceVariables($template, $templateVariables);
$lines = \explode("\n", $code);
$lines = \array_map('rtrim', $lines);
return \implode("\n", $lines);
} | php | private function generateProxyClass(): string
{
$class = $this->reflectionClass;
if ($class->isFinal()) {
throw new \RuntimeException(sprintf(
'Can not generate proxy for final class "%s".',
$class->getName()
));
}
if ($class->isAbstract()) {
throw new \RuntimeException(sprintf(
'Can not generate proxy for abstract class "%s".',
$class->getName()
));
}
$methodCodes = [];
$uses = $this->getAllUseStatementsMarkedAsAnnotation($class);
$uses[] = 'FiveLab\Component\Transactional\Proxy\ProxyInterface as FiveLabTransactionalProxyInterface';
$uses = \array_map(function ($use) {
return 'use '.$use.';';
}, $uses);
$interfaces = [
'FiveLabTransactionalProxyInterface',
];
foreach ($this->getProxyMethods() as $method) {
$methodCodes[] = $this->generateProxyMethod($method);
}
$docComment = $class->getDocComment();
$templateVariables = [
'uses' => \implode("\n", $uses),
'namespace' => $class->getNamespaceName(),
'docComment' => $docComment,
'proxyClassName' => $class->getShortName().'Proxy',
'className' => '\\'.$class->getName(),
'proxyMethods' => \implode("\n\n", $methodCodes),
'interfaces' => \implode(', ', $interfaces),
'realClassName' => $class->getName(),
];
$template = $this->getTemplateForProxyClass();
$code = $this->replaceVariables($template, $templateVariables);
$lines = \explode("\n", $code);
$lines = \array_map('rtrim', $lines);
return \implode("\n", $lines);
} | [
"private",
"function",
"generateProxyClass",
"(",
")",
":",
"string",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"reflectionClass",
";",
"if",
"(",
"$",
"class",
"->",
"isFinal",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Can not generate proxy for final class \"%s\".'",
",",
"$",
"class",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"class",
"->",
"isAbstract",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Can not generate proxy for abstract class \"%s\".'",
",",
"$",
"class",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"methodCodes",
"=",
"[",
"]",
";",
"$",
"uses",
"=",
"$",
"this",
"->",
"getAllUseStatementsMarkedAsAnnotation",
"(",
"$",
"class",
")",
";",
"$",
"uses",
"[",
"]",
"=",
"'FiveLab\\Component\\Transactional\\Proxy\\ProxyInterface as FiveLabTransactionalProxyInterface'",
";",
"$",
"uses",
"=",
"\\",
"array_map",
"(",
"function",
"(",
"$",
"use",
")",
"{",
"return",
"'use '",
".",
"$",
"use",
".",
"';'",
";",
"}",
",",
"$",
"uses",
")",
";",
"$",
"interfaces",
"=",
"[",
"'FiveLabTransactionalProxyInterface'",
",",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getProxyMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"methodCodes",
"[",
"]",
"=",
"$",
"this",
"->",
"generateProxyMethod",
"(",
"$",
"method",
")",
";",
"}",
"$",
"docComment",
"=",
"$",
"class",
"->",
"getDocComment",
"(",
")",
";",
"$",
"templateVariables",
"=",
"[",
"'uses'",
"=>",
"\\",
"implode",
"(",
"\"\\n\"",
",",
"$",
"uses",
")",
",",
"'namespace'",
"=>",
"$",
"class",
"->",
"getNamespaceName",
"(",
")",
",",
"'docComment'",
"=>",
"$",
"docComment",
",",
"'proxyClassName'",
"=>",
"$",
"class",
"->",
"getShortName",
"(",
")",
".",
"'Proxy'",
",",
"'className'",
"=>",
"'\\\\'",
".",
"$",
"class",
"->",
"getName",
"(",
")",
",",
"'proxyMethods'",
"=>",
"\\",
"implode",
"(",
"\"\\n\\n\"",
",",
"$",
"methodCodes",
")",
",",
"'interfaces'",
"=>",
"\\",
"implode",
"(",
"', '",
",",
"$",
"interfaces",
")",
",",
"'realClassName'",
"=>",
"$",
"class",
"->",
"getName",
"(",
")",
",",
"]",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplateForProxyClass",
"(",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"replaceVariables",
"(",
"$",
"template",
",",
"$",
"templateVariables",
")",
";",
"$",
"lines",
"=",
"\\",
"explode",
"(",
"\"\\n\"",
",",
"$",
"code",
")",
";",
"$",
"lines",
"=",
"\\",
"array_map",
"(",
"'rtrim'",
",",
"$",
"lines",
")",
";",
"return",
"\\",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lines",
")",
";",
"}"
] | Generate proxy class
@return string | [
"Generate",
"proxy",
"class"
] | d2a406543f9eab35ad618d7f4436090487508fc9 | https://github.com/FiveLab/Transactional/blob/d2a406543f9eab35ad618d7f4436090487508fc9/src/Proxy/Generator/ProxyCodeGenerator.php#L247-L302 |
10,528 | FiveLab/Transactional | src/Proxy/Generator/ProxyCodeGenerator.php | ProxyCodeGenerator.appendTabulationCharacter | private function appendTabulationCharacter($text, $count): string
{
$lines = \explode("\n", $text);
foreach ($lines as $index => $line) {
$lines[$index] = \str_repeat(" ", $count).rtrim($line);
}
return \implode(PHP_EOL, $lines);
} | php | private function appendTabulationCharacter($text, $count): string
{
$lines = \explode("\n", $text);
foreach ($lines as $index => $line) {
$lines[$index] = \str_repeat(" ", $count).rtrim($line);
}
return \implode(PHP_EOL, $lines);
} | [
"private",
"function",
"appendTabulationCharacter",
"(",
"$",
"text",
",",
"$",
"count",
")",
":",
"string",
"{",
"$",
"lines",
"=",
"\\",
"explode",
"(",
"\"\\n\"",
",",
"$",
"text",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"index",
"=>",
"$",
"line",
")",
"{",
"$",
"lines",
"[",
"$",
"index",
"]",
"=",
"\\",
"str_repeat",
"(",
"\" \"",
",",
"$",
"count",
")",
".",
"rtrim",
"(",
"$",
"line",
")",
";",
"}",
"return",
"\\",
"implode",
"(",
"PHP_EOL",
",",
"$",
"lines",
")",
";",
"}"
] | Append tabulation character for lines
@param string $text
@param integer $count
@return string | [
"Append",
"tabulation",
"character",
"for",
"lines"
] | d2a406543f9eab35ad618d7f4436090487508fc9 | https://github.com/FiveLab/Transactional/blob/d2a406543f9eab35ad618d7f4436090487508fc9/src/Proxy/Generator/ProxyCodeGenerator.php#L532-L541 |
10,529 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.move | public static function move($source, $des)
{
if (!is_file($source)) {
return false;
}
try {
@rename($source, $des);
return true;
} catch (\Exception $e) {
return false;
}
} | php | public static function move($source, $des)
{
if (!is_file($source)) {
return false;
}
try {
@rename($source, $des);
return true;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"static",
"function",
"move",
"(",
"$",
"source",
",",
"$",
"des",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"source",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"@",
"rename",
"(",
"$",
"source",
",",
"$",
"des",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | move the file or dir.
@param $source
@param $des
@return bool | [
"move",
"the",
"file",
"or",
"dir",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L21-L32 |
10,530 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.copy | public static function copy($source, $des)
{
if (!is_file($source)) {
return false;
}
try {
@copy($source, $des);
return true;
} catch (\Exception $e) {
return false;
}
} | php | public static function copy($source, $des)
{
if (!is_file($source)) {
return false;
}
try {
@copy($source, $des);
return true;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"static",
"function",
"copy",
"(",
"$",
"source",
",",
"$",
"des",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"source",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"@",
"copy",
"(",
"$",
"source",
",",
"$",
"des",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | copy the file.
@param $source
@param $des
@return bool | [
"copy",
"the",
"file",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L41-L52 |
10,531 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.remove | public static function remove($source)
{
if (!is_file($source)) {
return false;
}
try {
@unlink($source);
return true;
} catch (\Exception $e) {
return false;
}
} | php | public static function remove($source)
{
if (!is_file($source)) {
return false;
}
try {
@unlink($source);
return true;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"source",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"@",
"unlink",
"(",
"$",
"source",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | delete the file.
@param $source
@return bool | [
"delete",
"the",
"file",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L60-L71 |
10,532 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.create | public static function create($source, $data)
{
try {
$file = @fopen($source, 'w');
@fwrite($file, $data);
@fclose($file);
return true;
} catch (\Exception $e) {
return false;
}
} | php | public static function create($source, $data)
{
try {
$file = @fopen($source, 'w');
@fwrite($file, $data);
@fclose($file);
return true;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"source",
",",
"$",
"data",
")",
"{",
"try",
"{",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"source",
",",
"'w'",
")",
";",
"@",
"fwrite",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"@",
"fclose",
"(",
"$",
"file",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | create the file.
@param $source
@param $data
@return bool | [
"create",
"the",
"file",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L80-L90 |
10,533 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.append | public static function append($source, $data)
{
try {
if (is_file($source)) {
$file = @fopen($source, 'a');
@fwrite($file, $data);
@fclose($file);
return true;
}
} catch (\Exception $e) {
}
return false;
} | php | public static function append($source, $data)
{
try {
if (is_file($source)) {
$file = @fopen($source, 'a');
@fwrite($file, $data);
@fclose($file);
return true;
}
} catch (\Exception $e) {
}
return false;
} | [
"public",
"static",
"function",
"append",
"(",
"$",
"source",
",",
"$",
"data",
")",
"{",
"try",
"{",
"if",
"(",
"is_file",
"(",
"$",
"source",
")",
")",
"{",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"source",
",",
"'a'",
")",
";",
"@",
"fwrite",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"@",
"fclose",
"(",
"$",
"file",
")",
";",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"return",
"false",
";",
"}"
] | append the content to the file.
@param $source
@param $data
@return bool | [
"append",
"the",
"content",
"to",
"the",
"file",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L99-L111 |
10,534 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.read | public static function read($source, $length = 0)
{
if (!is_file($source) || !is_readable($source)) {
return false;
}
try {
if ($length <= 0 || $length > filesize($source)) {
return file_get_contents($source);
}
$file = @fopen($source, 'r');
$content = @fread($file, $length);
@fclose($file);
return $content;
} catch (\Exception $e) {
return false;
}
} | php | public static function read($source, $length = 0)
{
if (!is_file($source) || !is_readable($source)) {
return false;
}
try {
if ($length <= 0 || $length > filesize($source)) {
return file_get_contents($source);
}
$file = @fopen($source, 'r');
$content = @fread($file, $length);
@fclose($file);
return $content;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"static",
"function",
"read",
"(",
"$",
"source",
",",
"$",
"length",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"source",
")",
"||",
"!",
"is_readable",
"(",
"$",
"source",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"$",
"length",
"<=",
"0",
"||",
"$",
"length",
">",
"filesize",
"(",
"$",
"source",
")",
")",
"{",
"return",
"file_get_contents",
"(",
"$",
"source",
")",
";",
"}",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"source",
",",
"'r'",
")",
";",
"$",
"content",
"=",
"@",
"fread",
"(",
"$",
"file",
",",
"$",
"length",
")",
";",
"@",
"fclose",
"(",
"$",
"file",
")",
";",
"return",
"$",
"content",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | read the content from the fle.
@param $source
@param $length int
@return bool|string | [
"read",
"the",
"content",
"from",
"the",
"fle",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L120-L137 |
10,535 | cube-group/myaf-utils | src/FileUtil.php | FileUtil.saveInputAsFile | public static function saveInputAsFile($content, $tmpDir = '', $key = '')
{
if (!$tmpDir) {
$tmpDir = ini_get('upload_tmp_dir');
}
if (!is_dir($tmpDir)) {
return false;
}
if (!$key) {
$key = uniqid();
}
if (!$content) {
return false;
}
$tmp_file = realpath($tmpDir) . '/' . $key;
if (self::create($tmp_file, $content) > 0) {
return ['name' => $key, 'path' => $tmp_file];
} else {
return false;
}
} | php | public static function saveInputAsFile($content, $tmpDir = '', $key = '')
{
if (!$tmpDir) {
$tmpDir = ini_get('upload_tmp_dir');
}
if (!is_dir($tmpDir)) {
return false;
}
if (!$key) {
$key = uniqid();
}
if (!$content) {
return false;
}
$tmp_file = realpath($tmpDir) . '/' . $key;
if (self::create($tmp_file, $content) > 0) {
return ['name' => $key, 'path' => $tmp_file];
} else {
return false;
}
} | [
"public",
"static",
"function",
"saveInputAsFile",
"(",
"$",
"content",
",",
"$",
"tmpDir",
"=",
"''",
",",
"$",
"key",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"tmpDir",
")",
"{",
"$",
"tmpDir",
"=",
"ini_get",
"(",
"'upload_tmp_dir'",
")",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"tmpDir",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"uniqid",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"return",
"false",
";",
"}",
"$",
"tmp_file",
"=",
"realpath",
"(",
"$",
"tmpDir",
")",
".",
"'/'",
".",
"$",
"key",
";",
"if",
"(",
"self",
"::",
"create",
"(",
"$",
"tmp_file",
",",
"$",
"content",
")",
">",
"0",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"key",
",",
"'path'",
"=>",
"$",
"tmp_file",
"]",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | put the format php input stream into the temporary file.
return [
['name'=>'file name','path'=>'/var/cache/a.txt']
];
@param $content string
@param $tmpDir string
@param $key string
@return array|bool
@throws \Exception | [
"put",
"the",
"format",
"php",
"input",
"stream",
"into",
"the",
"temporary",
"file",
"."
] | febc3e1936ebdf763cf5478647e5ba22b3fd2812 | https://github.com/cube-group/myaf-utils/blob/febc3e1936ebdf763cf5478647e5ba22b3fd2812/src/FileUtil.php#L188-L208 |
10,536 | Djeg/Minibus | src/Knp/Minibus/Line/Line.php | Line.lead | public function lead(MinibusInterface $minibus)
{
// start the lead.
$startEvent = $this->eventFactory->createStart($minibus);
$this->dispatcher->dispatch(LineEvents::START, $startEvent);
$minibus = $startEvent->getMinibus();
// launch the stations
foreach ($this->stations as $station) {
$configuration = $this->stations[$station];
// pre validate entering passengers
$gateOpenEvent = $this->eventFactory->createGate($minibus, $station);
$this->dispatcher->dispatch(LineEvents::GATE_OPEN, $gateOpenEvent);
// parse the configuration if needed
if ($station instanceof Configurable) {
$configuration = $this->configurationProcessor->processConfiguration(
$station->getConfiguration(),
[$configuration]
);
}
// launch the station
$station->handle($minibus, $configuration);
// post validate leaving passengers
$gateCloseEvent = $this->eventFactory->createGate($minibus, $station);
$this->dispatcher->dispatch(LineEvents::GATE_CLOSE, $gateCloseEvent);
}
// process terminus configuration if needed
if (null !== $this->terminus and $this->terminus instanceof Configurable) {
$this->configuration = $this->configurationProcessor->processConfiguration(
$this->terminus->getConfiguration(),
[$this->configuration]
);
}
// terminate the line
$terminusEvent = $this->eventFactory->createTerminus(
$minibus,
$this->terminus,
$this->configuration
);
$this->dispatcher->dispatch(LineEvents::TERMINUS, $terminusEvent);
$terminus = $terminusEvent->getTerminus();
$configuration = $terminusEvent->getConfiguration();
return null === $terminus ? $minibus : $terminus->terminate($minibus, $configuration);
} | php | public function lead(MinibusInterface $minibus)
{
// start the lead.
$startEvent = $this->eventFactory->createStart($minibus);
$this->dispatcher->dispatch(LineEvents::START, $startEvent);
$minibus = $startEvent->getMinibus();
// launch the stations
foreach ($this->stations as $station) {
$configuration = $this->stations[$station];
// pre validate entering passengers
$gateOpenEvent = $this->eventFactory->createGate($minibus, $station);
$this->dispatcher->dispatch(LineEvents::GATE_OPEN, $gateOpenEvent);
// parse the configuration if needed
if ($station instanceof Configurable) {
$configuration = $this->configurationProcessor->processConfiguration(
$station->getConfiguration(),
[$configuration]
);
}
// launch the station
$station->handle($minibus, $configuration);
// post validate leaving passengers
$gateCloseEvent = $this->eventFactory->createGate($minibus, $station);
$this->dispatcher->dispatch(LineEvents::GATE_CLOSE, $gateCloseEvent);
}
// process terminus configuration if needed
if (null !== $this->terminus and $this->terminus instanceof Configurable) {
$this->configuration = $this->configurationProcessor->processConfiguration(
$this->terminus->getConfiguration(),
[$this->configuration]
);
}
// terminate the line
$terminusEvent = $this->eventFactory->createTerminus(
$minibus,
$this->terminus,
$this->configuration
);
$this->dispatcher->dispatch(LineEvents::TERMINUS, $terminusEvent);
$terminus = $terminusEvent->getTerminus();
$configuration = $terminusEvent->getConfiguration();
return null === $terminus ? $minibus : $terminus->terminate($minibus, $configuration);
} | [
"public",
"function",
"lead",
"(",
"MinibusInterface",
"$",
"minibus",
")",
"{",
"// start the lead.",
"$",
"startEvent",
"=",
"$",
"this",
"->",
"eventFactory",
"->",
"createStart",
"(",
"$",
"minibus",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"LineEvents",
"::",
"START",
",",
"$",
"startEvent",
")",
";",
"$",
"minibus",
"=",
"$",
"startEvent",
"->",
"getMinibus",
"(",
")",
";",
"// launch the stations",
"foreach",
"(",
"$",
"this",
"->",
"stations",
"as",
"$",
"station",
")",
"{",
"$",
"configuration",
"=",
"$",
"this",
"->",
"stations",
"[",
"$",
"station",
"]",
";",
"// pre validate entering passengers",
"$",
"gateOpenEvent",
"=",
"$",
"this",
"->",
"eventFactory",
"->",
"createGate",
"(",
"$",
"minibus",
",",
"$",
"station",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"LineEvents",
"::",
"GATE_OPEN",
",",
"$",
"gateOpenEvent",
")",
";",
"// parse the configuration if needed",
"if",
"(",
"$",
"station",
"instanceof",
"Configurable",
")",
"{",
"$",
"configuration",
"=",
"$",
"this",
"->",
"configurationProcessor",
"->",
"processConfiguration",
"(",
"$",
"station",
"->",
"getConfiguration",
"(",
")",
",",
"[",
"$",
"configuration",
"]",
")",
";",
"}",
"// launch the station",
"$",
"station",
"->",
"handle",
"(",
"$",
"minibus",
",",
"$",
"configuration",
")",
";",
"// post validate leaving passengers",
"$",
"gateCloseEvent",
"=",
"$",
"this",
"->",
"eventFactory",
"->",
"createGate",
"(",
"$",
"minibus",
",",
"$",
"station",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"LineEvents",
"::",
"GATE_CLOSE",
",",
"$",
"gateCloseEvent",
")",
";",
"}",
"// process terminus configuration if needed",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"terminus",
"and",
"$",
"this",
"->",
"terminus",
"instanceof",
"Configurable",
")",
"{",
"$",
"this",
"->",
"configuration",
"=",
"$",
"this",
"->",
"configurationProcessor",
"->",
"processConfiguration",
"(",
"$",
"this",
"->",
"terminus",
"->",
"getConfiguration",
"(",
")",
",",
"[",
"$",
"this",
"->",
"configuration",
"]",
")",
";",
"}",
"// terminate the line",
"$",
"terminusEvent",
"=",
"$",
"this",
"->",
"eventFactory",
"->",
"createTerminus",
"(",
"$",
"minibus",
",",
"$",
"this",
"->",
"terminus",
",",
"$",
"this",
"->",
"configuration",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"LineEvents",
"::",
"TERMINUS",
",",
"$",
"terminusEvent",
")",
";",
"$",
"terminus",
"=",
"$",
"terminusEvent",
"->",
"getTerminus",
"(",
")",
";",
"$",
"configuration",
"=",
"$",
"terminusEvent",
"->",
"getConfiguration",
"(",
")",
";",
"return",
"null",
"===",
"$",
"terminus",
"?",
"$",
"minibus",
":",
"$",
"terminus",
"->",
"terminate",
"(",
"$",
"minibus",
",",
"$",
"configuration",
")",
";",
"}"
] | Lead the minibus thrie all the stations. If you have defined a Terminus
then the terminus resolved data should be return else the minibus is return.
This method also dispatch events
@see LineEvents
@param Minibus $minibus
@return Minibus|mixed | [
"Lead",
"the",
"minibus",
"thrie",
"all",
"the",
"stations",
".",
"If",
"you",
"have",
"defined",
"a",
"Terminus",
"then",
"the",
"terminus",
"resolved",
"data",
"should",
"be",
"return",
"else",
"the",
"minibus",
"is",
"return",
".",
"This",
"method",
"also",
"dispatch",
"events"
] | 59a9c348469294fc97f305cd5002e488e8b12370 | https://github.com/Djeg/Minibus/blob/59a9c348469294fc97f305cd5002e488e8b12370/src/Knp/Minibus/Line/Line.php#L82-L133 |
10,537 | themichaelhall/bluemvc-core | src/Base/AbstractRequest.php | AbstractRequest.getCookieValue | public function getCookieValue(string $name): ?string
{
$cookie = $this->cookies->get($name);
return $cookie !== null ? $cookie->getValue() : null;
} | php | public function getCookieValue(string $name): ?string
{
$cookie = $this->cookies->get($name);
return $cookie !== null ? $cookie->getValue() : null;
} | [
"public",
"function",
"getCookieValue",
"(",
"string",
"$",
"name",
")",
":",
"?",
"string",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"cookies",
"->",
"get",
"(",
"$",
"name",
")",
";",
"return",
"$",
"cookie",
"!==",
"null",
"?",
"$",
"cookie",
"->",
"getValue",
"(",
")",
":",
"null",
";",
"}"
] | Returns the cookie value by cookie name if it exists, null otherwise.
@since 1.1.0
@param string $name The cookie name.
@return string|null The cookie value by cookie name if it exists, false otherwise. | [
"Returns",
"the",
"cookie",
"value",
"by",
"cookie",
"name",
"if",
"it",
"exists",
"null",
"otherwise",
"."
] | cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680 | https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Base/AbstractRequest.php#L80-L85 |
10,538 | themichaelhall/bluemvc-core | src/Base/AbstractRequest.php | AbstractRequest.getReferrer | public function getReferrer(): ?UrlInterface
{
$referrerHeader = $this->getHeader('Referer');
if ($referrerHeader === null) {
return null;
}
return Url::tryParse($referrerHeader);
} | php | public function getReferrer(): ?UrlInterface
{
$referrerHeader = $this->getHeader('Referer');
if ($referrerHeader === null) {
return null;
}
return Url::tryParse($referrerHeader);
} | [
"public",
"function",
"getReferrer",
"(",
")",
":",
"?",
"UrlInterface",
"{",
"$",
"referrerHeader",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"'Referer'",
")",
";",
"if",
"(",
"$",
"referrerHeader",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Url",
"::",
"tryParse",
"(",
"$",
"referrerHeader",
")",
";",
"}"
] | Returns the referrer or null if request has no or invalid referrer.
@since 1.1.0
@return UrlInterface|null The referrer or null if request has no or invalid referrer. | [
"Returns",
"the",
"referrer",
"or",
"null",
"if",
"request",
"has",
"no",
"or",
"invalid",
"referrer",
"."
] | cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680 | https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Base/AbstractRequest.php#L196-L204 |
10,539 | themichaelhall/bluemvc-core | src/Base/AbstractRequest.php | AbstractRequest.setSessionItem | public function setSessionItem(string $name, $value): void
{
$this->sessionItems->set($name, $value);
} | php | public function setSessionItem(string $name, $value): void
{
$this->sessionItems->set($name, $value);
} | [
"public",
"function",
"setSessionItem",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"sessionItems",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] | Sets a session item.
@since 2.0.0
@param string $name The session item name.
@param mixed $value The session item value. | [
"Sets",
"a",
"session",
"item",
"."
] | cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680 | https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Base/AbstractRequest.php#L302-L305 |
10,540 | phplegends/legion | src/Routing/Dispatcher.php | Dispatcher.buildRouteAction | protected function buildRouteAction(Route $route)
{
$action = $route->getAction();
if ($action instanceof \Closure) {
$controller = new Controller();
return $action->bindTo($controller, get_class($controller));
}
list ($class, $method) = $action;
$class = new $class;
return [$class, $method];
} | php | protected function buildRouteAction(Route $route)
{
$action = $route->getAction();
if ($action instanceof \Closure) {
$controller = new Controller();
return $action->bindTo($controller, get_class($controller));
}
list ($class, $method) = $action;
$class = new $class;
return [$class, $method];
} | [
"protected",
"function",
"buildRouteAction",
"(",
"Route",
"$",
"route",
")",
"{",
"$",
"action",
"=",
"$",
"route",
"->",
"getAction",
"(",
")",
";",
"if",
"(",
"$",
"action",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"controller",
"=",
"new",
"Controller",
"(",
")",
";",
"return",
"$",
"action",
"->",
"bindTo",
"(",
"$",
"controller",
",",
"get_class",
"(",
"$",
"controller",
")",
")",
";",
"}",
"list",
"(",
"$",
"class",
",",
"$",
"method",
")",
"=",
"$",
"action",
";",
"$",
"class",
"=",
"new",
"$",
"class",
";",
"return",
"[",
"$",
"class",
",",
"$",
"method",
"]",
";",
"}"
] | Overwrites buildRouteAction of Trait
@param PHPLegends\Routes\Route $route
@return callable | [
"Overwrites",
"buildRouteAction",
"of",
"Trait"
] | 270eae47bdb27abda0d77d07f8af0fdf99c86ef1 | https://github.com/phplegends/legion/blob/270eae47bdb27abda0d77d07f8af0fdf99c86ef1/src/Routing/Dispatcher.php#L127-L143 |
10,541 | nice-php/doctrine-key-value | src/Extension/DoctrineKeyValueExtension.php | DoctrineKeyValueExtension.configureStorage | private function configureStorage(array $config, ContainerBuilder $container)
{
$container->register('doctrine.key_value.storage', 'Doctrine\KeyValueStore\Storage\DoctrineCacheStorage')
->setPublic(false)
->addArgument(new Reference('cache.' . $config['cache_driver']));
} | php | private function configureStorage(array $config, ContainerBuilder $container)
{
$container->register('doctrine.key_value.storage', 'Doctrine\KeyValueStore\Storage\DoctrineCacheStorage')
->setPublic(false)
->addArgument(new Reference('cache.' . $config['cache_driver']));
} | [
"private",
"function",
"configureStorage",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"container",
"->",
"register",
"(",
"'doctrine.key_value.storage'",
",",
"'Doctrine\\KeyValueStore\\Storage\\DoctrineCacheStorage'",
")",
"->",
"setPublic",
"(",
"false",
")",
"->",
"addArgument",
"(",
"new",
"Reference",
"(",
"'cache.'",
".",
"$",
"config",
"[",
"'cache_driver'",
"]",
")",
")",
";",
"}"
] | Configure the data store.
@param array $config
@param ContainerBuilder $container | [
"Configure",
"the",
"data",
"store",
"."
] | dbfa2bce94c940f2384737a64b42729cfcc141cd | https://github.com/nice-php/doctrine-key-value/blob/dbfa2bce94c940f2384737a64b42729cfcc141cd/src/Extension/DoctrineKeyValueExtension.php#L64-L69 |
10,542 | nice-php/doctrine-key-value | src/Extension/DoctrineKeyValueExtension.php | DoctrineKeyValueExtension.configureMetadataDriver | private function configureMetadataDriver(array $config, ContainerBuilder $container)
{
$container->register('doctrine.key_value.metadata.annotation.reader', 'Doctrine\Common\Annotations\AnnotationReader')
->setPublic(false);
$container->register('doctrine.key_value.metadata.annotation', 'Doctrine\KeyValueStore\Mapping\AnnotationDriver')
->setPublic(false)
->addArgument(new Reference('doctrine.key_value.metadata.annotation.reader'));
} | php | private function configureMetadataDriver(array $config, ContainerBuilder $container)
{
$container->register('doctrine.key_value.metadata.annotation.reader', 'Doctrine\Common\Annotations\AnnotationReader')
->setPublic(false);
$container->register('doctrine.key_value.metadata.annotation', 'Doctrine\KeyValueStore\Mapping\AnnotationDriver')
->setPublic(false)
->addArgument(new Reference('doctrine.key_value.metadata.annotation.reader'));
} | [
"private",
"function",
"configureMetadataDriver",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"container",
"->",
"register",
"(",
"'doctrine.key_value.metadata.annotation.reader'",
",",
"'Doctrine\\Common\\Annotations\\AnnotationReader'",
")",
"->",
"setPublic",
"(",
"false",
")",
";",
"$",
"container",
"->",
"register",
"(",
"'doctrine.key_value.metadata.annotation'",
",",
"'Doctrine\\KeyValueStore\\Mapping\\AnnotationDriver'",
")",
"->",
"setPublic",
"(",
"false",
")",
"->",
"addArgument",
"(",
"new",
"Reference",
"(",
"'doctrine.key_value.metadata.annotation.reader'",
")",
")",
";",
"}"
] | Configure the metadata driver.
@param array $config
@param ContainerBuilder $container | [
"Configure",
"the",
"metadata",
"driver",
"."
] | dbfa2bce94c940f2384737a64b42729cfcc141cd | https://github.com/nice-php/doctrine-key-value/blob/dbfa2bce94c940f2384737a64b42729cfcc141cd/src/Extension/DoctrineKeyValueExtension.php#L77-L85 |
10,543 | nice-php/doctrine-key-value | src/Extension/DoctrineKeyValueExtension.php | DoctrineKeyValueExtension.configureEntityManager | private function configureEntityManager(array $config, ContainerBuilder $container)
{
$container->register('doctrine.key_value.configuration', 'Doctrine\KeyValueStore\Configuration')
->addMethodCall('setMappingDriverImpl', array(new Reference('doctrine.key_value.metadata.annotation')));
$container->register('doctrine.key_value.entity_manager', 'Doctrine\KeyValueStore\EntityManager')
->addArgument(new Reference('doctrine.key_value.storage'))
->addArgument(new Reference('doctrine.key_value.configuration'));
} | php | private function configureEntityManager(array $config, ContainerBuilder $container)
{
$container->register('doctrine.key_value.configuration', 'Doctrine\KeyValueStore\Configuration')
->addMethodCall('setMappingDriverImpl', array(new Reference('doctrine.key_value.metadata.annotation')));
$container->register('doctrine.key_value.entity_manager', 'Doctrine\KeyValueStore\EntityManager')
->addArgument(new Reference('doctrine.key_value.storage'))
->addArgument(new Reference('doctrine.key_value.configuration'));
} | [
"private",
"function",
"configureEntityManager",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"container",
"->",
"register",
"(",
"'doctrine.key_value.configuration'",
",",
"'Doctrine\\KeyValueStore\\Configuration'",
")",
"->",
"addMethodCall",
"(",
"'setMappingDriverImpl'",
",",
"array",
"(",
"new",
"Reference",
"(",
"'doctrine.key_value.metadata.annotation'",
")",
")",
")",
";",
"$",
"container",
"->",
"register",
"(",
"'doctrine.key_value.entity_manager'",
",",
"'Doctrine\\KeyValueStore\\EntityManager'",
")",
"->",
"addArgument",
"(",
"new",
"Reference",
"(",
"'doctrine.key_value.storage'",
")",
")",
"->",
"addArgument",
"(",
"new",
"Reference",
"(",
"'doctrine.key_value.configuration'",
")",
")",
";",
"}"
] | Configure the entity manager.
@param array $config
@param ContainerBuilder $container | [
"Configure",
"the",
"entity",
"manager",
"."
] | dbfa2bce94c940f2384737a64b42729cfcc141cd | https://github.com/nice-php/doctrine-key-value/blob/dbfa2bce94c940f2384737a64b42729cfcc141cd/src/Extension/DoctrineKeyValueExtension.php#L93-L101 |
10,544 | xjtuana-dev/xjtu-api-php | lib/XjtuApi.php | XjtuApi.http | protected function http() {
// 若$this->http不是\GuzzleHttp\Client实例,则创建一个
if (!$this->http instanceof Client) {
$this->http = new Client(
array_merge(
[ 'base_uri' => $this->url ],
$this->options
)
);
}
return $this->http;
} | php | protected function http() {
// 若$this->http不是\GuzzleHttp\Client实例,则创建一个
if (!$this->http instanceof Client) {
$this->http = new Client(
array_merge(
[ 'base_uri' => $this->url ],
$this->options
)
);
}
return $this->http;
} | [
"protected",
"function",
"http",
"(",
")",
"{",
"// 若$this->http不是\\GuzzleHttp\\Client实例,则创建一个",
"if",
"(",
"!",
"$",
"this",
"->",
"http",
"instanceof",
"Client",
")",
"{",
"$",
"this",
"->",
"http",
"=",
"new",
"Client",
"(",
"array_merge",
"(",
"[",
"'base_uri'",
"=>",
"$",
"this",
"->",
"url",
"]",
",",
"$",
"this",
"->",
"options",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"http",
";",
"}"
] | Get the http client instance
@return \GuzzleHttp\Client | [
"Get",
"the",
"http",
"client",
"instance"
] | e9cc1574b7546d9e35abda27bfabe251a639d547 | https://github.com/xjtuana-dev/xjtu-api-php/blob/e9cc1574b7546d9e35abda27bfabe251a639d547/lib/XjtuApi.php#L68-L80 |
10,545 | xloit/xloit-bridge-zend-authentication | src/AuthenticationService.php | AuthenticationService.getEvent | public function getEvent()
{
if (null === $this->event) {
$event = new AuthenticationEvent();
$this->setEvent($event);
}
return $this->event;
} | php | public function getEvent()
{
if (null === $this->event) {
$event = new AuthenticationEvent();
$this->setEvent($event);
}
return $this->event;
} | [
"public",
"function",
"getEvent",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"event",
")",
"{",
"$",
"event",
"=",
"new",
"AuthenticationEvent",
"(",
")",
";",
"$",
"this",
"->",
"setEvent",
"(",
"$",
"event",
")",
";",
"}",
"return",
"$",
"this",
"->",
"event",
";",
"}"
] | Get the auth event.
@return AuthenticationEvent
@throws \Zend\EventManager\Exception\InvalidArgumentException | [
"Get",
"the",
"auth",
"event",
"."
] | 299c6ad8d5756c8db040b39a50ecfcc137c42b72 | https://github.com/xloit/xloit-bridge-zend-authentication/blob/299c6ad8d5756c8db040b39a50ecfcc137c42b72/src/AuthenticationService.php#L164-L173 |
10,546 | xloit/xloit-bridge-zend-authentication | src/AuthenticationService.php | AuthenticationService.setEvent | public function setEvent(EventInterface $event)
{
$target = $this;
if (!($event instanceof AuthenticationEvent)) {
$eventParams = $event->getParams();
$eventTarget = $event->getTarget();
if ($eventTarget) {
$target = $eventTarget;
}
$event = new AuthenticationEvent();
$event->setParams($eventParams);
}
$event->setIdentity(null)->setTarget($target);
$this->event = $event;
return $this;
} | php | public function setEvent(EventInterface $event)
{
$target = $this;
if (!($event instanceof AuthenticationEvent)) {
$eventParams = $event->getParams();
$eventTarget = $event->getTarget();
if ($eventTarget) {
$target = $eventTarget;
}
$event = new AuthenticationEvent();
$event->setParams($eventParams);
}
$event->setIdentity(null)->setTarget($target);
$this->event = $event;
return $this;
} | [
"public",
"function",
"setEvent",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"$",
"target",
"=",
"$",
"this",
";",
"if",
"(",
"!",
"(",
"$",
"event",
"instanceof",
"AuthenticationEvent",
")",
")",
"{",
"$",
"eventParams",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"eventTarget",
"=",
"$",
"event",
"->",
"getTarget",
"(",
")",
";",
"if",
"(",
"$",
"eventTarget",
")",
"{",
"$",
"target",
"=",
"$",
"eventTarget",
";",
"}",
"$",
"event",
"=",
"new",
"AuthenticationEvent",
"(",
")",
";",
"$",
"event",
"->",
"setParams",
"(",
"$",
"eventParams",
")",
";",
"}",
"$",
"event",
"->",
"setIdentity",
"(",
"null",
")",
"->",
"setTarget",
"(",
"$",
"target",
")",
";",
"$",
"this",
"->",
"event",
"=",
"$",
"event",
";",
"return",
"$",
"this",
";",
"}"
] | Set an event to use during dispatch.
By default, will re-cast to AdapterChainEvent if another event type is provided.
@param EventInterface $event
@return $this
@throws \Zend\EventManager\Exception\InvalidArgumentException | [
"Set",
"an",
"event",
"to",
"use",
"during",
"dispatch",
".",
"By",
"default",
"will",
"re",
"-",
"cast",
"to",
"AdapterChainEvent",
"if",
"another",
"event",
"type",
"is",
"provided",
"."
] | 299c6ad8d5756c8db040b39a50ecfcc137c42b72 | https://github.com/xloit/xloit-bridge-zend-authentication/blob/299c6ad8d5756c8db040b39a50ecfcc137c42b72/src/AuthenticationService.php#L184-L206 |
10,547 | xloit/xloit-bridge-zend-authentication | src/AuthenticationService.php | AuthenticationService.sign | public function sign($username, $password, Adapter\AdapterInterface $adapter = null, Request $request = null)
{
/** @var Adapter\AdapterInterface $adapter */
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$adapter = $adapter ?: $this->getAdapter();
$adapter->setIdentity($username);
$adapter->setCredential($password);
return $this->authenticate($adapter, $request);
} | php | public function sign($username, $password, Adapter\AdapterInterface $adapter = null, Request $request = null)
{
/** @var Adapter\AdapterInterface $adapter */
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$adapter = $adapter ?: $this->getAdapter();
$adapter->setIdentity($username);
$adapter->setCredential($password);
return $this->authenticate($adapter, $request);
} | [
"public",
"function",
"sign",
"(",
"$",
"username",
",",
"$",
"password",
",",
"Adapter",
"\\",
"AdapterInterface",
"$",
"adapter",
"=",
"null",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"/** @var Adapter\\AdapterInterface $adapter */",
"/** @noinspection CallableParameterUseCaseInTypeContextInspection */",
"$",
"adapter",
"=",
"$",
"adapter",
"?",
":",
"$",
"this",
"->",
"getAdapter",
"(",
")",
";",
"$",
"adapter",
"->",
"setIdentity",
"(",
"$",
"username",
")",
";",
"$",
"adapter",
"->",
"setCredential",
"(",
"$",
"password",
")",
";",
"return",
"$",
"this",
"->",
"authenticate",
"(",
"$",
"adapter",
",",
"$",
"request",
")",
";",
"}"
] | Sign-in and provides an authentication result.
@param string $username
@param string $password
@param Adapter\AdapterInterface|null $adapter
@param Request $request
@return AuthenticationResult
@throws \Xloit\Bridge\Zend\Authentication\Exception\AuthenticationStopException
@throws \Xloit\Bridge\Zend\Authentication\Exception\RuntimeException
@throws \Zend\Authentication\Adapter\Exception\ExceptionInterface
@throws \Zend\Authentication\Exception\RuntimeException
@throws \Zend\Authentication\Exception\ExceptionInterface
@throws \Zend\EventManager\Exception\InvalidArgumentException | [
"Sign",
"-",
"in",
"and",
"provides",
"an",
"authentication",
"result",
"."
] | 299c6ad8d5756c8db040b39a50ecfcc137c42b72 | https://github.com/xloit/xloit-bridge-zend-authentication/blob/299c6ad8d5756c8db040b39a50ecfcc137c42b72/src/AuthenticationService.php#L301-L311 |
10,548 | xloit/xloit-bridge-zend-authentication | src/AuthenticationService.php | AuthenticationService.logout | public function logout(Adapter\AdapterInterface $adapter = null, Request $request = null)
{
$event = $this->prepareEvent($adapter, $request);
$event->setResult($event->getAdapter()->logout());
$this->clearIdentity();
return $this->triggerEventResult(AuthenticationEvent::AUTH_LOGOUT, $event);
} | php | public function logout(Adapter\AdapterInterface $adapter = null, Request $request = null)
{
$event = $this->prepareEvent($adapter, $request);
$event->setResult($event->getAdapter()->logout());
$this->clearIdentity();
return $this->triggerEventResult(AuthenticationEvent::AUTH_LOGOUT, $event);
} | [
"public",
"function",
"logout",
"(",
"Adapter",
"\\",
"AdapterInterface",
"$",
"adapter",
"=",
"null",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"event",
"=",
"$",
"this",
"->",
"prepareEvent",
"(",
"$",
"adapter",
",",
"$",
"request",
")",
";",
"$",
"event",
"->",
"setResult",
"(",
"$",
"event",
"->",
"getAdapter",
"(",
")",
"->",
"logout",
"(",
")",
")",
";",
"$",
"this",
"->",
"clearIdentity",
"(",
")",
";",
"return",
"$",
"this",
"->",
"triggerEventResult",
"(",
"AuthenticationEvent",
"::",
"AUTH_LOGOUT",
",",
"$",
"event",
")",
";",
"}"
] | Logout and provides an authentication result.
@param Adapter\AdapterInterface|null $adapter
@param Request $request
@return AuthenticationResult
@throws \Xloit\Bridge\Zend\Authentication\Exception\AuthenticationStopException
@throws \Xloit\Bridge\Zend\Authentication\Exception\RuntimeException
@throws \Zend\Authentication\Exception\ExceptionInterface
@throws \Zend\EventManager\Exception\InvalidArgumentException | [
"Logout",
"and",
"provides",
"an",
"authentication",
"result",
"."
] | 299c6ad8d5756c8db040b39a50ecfcc137c42b72 | https://github.com/xloit/xloit-bridge-zend-authentication/blob/299c6ad8d5756c8db040b39a50ecfcc137c42b72/src/AuthenticationService.php#L325-L334 |
10,549 | AthensFramework/Core | src/field/Field.php | Field.getSubmitted | public function getSubmitted()
{
$fieldType = $this->getType();
$data = array_key_exists($this->getSlug(), $_POST) === true ? $_POST[$this->getSlug()]: "";
if (in_array($fieldType, [static::TYPE_CHOICE, static::TYPE_MULTIPLE_CHOICE]) === true) {
$data = $this->parseChoiceSlugs($data);
if (is_array($data) === true) {
foreach ($data as $index => $datum) {
$data[$index] = $datum->getValue();
}
} else {
$data = $data->getValue();
}
}
return $data;
} | php | public function getSubmitted()
{
$fieldType = $this->getType();
$data = array_key_exists($this->getSlug(), $_POST) === true ? $_POST[$this->getSlug()]: "";
if (in_array($fieldType, [static::TYPE_CHOICE, static::TYPE_MULTIPLE_CHOICE]) === true) {
$data = $this->parseChoiceSlugs($data);
if (is_array($data) === true) {
foreach ($data as $index => $datum) {
$data[$index] = $datum->getValue();
}
} else {
$data = $data->getValue();
}
}
return $data;
} | [
"public",
"function",
"getSubmitted",
"(",
")",
"{",
"$",
"fieldType",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"$",
"data",
"=",
"array_key_exists",
"(",
"$",
"this",
"->",
"getSlug",
"(",
")",
",",
"$",
"_POST",
")",
"===",
"true",
"?",
"$",
"_POST",
"[",
"$",
"this",
"->",
"getSlug",
"(",
")",
"]",
":",
"\"\"",
";",
"if",
"(",
"in_array",
"(",
"$",
"fieldType",
",",
"[",
"static",
"::",
"TYPE_CHOICE",
",",
"static",
"::",
"TYPE_MULTIPLE_CHOICE",
"]",
")",
"===",
"true",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"parseChoiceSlugs",
"(",
"$",
"data",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"index",
"=>",
"$",
"datum",
")",
"{",
"$",
"data",
"[",
"$",
"index",
"]",
"=",
"$",
"datum",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | Provides the data that was submitted to this field, if applicable.
@return string | [
"Provides",
"the",
"data",
"that",
"was",
"submitted",
"to",
"this",
"field",
"if",
"applicable",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/field/Field.php#L116-L135 |
10,550 | AthensFramework/Core | src/field/Field.php | Field.getChoiceSlugs | protected function getChoiceSlugs()
{
$choiceSlugs = [];
foreach ($this->choices as $index => $choice) {
$choiceSlugs[] = StringUtils::slugify("$index-{$choice->getAlias()}");
}
return $choiceSlugs;
} | php | protected function getChoiceSlugs()
{
$choiceSlugs = [];
foreach ($this->choices as $index => $choice) {
$choiceSlugs[] = StringUtils::slugify("$index-{$choice->getAlias()}");
}
return $choiceSlugs;
} | [
"protected",
"function",
"getChoiceSlugs",
"(",
")",
"{",
"$",
"choiceSlugs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"choices",
"as",
"$",
"index",
"=>",
"$",
"choice",
")",
"{",
"$",
"choiceSlugs",
"[",
"]",
"=",
"StringUtils",
"::",
"slugify",
"(",
"\"$index-{$choice->getAlias()}\"",
")",
";",
"}",
"return",
"$",
"choiceSlugs",
";",
"}"
] | Provides the slugs which shall be used to identify valid submissions to this field.
@return string[] | [
"Provides",
"the",
"slugs",
"which",
"shall",
"be",
"used",
"to",
"identify",
"valid",
"submissions",
"to",
"this",
"field",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/field/Field.php#L184-L192 |
10,551 | AthensFramework/Core | src/field/Field.php | Field.setInitial | public function setInitial($value)
{
if ($value instanceof DateTime) {
$value = new DateTimeWrapper($value->format('c'));
}
$this->initial = $value;
return $this;
} | php | public function setInitial($value)
{
if ($value instanceof DateTime) {
$value = new DateTimeWrapper($value->format('c'));
}
$this->initial = $value;
return $this;
} | [
"public",
"function",
"setInitial",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"DateTime",
")",
"{",
"$",
"value",
"=",
"new",
"DateTimeWrapper",
"(",
"$",
"value",
"->",
"format",
"(",
"'c'",
")",
")",
";",
"}",
"$",
"this",
"->",
"initial",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the initial value to be displayed by the field.
@param string $value
@return FieldInterface | [
"Sets",
"the",
"initial",
"value",
"to",
"be",
"displayed",
"by",
"the",
"field",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/field/Field.php#L332-L340 |
10,552 | AthensFramework/Core | src/field/Field.php | Field.validate | public function validate()
{
$data = $this->wasSubmitted() === true ? $this->getSubmitted() : null;
// Invalid selection on choice/multiple choice field
if ($data === []) {
$this->addError("Unrecognized choice.");
}
if ($this->isRequired() === true && $data === null) {
$this->addError("This field is required.");
}
if ($this->getErrors() === []) {
$this->setValidatedData($data);
}
} | php | public function validate()
{
$data = $this->wasSubmitted() === true ? $this->getSubmitted() : null;
// Invalid selection on choice/multiple choice field
if ($data === []) {
$this->addError("Unrecognized choice.");
}
if ($this->isRequired() === true && $data === null) {
$this->addError("This field is required.");
}
if ($this->getErrors() === []) {
$this->setValidatedData($data);
}
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"wasSubmitted",
"(",
")",
"===",
"true",
"?",
"$",
"this",
"->",
"getSubmitted",
"(",
")",
":",
"null",
";",
"// Invalid selection on choice/multiple choice field",
"if",
"(",
"$",
"data",
"===",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"\"Unrecognized choice.\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isRequired",
"(",
")",
"===",
"true",
"&&",
"$",
"data",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"\"This field is required.\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getErrors",
"(",
")",
"===",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setValidatedData",
"(",
"$",
"data",
")",
";",
"}",
"}"
] | Perform basic validation on the field, add any apparent errors, and
mark valid data.
@return void | [
"Perform",
"basic",
"validation",
"on",
"the",
"field",
"add",
"any",
"apparent",
"errors",
"and",
"mark",
"valid",
"data",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/field/Field.php#L393-L409 |
10,553 | InnoGr/FivePercent-Api | src/EventListener/ApiAuthorizationSubscriber.php | ApiAuthorizationSubscriber.authorize | public function authorize(ActionDispatchEvent $event)
{
$callable = $event->getCallable();
if (!$callable->isMethod() && !$callable->isMethodStatic()) {
// Native function or \Closure
return;
}
$class = $callable->getReflection()->getDeclaringClass()->getName();
$method = $callable->getReflection()->getName();
$parameters = $event->getParameters();
$action = $event->getAction();
foreach ($action->getSecurityGroups() as $group) {
$authorized = $this->authorizationChecker
->isGrantedMethodCall($class, $method, $parameters, [], $group);
if (!$authorized) {
throw new AccessDeniedException();
}
}
} | php | public function authorize(ActionDispatchEvent $event)
{
$callable = $event->getCallable();
if (!$callable->isMethod() && !$callable->isMethodStatic()) {
// Native function or \Closure
return;
}
$class = $callable->getReflection()->getDeclaringClass()->getName();
$method = $callable->getReflection()->getName();
$parameters = $event->getParameters();
$action = $event->getAction();
foreach ($action->getSecurityGroups() as $group) {
$authorized = $this->authorizationChecker
->isGrantedMethodCall($class, $method, $parameters, [], $group);
if (!$authorized) {
throw new AccessDeniedException();
}
}
} | [
"public",
"function",
"authorize",
"(",
"ActionDispatchEvent",
"$",
"event",
")",
"{",
"$",
"callable",
"=",
"$",
"event",
"->",
"getCallable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"callable",
"->",
"isMethod",
"(",
")",
"&&",
"!",
"$",
"callable",
"->",
"isMethodStatic",
"(",
")",
")",
"{",
"// Native function or \\Closure",
"return",
";",
"}",
"$",
"class",
"=",
"$",
"callable",
"->",
"getReflection",
"(",
")",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"method",
"=",
"$",
"callable",
"->",
"getReflection",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"parameters",
"=",
"$",
"event",
"->",
"getParameters",
"(",
")",
";",
"$",
"action",
"=",
"$",
"event",
"->",
"getAction",
"(",
")",
";",
"foreach",
"(",
"$",
"action",
"->",
"getSecurityGroups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"$",
"authorized",
"=",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGrantedMethodCall",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"parameters",
",",
"[",
"]",
",",
"$",
"group",
")",
";",
"if",
"(",
"!",
"$",
"authorized",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
")",
";",
"}",
"}",
"}"
] | Authorize and authenticate on API method
@param ActionDispatchEvent $event | [
"Authorize",
"and",
"authenticate",
"on",
"API",
"method"
] | 57b78ddc3c9d91a7139c276711e5792824ceab9c | https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/EventListener/ApiAuthorizationSubscriber.php#L48-L70 |
10,554 | loevgaard/dandomain-foundation-bundle | Updater/DeliveryUpdater.php | DeliveryUpdater.updateFromEmbeddedApiResponse | public function updateFromEmbeddedApiResponse(array $data, DeliveryInterface $delivery = null): DeliveryInterface
{
if (!$delivery) {
$delivery = new Delivery();
}
$delivery
->setAddress($data['address'])
->setAddress2($data['address2'])
->setAttention($data['attention'])
->setCity($data['city'])
->setCountry($data['country'])
->setCountryId($data['countryId'])
->setCvr($data['cvr'])
->setEan($data['ean'])
->setEmail($data['email'])
->setFax($data['fax'])
->setName($data['name'])
->setPhone($data['phone'])
->setState($data['state'])
->setZipCode($data['zipCode'])
;
return $delivery;
} | php | public function updateFromEmbeddedApiResponse(array $data, DeliveryInterface $delivery = null): DeliveryInterface
{
if (!$delivery) {
$delivery = new Delivery();
}
$delivery
->setAddress($data['address'])
->setAddress2($data['address2'])
->setAttention($data['attention'])
->setCity($data['city'])
->setCountry($data['country'])
->setCountryId($data['countryId'])
->setCvr($data['cvr'])
->setEan($data['ean'])
->setEmail($data['email'])
->setFax($data['fax'])
->setName($data['name'])
->setPhone($data['phone'])
->setState($data['state'])
->setZipCode($data['zipCode'])
;
return $delivery;
} | [
"public",
"function",
"updateFromEmbeddedApiResponse",
"(",
"array",
"$",
"data",
",",
"DeliveryInterface",
"$",
"delivery",
"=",
"null",
")",
":",
"DeliveryInterface",
"{",
"if",
"(",
"!",
"$",
"delivery",
")",
"{",
"$",
"delivery",
"=",
"new",
"Delivery",
"(",
")",
";",
"}",
"$",
"delivery",
"->",
"setAddress",
"(",
"$",
"data",
"[",
"'address'",
"]",
")",
"->",
"setAddress2",
"(",
"$",
"data",
"[",
"'address2'",
"]",
")",
"->",
"setAttention",
"(",
"$",
"data",
"[",
"'attention'",
"]",
")",
"->",
"setCity",
"(",
"$",
"data",
"[",
"'city'",
"]",
")",
"->",
"setCountry",
"(",
"$",
"data",
"[",
"'country'",
"]",
")",
"->",
"setCountryId",
"(",
"$",
"data",
"[",
"'countryId'",
"]",
")",
"->",
"setCvr",
"(",
"$",
"data",
"[",
"'cvr'",
"]",
")",
"->",
"setEan",
"(",
"$",
"data",
"[",
"'ean'",
"]",
")",
"->",
"setEmail",
"(",
"$",
"data",
"[",
"'email'",
"]",
")",
"->",
"setFax",
"(",
"$",
"data",
"[",
"'fax'",
"]",
")",
"->",
"setName",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
"->",
"setPhone",
"(",
"$",
"data",
"[",
"'phone'",
"]",
")",
"->",
"setState",
"(",
"$",
"data",
"[",
"'state'",
"]",
")",
"->",
"setZipCode",
"(",
"$",
"data",
"[",
"'zipCode'",
"]",
")",
";",
"return",
"$",
"delivery",
";",
"}"
] | This method is called when a delivery object is embedded in another object, i.e. orders.
@param array $data
@param DeliveryInterface|null $delivery
@return DeliveryInterface | [
"This",
"method",
"is",
"called",
"when",
"a",
"delivery",
"object",
"is",
"embedded",
"in",
"another",
"object",
"i",
".",
"e",
".",
"orders",
"."
] | f3658aadf499d03f88465aa0b144626866c57b84 | https://github.com/loevgaard/dandomain-foundation-bundle/blob/f3658aadf499d03f88465aa0b144626866c57b84/Updater/DeliveryUpdater.php#L18-L42 |
10,555 | phPoirot/Module-Authorization | src/Authorization/Services/ServiceAuthenticatorsContainer.php | ServiceAuthenticatorsContainer._getConf | protected function _getConf()
{
// retrieve and cache config
$services = $this->services();
/** @var aSapi $config */
$config = $services->get('/sapi');
$orig = $config = $config->config();
/** @var DataEntity $config */
$config = $config->get(\Module\Authorization\Module::CONF, array());
if (!isset($config[self::CONF]) && !is_array($config[self::CONF]))
return null;
$config = $config[self::CONF];
return $config;
} | php | protected function _getConf()
{
// retrieve and cache config
$services = $this->services();
/** @var aSapi $config */
$config = $services->get('/sapi');
$orig = $config = $config->config();
/** @var DataEntity $config */
$config = $config->get(\Module\Authorization\Module::CONF, array());
if (!isset($config[self::CONF]) && !is_array($config[self::CONF]))
return null;
$config = $config[self::CONF];
return $config;
} | [
"protected",
"function",
"_getConf",
"(",
")",
"{",
"// retrieve and cache config",
"$",
"services",
"=",
"$",
"this",
"->",
"services",
"(",
")",
";",
"/** @var aSapi $config */",
"$",
"config",
"=",
"$",
"services",
"->",
"get",
"(",
"'/sapi'",
")",
";",
"$",
"orig",
"=",
"$",
"config",
"=",
"$",
"config",
"->",
"config",
"(",
")",
";",
"/** @var DataEntity $config */",
"$",
"config",
"=",
"$",
"config",
"->",
"get",
"(",
"\\",
"Module",
"\\",
"Authorization",
"\\",
"Module",
"::",
"CONF",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"self",
"::",
"CONF",
"]",
")",
"&&",
"!",
"is_array",
"(",
"$",
"config",
"[",
"self",
"::",
"CONF",
"]",
")",
")",
"return",
"null",
";",
"$",
"config",
"=",
"$",
"config",
"[",
"self",
"::",
"CONF",
"]",
";",
"return",
"$",
"config",
";",
"}"
] | Get Config Values
@return mixed|null
@throws \Exception | [
"Get",
"Config",
"Values"
] | 1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06 | https://github.com/phPoirot/Module-Authorization/blob/1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06/src/Authorization/Services/ServiceAuthenticatorsContainer.php#L43-L60 |
10,556 | asbsoft/yii2-common_2_170212 | i18n/BaseLangHelper.php | BaseLangHelper.activeLanguagesArray | public static function activeLanguagesArray()
{
if (!empty(Yii::$app->langManager) && !empty(Yii::$app->langManager->langsConfig)) {
return Yii::$app->langManager->langsConfig;
} else {
return include(dirname(__DIR__) . '/config/langs-default.php');
}
} | php | public static function activeLanguagesArray()
{
if (!empty(Yii::$app->langManager) && !empty(Yii::$app->langManager->langsConfig)) {
return Yii::$app->langManager->langsConfig;
} else {
return include(dirname(__DIR__) . '/config/langs-default.php');
}
} | [
"public",
"static",
"function",
"activeLanguagesArray",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"langManager",
")",
"&&",
"!",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"langManager",
"->",
"langsConfig",
")",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"langManager",
"->",
"langsConfig",
";",
"}",
"else",
"{",
"return",
"include",
"(",
"dirname",
"(",
"__DIR__",
")",
".",
"'/config/langs-default.php'",
")",
";",
"}",
"}"
] | Get basic active languages array according to sort criteria.
@return array of Lang objects | [
"Get",
"basic",
"active",
"languages",
"array",
"according",
"to",
"sort",
"criteria",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/i18n/BaseLangHelper.php#L18-L25 |
10,557 | asbsoft/yii2-common_2_170212 | i18n/BaseLangHelper.php | BaseLangHelper.findLanguageByCode2 | public static function findLanguageByCode2($langCode2)
{
$langList = static::activeLanguagesArray();
foreach ($langList as $lang) {
if ($lang['code2'] == $langCode2) return $lang;
}
return false;
} | php | public static function findLanguageByCode2($langCode2)
{
$langList = static::activeLanguagesArray();
foreach ($langList as $lang) {
if ($lang['code2'] == $langCode2) return $lang;
}
return false;
} | [
"public",
"static",
"function",
"findLanguageByCode2",
"(",
"$",
"langCode2",
")",
"{",
"$",
"langList",
"=",
"static",
"::",
"activeLanguagesArray",
"(",
")",
";",
"foreach",
"(",
"$",
"langList",
"as",
"$",
"lang",
")",
"{",
"if",
"(",
"$",
"lang",
"[",
"'code2'",
"]",
"==",
"$",
"langCode2",
")",
"return",
"$",
"lang",
";",
"}",
"return",
"false",
";",
"}"
] | Find language by 2-symbols language code
@param string 2-symbols language code
@return Lang|false object | [
"Find",
"language",
"by",
"2",
"-",
"symbols",
"language",
"code"
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/i18n/BaseLangHelper.php#L112-L119 |
10,558 | pletfix/core | src/Services/AssetManager.php | AssetManager.build | private function build($dest = null, $plugin = null)
{
if ($plugin !== null) {
/** @noinspection PhpIncludeInspection */
$builds = file_exists($this->pluginManifestOfAssets) ? include $this->pluginManifestOfAssets : [];
if (!isset($builds[$plugin])) {
throw new InvalidArgumentException('Plugin "' . $plugin . '" has no assets or is not installed.');
}
/** @noinspection PhpIncludeInspection */
$build = $builds[$plugin];
}
else {
/** @noinspection PhpIncludeInspection */
$build = require $this->buildFile;
}
// get only one asset if specified
if ($dest !== null) {
if (!isset($build[$dest])) {
throw new InvalidArgumentException('Asset "' . $dest . '" is not defined.');
}
$build = [$dest => $build[$dest]];
}
// make relative path to absolute
$basePath = base_path();
foreach ($build as $asset => $sources) {
foreach ($sources as $i => $source) {
if (!is_absolute_path($source)) {
$build[$asset][$i] = $basePath . DIRECTORY_SEPARATOR . $source;
}
}
}
return $build;
} | php | private function build($dest = null, $plugin = null)
{
if ($plugin !== null) {
/** @noinspection PhpIncludeInspection */
$builds = file_exists($this->pluginManifestOfAssets) ? include $this->pluginManifestOfAssets : [];
if (!isset($builds[$plugin])) {
throw new InvalidArgumentException('Plugin "' . $plugin . '" has no assets or is not installed.');
}
/** @noinspection PhpIncludeInspection */
$build = $builds[$plugin];
}
else {
/** @noinspection PhpIncludeInspection */
$build = require $this->buildFile;
}
// get only one asset if specified
if ($dest !== null) {
if (!isset($build[$dest])) {
throw new InvalidArgumentException('Asset "' . $dest . '" is not defined.');
}
$build = [$dest => $build[$dest]];
}
// make relative path to absolute
$basePath = base_path();
foreach ($build as $asset => $sources) {
foreach ($sources as $i => $source) {
if (!is_absolute_path($source)) {
$build[$asset][$i] = $basePath . DIRECTORY_SEPARATOR . $source;
}
}
}
return $build;
} | [
"private",
"function",
"build",
"(",
"$",
"dest",
"=",
"null",
",",
"$",
"plugin",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"plugin",
"!==",
"null",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"$",
"builds",
"=",
"file_exists",
"(",
"$",
"this",
"->",
"pluginManifestOfAssets",
")",
"?",
"include",
"$",
"this",
"->",
"pluginManifestOfAssets",
":",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"builds",
"[",
"$",
"plugin",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Plugin \"'",
".",
"$",
"plugin",
".",
"'\" has no assets or is not installed.'",
")",
";",
"}",
"/** @noinspection PhpIncludeInspection */",
"$",
"build",
"=",
"$",
"builds",
"[",
"$",
"plugin",
"]",
";",
"}",
"else",
"{",
"/** @noinspection PhpIncludeInspection */",
"$",
"build",
"=",
"require",
"$",
"this",
"->",
"buildFile",
";",
"}",
"// get only one asset if specified",
"if",
"(",
"$",
"dest",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"build",
"[",
"$",
"dest",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Asset \"'",
".",
"$",
"dest",
".",
"'\" is not defined.'",
")",
";",
"}",
"$",
"build",
"=",
"[",
"$",
"dest",
"=>",
"$",
"build",
"[",
"$",
"dest",
"]",
"]",
";",
"}",
"// make relative path to absolute",
"$",
"basePath",
"=",
"base_path",
"(",
")",
";",
"foreach",
"(",
"$",
"build",
"as",
"$",
"asset",
"=>",
"$",
"sources",
")",
"{",
"foreach",
"(",
"$",
"sources",
"as",
"$",
"i",
"=>",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"is_absolute_path",
"(",
"$",
"source",
")",
")",
"{",
"$",
"build",
"[",
"$",
"asset",
"]",
"[",
"$",
"i",
"]",
"=",
"$",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"source",
";",
"}",
"}",
"}",
"return",
"$",
"build",
";",
"}"
] | Get the build information array.
@param string|null $dest
@param string|null $plugin
@return array | [
"Get",
"the",
"build",
"information",
"array",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/AssetManager.php#L111-L146 |
10,559 | pletfix/core | src/Services/AssetManager.php | AssetManager.buildUniqueFile | private function buildUniqueFile($file)
{
// be sure the folder public/build is exist
$dir = public_path('build');
if (!file_exists($dir)) {
if (!make_dir($dir, 0755)) { // @codeCoverageIgnore
throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
} // @codeCoverageIgnore
}
// be sure the manifest path is exist
$dir = dirname($this->manifestFile);
if (!file_exists($dir)) {
if (!make_dir($dir, 0755)) {
throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
}
}
// generate unique file
$ext = pathinfo($file, PATHINFO_EXTENSION);
$uniqueFile = 'build/' . basename($file, '.' . $ext) . '-' . uniqid() . '.' . $ext;
copy(public_path($file), public_path($uniqueFile));
// update manifest
$oldFile = isset($this->manifest[$file]) ? public_path($this->manifest[$file]) : null;
$this->manifest[$file] = $uniqueFile;
if (file_put_contents($this->manifestFile, '<?php return ' . var_export($this->manifest, true) . ';' . PHP_EOL, LOCK_EX) === false) {
throw new RuntimeException(sprintf('Asset Manager was not able to save manifest file "%s"', $this->manifestFile)); // @codeCoverageIgnore
}
// delete old unique file
if ($oldFile !== null && file_exists($oldFile)) {
unlink($oldFile);
}
} | php | private function buildUniqueFile($file)
{
// be sure the folder public/build is exist
$dir = public_path('build');
if (!file_exists($dir)) {
if (!make_dir($dir, 0755)) { // @codeCoverageIgnore
throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
} // @codeCoverageIgnore
}
// be sure the manifest path is exist
$dir = dirname($this->manifestFile);
if (!file_exists($dir)) {
if (!make_dir($dir, 0755)) {
throw new RuntimeException('Unable to create directory ' . $dir); // @codeCoverageIgnore
}
}
// generate unique file
$ext = pathinfo($file, PATHINFO_EXTENSION);
$uniqueFile = 'build/' . basename($file, '.' . $ext) . '-' . uniqid() . '.' . $ext;
copy(public_path($file), public_path($uniqueFile));
// update manifest
$oldFile = isset($this->manifest[$file]) ? public_path($this->manifest[$file]) : null;
$this->manifest[$file] = $uniqueFile;
if (file_put_contents($this->manifestFile, '<?php return ' . var_export($this->manifest, true) . ';' . PHP_EOL, LOCK_EX) === false) {
throw new RuntimeException(sprintf('Asset Manager was not able to save manifest file "%s"', $this->manifestFile)); // @codeCoverageIgnore
}
// delete old unique file
if ($oldFile !== null && file_exists($oldFile)) {
unlink($oldFile);
}
} | [
"private",
"function",
"buildUniqueFile",
"(",
"$",
"file",
")",
"{",
"// be sure the folder public/build is exist",
"$",
"dir",
"=",
"public_path",
"(",
"'build'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"!",
"make_dir",
"(",
"$",
"dir",
",",
"0755",
")",
")",
"{",
"// @codeCoverageIgnore",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to create directory '",
".",
"$",
"dir",
")",
";",
"// @codeCoverageIgnore",
"}",
"// @codeCoverageIgnore",
"}",
"// be sure the manifest path is exist",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"this",
"->",
"manifestFile",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"!",
"make_dir",
"(",
"$",
"dir",
",",
"0755",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to create directory '",
".",
"$",
"dir",
")",
";",
"// @codeCoverageIgnore",
"}",
"}",
"// generate unique file",
"$",
"ext",
"=",
"pathinfo",
"(",
"$",
"file",
",",
"PATHINFO_EXTENSION",
")",
";",
"$",
"uniqueFile",
"=",
"'build/'",
".",
"basename",
"(",
"$",
"file",
",",
"'.'",
".",
"$",
"ext",
")",
".",
"'-'",
".",
"uniqid",
"(",
")",
".",
"'.'",
".",
"$",
"ext",
";",
"copy",
"(",
"public_path",
"(",
"$",
"file",
")",
",",
"public_path",
"(",
"$",
"uniqueFile",
")",
")",
";",
"// update manifest",
"$",
"oldFile",
"=",
"isset",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"file",
"]",
")",
"?",
"public_path",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"file",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"manifest",
"[",
"$",
"file",
"]",
"=",
"$",
"uniqueFile",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"this",
"->",
"manifestFile",
",",
"'<?php return '",
".",
"var_export",
"(",
"$",
"this",
"->",
"manifest",
",",
"true",
")",
".",
"';'",
".",
"PHP_EOL",
",",
"LOCK_EX",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Asset Manager was not able to save manifest file \"%s\"'",
",",
"$",
"this",
"->",
"manifestFile",
")",
")",
";",
"// @codeCoverageIgnore",
"}",
"// delete old unique file",
"if",
"(",
"$",
"oldFile",
"!==",
"null",
"&&",
"file_exists",
"(",
"$",
"oldFile",
")",
")",
"{",
"unlink",
"(",
"$",
"oldFile",
")",
";",
"}",
"}"
] | Build an unique file and update the manifest
@param string $file Name of the file relative to public path. | [
"Build",
"an",
"unique",
"file",
"and",
"update",
"the",
"manifest"
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/AssetManager.php#L250-L284 |
10,560 | pletfix/core | src/Services/AssetManager.php | AssetManager.removeUniqueFile | private function removeUniqueFile($file)
{
if (!isset($this->manifest[$file])) {
return;
}
// delete unique file
$uniqueFile = public_path($this->manifest[$file]);
if ($uniqueFile !== null && file_exists($uniqueFile)) {
unlink($uniqueFile);
}
// update manifest
unset($this->manifest[$file]);
if (file_put_contents($this->manifestFile, '<?php return ' . var_export($this->manifest, true) . ';' . PHP_EOL, LOCK_EX) === false) {
throw new RuntimeException(sprintf('Asset Manager was not able to save manifest file "%s"', $this->manifestFile)); // @codeCoverageIgnore
}
} | php | private function removeUniqueFile($file)
{
if (!isset($this->manifest[$file])) {
return;
}
// delete unique file
$uniqueFile = public_path($this->manifest[$file]);
if ($uniqueFile !== null && file_exists($uniqueFile)) {
unlink($uniqueFile);
}
// update manifest
unset($this->manifest[$file]);
if (file_put_contents($this->manifestFile, '<?php return ' . var_export($this->manifest, true) . ';' . PHP_EOL, LOCK_EX) === false) {
throw new RuntimeException(sprintf('Asset Manager was not able to save manifest file "%s"', $this->manifestFile)); // @codeCoverageIgnore
}
} | [
"private",
"function",
"removeUniqueFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"file",
"]",
")",
")",
"{",
"return",
";",
"}",
"// delete unique file",
"$",
"uniqueFile",
"=",
"public_path",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"file",
"]",
")",
";",
"if",
"(",
"$",
"uniqueFile",
"!==",
"null",
"&&",
"file_exists",
"(",
"$",
"uniqueFile",
")",
")",
"{",
"unlink",
"(",
"$",
"uniqueFile",
")",
";",
"}",
"// update manifest",
"unset",
"(",
"$",
"this",
"->",
"manifest",
"[",
"$",
"file",
"]",
")",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"this",
"->",
"manifestFile",
",",
"'<?php return '",
".",
"var_export",
"(",
"$",
"this",
"->",
"manifest",
",",
"true",
")",
".",
"';'",
".",
"PHP_EOL",
",",
"LOCK_EX",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Asset Manager was not able to save manifest file \"%s\"'",
",",
"$",
"this",
"->",
"manifestFile",
")",
")",
";",
"// @codeCoverageIgnore",
"}",
"}"
] | Remove unique file and update the manifest
@param string $file Name of the file relative to public path. | [
"Remove",
"unique",
"file",
"and",
"update",
"the",
"manifest"
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/AssetManager.php#L326-L343 |
10,561 | a2c/BaconUserBundle | Controller/GroupController.php | GroupController.listAction | public function listAction()
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'INDEX')) {
throw $this->createAccessDeniedException();
}
$groups = $this->get('fos_user.group_manager')->findGroups();
return $this->render('FOSUserBundle:Group:list.html.twig', array(
'groups' => $groups
));
} | php | public function listAction()
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'INDEX')) {
throw $this->createAccessDeniedException();
}
$groups = $this->get('fos_user.group_manager')->findGroups();
return $this->render('FOSUserBundle:Group:list.html.twig', array(
'groups' => $groups
));
} | [
"public",
"function",
"listAction",
"(",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",
"'groups'",
",",
"'INDEX'",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"groups",
"=",
"$",
"this",
"->",
"get",
"(",
"'fos_user.group_manager'",
")",
"->",
"findGroups",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'FOSUserBundle:Group:list.html.twig'",
",",
"array",
"(",
"'groups'",
"=>",
"$",
"groups",
")",
")",
";",
"}"
] | Show all groups | [
"Show",
"all",
"groups"
] | 2d192aaa05edabb75b66ce8fae02e436333adc03 | https://github.com/a2c/BaconUserBundle/blob/2d192aaa05edabb75b66ce8fae02e436333adc03/Controller/GroupController.php#L35-L48 |
10,562 | a2c/BaconUserBundle | Controller/GroupController.php | GroupController.showAction | public function showAction($groupName)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'show')) {
throw $this->createAccessDeniedException();
}
$group = $this->findGroupBy('name', $groupName);
return $this->render('FOSUserBundle:Group:show.html.twig', array(
'group' => $group
));
} | php | public function showAction($groupName)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'show')) {
throw $this->createAccessDeniedException();
}
$group = $this->findGroupBy('name', $groupName);
return $this->render('FOSUserBundle:Group:show.html.twig', array(
'group' => $group
));
} | [
"public",
"function",
"showAction",
"(",
"$",
"groupName",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",
"'groups'",
",",
"'show'",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"group",
"=",
"$",
"this",
"->",
"findGroupBy",
"(",
"'name'",
",",
"$",
"groupName",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'FOSUserBundle:Group:show.html.twig'",
",",
"array",
"(",
"'group'",
"=>",
"$",
"group",
")",
")",
";",
"}"
] | Show one group | [
"Show",
"one",
"group"
] | 2d192aaa05edabb75b66ce8fae02e436333adc03 | https://github.com/a2c/BaconUserBundle/blob/2d192aaa05edabb75b66ce8fae02e436333adc03/Controller/GroupController.php#L53-L66 |
10,563 | a2c/BaconUserBundle | Controller/GroupController.php | GroupController.editAction | public function editAction(Request $request, $groupName)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'EDIT')) {
throw $this->createAccessDeniedException();
}
$group = $this->findGroupBy('name', $groupName);
/** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
$dispatcher = $this->get('event_dispatcher');
$event = new GetResponseGroupEvent($group, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_INITIALIZE, $event);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
/** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
$formFactory = $this->get('fos_user.group.form.factory');
$form = $formFactory->createForm();
$form->setData($group);
$form->handleRequest($request);
if ($form->isValid()) {
/** @var $groupManager \FOS\UserBundle\Model\GroupManagerInterface */
$groupManager = $this->get('fos_user.group_manager');
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_SUCCESS, $event);
$groupManager->updateGroup($group);
$this->get('session')->getFlashBag()->add('message', [
'type' => 'success',
'message' => sprintf('The record has been %s successfully.','updated'),
]);
if (null === $response = $event->getResponse()) {
$url = $this->generateUrl('fos_user_group_show', array('groupName' => $group->getName()));
$response = new RedirectResponse($url);
}
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
return $response;
}
return $this->render('FOSUserBundle:Group:edit.html.twig', array(
'form' => $form->createview(),
'group_name' => $group->getName(),
'group' => $group,
));
} | php | public function editAction(Request $request, $groupName)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'EDIT')) {
throw $this->createAccessDeniedException();
}
$group = $this->findGroupBy('name', $groupName);
/** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
$dispatcher = $this->get('event_dispatcher');
$event = new GetResponseGroupEvent($group, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_INITIALIZE, $event);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
/** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
$formFactory = $this->get('fos_user.group.form.factory');
$form = $formFactory->createForm();
$form->setData($group);
$form->handleRequest($request);
if ($form->isValid()) {
/** @var $groupManager \FOS\UserBundle\Model\GroupManagerInterface */
$groupManager = $this->get('fos_user.group_manager');
$event = new FormEvent($form, $request);
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_SUCCESS, $event);
$groupManager->updateGroup($group);
$this->get('session')->getFlashBag()->add('message', [
'type' => 'success',
'message' => sprintf('The record has been %s successfully.','updated'),
]);
if (null === $response = $event->getResponse()) {
$url = $this->generateUrl('fos_user_group_show', array('groupName' => $group->getName()));
$response = new RedirectResponse($url);
}
$dispatcher->dispatch(FOSUserEvents::GROUP_EDIT_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
return $response;
}
return $this->render('FOSUserBundle:Group:edit.html.twig', array(
'form' => $form->createview(),
'group_name' => $group->getName(),
'group' => $group,
));
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"groupName",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",
"'groups'",
",",
"'EDIT'",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"group",
"=",
"$",
"this",
"->",
"findGroupBy",
"(",
"'name'",
",",
"$",
"groupName",
")",
";",
"/** @var $dispatcher \\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface */",
"$",
"dispatcher",
"=",
"$",
"this",
"->",
"get",
"(",
"'event_dispatcher'",
")",
";",
"$",
"event",
"=",
"new",
"GetResponseGroupEvent",
"(",
"$",
"group",
",",
"$",
"request",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"FOSUserEvents",
"::",
"GROUP_EDIT_INITIALIZE",
",",
"$",
"event",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"event",
"->",
"getResponse",
"(",
")",
")",
"{",
"return",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"}",
"/** @var $formFactory \\FOS\\UserBundle\\Form\\Factory\\FactoryInterface */",
"$",
"formFactory",
"=",
"$",
"this",
"->",
"get",
"(",
"'fos_user.group.form.factory'",
")",
";",
"$",
"form",
"=",
"$",
"formFactory",
"->",
"createForm",
"(",
")",
";",
"$",
"form",
"->",
"setData",
"(",
"$",
"group",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"/** @var $groupManager \\FOS\\UserBundle\\Model\\GroupManagerInterface */",
"$",
"groupManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'fos_user.group_manager'",
")",
";",
"$",
"event",
"=",
"new",
"FormEvent",
"(",
"$",
"form",
",",
"$",
"request",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"FOSUserEvents",
"::",
"GROUP_EDIT_SUCCESS",
",",
"$",
"event",
")",
";",
"$",
"groupManager",
"->",
"updateGroup",
"(",
"$",
"group",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'message'",
",",
"[",
"'type'",
"=>",
"'success'",
",",
"'message'",
"=>",
"sprintf",
"(",
"'The record has been %s successfully.'",
",",
"'updated'",
")",
",",
"]",
")",
";",
"if",
"(",
"null",
"===",
"$",
"response",
"=",
"$",
"event",
"->",
"getResponse",
"(",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"generateUrl",
"(",
"'fos_user_group_show'",
",",
"array",
"(",
"'groupName'",
"=>",
"$",
"group",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"response",
"=",
"new",
"RedirectResponse",
"(",
"$",
"url",
")",
";",
"}",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"FOSUserEvents",
"::",
"GROUP_EDIT_COMPLETED",
",",
"new",
"FilterGroupResponseEvent",
"(",
"$",
"group",
",",
"$",
"request",
",",
"$",
"response",
")",
")",
";",
"return",
"$",
"response",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'FOSUserBundle:Group:edit.html.twig'",
",",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createview",
"(",
")",
",",
"'group_name'",
"=>",
"$",
"group",
"->",
"getName",
"(",
")",
",",
"'group'",
"=>",
"$",
"group",
",",
")",
")",
";",
"}"
] | Edit one group, show the edit form | [
"Edit",
"one",
"group",
"show",
"the",
"edit",
"form"
] | 2d192aaa05edabb75b66ce8fae02e436333adc03 | https://github.com/a2c/BaconUserBundle/blob/2d192aaa05edabb75b66ce8fae02e436333adc03/Controller/GroupController.php#L71-L129 |
10,564 | a2c/BaconUserBundle | Controller/GroupController.php | GroupController.deleteAction | public function deleteAction(Request $request, $groupName)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'DELETE')) {
throw $this->createAccessDeniedException();
}
$group = $this->findGroupBy('name', $groupName);
$this->get('fos_user.group_manager')->deleteGroup($group);
$response = new RedirectResponse($this->generateUrl('fos_user_group_list'));
$this->get('session')->getFlashBag()->add('message', [
'type' => 'success',
'message' => 'The record has been remove successfully.',
]);
/** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
$dispatcher = $this->get('event_dispatcher');
$dispatcher->dispatch(FOSUserEvents::GROUP_DELETE_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
return $response;
} | php | public function deleteAction(Request $request, $groupName)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('groups', 'DELETE')) {
throw $this->createAccessDeniedException();
}
$group = $this->findGroupBy('name', $groupName);
$this->get('fos_user.group_manager')->deleteGroup($group);
$response = new RedirectResponse($this->generateUrl('fos_user_group_list'));
$this->get('session')->getFlashBag()->add('message', [
'type' => 'success',
'message' => 'The record has been remove successfully.',
]);
/** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
$dispatcher = $this->get('event_dispatcher');
$dispatcher->dispatch(FOSUserEvents::GROUP_DELETE_COMPLETED, new FilterGroupResponseEvent($group, $request, $response));
return $response;
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"groupName",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",
"'groups'",
",",
"'DELETE'",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"group",
"=",
"$",
"this",
"->",
"findGroupBy",
"(",
"'name'",
",",
"$",
"groupName",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'fos_user.group_manager'",
")",
"->",
"deleteGroup",
"(",
"$",
"group",
")",
";",
"$",
"response",
"=",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'fos_user_group_list'",
")",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'message'",
",",
"[",
"'type'",
"=>",
"'success'",
",",
"'message'",
"=>",
"'The record has been remove successfully.'",
",",
"]",
")",
";",
"/** @var $dispatcher \\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface */",
"$",
"dispatcher",
"=",
"$",
"this",
"->",
"get",
"(",
"'event_dispatcher'",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"FOSUserEvents",
"::",
"GROUP_DELETE_COMPLETED",
",",
"new",
"FilterGroupResponseEvent",
"(",
"$",
"group",
",",
"$",
"request",
",",
"$",
"response",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Delete one group | [
"Delete",
"one",
"group"
] | 2d192aaa05edabb75b66ce8fae02e436333adc03 | https://github.com/a2c/BaconUserBundle/blob/2d192aaa05edabb75b66ce8fae02e436333adc03/Controller/GroupController.php#L182-L205 |
10,565 | a2c/BaconUserBundle | Controller/GroupController.php | GroupController.findGroupBy | protected function findGroupBy($key, $value)
{
if (!empty($value)) {
$group = $this->get('fos_user.group_manager')->{'findGroupBy'.ucfirst($key)}($value);
}
if (empty($group)) {
throw new NotFoundHttpException(sprintf('The group with "%s" does not exist for value "%s"', $key, $value));
}
return $group;
} | php | protected function findGroupBy($key, $value)
{
if (!empty($value)) {
$group = $this->get('fos_user.group_manager')->{'findGroupBy'.ucfirst($key)}($value);
}
if (empty($group)) {
throw new NotFoundHttpException(sprintf('The group with "%s" does not exist for value "%s"', $key, $value));
}
return $group;
} | [
"protected",
"function",
"findGroupBy",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"get",
"(",
"'fos_user.group_manager'",
")",
"->",
"{",
"'findGroupBy'",
".",
"ucfirst",
"(",
"$",
"key",
")",
"}",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"group",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"sprintf",
"(",
"'The group with \"%s\" does not exist for value \"%s\"'",
",",
"$",
"key",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"group",
";",
"}"
] | Find a group by a specific property
@param string $key property name
@param mixed $value property value
@throws NotFoundHttpException if user does not exist
@return \FOS\UserBundle\Model\GroupInterface | [
"Find",
"a",
"group",
"by",
"a",
"specific",
"property"
] | 2d192aaa05edabb75b66ce8fae02e436333adc03 | https://github.com/a2c/BaconUserBundle/blob/2d192aaa05edabb75b66ce8fae02e436333adc03/Controller/GroupController.php#L216-L227 |
10,566 | marando/phpSOFA | src/Marando/IAU/iauUt1utc.php | iauUt1utc.Ut1utc | public static function Ut1utc($ut11, $ut12, $dut1, &$utc1, &$utc2) {
$big1;
$i;
$iy;
$im;
$id;
$js;
$duts;
$u1;
$u2;
$d1;
$dats1;
$d2;
$fd;
$dats2;
$ddats;
$us1;
$us2;
$du;
/* UT1-UTC in seconds. */
$duts = $dut1;
/* Put the two parts of the UT1 into big-first order. */
$big1 = ( $ut11 >= $ut12 );
if ($big1) {
$u1 = $ut11;
$u2 = $ut12;
}
else {
$u1 = $ut12;
$u2 = $ut11;
}
/* See if the UT1 can possibly be in a leap-second day. */
$d1 = $u1;
$dats1 = 0;
for ($i = -1; $i <= 3; $i++) {
$d2 = $u2 + (double)$i;
if (IAU::Jd2cal($d1, $d2, $iy, $im, $id, $fd))
return -1;
$js = IAU::Dat($iy, $im, $id, 0.0, $dats2);
if ($js < 0)
return -1;
if ($i == - 1)
$dats1 = $dats2;
$ddats = $dats2 - $dats1;
if (abs($ddats) >= 0.5) {
/* Yes, leap second nearby: ensure UT1-UTC is "before" value. */
if ($ddats * $duts >= 0)
$duts -= $ddats;
/* UT1 for the start of the UTC day that ends in a leap. */
if (IAU::Cal2jd($iy, $im, $id, $d1, $d2))
return -1;
$us1 = $d1;
$us2 = $d2 - 1.0 + $duts / DAYSEC;
/* Is the UT1 after this point? */
$du = $u1 - $us1;
$du += $u2 - $us2;
if ($du > 0) {
/* Yes: fraction of the current UTC day that has elapsed. */
$fd = $du * DAYSEC / ( DAYSEC + $ddats );
/* Ramp UT1-UTC to bring about SOFA's JD(UTC) convention. */
$duts += $ddats * ( $fd <= 1.0 ? $fd : 1.0 );
}
/* Done. */
break;
}
$dats1 = $dats2;
}
/* Subtract the (possibly adjusted) UT1-UTC from UT1 to give UTC. */
$u2 -= $duts / DAYSEC;
/* Result, safeguarding precision. */
if ($big1) {
$utc1 = $u1;
$utc2 = $u2;
}
else {
$utc1 = $u2;
$utc2 = $u1;
}
/* Status. */
return $js;
} | php | public static function Ut1utc($ut11, $ut12, $dut1, &$utc1, &$utc2) {
$big1;
$i;
$iy;
$im;
$id;
$js;
$duts;
$u1;
$u2;
$d1;
$dats1;
$d2;
$fd;
$dats2;
$ddats;
$us1;
$us2;
$du;
/* UT1-UTC in seconds. */
$duts = $dut1;
/* Put the two parts of the UT1 into big-first order. */
$big1 = ( $ut11 >= $ut12 );
if ($big1) {
$u1 = $ut11;
$u2 = $ut12;
}
else {
$u1 = $ut12;
$u2 = $ut11;
}
/* See if the UT1 can possibly be in a leap-second day. */
$d1 = $u1;
$dats1 = 0;
for ($i = -1; $i <= 3; $i++) {
$d2 = $u2 + (double)$i;
if (IAU::Jd2cal($d1, $d2, $iy, $im, $id, $fd))
return -1;
$js = IAU::Dat($iy, $im, $id, 0.0, $dats2);
if ($js < 0)
return -1;
if ($i == - 1)
$dats1 = $dats2;
$ddats = $dats2 - $dats1;
if (abs($ddats) >= 0.5) {
/* Yes, leap second nearby: ensure UT1-UTC is "before" value. */
if ($ddats * $duts >= 0)
$duts -= $ddats;
/* UT1 for the start of the UTC day that ends in a leap. */
if (IAU::Cal2jd($iy, $im, $id, $d1, $d2))
return -1;
$us1 = $d1;
$us2 = $d2 - 1.0 + $duts / DAYSEC;
/* Is the UT1 after this point? */
$du = $u1 - $us1;
$du += $u2 - $us2;
if ($du > 0) {
/* Yes: fraction of the current UTC day that has elapsed. */
$fd = $du * DAYSEC / ( DAYSEC + $ddats );
/* Ramp UT1-UTC to bring about SOFA's JD(UTC) convention. */
$duts += $ddats * ( $fd <= 1.0 ? $fd : 1.0 );
}
/* Done. */
break;
}
$dats1 = $dats2;
}
/* Subtract the (possibly adjusted) UT1-UTC from UT1 to give UTC. */
$u2 -= $duts / DAYSEC;
/* Result, safeguarding precision. */
if ($big1) {
$utc1 = $u1;
$utc2 = $u2;
}
else {
$utc1 = $u2;
$utc2 = $u1;
}
/* Status. */
return $js;
} | [
"public",
"static",
"function",
"Ut1utc",
"(",
"$",
"ut11",
",",
"$",
"ut12",
",",
"$",
"dut1",
",",
"&",
"$",
"utc1",
",",
"&",
"$",
"utc2",
")",
"{",
"$",
"big1",
";",
"$",
"i",
";",
"$",
"iy",
";",
"$",
"im",
";",
"$",
"id",
";",
"$",
"js",
";",
"$",
"duts",
";",
"$",
"u1",
";",
"$",
"u2",
";",
"$",
"d1",
";",
"$",
"dats1",
";",
"$",
"d2",
";",
"$",
"fd",
";",
"$",
"dats2",
";",
"$",
"ddats",
";",
"$",
"us1",
";",
"$",
"us2",
";",
"$",
"du",
";",
"/* UT1-UTC in seconds. */",
"$",
"duts",
"=",
"$",
"dut1",
";",
"/* Put the two parts of the UT1 into big-first order. */",
"$",
"big1",
"=",
"(",
"$",
"ut11",
">=",
"$",
"ut12",
")",
";",
"if",
"(",
"$",
"big1",
")",
"{",
"$",
"u1",
"=",
"$",
"ut11",
";",
"$",
"u2",
"=",
"$",
"ut12",
";",
"}",
"else",
"{",
"$",
"u1",
"=",
"$",
"ut12",
";",
"$",
"u2",
"=",
"$",
"ut11",
";",
"}",
"/* See if the UT1 can possibly be in a leap-second day. */",
"$",
"d1",
"=",
"$",
"u1",
";",
"$",
"dats1",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"-",
"1",
";",
"$",
"i",
"<=",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"d2",
"=",
"$",
"u2",
"+",
"(",
"double",
")",
"$",
"i",
";",
"if",
"(",
"IAU",
"::",
"Jd2cal",
"(",
"$",
"d1",
",",
"$",
"d2",
",",
"$",
"iy",
",",
"$",
"im",
",",
"$",
"id",
",",
"$",
"fd",
")",
")",
"return",
"-",
"1",
";",
"$",
"js",
"=",
"IAU",
"::",
"Dat",
"(",
"$",
"iy",
",",
"$",
"im",
",",
"$",
"id",
",",
"0.0",
",",
"$",
"dats2",
")",
";",
"if",
"(",
"$",
"js",
"<",
"0",
")",
"return",
"-",
"1",
";",
"if",
"(",
"$",
"i",
"==",
"-",
"1",
")",
"$",
"dats1",
"=",
"$",
"dats2",
";",
"$",
"ddats",
"=",
"$",
"dats2",
"-",
"$",
"dats1",
";",
"if",
"(",
"abs",
"(",
"$",
"ddats",
")",
">=",
"0.5",
")",
"{",
"/* Yes, leap second nearby: ensure UT1-UTC is \"before\" value. */",
"if",
"(",
"$",
"ddats",
"*",
"$",
"duts",
">=",
"0",
")",
"$",
"duts",
"-=",
"$",
"ddats",
";",
"/* UT1 for the start of the UTC day that ends in a leap. */",
"if",
"(",
"IAU",
"::",
"Cal2jd",
"(",
"$",
"iy",
",",
"$",
"im",
",",
"$",
"id",
",",
"$",
"d1",
",",
"$",
"d2",
")",
")",
"return",
"-",
"1",
";",
"$",
"us1",
"=",
"$",
"d1",
";",
"$",
"us2",
"=",
"$",
"d2",
"-",
"1.0",
"+",
"$",
"duts",
"/",
"DAYSEC",
";",
"/* Is the UT1 after this point? */",
"$",
"du",
"=",
"$",
"u1",
"-",
"$",
"us1",
";",
"$",
"du",
"+=",
"$",
"u2",
"-",
"$",
"us2",
";",
"if",
"(",
"$",
"du",
">",
"0",
")",
"{",
"/* Yes: fraction of the current UTC day that has elapsed. */",
"$",
"fd",
"=",
"$",
"du",
"*",
"DAYSEC",
"/",
"(",
"DAYSEC",
"+",
"$",
"ddats",
")",
";",
"/* Ramp UT1-UTC to bring about SOFA's JD(UTC) convention. */",
"$",
"duts",
"+=",
"$",
"ddats",
"*",
"(",
"$",
"fd",
"<=",
"1.0",
"?",
"$",
"fd",
":",
"1.0",
")",
";",
"}",
"/* Done. */",
"break",
";",
"}",
"$",
"dats1",
"=",
"$",
"dats2",
";",
"}",
"/* Subtract the (possibly adjusted) UT1-UTC from UT1 to give UTC. */",
"$",
"u2",
"-=",
"$",
"duts",
"/",
"DAYSEC",
";",
"/* Result, safeguarding precision. */",
"if",
"(",
"$",
"big1",
")",
"{",
"$",
"utc1",
"=",
"$",
"u1",
";",
"$",
"utc2",
"=",
"$",
"u2",
";",
"}",
"else",
"{",
"$",
"utc1",
"=",
"$",
"u2",
";",
"$",
"utc2",
"=",
"$",
"u1",
";",
"}",
"/* Status. */",
"return",
"$",
"js",
";",
"}"
] | - - - - - - - - - -
i a u U t 1 u t c
- - - - - - - - - -
Time scale transformation: Universal Time, UT1, to Coordinated
Universal Time, UTC.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: canonical.
Given:
ut11,ut12 double UT1 as a 2-part Julian Date (Note 1)
dut1 double Delta UT1: UT1-UTC in seconds (Note 2)
Returned:
utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 3,4)
Returned (function value):
int status: +1 = dubious year (Note 5)
0 = OK
-1 = unacceptable date
Notes:
1) ut11+ut12 is Julian Date, apportioned in any convenient way
between the two arguments, for example where ut11 is the Julian
Day Number and ut12 is the fraction of a day. The returned utc1
and utc2 form an analogous pair, except that a special convention
is used, to deal with the problem of leap seconds - see Note 3.
2) Delta UT1 can be obtained from tabulations provided by the
International Earth Rotation and Reference Systems Service. The
value changes abruptly by 1s at a leap second; however, close to
a leap second the algorithm used here is tolerant of the "wrong"
choice of value being made.
3) JD cannot unambiguously represent UTC during a leap second unless
special measures are taken. The convention in the present
function is that the returned quasi JD day UTC1+UTC2 represents
UTC days whether the length is 86399, 86400 or 86401 SI seconds.
4) The function iauD2dtf can be used to transform the UTC quasi-JD
into calendar date and clock time, including UTC leap second
handling.
5) The warning status "dubious year" flags UTCs that predate the
introduction of the time scale or that are too far in the future
to be trusted. See iauDat for further details.
Called:
iauJd2cal JD to Gregorian calendar
iauDat delta(AT) = TAI-UTC
iauCal2jd Gregorian calendar to JD
References:
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004)
Explanatory Supplement to the Astronomical Almanac,
P. Kenneth Seidelmann (ed), University Science Books (1992)
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"U",
"t",
"1",
"u",
"t",
"c",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauUt1utc.php#L78-L170 |
10,567 | zepi/turbo-base | Zepi/Web/General/src/EventHandler/LoadAssetContent.php | LoadAssetContent.deliverContent | protected function deliverContent(Response $response, $type, $hash, $version, $content)
{
// Define the if modified since timestamp
$cachedAssetTimestamp = $this->assetCacheManager->getCachedAssetTimestamp($type, $hash, $version);
$ifModifiedSince = -1;
if ($this->isHeaderSetAndNotEmpty('HTTP_IF_MODIFIED_SINCE')) {
$ifModifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
// Define the etag
$eTag = md5($content);
$eTagHeader = -1;
if ($this->isHeaderSetAndNotEmpty('HTTP_IF_NONE_MATCH')) {
$eTagHeader = $_SERVER['HTTP_IF_NONE_MATCH'];
}
// Set the cache headers
$cacheTtl = 86400 * 365;
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cachedAssetTimestamp) . ' GMT');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $cacheTtl) . ' GMT');
header('Pragma: cache');
header('Etag: ' . $eTag);
header('Cache-Control: max-age=' . $cacheTtl);
// Verify the cached timestamp and the eTag
if ($cachedAssetTimestamp === $ifModifiedSince || $eTag === $eTagHeader) {
header('HTTP/1.1 304 Not Modified');
exit;
}
// Set the content type
$contentType = $this->getContentType($type, $version);
if ($contentType !== '') {
header('Content-type: ' . $contentType, true);
}
// Display the content
$response->setOutput($content);
} | php | protected function deliverContent(Response $response, $type, $hash, $version, $content)
{
// Define the if modified since timestamp
$cachedAssetTimestamp = $this->assetCacheManager->getCachedAssetTimestamp($type, $hash, $version);
$ifModifiedSince = -1;
if ($this->isHeaderSetAndNotEmpty('HTTP_IF_MODIFIED_SINCE')) {
$ifModifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
// Define the etag
$eTag = md5($content);
$eTagHeader = -1;
if ($this->isHeaderSetAndNotEmpty('HTTP_IF_NONE_MATCH')) {
$eTagHeader = $_SERVER['HTTP_IF_NONE_MATCH'];
}
// Set the cache headers
$cacheTtl = 86400 * 365;
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cachedAssetTimestamp) . ' GMT');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $cacheTtl) . ' GMT');
header('Pragma: cache');
header('Etag: ' . $eTag);
header('Cache-Control: max-age=' . $cacheTtl);
// Verify the cached timestamp and the eTag
if ($cachedAssetTimestamp === $ifModifiedSince || $eTag === $eTagHeader) {
header('HTTP/1.1 304 Not Modified');
exit;
}
// Set the content type
$contentType = $this->getContentType($type, $version);
if ($contentType !== '') {
header('Content-type: ' . $contentType, true);
}
// Display the content
$response->setOutput($content);
} | [
"protected",
"function",
"deliverContent",
"(",
"Response",
"$",
"response",
",",
"$",
"type",
",",
"$",
"hash",
",",
"$",
"version",
",",
"$",
"content",
")",
"{",
"// Define the if modified since timestamp",
"$",
"cachedAssetTimestamp",
"=",
"$",
"this",
"->",
"assetCacheManager",
"->",
"getCachedAssetTimestamp",
"(",
"$",
"type",
",",
"$",
"hash",
",",
"$",
"version",
")",
";",
"$",
"ifModifiedSince",
"=",
"-",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"isHeaderSetAndNotEmpty",
"(",
"'HTTP_IF_MODIFIED_SINCE'",
")",
")",
"{",
"$",
"ifModifiedSince",
"=",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
";",
"}",
"// Define the etag",
"$",
"eTag",
"=",
"md5",
"(",
"$",
"content",
")",
";",
"$",
"eTagHeader",
"=",
"-",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"isHeaderSetAndNotEmpty",
"(",
"'HTTP_IF_NONE_MATCH'",
")",
")",
"{",
"$",
"eTagHeader",
"=",
"$",
"_SERVER",
"[",
"'HTTP_IF_NONE_MATCH'",
"]",
";",
"}",
"// Set the cache headers",
"$",
"cacheTtl",
"=",
"86400",
"*",
"365",
";",
"header",
"(",
"'Last-Modified: '",
".",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"$",
"cachedAssetTimestamp",
")",
".",
"' GMT'",
")",
";",
"header",
"(",
"'Expires: '",
".",
"gmdate",
"(",
"\"D, d M Y H:i:s\"",
",",
"time",
"(",
")",
"+",
"$",
"cacheTtl",
")",
".",
"' GMT'",
")",
";",
"header",
"(",
"'Pragma: cache'",
")",
";",
"header",
"(",
"'Etag: '",
".",
"$",
"eTag",
")",
";",
"header",
"(",
"'Cache-Control: max-age='",
".",
"$",
"cacheTtl",
")",
";",
"// Verify the cached timestamp and the eTag",
"if",
"(",
"$",
"cachedAssetTimestamp",
"===",
"$",
"ifModifiedSince",
"||",
"$",
"eTag",
"===",
"$",
"eTagHeader",
")",
"{",
"header",
"(",
"'HTTP/1.1 304 Not Modified'",
")",
";",
"exit",
";",
"}",
"// Set the content type",
"$",
"contentType",
"=",
"$",
"this",
"->",
"getContentType",
"(",
"$",
"type",
",",
"$",
"version",
")",
";",
"if",
"(",
"$",
"contentType",
"!==",
"''",
")",
"{",
"header",
"(",
"'Content-type: '",
".",
"$",
"contentType",
",",
"true",
")",
";",
"}",
"// Display the content",
"$",
"response",
"->",
"setOutput",
"(",
"$",
"content",
")",
";",
"}"
] | Adds the needed headers and prepares the content
@param \Zepi\Turbo\Response\Response $response
@param string $type
@param string $hash
@param string $version
@param string $content | [
"Adds",
"the",
"needed",
"headers",
"and",
"prepares",
"the",
"content"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/EventHandler/LoadAssetContent.php#L115-L153 |
10,568 | zepi/turbo-base | Zepi/Web/General/src/EventHandler/LoadAssetContent.php | LoadAssetContent.getContentType | protected function getContentType($type, $version)
{
if ($type === 'css') {
return 'text/css';
} else if ($type === 'js') {
return 'text/javascript';
} else if ($type === 'image') {
$fileExtension = pathinfo($version, PATHINFO_EXTENSION);
if ($fileExtension === 'svg') {
return 'image/svg+xml';
} else if ($fileExtension === 'jpg') {
return 'image/jpeg';
} else if ($fileExtension === 'gif') {
return 'image/gif';
} else if ($fileExtension === 'png') {
return 'image/png';
}
}
} | php | protected function getContentType($type, $version)
{
if ($type === 'css') {
return 'text/css';
} else if ($type === 'js') {
return 'text/javascript';
} else if ($type === 'image') {
$fileExtension = pathinfo($version, PATHINFO_EXTENSION);
if ($fileExtension === 'svg') {
return 'image/svg+xml';
} else if ($fileExtension === 'jpg') {
return 'image/jpeg';
} else if ($fileExtension === 'gif') {
return 'image/gif';
} else if ($fileExtension === 'png') {
return 'image/png';
}
}
} | [
"protected",
"function",
"getContentType",
"(",
"$",
"type",
",",
"$",
"version",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"'css'",
")",
"{",
"return",
"'text/css'",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"===",
"'js'",
")",
"{",
"return",
"'text/javascript'",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"===",
"'image'",
")",
"{",
"$",
"fileExtension",
"=",
"pathinfo",
"(",
"$",
"version",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"$",
"fileExtension",
"===",
"'svg'",
")",
"{",
"return",
"'image/svg+xml'",
";",
"}",
"else",
"if",
"(",
"$",
"fileExtension",
"===",
"'jpg'",
")",
"{",
"return",
"'image/jpeg'",
";",
"}",
"else",
"if",
"(",
"$",
"fileExtension",
"===",
"'gif'",
")",
"{",
"return",
"'image/gif'",
";",
"}",
"else",
"if",
"(",
"$",
"fileExtension",
"===",
"'png'",
")",
"{",
"return",
"'image/png'",
";",
"}",
"}",
"}"
] | Returns the content type for the given asset type.
@access protected
@param string $type
@param string $version
@return string | [
"Returns",
"the",
"content",
"type",
"for",
"the",
"given",
"asset",
"type",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/EventHandler/LoadAssetContent.php#L174-L193 |
10,569 | webforge-labs/webforge-utils | src/php/Webforge/Common/Exception.php | Exception.toString | public function toString($format = 'text', $relativeDir = NULL, $relativeDirLabel = NULL) {
return self::getExceptionText($this, $format, $relativeDir, $relativeDirLabel);
} | php | public function toString($format = 'text', $relativeDir = NULL, $relativeDirLabel = NULL) {
return self::getExceptionText($this, $format, $relativeDir, $relativeDirLabel);
} | [
"public",
"function",
"toString",
"(",
"$",
"format",
"=",
"'text'",
",",
"$",
"relativeDir",
"=",
"NULL",
",",
"$",
"relativeDirLabel",
"=",
"NULL",
")",
"{",
"return",
"self",
"::",
"getExceptionText",
"(",
"$",
"this",
",",
"$",
"format",
",",
"$",
"relativeDir",
",",
"$",
"relativeDirLabel",
")",
";",
"}"
] | Returns a nicer string Representation for the Exception
@param string $format text|html
@return string | [
"Returns",
"a",
"nicer",
"string",
"Representation",
"for",
"the",
"Exception"
] | a476eeec046c22ad91794b0ab9fe15a1d3f92bfc | https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/Exception.php#L39-L41 |
10,570 | opsbears/piccolo-web | src/WebApplication.php | WebApplication.execute | public function execute() {
$dic = $this->getDIC();
/**
* @var InputProcessor $input
*/
$inputProcessor = $dic->make(InputProcessor::class);
/**
* @var RequestProcessor $request
*/
$requestProcessor = $dic->make(RequestProcessor::class);
/**
* @var ResponseInterface $response
*/
$response = $dic->make(ResponseInterface::class);
/**
* @var OutputProcessor $output
*/
$outputProcessor = $dic->make(OutputProcessor::class);
$request = $inputProcessor->execute();
$response = $requestProcessor->execute($request, $response);
$outputProcessor->execute($response);
} | php | public function execute() {
$dic = $this->getDIC();
/**
* @var InputProcessor $input
*/
$inputProcessor = $dic->make(InputProcessor::class);
/**
* @var RequestProcessor $request
*/
$requestProcessor = $dic->make(RequestProcessor::class);
/**
* @var ResponseInterface $response
*/
$response = $dic->make(ResponseInterface::class);
/**
* @var OutputProcessor $output
*/
$outputProcessor = $dic->make(OutputProcessor::class);
$request = $inputProcessor->execute();
$response = $requestProcessor->execute($request, $response);
$outputProcessor->execute($response);
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"dic",
"=",
"$",
"this",
"->",
"getDIC",
"(",
")",
";",
"/**\n\t\t * @var InputProcessor $input\n\t\t */",
"$",
"inputProcessor",
"=",
"$",
"dic",
"->",
"make",
"(",
"InputProcessor",
"::",
"class",
")",
";",
"/**\n\t\t * @var RequestProcessor $request\n\t\t */",
"$",
"requestProcessor",
"=",
"$",
"dic",
"->",
"make",
"(",
"RequestProcessor",
"::",
"class",
")",
";",
"/**\n\t\t * @var ResponseInterface $response\n\t\t */",
"$",
"response",
"=",
"$",
"dic",
"->",
"make",
"(",
"ResponseInterface",
"::",
"class",
")",
";",
"/**\n\t\t * @var OutputProcessor $output\n\t\t */",
"$",
"outputProcessor",
"=",
"$",
"dic",
"->",
"make",
"(",
"OutputProcessor",
"::",
"class",
")",
";",
"$",
"request",
"=",
"$",
"inputProcessor",
"->",
"execute",
"(",
")",
";",
"$",
"response",
"=",
"$",
"requestProcessor",
"->",
"execute",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"outputProcessor",
"->",
"execute",
"(",
"$",
"response",
")",
";",
"}"
] | Process a web request using the designated InputProcessor, RequestProcessor and OutputProcessor
Warning! This method contains hidden dependencies which will be initialized using the Dependency Injection
Container!
@see InputProcessor
@see RequestProcessor
@see OutputProcessor | [
"Process",
"a",
"web",
"request",
"using",
"the",
"designated",
"InputProcessor",
"RequestProcessor",
"and",
"OutputProcessor"
] | ac98224c77d6f32dd4d5fa559a2dc8f1ed8e6355 | https://github.com/opsbears/piccolo-web/blob/ac98224c77d6f32dd4d5fa559a2dc8f1ed8e6355/src/WebApplication.php#L27-L53 |
10,571 | dmeikle/pesedget | src/Gossamer/Pesedget/Commands/ListCommand.php | ListCommand.execute | public function execute($params = array()){
if($this->entity instanceof OneToOneJoinInterface) {
if(array_key_exists('locale', $params)) {
$this->getQueryBuilder()->where($params['locale']);
}
$this->getQueryBuilder()->join($this->entity->getJoinRelationships());
}
$this->getQueryBuilder()->where($params);
$query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ALL_ITEMS_QUERY, QueryBuilder::PARENT_AND_CHILD);
$result = $this->query($query);
$param = get_class($this->entity) . 's';
return array($param => $result, $param . 'Count' => $this->getTotalRowCount());
} | php | public function execute($params = array()){
if($this->entity instanceof OneToOneJoinInterface) {
if(array_key_exists('locale', $params)) {
$this->getQueryBuilder()->where($params['locale']);
}
$this->getQueryBuilder()->join($this->entity->getJoinRelationships());
}
$this->getQueryBuilder()->where($params);
$query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ALL_ITEMS_QUERY, QueryBuilder::PARENT_AND_CHILD);
$result = $this->query($query);
$param = get_class($this->entity) . 's';
return array($param => $result, $param . 'Count' => $this->getTotalRowCount());
} | [
"public",
"function",
"execute",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entity",
"instanceof",
"OneToOneJoinInterface",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'locale'",
",",
"$",
"params",
")",
")",
"{",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"where",
"(",
"$",
"params",
"[",
"'locale'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"join",
"(",
"$",
"this",
"->",
"entity",
"->",
"getJoinRelationships",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"where",
"(",
"$",
"params",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"getQuery",
"(",
"$",
"this",
"->",
"entity",
",",
"QueryBuilder",
"::",
"GET_ALL_ITEMS_QUERY",
",",
"QueryBuilder",
"::",
"PARENT_AND_CHILD",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"query",
")",
";",
"$",
"param",
"=",
"get_class",
"(",
"$",
"this",
"->",
"entity",
")",
".",
"'s'",
";",
"return",
"array",
"(",
"$",
"param",
"=>",
"$",
"result",
",",
"$",
"param",
".",
"'Count'",
"=>",
"$",
"this",
"->",
"getTotalRowCount",
"(",
")",
")",
";",
"}"
] | retrieves a multiple rows from the database
@param array URI params
@param array POST params | [
"retrieves",
"a",
"multiple",
"rows",
"from",
"the",
"database"
] | bcfca25569d1f47c073f08906a710ed895f77b4d | https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Commands/ListCommand.php#L25-L43 |
10,572 | OWeb/OWeb-Framework | OWeb/types/Header.php | Header.getCode | public function getCode($id=""){
switch($this->type){
case Headers::javascript :
$code = '<script id="'.$id.'" type="text/javascript" src="'.$this->code.'"></script>'."\n";
break;
case Headers::css :
$code = '<link id="'.$id.'" href="'.$this->code.'" rel="stylesheet" type="text/css" />'."\n";
break;
case Headers::jsCode :
$code = '<script id="'.$id.'" type="text/javascript" >'."\n".$this->code."\n</script>\n\n";
break;
default :
$code = $this->code;
}
return $code;
} | php | public function getCode($id=""){
switch($this->type){
case Headers::javascript :
$code = '<script id="'.$id.'" type="text/javascript" src="'.$this->code.'"></script>'."\n";
break;
case Headers::css :
$code = '<link id="'.$id.'" href="'.$this->code.'" rel="stylesheet" type="text/css" />'."\n";
break;
case Headers::jsCode :
$code = '<script id="'.$id.'" type="text/javascript" >'."\n".$this->code."\n</script>\n\n";
break;
default :
$code = $this->code;
}
return $code;
} | [
"public",
"function",
"getCode",
"(",
"$",
"id",
"=",
"\"\"",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"Headers",
"::",
"javascript",
":",
"$",
"code",
"=",
"'<script id=\"'",
".",
"$",
"id",
".",
"'\" type=\"text/javascript\" src=\"'",
".",
"$",
"this",
"->",
"code",
".",
"'\"></script>'",
".",
"\"\\n\"",
";",
"break",
";",
"case",
"Headers",
"::",
"css",
":",
"$",
"code",
"=",
"'<link id=\"'",
".",
"$",
"id",
".",
"'\" href=\"'",
".",
"$",
"this",
"->",
"code",
".",
"'\" rel=\"stylesheet\" type=\"text/css\" />'",
".",
"\"\\n\"",
";",
"break",
";",
"case",
"Headers",
"::",
"jsCode",
":",
"$",
"code",
"=",
"'<script id=\"'",
".",
"$",
"id",
".",
"'\" type=\"text/javascript\" >'",
".",
"\"\\n\"",
".",
"$",
"this",
"->",
"code",
".",
"\"\\n</script>\\n\\n\"",
";",
"break",
";",
"default",
":",
"$",
"code",
"=",
"$",
"this",
"->",
"code",
";",
"}",
"return",
"$",
"code",
";",
"}"
] | Returns the string od this header.
@return type The code of the Header | [
"Returns",
"the",
"string",
"od",
"this",
"header",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/types/Header.php#L51-L68 |
10,573 | vidhyar2612/enveditor | src/EnveditorStore.php | EnveditorStore.has | public function has($key , $value=null) {
return CoreManager::has($this->path,$key,$value);
} | php | public function has($key , $value=null) {
return CoreManager::has($this->path,$key,$value);
} | [
"public",
"function",
"has",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"return",
"CoreManager",
"::",
"has",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Check the key exists
@param string $key
@param string $value
@return boolean | [
"Check",
"the",
"key",
"exists"
] | 90a67b728e8bd06680eed463657e63ba5b2d61a2 | https://github.com/vidhyar2612/enveditor/blob/90a67b728e8bd06680eed463657e63ba5b2d61a2/src/EnveditorStore.php#L105-L107 |
10,574 | vidhyar2612/enveditor | src/EnveditorStore.php | EnveditorStore.create | public function create($key , $value=null) {
if($this->check_path()) {
return CoreManager::create($this->path,$key,$value);
}
return false;
} | php | public function create($key , $value=null) {
if($this->check_path()) {
return CoreManager::create($this->path,$key,$value);
}
return false;
} | [
"public",
"function",
"create",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"check_path",
"(",
")",
")",
"{",
"return",
"CoreManager",
"::",
"create",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Create a key with an value
@param string $key
@param string $value
@return boolean | [
"Create",
"a",
"key",
"with",
"an",
"value"
] | 90a67b728e8bd06680eed463657e63ba5b2d61a2 | https://github.com/vidhyar2612/enveditor/blob/90a67b728e8bd06680eed463657e63ba5b2d61a2/src/EnveditorStore.php#L118-L126 |
10,575 | erdemkeren/jet-sms-php | src/JetSmsService.php | JetSmsService.sendShortMessage | public function sendShortMessage($receivers, $body = null)
{
if (! $receivers instanceof ShortMessage) {
$receivers = $this->factory->create($receivers, $body);
}
if (is_callable($this->beforeSingleShortMessageCallback)) {
call_user_func_array($this->beforeSingleShortMessageCallback, [$receivers]);
}
$response = $this->client->sendShortMessage($receivers);
if (is_callable($this->afterSingleShortMessageCallback)) {
call_user_func_array($this->afterSingleShortMessageCallback, [$response, $receivers]);
}
return $response;
} | php | public function sendShortMessage($receivers, $body = null)
{
if (! $receivers instanceof ShortMessage) {
$receivers = $this->factory->create($receivers, $body);
}
if (is_callable($this->beforeSingleShortMessageCallback)) {
call_user_func_array($this->beforeSingleShortMessageCallback, [$receivers]);
}
$response = $this->client->sendShortMessage($receivers);
if (is_callable($this->afterSingleShortMessageCallback)) {
call_user_func_array($this->afterSingleShortMessageCallback, [$response, $receivers]);
}
return $response;
} | [
"public",
"function",
"sendShortMessage",
"(",
"$",
"receivers",
",",
"$",
"body",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"receivers",
"instanceof",
"ShortMessage",
")",
"{",
"$",
"receivers",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"$",
"receivers",
",",
"$",
"body",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"beforeSingleShortMessageCallback",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"beforeSingleShortMessageCallback",
",",
"[",
"$",
"receivers",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"sendShortMessage",
"(",
"$",
"receivers",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"afterSingleShortMessageCallback",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"afterSingleShortMessageCallback",
",",
"[",
"$",
"response",
",",
"$",
"receivers",
"]",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Send the given body to the given receivers.
@param array|string|ShortMessage $receivers The receiver(s) of the message or the message object.
@param string|null $body The body of the message or null when using short message object.
@return JetSmsResponseInterface The parsed JetSms response object. | [
"Send",
"the",
"given",
"body",
"to",
"the",
"given",
"receivers",
"."
] | 5b103a980bd2a8dce003964a17e2568736dfcf4e | https://github.com/erdemkeren/jet-sms-php/blob/5b103a980bd2a8dce003964a17e2568736dfcf4e/src/JetSmsService.php#L99-L116 |
10,576 | erdemkeren/jet-sms-php | src/JetSmsService.php | JetSmsService.sendShortMessages | public function sendShortMessages($messages)
{
if (! $messages instanceof ShortMessageCollection) {
$collection = $this->collectionFactory->create();
foreach ($messages as $message) {
$collection->push($this->factory->create(
$message['recipient'],
$message['message']
));
}
$messages = $collection;
}
if (is_callable($this->beforeMultipleShortMessageCallback)) {
call_user_func_array($this->beforeMultipleShortMessageCallback, [$messages]);
}
$response = $this->client->sendShortMessages($messages);
if (is_callable($this->afterMultipleShortMessageCallback)) {
call_user_func_array($this->afterMultipleShortMessageCallback, [$response, $messages]);
}
return $response;
} | php | public function sendShortMessages($messages)
{
if (! $messages instanceof ShortMessageCollection) {
$collection = $this->collectionFactory->create();
foreach ($messages as $message) {
$collection->push($this->factory->create(
$message['recipient'],
$message['message']
));
}
$messages = $collection;
}
if (is_callable($this->beforeMultipleShortMessageCallback)) {
call_user_func_array($this->beforeMultipleShortMessageCallback, [$messages]);
}
$response = $this->client->sendShortMessages($messages);
if (is_callable($this->afterMultipleShortMessageCallback)) {
call_user_func_array($this->afterMultipleShortMessageCallback, [$response, $messages]);
}
return $response;
} | [
"public",
"function",
"sendShortMessages",
"(",
"$",
"messages",
")",
"{",
"if",
"(",
"!",
"$",
"messages",
"instanceof",
"ShortMessageCollection",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"collectionFactory",
"->",
"create",
"(",
")",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"$",
"collection",
"->",
"push",
"(",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"$",
"message",
"[",
"'recipient'",
"]",
",",
"$",
"message",
"[",
"'message'",
"]",
")",
")",
";",
"}",
"$",
"messages",
"=",
"$",
"collection",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"beforeMultipleShortMessageCallback",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"beforeMultipleShortMessageCallback",
",",
"[",
"$",
"messages",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"sendShortMessages",
"(",
"$",
"messages",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"afterMultipleShortMessageCallback",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"afterMultipleShortMessageCallback",
",",
"[",
"$",
"response",
",",
"$",
"messages",
"]",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Send the given short messages.
@param array|ShortMessageCollection $messages An array containing short message arrays or collection.
@return JetSmsResponseInterface The parsed JetSms response object. | [
"Send",
"the",
"given",
"short",
"messages",
"."
] | 5b103a980bd2a8dce003964a17e2568736dfcf4e | https://github.com/erdemkeren/jet-sms-php/blob/5b103a980bd2a8dce003964a17e2568736dfcf4e/src/JetSmsService.php#L125-L151 |
10,577 | praxisnetau/silverware-google | src/Extensions/PageExtension.php | PageExtension.MetaTags | public function MetaTags(&$tags)
{
if ($code = GoogleAPI::singleton()->getVerificationCode()) {
// Add New Line (if does not exist):
if (!preg_match('/[\n]$/', $tags)) {
$tags .= "\n";
}
// Add Verification Code Meta Tag:
$tags .= sprintf(
"<meta name=\"%s\" content=\"%s\" />\n",
self::VERIFICATION_TAG_NAME,
Convert::raw2att($code)
);
}
} | php | public function MetaTags(&$tags)
{
if ($code = GoogleAPI::singleton()->getVerificationCode()) {
// Add New Line (if does not exist):
if (!preg_match('/[\n]$/', $tags)) {
$tags .= "\n";
}
// Add Verification Code Meta Tag:
$tags .= sprintf(
"<meta name=\"%s\" content=\"%s\" />\n",
self::VERIFICATION_TAG_NAME,
Convert::raw2att($code)
);
}
} | [
"public",
"function",
"MetaTags",
"(",
"&",
"$",
"tags",
")",
"{",
"if",
"(",
"$",
"code",
"=",
"GoogleAPI",
"::",
"singleton",
"(",
")",
"->",
"getVerificationCode",
"(",
")",
")",
"{",
"// Add New Line (if does not exist):",
"if",
"(",
"!",
"preg_match",
"(",
"'/[\\n]$/'",
",",
"$",
"tags",
")",
")",
"{",
"$",
"tags",
".=",
"\"\\n\"",
";",
"}",
"// Add Verification Code Meta Tag:",
"$",
"tags",
".=",
"sprintf",
"(",
"\"<meta name=\\\"%s\\\" content=\\\"%s\\\" />\\n\"",
",",
"self",
"::",
"VERIFICATION_TAG_NAME",
",",
"Convert",
"::",
"raw2att",
"(",
"$",
"code",
")",
")",
";",
"}",
"}"
] | Appends the additional Google tags to the provided meta tags.
@param string $tags
@return void | [
"Appends",
"the",
"additional",
"Google",
"tags",
"to",
"the",
"provided",
"meta",
"tags",
"."
] | 573632d33fe99c9d943fec8733fa5bbce57586f5 | https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/Extensions/PageExtension.php#L48-L67 |
10,578 | frogsystem/metamorphosis | src/frogsystem/metamorphosis/Services/FileConfig.php | FileConfig.getFileIterator | protected function getFileIterator($path, $pattern = '/^.+\.php$/')
{
if (is_dir($path)) {
return new \RegexIterator(new \DirectoryIterator($path), $pattern, \RegexIterator::GET_MATCH);
}
if (is_file($path) && 1 === preg_match($pattern, $path)) {
return [new \SplFileInfo($path)];
}
return [];
} | php | protected function getFileIterator($path, $pattern = '/^.+\.php$/')
{
if (is_dir($path)) {
return new \RegexIterator(new \DirectoryIterator($path), $pattern, \RegexIterator::GET_MATCH);
}
if (is_file($path) && 1 === preg_match($pattern, $path)) {
return [new \SplFileInfo($path)];
}
return [];
} | [
"protected",
"function",
"getFileIterator",
"(",
"$",
"path",
",",
"$",
"pattern",
"=",
"'/^.+\\.php$/'",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"new",
"\\",
"RegexIterator",
"(",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"path",
")",
",",
"$",
"pattern",
",",
"\\",
"RegexIterator",
"::",
"GET_MATCH",
")",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
"&&",
"1",
"===",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"path",
")",
")",
"{",
"return",
"[",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"path",
")",
"]",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Get the iterator for specified config files.
@param $path
@param string $pattern
@return array|\RegexIterator | [
"Get",
"the",
"iterator",
"for",
"specified",
"config",
"files",
"."
] | 27bceaab2a21c6c88b39037e2117d9ff7eb6c814 | https://github.com/frogsystem/metamorphosis/blob/27bceaab2a21c6c88b39037e2117d9ff7eb6c814/src/frogsystem/metamorphosis/Services/FileConfig.php#L40-L49 |
10,579 | velkuns/eureka-package-user | src/User/DataMapper/Mapper/User/UserMapper.php | UserMapper.findFromSession | public function findFromSession(Session $session)
{
$this->addWhere('user_email', $session->get('email'));
$this->addWhere('user_id', (int) $session->get('id'));
$this->addWhere('user_is_activated', 1);
try {
$user = $this->selectOne();
} catch (ExceptionNoData $exception) {
throw new LoginException('Login and / or password is incorrect!', 1000, $exception);
}
return $user;
} | php | public function findFromSession(Session $session)
{
$this->addWhere('user_email', $session->get('email'));
$this->addWhere('user_id', (int) $session->get('id'));
$this->addWhere('user_is_activated', 1);
try {
$user = $this->selectOne();
} catch (ExceptionNoData $exception) {
throw new LoginException('Login and / or password is incorrect!', 1000, $exception);
}
return $user;
} | [
"public",
"function",
"findFromSession",
"(",
"Session",
"$",
"session",
")",
"{",
"$",
"this",
"->",
"addWhere",
"(",
"'user_email'",
",",
"$",
"session",
"->",
"get",
"(",
"'email'",
")",
")",
";",
"$",
"this",
"->",
"addWhere",
"(",
"'user_id'",
",",
"(",
"int",
")",
"$",
"session",
"->",
"get",
"(",
"'id'",
")",
")",
";",
"$",
"this",
"->",
"addWhere",
"(",
"'user_is_activated'",
",",
"1",
")",
";",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"selectOne",
"(",
")",
";",
"}",
"catch",
"(",
"ExceptionNoData",
"$",
"exception",
")",
"{",
"throw",
"new",
"LoginException",
"(",
"'Login and / or password is incorrect!'",
",",
"1000",
",",
"$",
"exception",
")",
";",
"}",
"return",
"$",
"user",
";",
"}"
] | Find user with data from Session.
@param Session $session
@return User
@throws \Exception | [
"Find",
"user",
"with",
"data",
"from",
"Session",
"."
] | b5a60b5a234162558b390ee3d452e4254c790f2b | https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/DataMapper/Mapper/User/UserMapper.php#L53-L66 |
10,580 | amulen/nps-bundle | src/Amulen/NpsBundle/Utils/PaymentMethod.php | PaymentMethod.getOptions | public static function getOptions()
{
$options = [];
$options[] = [
'id' => Operation::PRODUCT_VISA,
'label' => "Visa",
];
$options[] = [
'id' => Operation::PRODUCT_MASTERCARD,
'label' => "Mastercard",
];
$options[] = [
'id' => Operation::PRODUCT_AMERICAN_EXPRESS,
'label' => "American Express",
];
$options[] = [
'id' => Operation::PRODUCT_DINERS,
'label' => "Diners",
];
return $options;
} | php | public static function getOptions()
{
$options = [];
$options[] = [
'id' => Operation::PRODUCT_VISA,
'label' => "Visa",
];
$options[] = [
'id' => Operation::PRODUCT_MASTERCARD,
'label' => "Mastercard",
];
$options[] = [
'id' => Operation::PRODUCT_AMERICAN_EXPRESS,
'label' => "American Express",
];
$options[] = [
'id' => Operation::PRODUCT_DINERS,
'label' => "Diners",
];
return $options;
} | [
"public",
"static",
"function",
"getOptions",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"$",
"options",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"Operation",
"::",
"PRODUCT_VISA",
",",
"'label'",
"=>",
"\"Visa\"",
",",
"]",
";",
"$",
"options",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"Operation",
"::",
"PRODUCT_MASTERCARD",
",",
"'label'",
"=>",
"\"Mastercard\"",
",",
"]",
";",
"$",
"options",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"Operation",
"::",
"PRODUCT_AMERICAN_EXPRESS",
",",
"'label'",
"=>",
"\"American Express\"",
",",
"]",
";",
"$",
"options",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"Operation",
"::",
"PRODUCT_DINERS",
",",
"'label'",
"=>",
"\"Diners\"",
",",
"]",
";",
"return",
"$",
"options",
";",
"}"
] | Payment options.
@return array | [
"Payment",
"options",
"."
] | 10c9e139c0cf1138e6b710477c182c6a28c92f07 | https://github.com/amulen/nps-bundle/blob/10c9e139c0cf1138e6b710477c182c6a28c92f07/src/Amulen/NpsBundle/Utils/PaymentMethod.php#L16-L39 |
10,581 | unimatrix/cake | src/View/Helper/DebugHelper.php | DebugHelper.requestStartTime | public static function requestStartTime($test = false) {
if(defined('TIME_START') && $test === false) $startTime = TIME_START;
elseif(isset($GLOBALS['TIME_START'])) $startTime = $GLOBALS['TIME_START'];
else $startTime = env('REQUEST_TIME');
return $startTime;
} | php | public static function requestStartTime($test = false) {
if(defined('TIME_START') && $test === false) $startTime = TIME_START;
elseif(isset($GLOBALS['TIME_START'])) $startTime = $GLOBALS['TIME_START'];
else $startTime = env('REQUEST_TIME');
return $startTime;
} | [
"public",
"static",
"function",
"requestStartTime",
"(",
"$",
"test",
"=",
"false",
")",
"{",
"if",
"(",
"defined",
"(",
"'TIME_START'",
")",
"&&",
"$",
"test",
"===",
"false",
")",
"$",
"startTime",
"=",
"TIME_START",
";",
"elseif",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TIME_START'",
"]",
")",
")",
"$",
"startTime",
"=",
"$",
"GLOBALS",
"[",
"'TIME_START'",
"]",
";",
"else",
"$",
"startTime",
"=",
"env",
"(",
"'REQUEST_TIME'",
")",
";",
"return",
"$",
"startTime",
";",
"}"
] | Get the time the current request started.
@param bool $test Stub to help test the code by avoiding the constant
@return float time of request start | [
"Get",
"the",
"time",
"the",
"current",
"request",
"started",
"."
] | 23003aba497822bd473fdbf60514052dda1874fc | https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/View/Helper/DebugHelper.php#L45-L51 |
10,582 | bfitech/zapmin | src/AdminStorePrepare.php | AdminStorePrepare.adm_get_safe_user_data | public function adm_get_safe_user_data() {
if (!$this->store_is_logged_in())
return [AdminStoreError::USER_NOT_LOGGED_IN];
$data = $this->user_data;
foreach (['upass', 'usalt', 'sid', 'token', 'expire'] as $key)
unset($data[$key]);
return [0, $data];
} | php | public function adm_get_safe_user_data() {
if (!$this->store_is_logged_in())
return [AdminStoreError::USER_NOT_LOGGED_IN];
$data = $this->user_data;
foreach (['upass', 'usalt', 'sid', 'token', 'expire'] as $key)
unset($data[$key]);
return [0, $data];
} | [
"public",
"function",
"adm_get_safe_user_data",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"store_is_logged_in",
"(",
")",
")",
"return",
"[",
"AdminStoreError",
"::",
"USER_NOT_LOGGED_IN",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"user_data",
";",
"foreach",
"(",
"[",
"'upass'",
",",
"'usalt'",
",",
"'sid'",
",",
"'token'",
",",
"'expire'",
"]",
"as",
"$",
"key",
")",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"return",
"[",
"0",
",",
"$",
"data",
"]",
";",
"}"
] | Get user data excluding sensitive info. | [
"Get",
"user",
"data",
"excluding",
"sensitive",
"info",
"."
] | 4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe | https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStorePrepare.php#L95-L102 |
10,583 | detailnet/dfw-mail | src/Detail/Mail/MtMail/OverrideHeadersComposerPlugin.php | OverrideHeadersComposerPlugin.attach | public function attach(EventManagerInterface $events)
{
$this->listeners[] = $events->attach(
ComposerEvent::EVENT_HEADERS_POST,
array($this, 'injectOverrideHeaders'),
-100 // The priority needs to be lower than the other plugins
);
} | php | public function attach(EventManagerInterface $events)
{
$this->listeners[] = $events->attach(
ComposerEvent::EVENT_HEADERS_POST,
array($this, 'injectOverrideHeaders'),
-100 // The priority needs to be lower than the other plugins
);
} | [
"public",
"function",
"attach",
"(",
"EventManagerInterface",
"$",
"events",
")",
"{",
"$",
"this",
"->",
"listeners",
"[",
"]",
"=",
"$",
"events",
"->",
"attach",
"(",
"ComposerEvent",
"::",
"EVENT_HEADERS_POST",
",",
"array",
"(",
"$",
"this",
",",
"'injectOverrideHeaders'",
")",
",",
"-",
"100",
"// The priority needs to be lower than the other plugins",
")",
";",
"}"
] | Attach listener.
@param EventManagerInterface $events | [
"Attach",
"listener",
"."
] | 87e9f72d5aefc0cfbd2afe75135dc3a343d01138 | https://github.com/detailnet/dfw-mail/blob/87e9f72d5aefc0cfbd2afe75135dc3a343d01138/src/Detail/Mail/MtMail/OverrideHeadersComposerPlugin.php#L42-L49 |
10,584 | starbs/http | src/Controllers/AbstractController.php | AbstractController.index | public function index(Request $request, Response $response, array $args)
{
$this->request = $request;
$this->response = $response;
$this->args = $args;
return $this->fire();
} | php | public function index(Request $request, Response $response, array $args)
{
$this->request = $request;
$this->response = $response;
$this->args = $args;
return $this->fire();
} | [
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"array",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"response",
";",
"$",
"this",
"->",
"args",
"=",
"$",
"args",
";",
"return",
"$",
"this",
"->",
"fire",
"(",
")",
";",
"}"
] | Setup the controller, then run the fire method.
@param \Symfony\Component\HttpFoundation\Request $request
@param \Symfony\Component\HttpFoundation\Response $response
@param string[] $args
@return \Symfony\Component\HttpFoundation\Response | [
"Setup",
"the",
"controller",
"then",
"run",
"the",
"fire",
"method",
"."
] | 71201c9ecd912e43d44dee7bd6a6c2f64b8b0941 | https://github.com/starbs/http/blob/71201c9ecd912e43d44dee7bd6a6c2f64b8b0941/src/Controllers/AbstractController.php#L74-L81 |
10,585 | starbs/http | src/Controllers/AbstractController.php | AbstractController.success | protected function success(array $data, $code = 200)
{
$this->response->setStatusCode($code);
$this->response->headers->add(['Content-Type' => 'application/json']);
$this->response->setContent(json_encode(['success' => $data], JSON_PRETTY_PRINT));
return $this->response;
} | php | protected function success(array $data, $code = 200)
{
$this->response->setStatusCode($code);
$this->response->headers->add(['Content-Type' => 'application/json']);
$this->response->setContent(json_encode(['success' => $data], JSON_PRETTY_PRINT));
return $this->response;
} | [
"protected",
"function",
"success",
"(",
"array",
"$",
"data",
",",
"$",
"code",
"=",
"200",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"setStatusCode",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"response",
"->",
"headers",
"->",
"add",
"(",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
")",
";",
"$",
"this",
"->",
"response",
"->",
"setContent",
"(",
"json_encode",
"(",
"[",
"'success'",
"=>",
"$",
"data",
"]",
",",
"JSON_PRETTY_PRINT",
")",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | Get a success response json.
@param string[] $data
@param int $code
@return \Symfony\Component\HttpFoundation\Response | [
"Get",
"a",
"success",
"response",
"json",
"."
] | 71201c9ecd912e43d44dee7bd6a6c2f64b8b0941 | https://github.com/starbs/http/blob/71201c9ecd912e43d44dee7bd6a6c2f64b8b0941/src/Controllers/AbstractController.php#L98-L105 |
10,586 | starbs/http | src/Controllers/AbstractController.php | AbstractController.redirect | protected function redirect($url, $code = 302)
{
$this->response->setStatusCode($code);
$this->response->headers->set('Location', $url);
return $this->response;
} | php | protected function redirect($url, $code = 302)
{
$this->response->setStatusCode($code);
$this->response->headers->set('Location', $url);
return $this->response;
} | [
"protected",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"code",
"=",
"302",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"setStatusCode",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Location'",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | Get a redirection response.
@param string $url
@param int $code
@return \Symfony\Component\HttpFoundation\Response | [
"Get",
"a",
"redirection",
"response",
"."
] | 71201c9ecd912e43d44dee7bd6a6c2f64b8b0941 | https://github.com/starbs/http/blob/71201c9ecd912e43d44dee7bd6a6c2f64b8b0941/src/Controllers/AbstractController.php#L115-L121 |
10,587 | starbs/http | src/Controllers/AbstractController.php | AbstractController.raw | protected function raw($data, $mime, $code = 200)
{
$this->response->setStatusCode($code);
$this->response->headers->add(['Content-Type' => $mime]);
$this->response->setContent($data);
return $this->response;
} | php | protected function raw($data, $mime, $code = 200)
{
$this->response->setStatusCode($code);
$this->response->headers->add(['Content-Type' => $mime]);
$this->response->setContent($data);
return $this->response;
} | [
"protected",
"function",
"raw",
"(",
"$",
"data",
",",
"$",
"mime",
",",
"$",
"code",
"=",
"200",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"setStatusCode",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"response",
"->",
"headers",
"->",
"add",
"(",
"[",
"'Content-Type'",
"=>",
"$",
"mime",
"]",
")",
";",
"$",
"this",
"->",
"response",
"->",
"setContent",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | Get a custom response.
@param string $data
@param string $mime
@param int $code
@return \Symfony\Component\HttpFoundation\Response | [
"Get",
"a",
"custom",
"response",
"."
] | 71201c9ecd912e43d44dee7bd6a6c2f64b8b0941 | https://github.com/starbs/http/blob/71201c9ecd912e43d44dee7bd6a6c2f64b8b0941/src/Controllers/AbstractController.php#L149-L156 |
10,588 | JamesRezo/webhelper-parser | src/Directive/InclusionDirective.php | InclusionDirective.setFiles | public function setFiles()
{
$this->files = [];
$path = $this->getValue();
if (!preg_match('#^/#', $path)) {
$path = $this->parser->getServer()->getPrefix().'/'.$path;
}
$iterator = new GlobIterator($path);
foreach ($iterator as $path) {
$this->files[] = $path;
}
return $this;
} | php | public function setFiles()
{
$this->files = [];
$path = $this->getValue();
if (!preg_match('#^/#', $path)) {
$path = $this->parser->getServer()->getPrefix().'/'.$path;
}
$iterator = new GlobIterator($path);
foreach ($iterator as $path) {
$this->files[] = $path;
}
return $this;
} | [
"public",
"function",
"setFiles",
"(",
")",
"{",
"$",
"this",
"->",
"files",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'#^/#'",
",",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"parser",
"->",
"getServer",
"(",
")",
"->",
"getPrefix",
"(",
")",
".",
"'/'",
".",
"$",
"path",
";",
"}",
"$",
"iterator",
"=",
"new",
"GlobIterator",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Detects and memoizes the included files. | [
"Detects",
"and",
"memoizes",
"the",
"included",
"files",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Directive/InclusionDirective.php#L69-L84 |
10,589 | JamesRezo/webhelper-parser | src/Directive/InclusionDirective.php | InclusionDirective.compileFiles | public function compileFiles()
{
foreach ($this->files as $file) {
$activeConfig = $this->parser->setConfigFile($file)->getActiveConfig();
$this->add($activeConfig);
}
return $this;
} | php | public function compileFiles()
{
foreach ($this->files as $file) {
$activeConfig = $this->parser->setConfigFile($file)->getActiveConfig();
$this->add($activeConfig);
}
return $this;
} | [
"public",
"function",
"compileFiles",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"activeConfig",
"=",
"$",
"this",
"->",
"parser",
"->",
"setConfigFile",
"(",
"$",
"file",
")",
"->",
"getActiveConfig",
"(",
")",
";",
"$",
"this",
"->",
"add",
"(",
"$",
"activeConfig",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Fills the block directives by compiling the memoized files. | [
"Fills",
"the",
"block",
"directives",
"by",
"compiling",
"the",
"memoized",
"files",
"."
] | 0b39e7abe8f35afbeacdd6681fa9d0767888c646 | https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Directive/InclusionDirective.php#L89-L97 |
10,590 | novuso/common | src/Domain/Value/DateTime/Timezone.php | Timezone.compareParts | protected function compareParts(array $thisParts, array $thatParts): int
{
$compMajor = strnatcmp($thisParts[0], $thatParts[0]);
if ($compMajor > 0) {
return 1;
}
if ($compMajor < 0) {
return -1;
}
$compMinor = strnatcmp($thisParts[1], $thatParts[1]);
if ($compMinor > 0) {
return 1;
}
if ($compMinor < 0) {
return -1;
}
if (isset($thisParts[2]) && isset($thatParts[2])) {
$compSub = strnatcmp($thisParts[2], $thatParts[2]);
return $compSub <=> 0;
}
return 0;
} | php | protected function compareParts(array $thisParts, array $thatParts): int
{
$compMajor = strnatcmp($thisParts[0], $thatParts[0]);
if ($compMajor > 0) {
return 1;
}
if ($compMajor < 0) {
return -1;
}
$compMinor = strnatcmp($thisParts[1], $thatParts[1]);
if ($compMinor > 0) {
return 1;
}
if ($compMinor < 0) {
return -1;
}
if (isset($thisParts[2]) && isset($thatParts[2])) {
$compSub = strnatcmp($thisParts[2], $thatParts[2]);
return $compSub <=> 0;
}
return 0;
} | [
"protected",
"function",
"compareParts",
"(",
"array",
"$",
"thisParts",
",",
"array",
"$",
"thatParts",
")",
":",
"int",
"{",
"$",
"compMajor",
"=",
"strnatcmp",
"(",
"$",
"thisParts",
"[",
"0",
"]",
",",
"$",
"thatParts",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"compMajor",
">",
"0",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"compMajor",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"$",
"compMinor",
"=",
"strnatcmp",
"(",
"$",
"thisParts",
"[",
"1",
"]",
",",
"$",
"thatParts",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"compMinor",
">",
"0",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"compMinor",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"thisParts",
"[",
"2",
"]",
")",
"&&",
"isset",
"(",
"$",
"thatParts",
"[",
"2",
"]",
")",
")",
"{",
"$",
"compSub",
"=",
"strnatcmp",
"(",
"$",
"thisParts",
"[",
"2",
"]",
",",
"$",
"thatParts",
"[",
"2",
"]",
")",
";",
"return",
"$",
"compSub",
"<=>",
"0",
";",
"}",
"return",
"0",
";",
"}"
] | Compares two timezones by segments
@param array $thisParts This parts
@param array $thatParts Other parts
@return int | [
"Compares",
"two",
"timezones",
"by",
"segments"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Timezone.php#L120-L143 |
10,591 | marando/phpSOFA | src/Marando/IAU/iauApco.php | iauApco.Apco | public static function Apco($date1, $date2, array $ebpv, array $ehp, $x,
$y, $s, $theta, $elong, $phi, $hm, $xp, $yp, $sp, $refa, $refb,
iauASTROM &$astrom) {
$sl;
$cl;
$r = [];
$pvc = [];
$pv = [[],[]];
/* Longitude with adjustment for TIO locator s'. */
$astrom->along = $elong + $sp;
/* Polar motion, rotated onto the local meridian. */
$sl = sin($astrom->along);
$cl = cos($astrom->along);
$astrom->xpl = $xp * $cl - $yp * $sl;
$astrom->ypl = $xp * $sl + $yp * $cl;
/* Functions of latitude. */
$astrom->sphi = sin($phi);
$astrom->cphi = cos($phi);
/* Refraction constants. */
$astrom->refa = $refa;
$astrom->refb = $refb;
/* Local Earth rotation angle. */
IAU::Aper($theta, $astrom);
/* Disable the (redundant) diurnal aberration step. */
$astrom->diurab = 0.0;
/* CIO based BPN matrix. */
IAU::C2ixys($x, $y, $s, $r);
/* Observer's geocentric position and velocity (m, m/s, CIRS). */
IAU::Pvtob($elong, $phi, $hm, $xp, $yp, $sp, $theta, $pvc);
/* Rotate into GCRS. */
IAU::Trxpv($r, $pvc, $pv);
/* ICRS <-> GCRS parameters. */
IAU::Apcs($date1, $date2, $pv, $ebpv, $ehp, $astrom);
/* Store the CIO based BPN matrix. */
IAU::Cr($r, $astrom->bpn);
/* Finished. */
} | php | public static function Apco($date1, $date2, array $ebpv, array $ehp, $x,
$y, $s, $theta, $elong, $phi, $hm, $xp, $yp, $sp, $refa, $refb,
iauASTROM &$astrom) {
$sl;
$cl;
$r = [];
$pvc = [];
$pv = [[],[]];
/* Longitude with adjustment for TIO locator s'. */
$astrom->along = $elong + $sp;
/* Polar motion, rotated onto the local meridian. */
$sl = sin($astrom->along);
$cl = cos($astrom->along);
$astrom->xpl = $xp * $cl - $yp * $sl;
$astrom->ypl = $xp * $sl + $yp * $cl;
/* Functions of latitude. */
$astrom->sphi = sin($phi);
$astrom->cphi = cos($phi);
/* Refraction constants. */
$astrom->refa = $refa;
$astrom->refb = $refb;
/* Local Earth rotation angle. */
IAU::Aper($theta, $astrom);
/* Disable the (redundant) diurnal aberration step. */
$astrom->diurab = 0.0;
/* CIO based BPN matrix. */
IAU::C2ixys($x, $y, $s, $r);
/* Observer's geocentric position and velocity (m, m/s, CIRS). */
IAU::Pvtob($elong, $phi, $hm, $xp, $yp, $sp, $theta, $pvc);
/* Rotate into GCRS. */
IAU::Trxpv($r, $pvc, $pv);
/* ICRS <-> GCRS parameters. */
IAU::Apcs($date1, $date2, $pv, $ebpv, $ehp, $astrom);
/* Store the CIO based BPN matrix. */
IAU::Cr($r, $astrom->bpn);
/* Finished. */
} | [
"public",
"static",
"function",
"Apco",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"array",
"$",
"ebpv",
",",
"array",
"$",
"ehp",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"s",
",",
"$",
"theta",
",",
"$",
"elong",
",",
"$",
"phi",
",",
"$",
"hm",
",",
"$",
"xp",
",",
"$",
"yp",
",",
"$",
"sp",
",",
"$",
"refa",
",",
"$",
"refb",
",",
"iauASTROM",
"&",
"$",
"astrom",
")",
"{",
"$",
"sl",
";",
"$",
"cl",
";",
"$",
"r",
"=",
"[",
"]",
";",
"$",
"pvc",
"=",
"[",
"]",
";",
"$",
"pv",
"=",
"[",
"[",
"]",
",",
"[",
"]",
"]",
";",
"/* Longitude with adjustment for TIO locator s'. */",
"$",
"astrom",
"->",
"along",
"=",
"$",
"elong",
"+",
"$",
"sp",
";",
"/* Polar motion, rotated onto the local meridian. */",
"$",
"sl",
"=",
"sin",
"(",
"$",
"astrom",
"->",
"along",
")",
";",
"$",
"cl",
"=",
"cos",
"(",
"$",
"astrom",
"->",
"along",
")",
";",
"$",
"astrom",
"->",
"xpl",
"=",
"$",
"xp",
"*",
"$",
"cl",
"-",
"$",
"yp",
"*",
"$",
"sl",
";",
"$",
"astrom",
"->",
"ypl",
"=",
"$",
"xp",
"*",
"$",
"sl",
"+",
"$",
"yp",
"*",
"$",
"cl",
";",
"/* Functions of latitude. */",
"$",
"astrom",
"->",
"sphi",
"=",
"sin",
"(",
"$",
"phi",
")",
";",
"$",
"astrom",
"->",
"cphi",
"=",
"cos",
"(",
"$",
"phi",
")",
";",
"/* Refraction constants. */",
"$",
"astrom",
"->",
"refa",
"=",
"$",
"refa",
";",
"$",
"astrom",
"->",
"refb",
"=",
"$",
"refb",
";",
"/* Local Earth rotation angle. */",
"IAU",
"::",
"Aper",
"(",
"$",
"theta",
",",
"$",
"astrom",
")",
";",
"/* Disable the (redundant) diurnal aberration step. */",
"$",
"astrom",
"->",
"diurab",
"=",
"0.0",
";",
"/* CIO based BPN matrix. */",
"IAU",
"::",
"C2ixys",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"s",
",",
"$",
"r",
")",
";",
"/* Observer's geocentric position and velocity (m, m/s, CIRS). */",
"IAU",
"::",
"Pvtob",
"(",
"$",
"elong",
",",
"$",
"phi",
",",
"$",
"hm",
",",
"$",
"xp",
",",
"$",
"yp",
",",
"$",
"sp",
",",
"$",
"theta",
",",
"$",
"pvc",
")",
";",
"/* Rotate into GCRS. */",
"IAU",
"::",
"Trxpv",
"(",
"$",
"r",
",",
"$",
"pvc",
",",
"$",
"pv",
")",
";",
"/* ICRS <-> GCRS parameters. */",
"IAU",
"::",
"Apcs",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"pv",
",",
"$",
"ebpv",
",",
"$",
"ehp",
",",
"$",
"astrom",
")",
";",
"/* Store the CIO based BPN matrix. */",
"IAU",
"::",
"Cr",
"(",
"$",
"r",
",",
"$",
"astrom",
"->",
"bpn",
")",
";",
"/* Finished. */",
"}"
] | - - - - - - - -
i a u A p c o
- - - - - - - -
For a terrestrial observer, prepare star-independent astrometry
parameters for transformations between ICRS and observed
coordinates. The caller supplies the Earth ephemeris, the Earth
rotation information and the refraction constants as well as the
site coordinates.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
date1 double TDB as a 2-part...
date2 double ...Julian Date (Note 1)
ebpv double[2][3] Earth barycentric PV (au, au/day, Note 2)
ehp double[3] Earth heliocentric P (au, Note 2)
x,y double CIP X,Y (components of unit vector)
s double the CIO locator s (radians)
theta double Earth rotation angle (radians)
elong double longitude (radians, east +ve, Note 3)
phi double latitude (geodetic, radians, Note 3)
hm double height above ellipsoid (m, geodetic, Note 3)
xp,yp double polar motion coordinates (radians, Note 4)
sp double the TIO locator s' (radians, Note 4)
refa double refraction constant A (radians, Note 5)
refb double refraction constant B (radians, Note 5)
Returned:
astrom iauASTROM* star-independent astrometry parameters:
pmt double PM time interval (SSB, Julian years)
eb double[3] SSB to observer (vector, au)
eh double[3] Sun to observer (unit vector)
em double distance from Sun to observer (au)
v double[3] barycentric observer velocity (vector, c)
bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor
bpn double[3][3] bias-precession-nutation matrix
along double longitude + s' (radians)
xpl double polar motion xp wrt local meridian (radians)
ypl double polar motion yp wrt local meridian (radians)
sphi double sine of geodetic latitude
cphi double cosine of geodetic latitude
diurab double magnitude of diurnal aberration vector
eral double "local" Earth rotation angle (radians)
refa double refraction constant A (radians)
refb double refraction constant B (radians)
Notes:
1) The TDB date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TDB)=2450123.7 could be expressed in any of these ways, among
others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in cases
where the loss of several decimal digits of resolution is
acceptable. The J2000 method is best matched to the way the
argument is handled internally and will deliver the optimum
resolution. The MJD method and the date & time methods are both
good compromises between resolution and convenience. For most
applications of this function the choice will not be at all
critical.
TT can be used instead of TDB without any significant impact on
accuracy.
2) The vectors eb, eh, and all the astrom vectors, are with respect
to BCRS axes.
3) The geographical coordinates are with respect to the WGS84
reference ellipsoid. TAKE CARE WITH THE LONGITUDE SIGN
CONVENTION: the longitude required by the present function is
right-handed, i.e. east-positive, in accordance with geographical
convention.
4) xp and yp are the coordinates (in radians) of the Celestial
Intermediate Pole with respect to the International Terrestrial
Reference System (see IERS Conventions), measured along the
meridians 0 and 90 deg west respectively. sp is the TIO locator
s', in radians, which positions the Terrestrial Intermediate
Origin on the equator. For many applications, xp, yp and
(especially) sp can be set to zero.
Internally, the polar motion is stored in a form rotated onto the
local meridian.
5) The refraction constants refa and refb are for use in a
dZ = A*tan(Z)+B*tan^3(Z) model, where Z is the observed
(i.e. refracted) zenith distance and dZ is the amount of
refraction.
6) It is advisable to take great care with units, as even unlikely
values of the input parameters are accepted and processed in
accordance with the models used.
7) In cases where the caller does not wish to provide the Earth
Ephemeris, the Earth rotation information and refraction
constants, the function iauApco13 can be used instead of the
present function. This starts from UTC and weather readings etc.
and computes suitable values using other SOFA functions.
8) This is one of several functions that inserts into the astrom
structure star-independent parameters needed for the chain of
astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed.
The various functions support different classes of observer and
portions of the transformation chain:
functions observer transformation
iauApcg iauApcg13 geocentric ICRS <-> GCRS
iauApci iauApci13 terrestrial ICRS <-> CIRS
iauApco iauApco13 terrestrial ICRS <-> observed
iauApcs iauApcs13 space ICRS <-> GCRS
iauAper iauAper13 terrestrial update Earth rotation
iauApio iauApio13 terrestrial CIRS <-> observed
Those with names ending in "13" use contemporary SOFA models to
compute the various ephemerides. The others accept ephemerides
supplied by the caller.
The transformation from ICRS to GCRS covers space motion,
parallax, light deflection, and aberration. From GCRS to CIRS
comprises frame bias and precession-nutation. From CIRS to
observed takes account of Earth rotation, polar motion, diurnal
aberration and parallax (unless subsumed into the ICRS <-> GCRS
transformation), and atmospheric refraction.
9) The context structure astrom produced by this function is used by
iauAtioq, iauAtoiq, iauAtciq* and iauAticq*.
Called:
iauAper astrometry parameters: update ERA
iauC2ixys celestial-to-intermediate matrix, given X,Y and s
iauPvtob position/velocity of terrestrial station
iauTrxpv product of transpose of r-matrix and pv-vector
iauApcs astrometry parameters, ICRS-GCRS, space observer
iauCr copy r-matrix
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"A",
"p",
"c",
"o",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauApco.php#L163-L212 |
10,592 | GustavSoftware/Cache | src/Configuration.php | Configuration.setImplementation | public function setImplementation(string $className): Configuration
{
if(!\is_subclass_of($className, ACacheManager::class)) {
throw CacheException::invalidImplementation($className);
}
$this->_implementation = $className;
return $this;
} | php | public function setImplementation(string $className): Configuration
{
if(!\is_subclass_of($className, ACacheManager::class)) {
throw CacheException::invalidImplementation($className);
}
$this->_implementation = $className;
return $this;
} | [
"public",
"function",
"setImplementation",
"(",
"string",
"$",
"className",
")",
":",
"Configuration",
"{",
"if",
"(",
"!",
"\\",
"is_subclass_of",
"(",
"$",
"className",
",",
"ACacheManager",
"::",
"class",
")",
")",
"{",
"throw",
"CacheException",
"::",
"invalidImplementation",
"(",
"$",
"className",
")",
";",
"}",
"$",
"this",
"->",
"_implementation",
"=",
"$",
"className",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the class name of the implementation of the cache manager that
should be used on runtime. Consider that this class name has to extent
the \Gustav\Cache\ACacheManager class. Otherwise this method will throw
an CacheException.
@param string $className
The class name of the implementation to use here
@return \Gustav\Cache\Configuration
This object
@throws \Gustav\Cache\CacheException
Invalid implementation | [
"Sets",
"the",
"class",
"name",
"of",
"the",
"implementation",
"of",
"the",
"cache",
"manager",
"that",
"should",
"be",
"used",
"on",
"runtime",
".",
"Consider",
"that",
"this",
"class",
"name",
"has",
"to",
"extent",
"the",
"\\",
"Gustav",
"\\",
"Cache",
"\\",
"ACacheManager",
"class",
".",
"Otherwise",
"this",
"method",
"will",
"throw",
"an",
"CacheException",
"."
] | 2a70db567aa13499487c24b399f7c9d46937df0d | https://github.com/GustavSoftware/Cache/blob/2a70db567aa13499487c24b399f7c9d46937df0d/src/Configuration.php#L87-L94 |
10,593 | bugotech/foundation | src/Application.php | Application.path | public function path($type, $path = null)
{
$instance = sprintf('path.%s', $type);
$base = $this->basePath;
// Verificar se foi instanciado um path diferente
if (array_key_exists($instance, $this->instances)) {
$base = $this->instances[$instance];
}
// Verificar se foi implementado em config
$key = sprintf('paths.%s', strtolower($type));
$base = config($key, $base);
// Verificar se deve colocar a base
if (substr($base, 0, 2) == './') {
$base = $this->basePath . DIRECTORY_SEPARATOR . substr($base, 2);
}
// Verificar se deve adiconar type no path
if ($base == $this->basePath) {
$path = is_null($path) ? $type : $type . DIRECTORY_SEPARATOR . $path;
}
// Retornar
return is_null($path) ? $base : $base . DIRECTORY_SEPARATOR . $path;
} | php | public function path($type, $path = null)
{
$instance = sprintf('path.%s', $type);
$base = $this->basePath;
// Verificar se foi instanciado um path diferente
if (array_key_exists($instance, $this->instances)) {
$base = $this->instances[$instance];
}
// Verificar se foi implementado em config
$key = sprintf('paths.%s', strtolower($type));
$base = config($key, $base);
// Verificar se deve colocar a base
if (substr($base, 0, 2) == './') {
$base = $this->basePath . DIRECTORY_SEPARATOR . substr($base, 2);
}
// Verificar se deve adiconar type no path
if ($base == $this->basePath) {
$path = is_null($path) ? $type : $type . DIRECTORY_SEPARATOR . $path;
}
// Retornar
return is_null($path) ? $base : $base . DIRECTORY_SEPARATOR . $path;
} | [
"public",
"function",
"path",
"(",
"$",
"type",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"sprintf",
"(",
"'path.%s'",
",",
"$",
"type",
")",
";",
"$",
"base",
"=",
"$",
"this",
"->",
"basePath",
";",
"// Verificar se foi instanciado um path diferente",
"if",
"(",
"array_key_exists",
"(",
"$",
"instance",
",",
"$",
"this",
"->",
"instances",
")",
")",
"{",
"$",
"base",
"=",
"$",
"this",
"->",
"instances",
"[",
"$",
"instance",
"]",
";",
"}",
"// Verificar se foi implementado em config",
"$",
"key",
"=",
"sprintf",
"(",
"'paths.%s'",
",",
"strtolower",
"(",
"$",
"type",
")",
")",
";",
"$",
"base",
"=",
"config",
"(",
"$",
"key",
",",
"$",
"base",
")",
";",
"// Verificar se deve colocar a base",
"if",
"(",
"substr",
"(",
"$",
"base",
",",
"0",
",",
"2",
")",
"==",
"'./'",
")",
"{",
"$",
"base",
"=",
"$",
"this",
"->",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"substr",
"(",
"$",
"base",
",",
"2",
")",
";",
"}",
"// Verificar se deve adiconar type no path",
"if",
"(",
"$",
"base",
"==",
"$",
"this",
"->",
"basePath",
")",
"{",
"$",
"path",
"=",
"is_null",
"(",
"$",
"path",
")",
"?",
"$",
"type",
":",
"$",
"type",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"path",
";",
"}",
"// Retornar",
"return",
"is_null",
"(",
"$",
"path",
")",
"?",
"$",
"base",
":",
"$",
"base",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"path",
";",
"}"
] | Return path of type.
@param $type
@param null $path
@return string | [
"Return",
"path",
"of",
"type",
"."
] | e4b96cd1cef117e9c5f2c6f5671d260853317658 | https://github.com/bugotech/foundation/blob/e4b96cd1cef117e9c5f2c6f5671d260853317658/src/Application.php#L283-L309 |
10,594 | bugotech/foundation | src/Application.php | Application.registerContainerBase | protected function registerContainerBase()
{
// Composer
$this->singleton('composer', function ($app) {
return new Composer($app->make('files'), $this->basePath());
});
// Config
$this->singleton('config', function () {
return new ConfigRepository();
});
// Files e Storage
$this->loadComponent('filesystems', '\Bugotech\Foundation\IO\FilesystemServiceProvider', 'filesystem');
// Log
$this->singleton('log', function () {
return new Logger('netforce', [$this->getMonologHandler()]);
});
// Artisan - Console
$this->register('\Bugotech\Foundation\Console\ConsoleServiceProvider');
// Cache
$this->singleton('cache', function () {
return $this->loadComponent('cache', 'Illuminate\Cache\CacheServiceProvider');
});
$this->singleton('cache.store', function () {
return $this->loadComponent('cache', 'Illuminate\Cache\CacheServiceProvider', 'cache.store');
});
// Hash
$this->register('\Illuminate\Hashing\HashServiceProvider');
// Encryption
$this->register('\Illuminate\Encryption\EncryptionServiceProvider');
} | php | protected function registerContainerBase()
{
// Composer
$this->singleton('composer', function ($app) {
return new Composer($app->make('files'), $this->basePath());
});
// Config
$this->singleton('config', function () {
return new ConfigRepository();
});
// Files e Storage
$this->loadComponent('filesystems', '\Bugotech\Foundation\IO\FilesystemServiceProvider', 'filesystem');
// Log
$this->singleton('log', function () {
return new Logger('netforce', [$this->getMonologHandler()]);
});
// Artisan - Console
$this->register('\Bugotech\Foundation\Console\ConsoleServiceProvider');
// Cache
$this->singleton('cache', function () {
return $this->loadComponent('cache', 'Illuminate\Cache\CacheServiceProvider');
});
$this->singleton('cache.store', function () {
return $this->loadComponent('cache', 'Illuminate\Cache\CacheServiceProvider', 'cache.store');
});
// Hash
$this->register('\Illuminate\Hashing\HashServiceProvider');
// Encryption
$this->register('\Illuminate\Encryption\EncryptionServiceProvider');
} | [
"protected",
"function",
"registerContainerBase",
"(",
")",
"{",
"// Composer",
"$",
"this",
"->",
"singleton",
"(",
"'composer'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Composer",
"(",
"$",
"app",
"->",
"make",
"(",
"'files'",
")",
",",
"$",
"this",
"->",
"basePath",
"(",
")",
")",
";",
"}",
")",
";",
"// Config",
"$",
"this",
"->",
"singleton",
"(",
"'config'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"ConfigRepository",
"(",
")",
";",
"}",
")",
";",
"// Files e Storage",
"$",
"this",
"->",
"loadComponent",
"(",
"'filesystems'",
",",
"'\\Bugotech\\Foundation\\IO\\FilesystemServiceProvider'",
",",
"'filesystem'",
")",
";",
"// Log",
"$",
"this",
"->",
"singleton",
"(",
"'log'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"Logger",
"(",
"'netforce'",
",",
"[",
"$",
"this",
"->",
"getMonologHandler",
"(",
")",
"]",
")",
";",
"}",
")",
";",
"// Artisan - Console",
"$",
"this",
"->",
"register",
"(",
"'\\Bugotech\\Foundation\\Console\\ConsoleServiceProvider'",
")",
";",
"// Cache",
"$",
"this",
"->",
"singleton",
"(",
"'cache'",
",",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"loadComponent",
"(",
"'cache'",
",",
"'Illuminate\\Cache\\CacheServiceProvider'",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"singleton",
"(",
"'cache.store'",
",",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"loadComponent",
"(",
"'cache'",
",",
"'Illuminate\\Cache\\CacheServiceProvider'",
",",
"'cache.store'",
")",
";",
"}",
")",
";",
"// Hash",
"$",
"this",
"->",
"register",
"(",
"'\\Illuminate\\Hashing\\HashServiceProvider'",
")",
";",
"// Encryption",
"$",
"this",
"->",
"register",
"(",
"'\\Illuminate\\Encryption\\EncryptionServiceProvider'",
")",
";",
"}"
] | Register the core conteiner base structures.
@return void | [
"Register",
"the",
"core",
"conteiner",
"base",
"structures",
"."
] | e4b96cd1cef117e9c5f2c6f5671d260853317658 | https://github.com/bugotech/foundation/blob/e4b96cd1cef117e9c5f2c6f5671d260853317658/src/Application.php#L372-L408 |
10,595 | unyx/diagnostics | debug/Handler.php | Handler.apply | public function apply($condition, callable $onMatch = null) : self
{
if (!is_callable($condition)) {
if (!$condition instanceof Condition) {
throw new \InvalidArgumentException('Expected a \nyx\diagnostics\Condition or a callable as first argument, got ['.diagnostics\Debug::getTypeName($condition).'] instead.');
}
$this->conditions[] = $condition;
} else {
// Both parameters are/should be callables.
if (null === $onMatch) {
throw new \InvalidArgumentException('A callable must be given as second parameter when the first is also a callable.');
}
$this->conditions[] = [
'matcher' => $condition,
'onMatch' => $onMatch
];
}
return $this;
} | php | public function apply($condition, callable $onMatch = null) : self
{
if (!is_callable($condition)) {
if (!$condition instanceof Condition) {
throw new \InvalidArgumentException('Expected a \nyx\diagnostics\Condition or a callable as first argument, got ['.diagnostics\Debug::getTypeName($condition).'] instead.');
}
$this->conditions[] = $condition;
} else {
// Both parameters are/should be callables.
if (null === $onMatch) {
throw new \InvalidArgumentException('A callable must be given as second parameter when the first is also a callable.');
}
$this->conditions[] = [
'matcher' => $condition,
'onMatch' => $onMatch
];
}
return $this;
} | [
"public",
"function",
"apply",
"(",
"$",
"condition",
",",
"callable",
"$",
"onMatch",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"condition",
")",
")",
"{",
"if",
"(",
"!",
"$",
"condition",
"instanceof",
"Condition",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected a \\nyx\\diagnostics\\Condition or a callable as first argument, got ['",
".",
"diagnostics",
"\\",
"Debug",
"::",
"getTypeName",
"(",
"$",
"condition",
")",
".",
"'] instead.'",
")",
";",
"}",
"$",
"this",
"->",
"conditions",
"[",
"]",
"=",
"$",
"condition",
";",
"}",
"else",
"{",
"// Both parameters are/should be callables.",
"if",
"(",
"null",
"===",
"$",
"onMatch",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'A callable must be given as second parameter when the first is also a callable.'",
")",
";",
"}",
"$",
"this",
"->",
"conditions",
"[",
"]",
"=",
"[",
"'matcher'",
"=>",
"$",
"condition",
",",
"'onMatch'",
"=>",
"$",
"onMatch",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Applies a Condition to this Handler.
@param Condition|callable $condition Either a Condition instance or a 'matcher' callable accepting one
two arguments - an Exception and a Handler instance, and
returning true/false when the given Exception is a match or not.
When a callable is given, the second argument to this method must
also be given.
@param callable $onMatch A callable containing the code that should be executed when the
'matcher' callable given as first argument returns true. This
argument is ignored when a concrete Condition instance is given
as the first argument instead of a callable.
@return $this
@throws \InvalidArgumentException When a callable is given as first argument but the second is
missing or when neither a Condition instance nor a callable are
given as the first argument. | [
"Applies",
"a",
"Condition",
"to",
"this",
"Handler",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Handler.php#L60-L81 |
10,596 | unyx/diagnostics | debug/Handler.php | Handler.runConditions | protected function runConditions(\Exception $exception) : bool
{
$prevent = false;
foreach ($this->conditions as $condition) {
// We can call the methods on a Condition instance directly.
if ($condition instanceof Condition) {
if (true === $condition->matches($exception, $this)) {
$response = $condition->onMatch($exception, $this);
} else {
continue;
}
}
// Otherwise we're dealing with our little 'array' condition, ie. two callables. Run the match straight
// away.
elseif (true === call_user_func($condition['matcher'], $exception, $this)) {
$response = call_user_func($condition['onMatch'], $exception, $this);
} else {
continue;
}
// Now let's check what onMatch() returned and see if it's a QUIT and we may exit.
if (($response & definitions\Signals::QUIT) === definitions\Signals::QUIT && $this->allowQuit) {
exit;
}
// Using the PREVENT signal on its own will not break the loop but we will need to pass it to the Handler
// afterwards so it knows that it shouldn't proceed with its own code.
if (($response & definitions\Signals::PREVENT) === definitions\Signals::PREVENT) {
$prevent = true;
}
// QUIT includes STOP so this will catch both situations.
if (($response & definitions\Signals::STOP) === definitions\Signals::STOP) {
break;
}
}
return $prevent;
} | php | protected function runConditions(\Exception $exception) : bool
{
$prevent = false;
foreach ($this->conditions as $condition) {
// We can call the methods on a Condition instance directly.
if ($condition instanceof Condition) {
if (true === $condition->matches($exception, $this)) {
$response = $condition->onMatch($exception, $this);
} else {
continue;
}
}
// Otherwise we're dealing with our little 'array' condition, ie. two callables. Run the match straight
// away.
elseif (true === call_user_func($condition['matcher'], $exception, $this)) {
$response = call_user_func($condition['onMatch'], $exception, $this);
} else {
continue;
}
// Now let's check what onMatch() returned and see if it's a QUIT and we may exit.
if (($response & definitions\Signals::QUIT) === definitions\Signals::QUIT && $this->allowQuit) {
exit;
}
// Using the PREVENT signal on its own will not break the loop but we will need to pass it to the Handler
// afterwards so it knows that it shouldn't proceed with its own code.
if (($response & definitions\Signals::PREVENT) === definitions\Signals::PREVENT) {
$prevent = true;
}
// QUIT includes STOP so this will catch both situations.
if (($response & definitions\Signals::STOP) === definitions\Signals::STOP) {
break;
}
}
return $prevent;
} | [
"protected",
"function",
"runConditions",
"(",
"\\",
"Exception",
"$",
"exception",
")",
":",
"bool",
"{",
"$",
"prevent",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"conditions",
"as",
"$",
"condition",
")",
"{",
"// We can call the methods on a Condition instance directly.",
"if",
"(",
"$",
"condition",
"instanceof",
"Condition",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"condition",
"->",
"matches",
"(",
"$",
"exception",
",",
"$",
"this",
")",
")",
"{",
"$",
"response",
"=",
"$",
"condition",
"->",
"onMatch",
"(",
"$",
"exception",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"}",
"// Otherwise we're dealing with our little 'array' condition, ie. two callables. Run the match straight",
"// away.",
"elseif",
"(",
"true",
"===",
"call_user_func",
"(",
"$",
"condition",
"[",
"'matcher'",
"]",
",",
"$",
"exception",
",",
"$",
"this",
")",
")",
"{",
"$",
"response",
"=",
"call_user_func",
"(",
"$",
"condition",
"[",
"'onMatch'",
"]",
",",
"$",
"exception",
",",
"$",
"this",
")",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"// Now let's check what onMatch() returned and see if it's a QUIT and we may exit.",
"if",
"(",
"(",
"$",
"response",
"&",
"definitions",
"\\",
"Signals",
"::",
"QUIT",
")",
"===",
"definitions",
"\\",
"Signals",
"::",
"QUIT",
"&&",
"$",
"this",
"->",
"allowQuit",
")",
"{",
"exit",
";",
"}",
"// Using the PREVENT signal on its own will not break the loop but we will need to pass it to the Handler",
"// afterwards so it knows that it shouldn't proceed with its own code.",
"if",
"(",
"(",
"$",
"response",
"&",
"definitions",
"\\",
"Signals",
"::",
"PREVENT",
")",
"===",
"definitions",
"\\",
"Signals",
"::",
"PREVENT",
")",
"{",
"$",
"prevent",
"=",
"true",
";",
"}",
"// QUIT includes STOP so this will catch both situations.",
"if",
"(",
"(",
"$",
"response",
"&",
"definitions",
"\\",
"Signals",
"::",
"STOP",
")",
"===",
"definitions",
"\\",
"Signals",
"::",
"STOP",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"prevent",
";",
"}"
] | Runs through the registered Conditions and invokes their callbacks when they match the given Exception.
@param \Exception $exception The Exception conditions should match
@return bool True when any Condition returns the PREVENT signal, false otherwise. | [
"Runs",
"through",
"the",
"registered",
"Conditions",
"and",
"invokes",
"their",
"callbacks",
"when",
"they",
"match",
"the",
"given",
"Exception",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Handler.php#L111-L150 |
10,597 | unyx/diagnostics | debug/Handler.php | Handler.emitDebugEvent | protected function emitDebugEvent($name, \Throwable $exception)
{
// Don't proceed when we've got no Emitter.
if (null === $this->emitter) {
return null;
}
$this->emitter->emit($name, $event = new Event($exception, $this));
// Event Listeners may override the Exception. Need to account for that.
return $event->getThrowable();
} | php | protected function emitDebugEvent($name, \Throwable $exception)
{
// Don't proceed when we've got no Emitter.
if (null === $this->emitter) {
return null;
}
$this->emitter->emit($name, $event = new Event($exception, $this));
// Event Listeners may override the Exception. Need to account for that.
return $event->getThrowable();
} | [
"protected",
"function",
"emitDebugEvent",
"(",
"$",
"name",
",",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"// Don't proceed when we've got no Emitter.",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"emitter",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"emitter",
"->",
"emit",
"(",
"$",
"name",
",",
"$",
"event",
"=",
"new",
"Event",
"(",
"$",
"exception",
",",
"$",
"this",
")",
")",
";",
"// Event Listeners may override the Exception. Need to account for that.",
"return",
"$",
"event",
"->",
"getThrowable",
"(",
")",
";",
"}"
] | Helper method which emits a diagnostics\events\Debug event with the given name and the given initial
Exception and returns the Exception set in the Event after emission is done. All of it assuming an Emitter
is set for the Handler. False will be returned if that is not the case.
@param string $name The name of the Event to emit {@see definitions/Events}.
@param \Throwable $exception The initial Exception to be passed to listeners.
@return \Exception|null Either an Exception when event emission occurred or null if no Emitter
is set and therefore no events were emitted. | [
"Helper",
"method",
"which",
"emits",
"a",
"diagnostics",
"\\",
"events",
"\\",
"Debug",
"event",
"with",
"the",
"given",
"name",
"and",
"the",
"given",
"initial",
"Exception",
"and",
"returns",
"the",
"Exception",
"set",
"in",
"the",
"Event",
"after",
"emission",
"is",
"done",
".",
"All",
"of",
"it",
"assuming",
"an",
"Emitter",
"is",
"set",
"for",
"the",
"Handler",
".",
"False",
"will",
"be",
"returned",
"if",
"that",
"is",
"not",
"the",
"case",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Handler.php#L162-L173 |
10,598 | phossa2/libs | src/Phossa2/Session/Session.php | Session.checkStopped | protected function checkStopped()
{
if (null === $this->data) {
throw new RuntimeException(
Message::get(Message::SESSION_STOPPED),
Message::SESSION_STOPPED
);
}
} | php | protected function checkStopped()
{
if (null === $this->data) {
throw new RuntimeException(
Message::get(Message::SESSION_STOPPED),
Message::SESSION_STOPPED
);
}
} | [
"protected",
"function",
"checkStopped",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"data",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"SESSION_STOPPED",
")",
",",
"Message",
"::",
"SESSION_STOPPED",
")",
";",
"}",
"}"
] | Throw RuntimeException if stopped
@throws RuntimeException if session stopped
@access protected | [
"Throw",
"RuntimeException",
"if",
"stopped"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Session/Session.php#L250-L258 |
10,599 | jaztec/jaztec-admin | src/JaztecAdmin/Direct/Framework.php | Framework.getControllers | public function getControllers(array $values)
{
$config = $this->getServiceLocator()->get('Config');
/* $config array */
if (!isset($config['jaztec_admin']['modules']['controllers']['paths'])) {
return array();
}
$values['paths'] = $config['jaztec_admin']['modules']['controllers']['paths'];
return $this->getFiles($values['paths'], 'controller');
} | php | public function getControllers(array $values)
{
$config = $this->getServiceLocator()->get('Config');
/* $config array */
if (!isset($config['jaztec_admin']['modules']['controllers']['paths'])) {
return array();
}
$values['paths'] = $config['jaztec_admin']['modules']['controllers']['paths'];
return $this->getFiles($values['paths'], 'controller');
} | [
"public",
"function",
"getControllers",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'Config'",
")",
";",
"/* $config array */",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'jaztec_admin'",
"]",
"[",
"'modules'",
"]",
"[",
"'controllers'",
"]",
"[",
"'paths'",
"]",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"values",
"[",
"'paths'",
"]",
"=",
"$",
"config",
"[",
"'jaztec_admin'",
"]",
"[",
"'modules'",
"]",
"[",
"'controllers'",
"]",
"[",
"'paths'",
"]",
";",
"return",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"values",
"[",
"'paths'",
"]",
",",
"'controller'",
")",
";",
"}"
] | Scans the paths set in the KJSencha path loader to collect the controllers
and scans them against the ACL returning only the controllers the user is
allowed to use.
The reader will scan for Ext.define statements with a .controller. name.
@param array $values Client side params
@return array An array of the allowed controllers to be active. | [
"Scans",
"the",
"paths",
"set",
"in",
"the",
"KJSencha",
"path",
"loader",
"to",
"collect",
"the",
"controllers",
"and",
"scans",
"them",
"against",
"the",
"ACL",
"returning",
"only",
"the",
"controllers",
"the",
"user",
"is",
"allowed",
"to",
"use",
"."
] | c05b84077f05ed26529e2795f6adfe7b4ebd0edf | https://github.com/jaztec/jaztec-admin/blob/c05b84077f05ed26529e2795f6adfe7b4ebd0edf/src/JaztecAdmin/Direct/Framework.php#L34-L45 |
Subsets and Splits