repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
ekuiter/feature-php | FeaturePhp/Model/Configuration.php | Configuration.renderAnalysis | public function renderAnalysis($productLine = null, $textOnly = false) {
return (new ConfigurationRenderer($this, $productLine))->render($textOnly);
} | php | public function renderAnalysis($productLine = null, $textOnly = false) {
return (new ConfigurationRenderer($this, $productLine))->render($textOnly);
} | [
"public",
"function",
"renderAnalysis",
"(",
"$",
"productLine",
"=",
"null",
",",
"$",
"textOnly",
"=",
"false",
")",
"{",
"return",
"(",
"new",
"ConfigurationRenderer",
"(",
"$",
"this",
",",
"$",
"productLine",
")",
")",
"->",
"render",
"(",
"$",
"textOnly",
")",
";",
"}"
] | Analyzes the model and configuration by returning a web page.
@param \FeaturePhp\ProductLine\ProductLine $productLine
optional product line to render more information
@param bool $textOnly whether to render text or HTML
@return string | [
"Analyzes",
"the",
"model",
"and",
"configuration",
"by",
"returning",
"a",
"web",
"page",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Configuration.php#L121-L123 |
inhere/php-librarys | src/Web/AssetsRendererTrait.php | AssetsRendererTrait.dumpAssets | public function dumpAssets($position = 'top', $echo = true)
{
$assetHtml = '';
/** @var array $files css files */
if ($files = $this->getAttribute('__cssFiles:' . $position)) {
foreach ($files as $file) {
$assetHtml .= '<link href="' . $file . '" rel="stylesheet">' . PHP_EOL;
}
}
/** @var array $codes css codes */
if ($codes = $this->getAttribute('__cssCodes:' . $position)) {
$assetHtml .= '<style type="text/css">' . PHP_EOL;
foreach ($codes as $code) {
$assetHtml .= $code . PHP_EOL;
}
$assetHtml .= '</style>' . PHP_EOL;
}
/** @var array $files js files */
if ($files = $this->getAttribute('__jsFiles:' . $position)) {
foreach ($files as $file) {
$assetHtml .= '<script src="' . $file . '"></script>' . PHP_EOL;
}
}
/** @var array $codes js codes */
if ($codes = $this->getAttribute('__jsCodes:' . $position)) {
$jsCode = '';
foreach ($codes as $code) {
$jsCode .= $code . PHP_EOL;
}
if ($jsCode) {
$assetHtml .= "<script type=\"text/javascript\">\n{$jsCode}</script>\n";
}
}
if (!$echo) {
return $assetHtml;
}
// echo it.
if ($assetHtml) {
echo '<!-- dumped assets -->' . PHP_EOL . $assetHtml;
}
return null;
} | php | public function dumpAssets($position = 'top', $echo = true)
{
$assetHtml = '';
/** @var array $files css files */
if ($files = $this->getAttribute('__cssFiles:' . $position)) {
foreach ($files as $file) {
$assetHtml .= '<link href="' . $file . '" rel="stylesheet">' . PHP_EOL;
}
}
/** @var array $codes css codes */
if ($codes = $this->getAttribute('__cssCodes:' . $position)) {
$assetHtml .= '<style type="text/css">' . PHP_EOL;
foreach ($codes as $code) {
$assetHtml .= $code . PHP_EOL;
}
$assetHtml .= '</style>' . PHP_EOL;
}
/** @var array $files js files */
if ($files = $this->getAttribute('__jsFiles:' . $position)) {
foreach ($files as $file) {
$assetHtml .= '<script src="' . $file . '"></script>' . PHP_EOL;
}
}
/** @var array $codes js codes */
if ($codes = $this->getAttribute('__jsCodes:' . $position)) {
$jsCode = '';
foreach ($codes as $code) {
$jsCode .= $code . PHP_EOL;
}
if ($jsCode) {
$assetHtml .= "<script type=\"text/javascript\">\n{$jsCode}</script>\n";
}
}
if (!$echo) {
return $assetHtml;
}
// echo it.
if ($assetHtml) {
echo '<!-- dumped assets -->' . PHP_EOL . $assetHtml;
}
return null;
} | [
"public",
"function",
"dumpAssets",
"(",
"$",
"position",
"=",
"'top'",
",",
"$",
"echo",
"=",
"true",
")",
"{",
"$",
"assetHtml",
"=",
"''",
";",
"/** @var array $files css files */",
"if",
"(",
"$",
"files",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'__cssFiles:'",
".",
"$",
"position",
")",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"assetHtml",
".=",
"'<link href=\"'",
".",
"$",
"file",
".",
"'\" rel=\"stylesheet\">'",
".",
"PHP_EOL",
";",
"}",
"}",
"/** @var array $codes css codes */",
"if",
"(",
"$",
"codes",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'__cssCodes:'",
".",
"$",
"position",
")",
")",
"{",
"$",
"assetHtml",
".=",
"'<style type=\"text/css\">'",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"code",
")",
"{",
"$",
"assetHtml",
".=",
"$",
"code",
".",
"PHP_EOL",
";",
"}",
"$",
"assetHtml",
".=",
"'</style>'",
".",
"PHP_EOL",
";",
"}",
"/** @var array $files js files */",
"if",
"(",
"$",
"files",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'__jsFiles:'",
".",
"$",
"position",
")",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"assetHtml",
".=",
"'<script src=\"'",
".",
"$",
"file",
".",
"'\"></script>'",
".",
"PHP_EOL",
";",
"}",
"}",
"/** @var array $codes js codes */",
"if",
"(",
"$",
"codes",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'__jsCodes:'",
".",
"$",
"position",
")",
")",
"{",
"$",
"jsCode",
"=",
"''",
";",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"code",
")",
"{",
"$",
"jsCode",
".=",
"$",
"code",
".",
"PHP_EOL",
";",
"}",
"if",
"(",
"$",
"jsCode",
")",
"{",
"$",
"assetHtml",
".=",
"\"<script type=\\\"text/javascript\\\">\\n{$jsCode}</script>\\n\"",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"echo",
")",
"{",
"return",
"$",
"assetHtml",
";",
"}",
"// echo it.",
"if",
"(",
"$",
"assetHtml",
")",
"{",
"echo",
"'<!-- dumped assets -->'",
".",
"PHP_EOL",
".",
"$",
"assetHtml",
";",
"}",
"return",
"null",
";",
"}"
] | dump Assets
@param string $position
@param boolean $echo
@return string|null | [
"dump",
"Assets"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Web/AssetsRendererTrait.php#L244-L294 |
hametuha/wpametu | src/WPametu/UI/Field/Number.php | Number.get_field | protected function get_field( \WP_Post $post ){
$field = parent::get_field($post);
if( $this->prefix ){
$field = $this->prefix.' '.$field;
}
if( $this->suffix ){
$field .= $this->suffix;
}
return $field;
} | php | protected function get_field( \WP_Post $post ){
$field = parent::get_field($post);
if( $this->prefix ){
$field = $this->prefix.' '.$field;
}
if( $this->suffix ){
$field .= $this->suffix;
}
return $field;
} | [
"protected",
"function",
"get_field",
"(",
"\\",
"WP_Post",
"$",
"post",
")",
"{",
"$",
"field",
"=",
"parent",
"::",
"get_field",
"(",
"$",
"post",
")",
";",
"if",
"(",
"$",
"this",
"->",
"prefix",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"prefix",
".",
"' '",
".",
"$",
"field",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"suffix",
")",
"{",
"$",
"field",
".=",
"$",
"this",
"->",
"suffix",
";",
"}",
"return",
"$",
"field",
";",
"}"
] | Add suffix or prefix to field
@param \WP_Post $post
@return array|string | [
"Add",
"suffix",
"or",
"prefix",
"to",
"field"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Number.php#L42-L51 |
hametuha/wpametu | src/WPametu/UI/Field/Number.php | Number.get_field_arguments | protected function get_field_arguments(){
$args = parent::get_field_arguments();
if( $this->min ){
$args['min'] = $this->min;
}
if( $this->max ){
$args['max'] = $this->max;
}
if( is_admin() ){
$args['class'] .= ' number-input';
}
unset($args['data-max-length']);
unset($args['data-min-length']);
$args['step'] = $this->step;
return $args;
} | php | protected function get_field_arguments(){
$args = parent::get_field_arguments();
if( $this->min ){
$args['min'] = $this->min;
}
if( $this->max ){
$args['max'] = $this->max;
}
if( is_admin() ){
$args['class'] .= ' number-input';
}
unset($args['data-max-length']);
unset($args['data-min-length']);
$args['step'] = $this->step;
return $args;
} | [
"protected",
"function",
"get_field_arguments",
"(",
")",
"{",
"$",
"args",
"=",
"parent",
"::",
"get_field_arguments",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"min",
")",
"{",
"$",
"args",
"[",
"'min'",
"]",
"=",
"$",
"this",
"->",
"min",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"max",
")",
"{",
"$",
"args",
"[",
"'max'",
"]",
"=",
"$",
"this",
"->",
"max",
";",
"}",
"if",
"(",
"is_admin",
"(",
")",
")",
"{",
"$",
"args",
"[",
"'class'",
"]",
".=",
"' number-input'",
";",
"}",
"unset",
"(",
"$",
"args",
"[",
"'data-max-length'",
"]",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"'data-min-length'",
"]",
")",
";",
"$",
"args",
"[",
"'step'",
"]",
"=",
"$",
"this",
"->",
"step",
";",
"return",
"$",
"args",
";",
"}"
] | Field arguments
@return array | [
"Field",
"arguments"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Number.php#L58-L73 |
opsbears/piccolo | src/Module/ModuleDependencyGraph.php | ModuleDependencyGraph.getDotGraph | public function getDotGraph() : string {
$escapeClassName = function(string $class) : string {
return '"' . \str_replace('\\', '\\\\', $class) . '"';
};
$dotData = 'digraph modules {' . PHP_EOL;
foreach ($this->modules as $moduleSpec) {
$module = $moduleSpec['object'];
if ($module instanceof OrderAwareModule) {
foreach ($module->getModulesBefore() as $moduleBeforeClass) {
$dotData .= ' ' . $escapeClassName($moduleBeforeClass) . ' -> ' .
$escapeClassName($moduleSpec['class']) . ';' . PHP_EOL;
}
foreach ($module->getModulesAfter() as $moduleAfterClass) {
$dotData .= ' ' . $escapeClassName($moduleSpec['class']) . ' -> ' .
$escapeClassName($moduleAfterClass) . ';' . PHP_EOL;
}
} else {
$dotData .= ' ' . $escapeClassName($moduleSpec['class']) . ';' . PHP_EOL;
}
}
$dotData .= '}';
return $dotData;
} | php | public function getDotGraph() : string {
$escapeClassName = function(string $class) : string {
return '"' . \str_replace('\\', '\\\\', $class) . '"';
};
$dotData = 'digraph modules {' . PHP_EOL;
foreach ($this->modules as $moduleSpec) {
$module = $moduleSpec['object'];
if ($module instanceof OrderAwareModule) {
foreach ($module->getModulesBefore() as $moduleBeforeClass) {
$dotData .= ' ' . $escapeClassName($moduleBeforeClass) . ' -> ' .
$escapeClassName($moduleSpec['class']) . ';' . PHP_EOL;
}
foreach ($module->getModulesAfter() as $moduleAfterClass) {
$dotData .= ' ' . $escapeClassName($moduleSpec['class']) . ' -> ' .
$escapeClassName($moduleAfterClass) . ';' . PHP_EOL;
}
} else {
$dotData .= ' ' . $escapeClassName($moduleSpec['class']) . ';' . PHP_EOL;
}
}
$dotData .= '}';
return $dotData;
} | [
"public",
"function",
"getDotGraph",
"(",
")",
":",
"string",
"{",
"$",
"escapeClassName",
"=",
"function",
"(",
"string",
"$",
"class",
")",
":",
"string",
"{",
"return",
"'\"'",
".",
"\\",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"class",
")",
".",
"'\"'",
";",
"}",
";",
"$",
"dotData",
"=",
"'digraph modules {'",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"module",
"=",
"$",
"moduleSpec",
"[",
"'object'",
"]",
";",
"if",
"(",
"$",
"module",
"instanceof",
"OrderAwareModule",
")",
"{",
"foreach",
"(",
"$",
"module",
"->",
"getModulesBefore",
"(",
")",
"as",
"$",
"moduleBeforeClass",
")",
"{",
"$",
"dotData",
".=",
"' '",
".",
"$",
"escapeClassName",
"(",
"$",
"moduleBeforeClass",
")",
".",
"' -> '",
".",
"$",
"escapeClassName",
"(",
"$",
"moduleSpec",
"[",
"'class'",
"]",
")",
".",
"';'",
".",
"PHP_EOL",
";",
"}",
"foreach",
"(",
"$",
"module",
"->",
"getModulesAfter",
"(",
")",
"as",
"$",
"moduleAfterClass",
")",
"{",
"$",
"dotData",
".=",
"' '",
".",
"$",
"escapeClassName",
"(",
"$",
"moduleSpec",
"[",
"'class'",
"]",
")",
".",
"' -> '",
".",
"$",
"escapeClassName",
"(",
"$",
"moduleAfterClass",
")",
".",
"';'",
".",
"PHP_EOL",
";",
"}",
"}",
"else",
"{",
"$",
"dotData",
".=",
"' '",
".",
"$",
"escapeClassName",
"(",
"$",
"moduleSpec",
"[",
"'class'",
"]",
")",
".",
"';'",
".",
"PHP_EOL",
";",
"}",
"}",
"$",
"dotData",
".=",
"'}'",
";",
"return",
"$",
"dotData",
";",
"}"
] | Returns a GraphViz DOT graph to represent the circular dependency found. A PNG image can be generated using
this command: `dot -Tpng input.dot output.png`
@see https://en.wikipedia.org/wiki/DOT_(graph_description_language)
@return string | [
"Returns",
"a",
"GraphViz",
"DOT",
"graph",
"to",
"represent",
"the",
"circular",
"dependency",
"found",
".",
"A",
"PNG",
"image",
"can",
"be",
"generated",
"using",
"this",
"command",
":",
"dot",
"-",
"Tpng",
"input",
".",
"dot",
"output",
".",
"png"
] | train | https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleDependencyGraph.php#L47-L71 |
opsbears/piccolo | src/Module/ModuleDependencyGraph.php | ModuleDependencyGraph.getSortedModuleList | public function getSortedModuleList() : array {
$moduleList = $this->modules;
foreach ($moduleList as $moduleSpec) {
$moduleClass = $moduleSpec['class'];
$module = $moduleSpec['object'];
if ($module instanceof OrderAwareModule) {
//All modules that should be loaded after this one
foreach ($module->getModulesAfter() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['after'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['before'][] = $moduleClass;
}
}
//All modules that should be loaded before this one
foreach ($module->getModulesBefore() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['before'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['after'][] = $moduleClass;
}
}
}
}
$sortedList = [];
$noIncomingNodes = [];
foreach ($moduleList as $moduleSpec) {
$moduleSpec['after'] = \array_unique($moduleSpec['after']);
$moduleSpec['before'] = \array_unique($moduleSpec['before']);
if (empty($moduleSpec['before'])) {
$noIncomingNodes[$moduleSpec['class']] = $moduleSpec;
}
}
//Do the topological sorting (Kahn's algorithm)
while (!empty($noIncomingNodes)) {
$moduleSpec = array_shift($noIncomingNodes);
\array_push($sortedList, $moduleSpec);
unset($moduleList[$moduleSpec['class']]);
foreach ($moduleSpec['after'] as $nextModuleKey => $nextModuleClass) {
unset($moduleList[$nextModuleClass]['before'][
\array_search($moduleSpec['class'], $moduleList[$nextModuleClass]['before'])
]);
if (empty($moduleList[$nextModuleClass]['before'])) {
$noIncomingNodes[] = $moduleList[$nextModuleClass];
}
unset($moduleSpec['after'][$nextModuleKey]);
}
}
foreach ($moduleList as $key => $remainingModuleSpec) {
if (empty($remainingModuleSpec['before'])) {
$sortedList[] = $moduleList[$remainingModuleSpec['class']];
unset($moduleList[$key]);
}
}
if (!empty($moduleList)) {
throw new CircularModuleLoadOrderDetectedException($this->getDotGraph());
} else {
$result = [];
foreach ($sortedList as $moduleSpec) {
$result[] = $moduleSpec['object'];
}
return $result;
}
} | php | public function getSortedModuleList() : array {
$moduleList = $this->modules;
foreach ($moduleList as $moduleSpec) {
$moduleClass = $moduleSpec['class'];
$module = $moduleSpec['object'];
if ($module instanceof OrderAwareModule) {
//All modules that should be loaded after this one
foreach ($module->getModulesAfter() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['after'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['before'][] = $moduleClass;
}
}
//All modules that should be loaded before this one
foreach ($module->getModulesBefore() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['before'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['after'][] = $moduleClass;
}
}
}
}
$sortedList = [];
$noIncomingNodes = [];
foreach ($moduleList as $moduleSpec) {
$moduleSpec['after'] = \array_unique($moduleSpec['after']);
$moduleSpec['before'] = \array_unique($moduleSpec['before']);
if (empty($moduleSpec['before'])) {
$noIncomingNodes[$moduleSpec['class']] = $moduleSpec;
}
}
//Do the topological sorting (Kahn's algorithm)
while (!empty($noIncomingNodes)) {
$moduleSpec = array_shift($noIncomingNodes);
\array_push($sortedList, $moduleSpec);
unset($moduleList[$moduleSpec['class']]);
foreach ($moduleSpec['after'] as $nextModuleKey => $nextModuleClass) {
unset($moduleList[$nextModuleClass]['before'][
\array_search($moduleSpec['class'], $moduleList[$nextModuleClass]['before'])
]);
if (empty($moduleList[$nextModuleClass]['before'])) {
$noIncomingNodes[] = $moduleList[$nextModuleClass];
}
unset($moduleSpec['after'][$nextModuleKey]);
}
}
foreach ($moduleList as $key => $remainingModuleSpec) {
if (empty($remainingModuleSpec['before'])) {
$sortedList[] = $moduleList[$remainingModuleSpec['class']];
unset($moduleList[$key]);
}
}
if (!empty($moduleList)) {
throw new CircularModuleLoadOrderDetectedException($this->getDotGraph());
} else {
$result = [];
foreach ($sortedList as $moduleSpec) {
$result[] = $moduleSpec['object'];
}
return $result;
}
} | [
"public",
"function",
"getSortedModuleList",
"(",
")",
":",
"array",
"{",
"$",
"moduleList",
"=",
"$",
"this",
"->",
"modules",
";",
"foreach",
"(",
"$",
"moduleList",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"moduleClass",
"=",
"$",
"moduleSpec",
"[",
"'class'",
"]",
";",
"$",
"module",
"=",
"$",
"moduleSpec",
"[",
"'object'",
"]",
";",
"if",
"(",
"$",
"module",
"instanceof",
"OrderAwareModule",
")",
"{",
"//All modules that should be loaded after this one",
"foreach",
"(",
"$",
"module",
"->",
"getModulesAfter",
"(",
")",
"as",
"$",
"afterModuleClass",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"afterModuleClass",
",",
"$",
"moduleList",
")",
")",
"{",
"$",
"moduleList",
"[",
"$",
"moduleClass",
"]",
"[",
"'after'",
"]",
"[",
"]",
"=",
"$",
"afterModuleClass",
";",
"$",
"moduleList",
"[",
"$",
"afterModuleClass",
"]",
"[",
"'before'",
"]",
"[",
"]",
"=",
"$",
"moduleClass",
";",
"}",
"}",
"//All modules that should be loaded before this one",
"foreach",
"(",
"$",
"module",
"->",
"getModulesBefore",
"(",
")",
"as",
"$",
"afterModuleClass",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"afterModuleClass",
",",
"$",
"moduleList",
")",
")",
"{",
"$",
"moduleList",
"[",
"$",
"moduleClass",
"]",
"[",
"'before'",
"]",
"[",
"]",
"=",
"$",
"afterModuleClass",
";",
"$",
"moduleList",
"[",
"$",
"afterModuleClass",
"]",
"[",
"'after'",
"]",
"[",
"]",
"=",
"$",
"moduleClass",
";",
"}",
"}",
"}",
"}",
"$",
"sortedList",
"=",
"[",
"]",
";",
"$",
"noIncomingNodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"moduleList",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"moduleSpec",
"[",
"'after'",
"]",
"=",
"\\",
"array_unique",
"(",
"$",
"moduleSpec",
"[",
"'after'",
"]",
")",
";",
"$",
"moduleSpec",
"[",
"'before'",
"]",
"=",
"\\",
"array_unique",
"(",
"$",
"moduleSpec",
"[",
"'before'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"moduleSpec",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"noIncomingNodes",
"[",
"$",
"moduleSpec",
"[",
"'class'",
"]",
"]",
"=",
"$",
"moduleSpec",
";",
"}",
"}",
"//Do the topological sorting (Kahn's algorithm)",
"while",
"(",
"!",
"empty",
"(",
"$",
"noIncomingNodes",
")",
")",
"{",
"$",
"moduleSpec",
"=",
"array_shift",
"(",
"$",
"noIncomingNodes",
")",
";",
"\\",
"array_push",
"(",
"$",
"sortedList",
",",
"$",
"moduleSpec",
")",
";",
"unset",
"(",
"$",
"moduleList",
"[",
"$",
"moduleSpec",
"[",
"'class'",
"]",
"]",
")",
";",
"foreach",
"(",
"$",
"moduleSpec",
"[",
"'after'",
"]",
"as",
"$",
"nextModuleKey",
"=>",
"$",
"nextModuleClass",
")",
"{",
"unset",
"(",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
"[",
"'before'",
"]",
"[",
"\\",
"array_search",
"(",
"$",
"moduleSpec",
"[",
"'class'",
"]",
",",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
"[",
"'before'",
"]",
")",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"noIncomingNodes",
"[",
"]",
"=",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
";",
"}",
"unset",
"(",
"$",
"moduleSpec",
"[",
"'after'",
"]",
"[",
"$",
"nextModuleKey",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"moduleList",
"as",
"$",
"key",
"=>",
"$",
"remainingModuleSpec",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"remainingModuleSpec",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"sortedList",
"[",
"]",
"=",
"$",
"moduleList",
"[",
"$",
"remainingModuleSpec",
"[",
"'class'",
"]",
"]",
";",
"unset",
"(",
"$",
"moduleList",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"moduleList",
")",
")",
"{",
"throw",
"new",
"CircularModuleLoadOrderDetectedException",
"(",
"$",
"this",
"->",
"getDotGraph",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"sortedList",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"moduleSpec",
"[",
"'object'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}",
"}"
] | Returns a list of modules, sorted by dependencies.
@return Module[]
@throws CircularModuleLoadOrderDetectedException | [
"Returns",
"a",
"list",
"of",
"modules",
"sorted",
"by",
"dependencies",
"."
] | train | https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleDependencyGraph.php#L80-L148 |
ezsystems/ezcomments-ls-extension | classes/ezcomcommentcommonmanager.php | ezcomCommentCommonManager.afterAddingComment | public function afterAddingComment( $comment, $notification )
{
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
//add subscription
$subscription = ezcomSubscriptionManager::instance();
$user = eZUser::instance();
if ( $notification === true )
{
$subscription->addSubscription( $comment->attribute('email'),
$user,
$contentID,
$languageID,
$subscriptionType,
$comment->attribute( 'created' ) );
}
// insert data into notification queue
// if there is no subscription,not adding to notification queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType, null, 1 ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute('contentobject_id') );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'Notification added to queue', __METHOD__ );
}
} | php | public function afterAddingComment( $comment, $notification )
{
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
//add subscription
$subscription = ezcomSubscriptionManager::instance();
$user = eZUser::instance();
if ( $notification === true )
{
$subscription->addSubscription( $comment->attribute('email'),
$user,
$contentID,
$languageID,
$subscriptionType,
$comment->attribute( 'created' ) );
}
// insert data into notification queue
// if there is no subscription,not adding to notification queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType, null, 1 ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute('contentobject_id') );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'Notification added to queue', __METHOD__ );
}
} | [
"public",
"function",
"afterAddingComment",
"(",
"$",
"comment",
",",
"$",
"notification",
")",
"{",
"$",
"contentID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";",
"$",
"languageID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
";",
"$",
"subscriptionType",
"=",
"'ezcomcomment'",
";",
"//add subscription",
"$",
"subscription",
"=",
"ezcomSubscriptionManager",
"::",
"instance",
"(",
")",
";",
"$",
"user",
"=",
"eZUser",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"notification",
"===",
"true",
")",
"{",
"$",
"subscription",
"->",
"addSubscription",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'email'",
")",
",",
"$",
"user",
",",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'created'",
")",
")",
";",
"}",
"// insert data into notification queue",
"// if there is no subscription,not adding to notification queue",
"if",
"(",
"ezcomSubscription",
"::",
"exists",
"(",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"null",
",",
"1",
")",
")",
"{",
"$",
"notification",
"=",
"ezcomNotification",
"::",
"create",
"(",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'contentobject_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'language_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'comment_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'id'",
")",
")",
";",
"$",
"notification",
"->",
"store",
"(",
")",
";",
"eZDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'Notification added to queue'",
",",
"__METHOD__",
")",
";",
"}",
"}"
] | add subscription after adding comment
1) If 'notification' is true
add the user as a subscriber if subscriber with same email doesn't exist
otherwise get the subscriber
2) If 'notification' is true
if the subscription with user's email and contentid doesn't exist, add a new subscription,
3) If there is subscription, add the comment into notifiction queue
@see extension/ezcomments/classes/ezcomCommentManager#afterAddingComment($comment) | [
"add",
"subscription",
"after",
"adding",
"comment",
"1",
")",
"If",
"notification",
"is",
"true",
"add",
"the",
"user",
"as",
"a",
"subscriber",
"if",
"subscriber",
"with",
"same",
"email",
"doesn",
"t",
"exist",
"otherwise",
"get",
"the",
"subscriber",
"2",
")",
"If",
"notification",
"is",
"true",
"if",
"the",
"subscription",
"with",
"user",
"s",
"email",
"and",
"contentid",
"doesn",
"t",
"exist",
"add",
"a",
"new",
"subscription",
"3",
")",
"If",
"there",
"is",
"subscription",
"add",
"the",
"comment",
"into",
"notifiction",
"queue"
] | train | https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcommentcommonmanager.php#L40-L70 |
ezsystems/ezcomments-ls-extension | classes/ezcomcommentcommonmanager.php | ezcomCommentCommonManager.afterUpdatingComment | public function afterUpdatingComment( $comment, $notified, $time )
{
$user = eZUser::fetch( $comment->attribute( 'user_id' ) );
// if notified is true, add subscription, else cleanup the subscription on the user and content
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
if ( !is_null( $notified ) )
{
$subscriptionManager = ezcomSubscriptionManager::instance();
if ( $notified === true )
{
//add subscription but not send activation
try
{
$subscriptionManager->addSubscription( $comment->attribute( 'email' ),
$user,
$contentID,
$languageID,
$subscriptionType,
$time,
false );
}
catch ( Exception $e )
{
eZDebug::writeError( $e->getMessage(), __METHOD__ );
switch ( $e->getCode() )
{
case ezcomSubscriptionManager::ERROR_SUBSCRIBER_DISABLED:
return 'The subscriber is disabled.';
default:
return false;
}
}
}
else
{
$subscriptionManager->deleteSubscription( $comment->attribute( 'email' ),
$comment->attribute( 'contentobject_id' ),
$comment->attribute( 'language_id' ) );
}
}
//3. update queue. If there is subscription, add one record into queue table
// if there is subcription on this content, add one item into queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute( 'contentobject_id' ) );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'There are subscriptions, added an update notification to the queue.', __METHOD__ );
}
else
{
// todo: if there is no subscription on this content, consider to clean up the queue
}
return true;
} | php | public function afterUpdatingComment( $comment, $notified, $time )
{
$user = eZUser::fetch( $comment->attribute( 'user_id' ) );
// if notified is true, add subscription, else cleanup the subscription on the user and content
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
if ( !is_null( $notified ) )
{
$subscriptionManager = ezcomSubscriptionManager::instance();
if ( $notified === true )
{
//add subscription but not send activation
try
{
$subscriptionManager->addSubscription( $comment->attribute( 'email' ),
$user,
$contentID,
$languageID,
$subscriptionType,
$time,
false );
}
catch ( Exception $e )
{
eZDebug::writeError( $e->getMessage(), __METHOD__ );
switch ( $e->getCode() )
{
case ezcomSubscriptionManager::ERROR_SUBSCRIBER_DISABLED:
return 'The subscriber is disabled.';
default:
return false;
}
}
}
else
{
$subscriptionManager->deleteSubscription( $comment->attribute( 'email' ),
$comment->attribute( 'contentobject_id' ),
$comment->attribute( 'language_id' ) );
}
}
//3. update queue. If there is subscription, add one record into queue table
// if there is subcription on this content, add one item into queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute( 'contentobject_id' ) );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'There are subscriptions, added an update notification to the queue.', __METHOD__ );
}
else
{
// todo: if there is no subscription on this content, consider to clean up the queue
}
return true;
} | [
"public",
"function",
"afterUpdatingComment",
"(",
"$",
"comment",
",",
"$",
"notified",
",",
"$",
"time",
")",
"{",
"$",
"user",
"=",
"eZUser",
"::",
"fetch",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'user_id'",
")",
")",
";",
"// if notified is true, add subscription, else cleanup the subscription on the user and content",
"$",
"contentID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";",
"$",
"languageID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
";",
"$",
"subscriptionType",
"=",
"'ezcomcomment'",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"notified",
")",
")",
"{",
"$",
"subscriptionManager",
"=",
"ezcomSubscriptionManager",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"notified",
"===",
"true",
")",
"{",
"//add subscription but not send activation",
"try",
"{",
"$",
"subscriptionManager",
"->",
"addSubscription",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'email'",
")",
",",
"$",
"user",
",",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"time",
",",
"false",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"eZDebug",
"::",
"writeError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"switch",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
"{",
"case",
"ezcomSubscriptionManager",
"::",
"ERROR_SUBSCRIBER_DISABLED",
":",
"return",
"'The subscriber is disabled.'",
";",
"default",
":",
"return",
"false",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"subscriptionManager",
"->",
"deleteSubscription",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'email'",
")",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
")",
";",
"}",
"}",
"//3. update queue. If there is subscription, add one record into queue table",
"// if there is subcription on this content, add one item into queue",
"if",
"(",
"ezcomSubscription",
"::",
"exists",
"(",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
")",
")",
"{",
"$",
"notification",
"=",
"ezcomNotification",
"::",
"create",
"(",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'contentobject_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'language_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'comment_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'id'",
")",
")",
";",
"$",
"notification",
"->",
"store",
"(",
")",
";",
"eZDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'There are subscriptions, added an update notification to the queue.'",
",",
"__METHOD__",
")",
";",
"}",
"else",
"{",
"// todo: if there is no subscription on this content, consider to clean up the queue",
"}",
"return",
"true",
";",
"}"
] | clean up subscription after updating comment
@see extension/ezcomments/classes/ezcomCommentManager#afterUpdatingComment($comment, $notified) | [
"clean",
"up",
"subscription",
"after",
"updating",
"comment"
] | train | https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcommentcommonmanager.php#L85-L144 |
php-lug/lug | src/Component/Resource/Factory/Factory.php | Factory.create | public function create(array $options = [])
{
$class = $this->resource->getModel();
$object = new $class();
foreach ($options as $propertyPath => $value) {
$this->propertyAccessor->setValue($object, $propertyPath, $value);
}
return $object;
} | php | public function create(array $options = [])
{
$class = $this->resource->getModel();
$object = new $class();
foreach ($options as $propertyPath => $value) {
$this->propertyAccessor->setValue($object, $propertyPath, $value);
}
return $object;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"resource",
"->",
"getModel",
"(",
")",
";",
"$",
"object",
"=",
"new",
"$",
"class",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"propertyPath",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"propertyAccessor",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"propertyPath",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Factory/Factory.php#L45-L55 |
willhoffmann/domuserp-php | src/DomusClient.php | DomusClient.setBranch | public function setBranch($branch)
{
$request = new Request($this->handler);
$this->branch = $request->execute(
RequestMethods::HTTP_PUT,
$this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
[
'json' => [
'id' => $branch,
],
'headers' => [
'X-Session-ID' => $this->getToken()
]
]
)->id;
return $this;
} | php | public function setBranch($branch)
{
$request = new Request($this->handler);
$this->branch = $request->execute(
RequestMethods::HTTP_PUT,
$this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
[
'json' => [
'id' => $branch,
],
'headers' => [
'X-Session-ID' => $this->getToken()
]
]
)->id;
return $this;
} | [
"public",
"function",
"setBranch",
"(",
"$",
"branch",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"$",
"this",
"->",
"handler",
")",
";",
"$",
"this",
"->",
"branch",
"=",
"$",
"request",
"->",
"execute",
"(",
"RequestMethods",
"::",
"HTTP_PUT",
",",
"$",
"this",
"->",
"makeUrl",
"(",
"RequestMethods",
"::",
"DOMUSERP_API_PEDIDOVENDA",
".",
"'/auth'",
")",
",",
"[",
"'json'",
"=>",
"[",
"'id'",
"=>",
"$",
"branch",
",",
"]",
",",
"'headers'",
"=>",
"[",
"'X-Session-ID'",
"=>",
"$",
"this",
"->",
"getToken",
"(",
")",
"]",
"]",
")",
"->",
"id",
";",
"return",
"$",
"this",
";",
"}"
] | Set branch
@param $branch
@return $this
@throws \GuzzleHttp\Exception\GuzzleException | [
"Set",
"branch"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/DomusClient.php#L101-L118 |
willhoffmann/domuserp-php | src/DomusClient.php | DomusClient.authenticate | public function authenticate()
{
$request = new Request($this->handler);
$this->token = $request->execute(
RequestMethods::HTTP_POST,
$this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
[
'json' => [
'login' => $this->username,
'password' => $this->password
]
]
)->token;
return $this;
} | php | public function authenticate()
{
$request = new Request($this->handler);
$this->token = $request->execute(
RequestMethods::HTTP_POST,
$this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
[
'json' => [
'login' => $this->username,
'password' => $this->password
]
]
)->token;
return $this;
} | [
"public",
"function",
"authenticate",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"$",
"this",
"->",
"handler",
")",
";",
"$",
"this",
"->",
"token",
"=",
"$",
"request",
"->",
"execute",
"(",
"RequestMethods",
"::",
"HTTP_POST",
",",
"$",
"this",
"->",
"makeUrl",
"(",
"RequestMethods",
"::",
"DOMUSERP_API_PEDIDOVENDA",
".",
"'/auth'",
")",
",",
"[",
"'json'",
"=>",
"[",
"'login'",
"=>",
"$",
"this",
"->",
"username",
",",
"'password'",
"=>",
"$",
"this",
"->",
"password",
"]",
"]",
")",
"->",
"token",
";",
"return",
"$",
"this",
";",
"}"
] | Request an access token and sets it to the client.
@return $this
@throws \GuzzleHttp\Exception\GuzzleException | [
"Request",
"an",
"access",
"token",
"and",
"sets",
"it",
"to",
"the",
"client",
"."
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/DomusClient.php#L156-L171 |
willhoffmann/domuserp-php | src/DomusClient.php | DomusClient.makeUrl | public function makeUrl($resource)
{
$host = trim(str_replace(['http://', 'https://'], null, $this->host), '/');
$resource = trim($resource, '/');
//Create URI
$uri = $host . ':' . $this->port . '/' . $resource;
return $uri;
} | php | public function makeUrl($resource)
{
$host = trim(str_replace(['http://', 'https://'], null, $this->host), '/');
$resource = trim($resource, '/');
//Create URI
$uri = $host . ':' . $this->port . '/' . $resource;
return $uri;
} | [
"public",
"function",
"makeUrl",
"(",
"$",
"resource",
")",
"{",
"$",
"host",
"=",
"trim",
"(",
"str_replace",
"(",
"[",
"'http://'",
",",
"'https://'",
"]",
",",
"null",
",",
"$",
"this",
"->",
"host",
")",
",",
"'/'",
")",
";",
"$",
"resource",
"=",
"trim",
"(",
"$",
"resource",
",",
"'/'",
")",
";",
"//Create URI",
"$",
"uri",
"=",
"$",
"host",
".",
"':'",
".",
"$",
"this",
"->",
"port",
".",
"'/'",
".",
"$",
"resource",
";",
"return",
"$",
"uri",
";",
"}"
] | Check and construct an real URL to make request
@param $resource
@return string | [
"Check",
"and",
"construct",
"an",
"real",
"URL",
"to",
"make",
"request"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/DomusClient.php#L179-L187 |
gdbots/iam-php | src/CreateUserHandler.php | CreateUserHandler.beforePutEvents | protected function beforePutEvents(NodeCreated $event, CreateNode $command, Pbjx $pbjx): void
{
parent::beforePutEvents($event, $command, $pbjx);
/** @var User $node */
$node = $event->get('node');
$node
->set('status', NodeStatus::PUBLISHED())
// roles SHOULD be set with grant-roles-to-user
->clear('roles');
if ($node->has('email')) {
$email = strtolower($node->get('email'));
$emailParts = explode('@', $email);
$node->set('email', $email);
$node->set('email_domain', array_pop($emailParts));
}
if (!$node->has('title')) {
$node->set('title', trim($node->get('first_name') . ' ' . $node->get('last_name')));
}
} | php | protected function beforePutEvents(NodeCreated $event, CreateNode $command, Pbjx $pbjx): void
{
parent::beforePutEvents($event, $command, $pbjx);
/** @var User $node */
$node = $event->get('node');
$node
->set('status', NodeStatus::PUBLISHED())
// roles SHOULD be set with grant-roles-to-user
->clear('roles');
if ($node->has('email')) {
$email = strtolower($node->get('email'));
$emailParts = explode('@', $email);
$node->set('email', $email);
$node->set('email_domain', array_pop($emailParts));
}
if (!$node->has('title')) {
$node->set('title', trim($node->get('first_name') . ' ' . $node->get('last_name')));
}
} | [
"protected",
"function",
"beforePutEvents",
"(",
"NodeCreated",
"$",
"event",
",",
"CreateNode",
"$",
"command",
",",
"Pbjx",
"$",
"pbjx",
")",
":",
"void",
"{",
"parent",
"::",
"beforePutEvents",
"(",
"$",
"event",
",",
"$",
"command",
",",
"$",
"pbjx",
")",
";",
"/** @var User $node */",
"$",
"node",
"=",
"$",
"event",
"->",
"get",
"(",
"'node'",
")",
";",
"$",
"node",
"->",
"set",
"(",
"'status'",
",",
"NodeStatus",
"::",
"PUBLISHED",
"(",
")",
")",
"// roles SHOULD be set with grant-roles-to-user",
"->",
"clear",
"(",
"'roles'",
")",
";",
"if",
"(",
"$",
"node",
"->",
"has",
"(",
"'email'",
")",
")",
"{",
"$",
"email",
"=",
"strtolower",
"(",
"$",
"node",
"->",
"get",
"(",
"'email'",
")",
")",
";",
"$",
"emailParts",
"=",
"explode",
"(",
"'@'",
",",
"$",
"email",
")",
";",
"$",
"node",
"->",
"set",
"(",
"'email'",
",",
"$",
"email",
")",
";",
"$",
"node",
"->",
"set",
"(",
"'email_domain'",
",",
"array_pop",
"(",
"$",
"emailParts",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"node",
"->",
"has",
"(",
"'title'",
")",
")",
"{",
"$",
"node",
"->",
"set",
"(",
"'title'",
",",
"trim",
"(",
"$",
"node",
"->",
"get",
"(",
"'first_name'",
")",
".",
"' '",
".",
"$",
"node",
"->",
"get",
"(",
"'last_name'",
")",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/CreateUserHandler.php#L29-L50 |
technote-space/wordpress-plugin-base | src/technote.php | Technote.get_instance | public static function get_instance( $plugin_name, $plugin_file, $slug_name = null ) {
if ( ! isset( self::$_instances[ $plugin_name ] ) ) {
$instances = new static( $plugin_name, $plugin_file, $slug_name );
self::$_instances[ $plugin_name ] = $instances;
$latest = self::$_latest_library_version;
$version = $instances->_library_version;
if ( ! isset( $latest ) || version_compare( $latest, $version, '<' ) ) {
self::$_latest_library_version = $version;
self::$_latest_library_directory = $instances->_library_directory;
}
}
return self::$_instances[ $plugin_name ];
} | php | public static function get_instance( $plugin_name, $plugin_file, $slug_name = null ) {
if ( ! isset( self::$_instances[ $plugin_name ] ) ) {
$instances = new static( $plugin_name, $plugin_file, $slug_name );
self::$_instances[ $plugin_name ] = $instances;
$latest = self::$_latest_library_version;
$version = $instances->_library_version;
if ( ! isset( $latest ) || version_compare( $latest, $version, '<' ) ) {
self::$_latest_library_version = $version;
self::$_latest_library_directory = $instances->_library_directory;
}
}
return self::$_instances[ $plugin_name ];
} | [
"public",
"static",
"function",
"get_instance",
"(",
"$",
"plugin_name",
",",
"$",
"plugin_file",
",",
"$",
"slug_name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_instances",
"[",
"$",
"plugin_name",
"]",
")",
")",
"{",
"$",
"instances",
"=",
"new",
"static",
"(",
"$",
"plugin_name",
",",
"$",
"plugin_file",
",",
"$",
"slug_name",
")",
";",
"self",
"::",
"$",
"_instances",
"[",
"$",
"plugin_name",
"]",
"=",
"$",
"instances",
";",
"$",
"latest",
"=",
"self",
"::",
"$",
"_latest_library_version",
";",
"$",
"version",
"=",
"$",
"instances",
"->",
"_library_version",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"latest",
")",
"||",
"version_compare",
"(",
"$",
"latest",
",",
"$",
"version",
",",
"'<'",
")",
")",
"{",
"self",
"::",
"$",
"_latest_library_version",
"=",
"$",
"version",
";",
"self",
"::",
"$",
"_latest_library_directory",
"=",
"$",
"instances",
"->",
"_library_directory",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"_instances",
"[",
"$",
"plugin_name",
"]",
";",
"}"
] | @param string $plugin_name
@param string $plugin_file
@param string|null $slug_name
@return Technote | [
"@param",
"string",
"$plugin_name",
"@param",
"string",
"$plugin_file",
"@param",
"string|null",
"$slug_name"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L263-L277 |
technote-space/wordpress-plugin-base | src/technote.php | Technote.setup_actions | private function setup_actions() {
if ( $this->is_theme ) {
add_action( 'after_setup_theme', function () {
$this->plugins_loaded();
} );
add_action( 'after_switch_theme', function () {
$this->plugins_loaded();
$this->main_init();
$this->filter->do_action( 'app_activated', $this );
} );
add_action( 'switch_theme', function () {
$this->filter->do_action( 'app_deactivated', $this );
} );
} else {
add_action( 'plugins_loaded', function () {
$this->plugins_loaded();
} );
add_action( 'activated_plugin', function ( $plugin ) {
$this->plugins_loaded();
$this->main_init();
if ( $this->define->plugin_base_name === $plugin ) {
$this->filter->do_action( 'app_activated', $this );
}
} );
add_action( 'deactivated_plugin', function ( $plugin ) {
if ( $this->define->plugin_base_name === $plugin ) {
$this->filter->do_action( 'app_deactivated', $this );
}
} );
}
add_action( 'init', function () {
$this->main_init();
}, 1 );
} | php | private function setup_actions() {
if ( $this->is_theme ) {
add_action( 'after_setup_theme', function () {
$this->plugins_loaded();
} );
add_action( 'after_switch_theme', function () {
$this->plugins_loaded();
$this->main_init();
$this->filter->do_action( 'app_activated', $this );
} );
add_action( 'switch_theme', function () {
$this->filter->do_action( 'app_deactivated', $this );
} );
} else {
add_action( 'plugins_loaded', function () {
$this->plugins_loaded();
} );
add_action( 'activated_plugin', function ( $plugin ) {
$this->plugins_loaded();
$this->main_init();
if ( $this->define->plugin_base_name === $plugin ) {
$this->filter->do_action( 'app_activated', $this );
}
} );
add_action( 'deactivated_plugin', function ( $plugin ) {
if ( $this->define->plugin_base_name === $plugin ) {
$this->filter->do_action( 'app_deactivated', $this );
}
} );
}
add_action( 'init', function () {
$this->main_init();
}, 1 );
} | [
"private",
"function",
"setup_actions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_theme",
")",
"{",
"add_action",
"(",
"'after_setup_theme'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"plugins_loaded",
"(",
")",
";",
"}",
")",
";",
"add_action",
"(",
"'after_switch_theme'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"plugins_loaded",
"(",
")",
";",
"$",
"this",
"->",
"main_init",
"(",
")",
";",
"$",
"this",
"->",
"filter",
"->",
"do_action",
"(",
"'app_activated'",
",",
"$",
"this",
")",
";",
"}",
")",
";",
"add_action",
"(",
"'switch_theme'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"filter",
"->",
"do_action",
"(",
"'app_deactivated'",
",",
"$",
"this",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"add_action",
"(",
"'plugins_loaded'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"plugins_loaded",
"(",
")",
";",
"}",
")",
";",
"add_action",
"(",
"'activated_plugin'",
",",
"function",
"(",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"plugins_loaded",
"(",
")",
";",
"$",
"this",
"->",
"main_init",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"define",
"->",
"plugin_base_name",
"===",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"filter",
"->",
"do_action",
"(",
"'app_activated'",
",",
"$",
"this",
")",
";",
"}",
"}",
")",
";",
"add_action",
"(",
"'deactivated_plugin'",
",",
"function",
"(",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"define",
"->",
"plugin_base_name",
"===",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"filter",
"->",
"do_action",
"(",
"'app_deactivated'",
",",
"$",
"this",
")",
";",
"}",
"}",
")",
";",
"}",
"add_action",
"(",
"'init'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"main_init",
"(",
")",
";",
"}",
",",
"1",
")",
";",
"}"
] | setup actions
@since 2.0.0
@since 2.7.3 Fixed: suppress error when activate plugin
@since 2.10.1 Improved: for theme (#115) | [
"setup",
"actions"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L309-L347 |
technote-space/wordpress-plugin-base | src/technote.php | Technote.plugins_loaded | private function plugins_loaded() {
if ( $this->_plugins_loaded ) {
return;
}
$this->_plugins_loaded = true;
spl_autoload_register( function ( $class ) {
return $this->get_main()->load_class( $class );
} );
$this->load_functions();
} | php | private function plugins_loaded() {
if ( $this->_plugins_loaded ) {
return;
}
$this->_plugins_loaded = true;
spl_autoload_register( function ( $class ) {
return $this->get_main()->load_class( $class );
} );
$this->load_functions();
} | [
"private",
"function",
"plugins_loaded",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_plugins_loaded",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_plugins_loaded",
"=",
"true",
";",
"spl_autoload_register",
"(",
"function",
"(",
"$",
"class",
")",
"{",
"return",
"$",
"this",
"->",
"get_main",
"(",
")",
"->",
"load_class",
"(",
"$",
"class",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"load_functions",
"(",
")",
";",
"}"
] | load basic files | [
"load",
"basic",
"files"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L352-L363 |
technote-space/wordpress-plugin-base | src/technote.php | Technote.load_functions | private function load_functions() {
if ( $this->is_theme ) {
return;
}
$functions = $this->define->plugin_dir . DS . 'functions.php';
if ( is_readable( $functions ) ) {
/** @noinspection PhpIncludeInspection */
require_once $functions;
}
} | php | private function load_functions() {
if ( $this->is_theme ) {
return;
}
$functions = $this->define->plugin_dir . DS . 'functions.php';
if ( is_readable( $functions ) ) {
/** @noinspection PhpIncludeInspection */
require_once $functions;
}
} | [
"private",
"function",
"load_functions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_theme",
")",
"{",
"return",
";",
"}",
"$",
"functions",
"=",
"$",
"this",
"->",
"define",
"->",
"plugin_dir",
".",
"DS",
".",
"'functions.php'",
";",
"if",
"(",
"is_readable",
"(",
"$",
"functions",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"require_once",
"$",
"functions",
";",
"}",
"}"
] | load functions file
@since 2.10.1 Improved: for theme (#115) | [
"load",
"functions",
"file"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L369-L378 |
technote-space/wordpress-plugin-base | src/technote.php | Technote.uninstall | private static function uninstall( $plugin_base_name ) {
$app = self::find_plugin( $plugin_base_name );
if ( ! isset( $app ) ) {
return;
}
$app->_is_uninstall = true;
$app->plugins_loaded();
$app->main_init();
$app->uninstall->uninstall();
} | php | private static function uninstall( $plugin_base_name ) {
$app = self::find_plugin( $plugin_base_name );
if ( ! isset( $app ) ) {
return;
}
$app->_is_uninstall = true;
$app->plugins_loaded();
$app->main_init();
$app->uninstall->uninstall();
} | [
"private",
"static",
"function",
"uninstall",
"(",
"$",
"plugin_base_name",
")",
"{",
"$",
"app",
"=",
"self",
"::",
"find_plugin",
"(",
"$",
"plugin_base_name",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"app",
")",
")",
"{",
"return",
";",
"}",
"$",
"app",
"->",
"_is_uninstall",
"=",
"true",
";",
"$",
"app",
"->",
"plugins_loaded",
"(",
")",
";",
"$",
"app",
"->",
"main_init",
"(",
")",
";",
"$",
"app",
"->",
"uninstall",
"->",
"uninstall",
"(",
")",
";",
"}"
] | @since 2.0.2 Fixed: Uninstall behavior
@param string $plugin_base_name | [
"@since",
"2",
".",
"0",
".",
"2",
"Fixed",
":",
"Uninstall",
"behavior"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L385-L395 |
technote-space/wordpress-plugin-base | src/technote.php | Technote.find_plugin | private static function find_plugin( $plugin_base_name ) {
/** @var \Technote $instance */
foreach ( self::$_instances as $plugin_name => $instance ) {
if ( $instance->is_theme ) {
continue;
}
$instance->plugins_loaded();
if ( $instance->define->plugin_base_name === $plugin_base_name ) {
return $instance;
}
}
return null;
} | php | private static function find_plugin( $plugin_base_name ) {
/** @var \Technote $instance */
foreach ( self::$_instances as $plugin_name => $instance ) {
if ( $instance->is_theme ) {
continue;
}
$instance->plugins_loaded();
if ( $instance->define->plugin_base_name === $plugin_base_name ) {
return $instance;
}
}
return null;
} | [
"private",
"static",
"function",
"find_plugin",
"(",
"$",
"plugin_base_name",
")",
"{",
"/** @var \\Technote $instance */",
"foreach",
"(",
"self",
"::",
"$",
"_instances",
"as",
"$",
"plugin_name",
"=>",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"instance",
"->",
"is_theme",
")",
"{",
"continue",
";",
"}",
"$",
"instance",
"->",
"plugins_loaded",
"(",
")",
";",
"if",
"(",
"$",
"instance",
"->",
"define",
"->",
"plugin_base_name",
"===",
"$",
"plugin_base_name",
")",
"{",
"return",
"$",
"instance",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | @since 2.7.4 Fixed: suppress error when uninstall plugin
@since 2.10.1 Improved: for theme (#115)
@param string $plugin_base_name
@return \Technote|null | [
"@since",
"2",
".",
"7",
".",
"4",
"Fixed",
":",
"suppress",
"error",
"when",
"uninstall",
"plugin",
"@since",
"2",
".",
"10",
".",
"1",
"Improved",
":",
"for",
"theme",
"(",
"#115",
")"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L405-L418 |
heidelpay/PhpDoc | src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php | ResolveInlineLinkAndSeeTags.resolveTag | private function resolveTag($match)
{
$tagReflector = $this->createLinkOrSeeTagFromRegexMatch($match);
if (!$tagReflector instanceof Tag\SeeTag && !$tagReflector instanceof Tag\LinkTag) {
return $match;
}
$link = $this->getLinkText($tagReflector);
$description = $tagReflector->getDescription();
if ($this->isUrl($link)) {
return $this->generateMarkdownLink($link, $description ?: $link);
}
$link = $this->resolveQsen($link);
$element = $this->findElement($link);
if (!$element) {
return $link;
}
return $this->resolveElement($element, $link, $description);
} | php | private function resolveTag($match)
{
$tagReflector = $this->createLinkOrSeeTagFromRegexMatch($match);
if (!$tagReflector instanceof Tag\SeeTag && !$tagReflector instanceof Tag\LinkTag) {
return $match;
}
$link = $this->getLinkText($tagReflector);
$description = $tagReflector->getDescription();
if ($this->isUrl($link)) {
return $this->generateMarkdownLink($link, $description ?: $link);
}
$link = $this->resolveQsen($link);
$element = $this->findElement($link);
if (!$element) {
return $link;
}
return $this->resolveElement($element, $link, $description);
} | [
"private",
"function",
"resolveTag",
"(",
"$",
"match",
")",
"{",
"$",
"tagReflector",
"=",
"$",
"this",
"->",
"createLinkOrSeeTagFromRegexMatch",
"(",
"$",
"match",
")",
";",
"if",
"(",
"!",
"$",
"tagReflector",
"instanceof",
"Tag",
"\\",
"SeeTag",
"&&",
"!",
"$",
"tagReflector",
"instanceof",
"Tag",
"\\",
"LinkTag",
")",
"{",
"return",
"$",
"match",
";",
"}",
"$",
"link",
"=",
"$",
"this",
"->",
"getLinkText",
"(",
"$",
"tagReflector",
")",
";",
"$",
"description",
"=",
"$",
"tagReflector",
"->",
"getDescription",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isUrl",
"(",
"$",
"link",
")",
")",
"{",
"return",
"$",
"this",
"->",
"generateMarkdownLink",
"(",
"$",
"link",
",",
"$",
"description",
"?",
":",
"$",
"link",
")",
";",
"}",
"$",
"link",
"=",
"$",
"this",
"->",
"resolveQsen",
"(",
"$",
"link",
")",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"findElement",
"(",
"$",
"link",
")",
";",
"if",
"(",
"!",
"$",
"element",
")",
"{",
"return",
"$",
"link",
";",
"}",
"return",
"$",
"this",
"->",
"resolveElement",
"(",
"$",
"element",
",",
"$",
"link",
",",
"$",
"description",
")",
";",
"}"
] | Resolves an individual tag, indicated by the results of the Regex used to extract tags.
@param string[] $match
@return string | [
"Resolves",
"an",
"individual",
"tag",
"indicated",
"by",
"the",
"results",
"of",
"the",
"Regex",
"used",
"to",
"extract",
"tags",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L107-L128 |
heidelpay/PhpDoc | src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php | ResolveInlineLinkAndSeeTags.createLinkOrSeeTagFromRegexMatch | private function createLinkOrSeeTagFromRegexMatch(array $match)
{
list($completeMatch, $tagName, $tagContent) = $match;
return Tag::createInstance('@' . $tagName . ' ' . $tagContent);
} | php | private function createLinkOrSeeTagFromRegexMatch(array $match)
{
list($completeMatch, $tagName, $tagContent) = $match;
return Tag::createInstance('@' . $tagName . ' ' . $tagContent);
} | [
"private",
"function",
"createLinkOrSeeTagFromRegexMatch",
"(",
"array",
"$",
"match",
")",
"{",
"list",
"(",
"$",
"completeMatch",
",",
"$",
"tagName",
",",
"$",
"tagContent",
")",
"=",
"$",
"match",
";",
"return",
"Tag",
"::",
"createInstance",
"(",
"'@'",
".",
"$",
"tagName",
".",
"' '",
".",
"$",
"tagContent",
")",
";",
"}"
] | Creates a Tag Reflector from the given array of tag line, tag name and tag content.
@param string[] $match
@return Tag | [
"Creates",
"a",
"Tag",
"Reflector",
"from",
"the",
"given",
"array",
"of",
"tag",
"line",
"tag",
"name",
"and",
"tag",
"content",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L161-L166 |
heidelpay/PhpDoc | src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php | ResolveInlineLinkAndSeeTags.resolveQsen | private function resolveQsen($link)
{
if (!$this->isFqsen($link)) {
$typeCollection = new TypeCollection(array($link), $this->createDocBlockContext());
// only a single element reference is allowed!
$link = $typeCollection[0];
}
return $link;
} | php | private function resolveQsen($link)
{
if (!$this->isFqsen($link)) {
$typeCollection = new TypeCollection(array($link), $this->createDocBlockContext());
// only a single element reference is allowed!
$link = $typeCollection[0];
}
return $link;
} | [
"private",
"function",
"resolveQsen",
"(",
"$",
"link",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFqsen",
"(",
"$",
"link",
")",
")",
"{",
"$",
"typeCollection",
"=",
"new",
"TypeCollection",
"(",
"array",
"(",
"$",
"link",
")",
",",
"$",
"this",
"->",
"createDocBlockContext",
"(",
")",
")",
";",
"// only a single element reference is allowed!",
"$",
"link",
"=",
"$",
"typeCollection",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"link",
";",
"}"
] | Resolves a QSEN to a FQSEN.
If a relative QSEN is provided then this method will attempt to resolve it given the current namespace and
namespace aliases.
@param string $link
@return string | [
"Resolves",
"a",
"QSEN",
"to",
"a",
"FQSEN",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L178-L188 |
heidelpay/PhpDoc | src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php | ResolveInlineLinkAndSeeTags.findElement | private function findElement($fqsen)
{
return isset($this->elementCollection[$fqsen]) ? $this->elementCollection[$fqsen] : null;
} | php | private function findElement($fqsen)
{
return isset($this->elementCollection[$fqsen]) ? $this->elementCollection[$fqsen] : null;
} | [
"private",
"function",
"findElement",
"(",
"$",
"fqsen",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"elementCollection",
"[",
"$",
"fqsen",
"]",
")",
"?",
"$",
"this",
"->",
"elementCollection",
"[",
"$",
"fqsen",
"]",
":",
"null",
";",
"}"
] | Tries to find an element with the given FQSEN in the elements listing for this project.
@param string $fqsen
@return DescriptorAbstract|null | [
"Tries",
"to",
"find",
"an",
"element",
"with",
"the",
"given",
"FQSEN",
"in",
"the",
"elements",
"listing",
"for",
"this",
"project",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L234-L237 |
heidelpay/PhpDoc | src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php | ResolveInlineLinkAndSeeTags.createDocBlockContext | private function createDocBlockContext()
{
$file = $this->descriptor->getFile();
$namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : array();
return new Context($this->descriptor->getNamespace(), $namespaceAliases);
} | php | private function createDocBlockContext()
{
$file = $this->descriptor->getFile();
$namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : array();
return new Context($this->descriptor->getNamespace(), $namespaceAliases);
} | [
"private",
"function",
"createDocBlockContext",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"descriptor",
"->",
"getFile",
"(",
")",
";",
"$",
"namespaceAliases",
"=",
"$",
"file",
"?",
"$",
"file",
"->",
"getNamespaceAliases",
"(",
")",
"->",
"getAll",
"(",
")",
":",
"array",
"(",
")",
";",
"return",
"new",
"Context",
"(",
"$",
"this",
"->",
"descriptor",
"->",
"getNamespace",
"(",
")",
",",
"$",
"namespaceAliases",
")",
";",
"}"
] | Creates a DocBlock context containing the namespace and aliases for the current descriptor.
@return Context | [
"Creates",
"a",
"DocBlock",
"context",
"containing",
"the",
"namespace",
"and",
"aliases",
"for",
"the",
"current",
"descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L244-L250 |
i-lateral/silverstripe-users | code/control/Users_Register_Controller.php | Users_Register_Controller.getMenu | public function getMenu($level = 1)
{
if (class_exists(ContentController::class)) {
$controller = Injector::inst()->get(ContentController::class);
return $controller->getMenu($level);
}
} | php | public function getMenu($level = 1)
{
if (class_exists(ContentController::class)) {
$controller = Injector::inst()->get(ContentController::class);
return $controller->getMenu($level);
}
} | [
"public",
"function",
"getMenu",
"(",
"$",
"level",
"=",
"1",
")",
"{",
"if",
"(",
"class_exists",
"(",
"ContentController",
"::",
"class",
")",
")",
"{",
"$",
"controller",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"ContentController",
"::",
"class",
")",
";",
"return",
"$",
"controller",
"->",
"getMenu",
"(",
"$",
"level",
")",
";",
"}",
"}"
] | If content controller exists, return it's menu function
@param int $level Menu level to return.
@return ArrayList | [
"If",
"content",
"controller",
"exists",
"return",
"it",
"s",
"menu",
"function"
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L104-L110 |
i-lateral/silverstripe-users | code/control/Users_Register_Controller.php | Users_Register_Controller.index | public function index(SS_HTTPRequest $request)
{
$this->customise(
array(
'Title' => _t('Users.Register', 'Register'),
'MetaTitle' => _t('Users.Register', 'Register'),
'Form' => $this->RegisterForm(),
)
);
$this->extend("updateIndexAction");
return $this->renderWith(
array(
"Users_Register",
"Users",
"Page"
)
);
} | php | public function index(SS_HTTPRequest $request)
{
$this->customise(
array(
'Title' => _t('Users.Register', 'Register'),
'MetaTitle' => _t('Users.Register', 'Register'),
'Form' => $this->RegisterForm(),
)
);
$this->extend("updateIndexAction");
return $this->renderWith(
array(
"Users_Register",
"Users",
"Page"
)
);
} | [
"public",
"function",
"index",
"(",
"SS_HTTPRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"customise",
"(",
"array",
"(",
"'Title'",
"=>",
"_t",
"(",
"'Users.Register'",
",",
"'Register'",
")",
",",
"'MetaTitle'",
"=>",
"_t",
"(",
"'Users.Register'",
",",
"'Register'",
")",
",",
"'Form'",
"=>",
"$",
"this",
"->",
"RegisterForm",
"(",
")",
",",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateIndexAction\"",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"array",
"(",
"\"Users_Register\"",
",",
"\"Users\"",
",",
"\"Page\"",
")",
")",
";",
"}"
] | Default action this controller will deal with
@param SS_HTTPRequest $request Current request
@return HTMLText | [
"Default",
"action",
"this",
"controller",
"will",
"deal",
"with"
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L131-L150 |
i-lateral/silverstripe-users | code/control/Users_Register_Controller.php | Users_Register_Controller.sendverification | public function sendverification(SS_HTTPRequest $request)
{
// If we don't allow verification emails, return an error
if (!Users::config()->send_verification_email) {
return $this->httpError(400);
}
$sent = false;
if (Member::currentUserID()) {
$member = Member::currentUser();
} else {
$member = Member::get()->byID($this->getRequest()->param("ID"));
}
if ($member && !$member->isVerified()) {
$sent = $this->send_verification_email($member);
}
$this->customise(
array(
"Title" => _t('Users.AccountVerification', 'Account Verification'),
"MetaTitle" => _t('Users.AccountVerification', 'Account Verification'),
"Content" => $this->renderWith(
"UsersSendVerificationContent",
array("Sent" => $sent)
),
"Sent" => $sent
)
);
$this->extend("updateSendVerificationAction");
return $this->renderWith(
array(
"Users_Register_sendverification",
"Users",
"Page"
)
);
} | php | public function sendverification(SS_HTTPRequest $request)
{
// If we don't allow verification emails, return an error
if (!Users::config()->send_verification_email) {
return $this->httpError(400);
}
$sent = false;
if (Member::currentUserID()) {
$member = Member::currentUser();
} else {
$member = Member::get()->byID($this->getRequest()->param("ID"));
}
if ($member && !$member->isVerified()) {
$sent = $this->send_verification_email($member);
}
$this->customise(
array(
"Title" => _t('Users.AccountVerification', 'Account Verification'),
"MetaTitle" => _t('Users.AccountVerification', 'Account Verification'),
"Content" => $this->renderWith(
"UsersSendVerificationContent",
array("Sent" => $sent)
),
"Sent" => $sent
)
);
$this->extend("updateSendVerificationAction");
return $this->renderWith(
array(
"Users_Register_sendverification",
"Users",
"Page"
)
);
} | [
"public",
"function",
"sendverification",
"(",
"SS_HTTPRequest",
"$",
"request",
")",
"{",
"// If we don't allow verification emails, return an error",
"if",
"(",
"!",
"Users",
"::",
"config",
"(",
")",
"->",
"send_verification_email",
")",
"{",
"return",
"$",
"this",
"->",
"httpError",
"(",
"400",
")",
";",
"}",
"$",
"sent",
"=",
"false",
";",
"if",
"(",
"Member",
"::",
"currentUserID",
"(",
")",
")",
"{",
"$",
"member",
"=",
"Member",
"::",
"currentUser",
"(",
")",
";",
"}",
"else",
"{",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"param",
"(",
"\"ID\"",
")",
")",
";",
"}",
"if",
"(",
"$",
"member",
"&&",
"!",
"$",
"member",
"->",
"isVerified",
"(",
")",
")",
"{",
"$",
"sent",
"=",
"$",
"this",
"->",
"send_verification_email",
"(",
"$",
"member",
")",
";",
"}",
"$",
"this",
"->",
"customise",
"(",
"array",
"(",
"\"Title\"",
"=>",
"_t",
"(",
"'Users.AccountVerification'",
",",
"'Account Verification'",
")",
",",
"\"MetaTitle\"",
"=>",
"_t",
"(",
"'Users.AccountVerification'",
",",
"'Account Verification'",
")",
",",
"\"Content\"",
"=>",
"$",
"this",
"->",
"renderWith",
"(",
"\"UsersSendVerificationContent\"",
",",
"array",
"(",
"\"Sent\"",
"=>",
"$",
"sent",
")",
")",
",",
"\"Sent\"",
"=>",
"$",
"sent",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateSendVerificationAction\"",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"array",
"(",
"\"Users_Register_sendverification\"",
",",
"\"Users\"",
",",
"\"Page\"",
")",
")",
";",
"}"
] | Send a verification email to the user provided (if verification
emails are enabled and account is not already verified)
@param SS_HTTPRequest $request Current request
@return HTMLText | [
"Send",
"a",
"verification",
"email",
"to",
"the",
"user",
"provided",
"(",
"if",
"verification",
"emails",
"are",
"enabled",
"and",
"account",
"is",
"not",
"already",
"verified",
")"
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L161-L201 |
i-lateral/silverstripe-users | code/control/Users_Register_Controller.php | Users_Register_Controller.verify | public function verify(SS_HTTPRequest $request)
{
$member = Member::get()->byID($this->getRequest()->param("ID"));
$code = $this->getRequest()->param("OtherID");
$verify = false;
// Check verification group exists, if not, make it
// Add a verified users group (only used if we turn on
// verification)
$verify_groups = Group::get()
->filter("Code", Users::config()->verification_groups);
$this->extend("onBeforeVerify", $member);
if (($member && $code) && $code == $member->VerificationCode) {
foreach ($verify_groups as $group) {
$group->Members()->add($member);
$verify = true;
}
}
$this->customise(
array(
"Title" => _t('Users.AccountVerification', 'Account Verification'),
"MetaTitle" => _t('Users.AccountVerification', 'Account Verification'),
"Content" => $this->renderWith(
"UsersVerifyContent",
array("Verify" => $verify)
),
"Verify" => $verify
)
);
$this->extend("onAfterVerify", $member);
return $this->renderWith(
array(
"Users_Register_verify",
"Users",
"Page"
)
);
} | php | public function verify(SS_HTTPRequest $request)
{
$member = Member::get()->byID($this->getRequest()->param("ID"));
$code = $this->getRequest()->param("OtherID");
$verify = false;
// Check verification group exists, if not, make it
// Add a verified users group (only used if we turn on
// verification)
$verify_groups = Group::get()
->filter("Code", Users::config()->verification_groups);
$this->extend("onBeforeVerify", $member);
if (($member && $code) && $code == $member->VerificationCode) {
foreach ($verify_groups as $group) {
$group->Members()->add($member);
$verify = true;
}
}
$this->customise(
array(
"Title" => _t('Users.AccountVerification', 'Account Verification'),
"MetaTitle" => _t('Users.AccountVerification', 'Account Verification'),
"Content" => $this->renderWith(
"UsersVerifyContent",
array("Verify" => $verify)
),
"Verify" => $verify
)
);
$this->extend("onAfterVerify", $member);
return $this->renderWith(
array(
"Users_Register_verify",
"Users",
"Page"
)
);
} | [
"public",
"function",
"verify",
"(",
"SS_HTTPRequest",
"$",
"request",
")",
"{",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"param",
"(",
"\"ID\"",
")",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"param",
"(",
"\"OtherID\"",
")",
";",
"$",
"verify",
"=",
"false",
";",
"// Check verification group exists, if not, make it",
"// Add a verified users group (only used if we turn on",
"// verification)",
"$",
"verify_groups",
"=",
"Group",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"\"Code\"",
",",
"Users",
"::",
"config",
"(",
")",
"->",
"verification_groups",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"onBeforeVerify\"",
",",
"$",
"member",
")",
";",
"if",
"(",
"(",
"$",
"member",
"&&",
"$",
"code",
")",
"&&",
"$",
"code",
"==",
"$",
"member",
"->",
"VerificationCode",
")",
"{",
"foreach",
"(",
"$",
"verify_groups",
"as",
"$",
"group",
")",
"{",
"$",
"group",
"->",
"Members",
"(",
")",
"->",
"add",
"(",
"$",
"member",
")",
";",
"$",
"verify",
"=",
"true",
";",
"}",
"}",
"$",
"this",
"->",
"customise",
"(",
"array",
"(",
"\"Title\"",
"=>",
"_t",
"(",
"'Users.AccountVerification'",
",",
"'Account Verification'",
")",
",",
"\"MetaTitle\"",
"=>",
"_t",
"(",
"'Users.AccountVerification'",
",",
"'Account Verification'",
")",
",",
"\"Content\"",
"=>",
"$",
"this",
"->",
"renderWith",
"(",
"\"UsersVerifyContent\"",
",",
"array",
"(",
"\"Verify\"",
"=>",
"$",
"verify",
")",
")",
",",
"\"Verify\"",
"=>",
"$",
"verify",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"onAfterVerify\"",
",",
"$",
"member",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"array",
"(",
"\"Users_Register_verify\"",
",",
"\"Users\"",
",",
"\"Page\"",
")",
")",
";",
"}"
] | Verify the provided user (ID) using the verification code (Other
ID) provided
@param SS_HTTPRequest $request Current Request
@return HTMLText | [
"Verify",
"the",
"provided",
"user",
"(",
"ID",
")",
"using",
"the",
"verification",
"code",
"(",
"Other",
"ID",
")",
"provided"
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L211-L253 |
i-lateral/silverstripe-users | code/control/Users_Register_Controller.php | Users_Register_Controller.RegisterForm | public function RegisterForm()
{
// If back URL set, push to session
if (isset($_REQUEST['BackURL'])) {
Session::set('BackURL', $_REQUEST['BackURL']);
}
$config = Users::config();
// Setup form fields
$fields = FieldList::create(
TextField::create("FirstName"),
TextField::create("Surname"),
EmailField::create("Email"),
$password_field = ConfirmedPasswordField::create("Password")
);
$password_field->minLength = $config->get("password_min_length");
$password_field->maxLength = $config->get("password_max_length");
$password_field->requireStrongPassword = $config->get("password_require_strong");
// Setup form actions
$actions = new FieldList(
FormAction::create("doRegister", "Register")
->addExtraClass("btn")
->addExtraClass("btn-green")
);
// Setup required fields
$required = new RequiredFields(
array(
"FirstName",
"Surname",
"Email",
"Password"
)
);
$form = Form::create(
$this,
"RegisterForm",
$fields,
$actions,
$required
)->addExtraClass("forms")
->addExtraClass("forms-columnar");
$this->extend("updateRegisterForm", $form);
$session_data = Session::get("Form.{$form->FormName()}.data");
if ($session_data && is_array($session_data)) {
$form->loadDataFrom($session_data);
Session::clear("Form.{$form->FormName()}.data");
}
return $form;
} | php | public function RegisterForm()
{
// If back URL set, push to session
if (isset($_REQUEST['BackURL'])) {
Session::set('BackURL', $_REQUEST['BackURL']);
}
$config = Users::config();
// Setup form fields
$fields = FieldList::create(
TextField::create("FirstName"),
TextField::create("Surname"),
EmailField::create("Email"),
$password_field = ConfirmedPasswordField::create("Password")
);
$password_field->minLength = $config->get("password_min_length");
$password_field->maxLength = $config->get("password_max_length");
$password_field->requireStrongPassword = $config->get("password_require_strong");
// Setup form actions
$actions = new FieldList(
FormAction::create("doRegister", "Register")
->addExtraClass("btn")
->addExtraClass("btn-green")
);
// Setup required fields
$required = new RequiredFields(
array(
"FirstName",
"Surname",
"Email",
"Password"
)
);
$form = Form::create(
$this,
"RegisterForm",
$fields,
$actions,
$required
)->addExtraClass("forms")
->addExtraClass("forms-columnar");
$this->extend("updateRegisterForm", $form);
$session_data = Session::get("Form.{$form->FormName()}.data");
if ($session_data && is_array($session_data)) {
$form->loadDataFrom($session_data);
Session::clear("Form.{$form->FormName()}.data");
}
return $form;
} | [
"public",
"function",
"RegisterForm",
"(",
")",
"{",
"// If back URL set, push to session",
"if",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'BackURL'",
"]",
")",
")",
"{",
"Session",
"::",
"set",
"(",
"'BackURL'",
",",
"$",
"_REQUEST",
"[",
"'BackURL'",
"]",
")",
";",
"}",
"$",
"config",
"=",
"Users",
"::",
"config",
"(",
")",
";",
"// Setup form fields",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
"TextField",
"::",
"create",
"(",
"\"FirstName\"",
")",
",",
"TextField",
"::",
"create",
"(",
"\"Surname\"",
")",
",",
"EmailField",
"::",
"create",
"(",
"\"Email\"",
")",
",",
"$",
"password_field",
"=",
"ConfirmedPasswordField",
"::",
"create",
"(",
"\"Password\"",
")",
")",
";",
"$",
"password_field",
"->",
"minLength",
"=",
"$",
"config",
"->",
"get",
"(",
"\"password_min_length\"",
")",
";",
"$",
"password_field",
"->",
"maxLength",
"=",
"$",
"config",
"->",
"get",
"(",
"\"password_max_length\"",
")",
";",
"$",
"password_field",
"->",
"requireStrongPassword",
"=",
"$",
"config",
"->",
"get",
"(",
"\"password_require_strong\"",
")",
";",
"// Setup form actions",
"$",
"actions",
"=",
"new",
"FieldList",
"(",
"FormAction",
"::",
"create",
"(",
"\"doRegister\"",
",",
"\"Register\"",
")",
"->",
"addExtraClass",
"(",
"\"btn\"",
")",
"->",
"addExtraClass",
"(",
"\"btn-green\"",
")",
")",
";",
"// Setup required fields",
"$",
"required",
"=",
"new",
"RequiredFields",
"(",
"array",
"(",
"\"FirstName\"",
",",
"\"Surname\"",
",",
"\"Email\"",
",",
"\"Password\"",
")",
")",
";",
"$",
"form",
"=",
"Form",
"::",
"create",
"(",
"$",
"this",
",",
"\"RegisterForm\"",
",",
"$",
"fields",
",",
"$",
"actions",
",",
"$",
"required",
")",
"->",
"addExtraClass",
"(",
"\"forms\"",
")",
"->",
"addExtraClass",
"(",
"\"forms-columnar\"",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateRegisterForm\"",
",",
"$",
"form",
")",
";",
"$",
"session_data",
"=",
"Session",
"::",
"get",
"(",
"\"Form.{$form->FormName()}.data\"",
")",
";",
"if",
"(",
"$",
"session_data",
"&&",
"is_array",
"(",
"$",
"session_data",
")",
")",
"{",
"$",
"form",
"->",
"loadDataFrom",
"(",
"$",
"session_data",
")",
";",
"Session",
"::",
"clear",
"(",
"\"Form.{$form->FormName()}.data\"",
")",
";",
"}",
"return",
"$",
"form",
";",
"}"
] | Registration form
@return Form | [
"Registration",
"form"
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L260-L318 |
i-lateral/silverstripe-users | code/control/Users_Register_Controller.php | Users_Register_Controller.doRegister | public function doRegister($data, $form)
{
$filter = array();
if (isset($data['Email'])) {
$filter['Email'] = $data['Email'];
}
$this->extend("updateMemberFilter", $filter);
// Check if a user already exists
if ($member = Member::get()->filter($filter)->first()) {
if ($member) {
$form->addErrorMessage(
"Blurb",
"Sorry, an account already exists with those details.",
"bad"
);
// Load errors into session and post back
unset($data["Password"]);
Session::set("Form.{$form->FormName()}.data", $data);
return $this->redirectBack();
}
}
$member = Member::create();
$member->Register($data);
$this->extend("updateNewMember", $member, $data);
$session_url = Session::get("BackURL");
$request_url = $this->getRequest()->requestVar("BackURL");
// If a back URL is used in session.
if (!empty($session_url)) {
$redirect_url = $session_url;
} elseif (!empty($request_url)) {
$redirect_url = $request_url;
} else {
$controller = Injector::inst()->get("Users_Account_Controller");
$redirect_url = $controller->Link();
}
return $this->redirect($redirect_url);
} | php | public function doRegister($data, $form)
{
$filter = array();
if (isset($data['Email'])) {
$filter['Email'] = $data['Email'];
}
$this->extend("updateMemberFilter", $filter);
// Check if a user already exists
if ($member = Member::get()->filter($filter)->first()) {
if ($member) {
$form->addErrorMessage(
"Blurb",
"Sorry, an account already exists with those details.",
"bad"
);
// Load errors into session and post back
unset($data["Password"]);
Session::set("Form.{$form->FormName()}.data", $data);
return $this->redirectBack();
}
}
$member = Member::create();
$member->Register($data);
$this->extend("updateNewMember", $member, $data);
$session_url = Session::get("BackURL");
$request_url = $this->getRequest()->requestVar("BackURL");
// If a back URL is used in session.
if (!empty($session_url)) {
$redirect_url = $session_url;
} elseif (!empty($request_url)) {
$redirect_url = $request_url;
} else {
$controller = Injector::inst()->get("Users_Account_Controller");
$redirect_url = $controller->Link();
}
return $this->redirect($redirect_url);
} | [
"public",
"function",
"doRegister",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"$",
"filter",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'Email'",
"]",
")",
")",
"{",
"$",
"filter",
"[",
"'Email'",
"]",
"=",
"$",
"data",
"[",
"'Email'",
"]",
";",
"}",
"$",
"this",
"->",
"extend",
"(",
"\"updateMemberFilter\"",
",",
"$",
"filter",
")",
";",
"// Check if a user already exists",
"if",
"(",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"$",
"filter",
")",
"->",
"first",
"(",
")",
")",
"{",
"if",
"(",
"$",
"member",
")",
"{",
"$",
"form",
"->",
"addErrorMessage",
"(",
"\"Blurb\"",
",",
"\"Sorry, an account already exists with those details.\"",
",",
"\"bad\"",
")",
";",
"// Load errors into session and post back",
"unset",
"(",
"$",
"data",
"[",
"\"Password\"",
"]",
")",
";",
"Session",
"::",
"set",
"(",
"\"Form.{$form->FormName()}.data\"",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"redirectBack",
"(",
")",
";",
"}",
"}",
"$",
"member",
"=",
"Member",
"::",
"create",
"(",
")",
";",
"$",
"member",
"->",
"Register",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateNewMember\"",
",",
"$",
"member",
",",
"$",
"data",
")",
";",
"$",
"session_url",
"=",
"Session",
"::",
"get",
"(",
"\"BackURL\"",
")",
";",
"$",
"request_url",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"requestVar",
"(",
"\"BackURL\"",
")",
";",
"// If a back URL is used in session.",
"if",
"(",
"!",
"empty",
"(",
"$",
"session_url",
")",
")",
"{",
"$",
"redirect_url",
"=",
"$",
"session_url",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"request_url",
")",
")",
"{",
"$",
"redirect_url",
"=",
"$",
"request_url",
";",
"}",
"else",
"{",
"$",
"controller",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"\"Users_Account_Controller\"",
")",
";",
"$",
"redirect_url",
"=",
"$",
"controller",
"->",
"Link",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"redirect_url",
")",
";",
"}"
] | Register a new member. This action is deigned to be intercepted at 2
points:
- Modify the initial member filter (so that you can perfom bespoke
member filtering
- Modify the member user before saving (so we can add extra permissions
etc)
@param array $data User submitted data
@param Form $form Registration form
@return SS_HTTPResponse | [
"Register",
"a",
"new",
"member",
".",
"This",
"action",
"is",
"deigned",
"to",
"be",
"intercepted",
"at",
"2",
"points",
":"
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L335-L381 |
philiplb/Valdi | src/Valdi/Validator/Regexp.php | Regexp.isValidComparison | protected function isValidComparison($value, $parameters) {
// Workaround for not using '@preg_match'.
$oldError = error_reporting(0);
$regexResult = preg_match($parameters[0], $value);
error_reporting($oldError);
return $regexResult === 1;
} | php | protected function isValidComparison($value, $parameters) {
// Workaround for not using '@preg_match'.
$oldError = error_reporting(0);
$regexResult = preg_match($parameters[0], $value);
error_reporting($oldError);
return $regexResult === 1;
} | [
"protected",
"function",
"isValidComparison",
"(",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"// Workaround for not using '@preg_match'.",
"$",
"oldError",
"=",
"error_reporting",
"(",
"0",
")",
";",
"$",
"regexResult",
"=",
"preg_match",
"(",
"$",
"parameters",
"[",
"0",
"]",
",",
"$",
"value",
")",
";",
"error_reporting",
"(",
"$",
"oldError",
")",
";",
"return",
"$",
"regexResult",
"===",
"1",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/Regexp.php#L27-L33 |
Speicher210/monsum-api | src/Transport/GuzzleTransport.php | GuzzleTransport.sendRequest | public function sendRequest($body)
{
try {
$response = $this->client->request(
'POST',
null,
[
'body' => $body
]
);
$body = $response->getBody()->getContents();
} catch (RequestException $e) {
$body = $e->getResponse()->getBody()->getContents();
}
return $body;
} | php | public function sendRequest($body)
{
try {
$response = $this->client->request(
'POST',
null,
[
'body' => $body
]
);
$body = $response->getBody()->getContents();
} catch (RequestException $e) {
$body = $e->getResponse()->getBody()->getContents();
}
return $body;
} | [
"public",
"function",
"sendRequest",
"(",
"$",
"body",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"null",
",",
"[",
"'body'",
"=>",
"$",
"body",
"]",
")",
";",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"$",
"body",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"}",
"return",
"$",
"body",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Transport/GuzzleTransport.php#L49-L66 |
InactiveProjects/limoncello-illuminate | app/Database/Migrations/MigrateRoles.php | MigrateRoles.apply | public function apply()
{
Schema::create(Model::TABLE_NAME, function (Blueprint $table) {
$table->unsignedInteger(Model::FIELD_ID);
$table->string(Model::FIELD_NAME, Model::LENGTH_NAME);
$table->timestamps();
$table->primary(Model::FIELD_ID);
});
} | php | public function apply()
{
Schema::create(Model::TABLE_NAME, function (Blueprint $table) {
$table->unsignedInteger(Model::FIELD_ID);
$table->string(Model::FIELD_NAME, Model::LENGTH_NAME);
$table->timestamps();
$table->primary(Model::FIELD_ID);
});
} | [
"public",
"function",
"apply",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"Model",
"::",
"TABLE_NAME",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"unsignedInteger",
"(",
"Model",
"::",
"FIELD_ID",
")",
";",
"$",
"table",
"->",
"string",
"(",
"Model",
"::",
"FIELD_NAME",
",",
"Model",
"::",
"LENGTH_NAME",
")",
";",
"$",
"table",
"->",
"timestamps",
"(",
")",
";",
"$",
"table",
"->",
"primary",
"(",
"Model",
"::",
"FIELD_ID",
")",
";",
"}",
")",
";",
"}"
] | @inheritdoc
@SuppressWarnings(PHPMD.StaticAccess) | [
"@inheritdoc"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Migrations/MigrateRoles.php#L16-L25 |
phpnfe/tools | src/Soap/CorrectedSoapClient.php | CorrectedSoapClient.__doRequest | public function __doRequest($request, $location, $action, $version, $oneWay = 0)
{
$aFind = [':ns1', 'ns1:', "\n", "\r"];
$sReplace = '';
$newrequest = str_replace($aFind, $sReplace, $request);
return parent::__doRequest($newrequest, $location, $action, $version, $oneWay);
} | php | public function __doRequest($request, $location, $action, $version, $oneWay = 0)
{
$aFind = [':ns1', 'ns1:', "\n", "\r"];
$sReplace = '';
$newrequest = str_replace($aFind, $sReplace, $request);
return parent::__doRequest($newrequest, $location, $action, $version, $oneWay);
} | [
"public",
"function",
"__doRequest",
"(",
"$",
"request",
",",
"$",
"location",
",",
"$",
"action",
",",
"$",
"version",
",",
"$",
"oneWay",
"=",
"0",
")",
"{",
"$",
"aFind",
"=",
"[",
"':ns1'",
",",
"'ns1:'",
",",
"\"\\n\"",
",",
"\"\\r\"",
"]",
";",
"$",
"sReplace",
"=",
"''",
";",
"$",
"newrequest",
"=",
"str_replace",
"(",
"$",
"aFind",
",",
"$",
"sReplace",
",",
"$",
"request",
")",
";",
"return",
"parent",
"::",
"__doRequest",
"(",
"$",
"newrequest",
",",
"$",
"location",
",",
"$",
"action",
",",
"$",
"version",
",",
"$",
"oneWay",
")",
";",
"}"
] | __doRequest.
@param string $request
@param string$location
@param string $action
@param int $version
@param int $oneWay
@return string | [
"__doRequest",
"."
] | train | https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Soap/CorrectedSoapClient.php#L37-L44 |
inhere/php-librarys | src/Helpers/HtmlHelper.php | HtmlHelper.unescap | public static function unescap($data, $type = 0, $encoding = 'UTF-8')
{
if (\is_array($data)) {
foreach ($data as $k => $v) {
$data[$k] = self::unescap($data, $type, $encoding);
}
} else {
if (!$type) {//默认使用 htmlspecialchars_decode()
$data = htmlspecialchars_decode($data, ENT_QUOTES);
} else {
$data = html_entity_decode($data, ENT_QUOTES, $encoding);
}
}
return $data;
} | php | public static function unescap($data, $type = 0, $encoding = 'UTF-8')
{
if (\is_array($data)) {
foreach ($data as $k => $v) {
$data[$k] = self::unescap($data, $type, $encoding);
}
} else {
if (!$type) {//默认使用 htmlspecialchars_decode()
$data = htmlspecialchars_decode($data, ENT_QUOTES);
} else {
$data = html_entity_decode($data, ENT_QUOTES, $encoding);
}
}
return $data;
} | [
"public",
"static",
"function",
"unescap",
"(",
"$",
"data",
",",
"$",
"type",
"=",
"0",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"data",
"[",
"$",
"k",
"]",
"=",
"self",
"::",
"unescap",
"(",
"$",
"data",
",",
"$",
"type",
",",
"$",
"encoding",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"//默认使用 htmlspecialchars_decode()",
"$",
"data",
"=",
"htmlspecialchars_decode",
"(",
"$",
"data",
",",
"ENT_QUOTES",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"html_entity_decode",
"(",
"$",
"data",
",",
"ENT_QUOTES",
",",
"$",
"encoding",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | 去掉html转义
@param $data
@param int $type
@param string $encoding
@return array|string | [
"去掉html转义"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/HtmlHelper.php#L115-L133 |
ronaldborla/chikka | src/Borla/Chikka/Service.php | Service.boot | public function boot() {
// Config path
$configPath = dirname(__FILE__) . '/../../config';
// Publish config
$this->publishes([
// Publish config
$configPath . '/chikka.php' => config_path('chikka.php'),
]);
// Merge config
$this->mergeConfigFrom($configPath . '/defaults.php', 'chikka');
} | php | public function boot() {
// Config path
$configPath = dirname(__FILE__) . '/../../config';
// Publish config
$this->publishes([
// Publish config
$configPath . '/chikka.php' => config_path('chikka.php'),
]);
// Merge config
$this->mergeConfigFrom($configPath . '/defaults.php', 'chikka');
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"// Config path",
"$",
"configPath",
"=",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../config'",
";",
"// Publish config",
"$",
"this",
"->",
"publishes",
"(",
"[",
"// Publish config",
"$",
"configPath",
".",
"'/chikka.php'",
"=>",
"config_path",
"(",
"'chikka.php'",
")",
",",
"]",
")",
";",
"// Merge config",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"$",
"configPath",
".",
"'/defaults.php'",
",",
"'chikka'",
")",
";",
"}"
] | On boot | [
"On",
"boot"
] | train | https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Service.php#L15-L25 |
infinity-next/sleuth | src/FileSleuth.php | FileSleuth.check | public function check($file, $verify = null)
{
if (is_string($verify))
{
$verify = "lead" . strtoupper($verify);
}
$detectives = [];
foreach ($this->detectives as $detectiveClass)
{
if ($detectiveClass::on())
{
$detectives[] = $detectiveClass;
}
}
$case = null;
foreach ($detectives as $detectiveClass)
{
$detective = new $detectiveClass();
$case = $detective->check($file, $verify);
if ($case)
{
return $detective;
}
}
return false;
} | php | public function check($file, $verify = null)
{
if (is_string($verify))
{
$verify = "lead" . strtoupper($verify);
}
$detectives = [];
foreach ($this->detectives as $detectiveClass)
{
if ($detectiveClass::on())
{
$detectives[] = $detectiveClass;
}
}
$case = null;
foreach ($detectives as $detectiveClass)
{
$detective = new $detectiveClass();
$case = $detective->check($file, $verify);
if ($case)
{
return $detective;
}
}
return false;
} | [
"public",
"function",
"check",
"(",
"$",
"file",
",",
"$",
"verify",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"verify",
")",
")",
"{",
"$",
"verify",
"=",
"\"lead\"",
".",
"strtoupper",
"(",
"$",
"verify",
")",
";",
"}",
"$",
"detectives",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"detectives",
"as",
"$",
"detectiveClass",
")",
"{",
"if",
"(",
"$",
"detectiveClass",
"::",
"on",
"(",
")",
")",
"{",
"$",
"detectives",
"[",
"]",
"=",
"$",
"detectiveClass",
";",
"}",
"}",
"$",
"case",
"=",
"null",
";",
"foreach",
"(",
"$",
"detectives",
"as",
"$",
"detectiveClass",
")",
"{",
"$",
"detective",
"=",
"new",
"$",
"detectiveClass",
"(",
")",
";",
"$",
"case",
"=",
"$",
"detective",
"->",
"check",
"(",
"$",
"file",
",",
"$",
"verify",
")",
";",
"if",
"(",
"$",
"case",
")",
"{",
"return",
"$",
"detective",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Runs the file against all dectives.
@param string $file Optional parameter to automatically run a check.
@param string|null $verify Extension to verify against. Checks all possible if unset.
@return null|boolean | [
"Runs",
"the",
"file",
"against",
"all",
"dectives",
"."
] | train | https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/FileSleuth.php#L49-L79 |
endorphin-studio/browser-detector-data | src/Storage/AbstractStorage.php | AbstractStorage.setDataDirectory | public function setDataDirectory(string $directory)
{
if (!is_dir($directory)) {
$exception = new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $directory));
$exception->setDirectory($exception);
$exception->setProvider(static::class);
throw $exception;
}
$this->dataDirectory = $directory;
} | php | public function setDataDirectory(string $directory)
{
if (!is_dir($directory)) {
$exception = new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $directory));
$exception->setDirectory($exception);
$exception->setProvider(static::class);
throw $exception;
}
$this->dataDirectory = $directory;
} | [
"public",
"function",
"setDataDirectory",
"(",
"string",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"exception",
"=",
"new",
"StorageException",
"(",
"sprintf",
"(",
"StorageException",
"::",
"DIRECTORY_NOT_FOUND",
",",
"$",
"directory",
")",
")",
";",
"$",
"exception",
"->",
"setDirectory",
"(",
"$",
"exception",
")",
";",
"$",
"exception",
"->",
"setProvider",
"(",
"static",
"::",
"class",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"$",
"this",
"->",
"dataDirectory",
"=",
"$",
"directory",
";",
"}"
] | Set data directory
@param string $directory
@throws StorageException | [
"Set",
"data",
"directory"
] | train | https://github.com/endorphin-studio/browser-detector-data/blob/cb1ace9f52f9677616c89f3b80c5148936d47b82/src/Storage/AbstractStorage.php#L36-L46 |
ZayconFoods/whatcounts | src/ZayconWhatCounts/MailingList.php | MailingList.setListId | public function setListId($list_id)
{
$this->list_id = (is_numeric($list_id)) ? abs(round($list_id)) : NULL;
return $this;
} | php | public function setListId($list_id)
{
$this->list_id = (is_numeric($list_id)) ? abs(round($list_id)) : NULL;
return $this;
} | [
"public",
"function",
"setListId",
"(",
"$",
"list_id",
")",
"{",
"$",
"this",
"->",
"list_id",
"=",
"(",
"is_numeric",
"(",
"$",
"list_id",
")",
")",
"?",
"abs",
"(",
"round",
"(",
"$",
"list_id",
")",
")",
":",
"NULL",
";",
"return",
"$",
"this",
";",
"}"
] | @param mixed $list_id
@return MailingList | [
"@param",
"mixed",
"$list_id"
] | train | https://github.com/ZayconFoods/whatcounts/blob/ff18491fc152571a72e4b558f8102f4fbb9bb7fd/src/ZayconWhatCounts/MailingList.php#L37-L42 |
gregorybesson/PlaygroundCms | src/Service/Page.php | Page.getActivePages | public function getActivePages($displayHome = true, $category = null)
{
$em = $this->serviceLocator->get('doctrine.entitymanager.orm_default');
$today = new \DateTime("now");
//$today->format('Y-m-d H:i:s');
$today = $today->format('Y-m-d') . ' 23:59:59';
$queryStr = 'SELECT p FROM PlaygroundCms\Entity\Page p
WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)
AND (p.closeDate >= :date OR p.closeDate IS NULL)
AND p.active = 1';
if ($displayHome) {
$queryStr .= " AND p.displayHome = true";
}
if ($category) {
$queryStr .= " AND p.category = :category";
}
$queryStr .= ' ORDER BY p.publicationDate DESC';
// Page active with a startDate before today (or without startDate)
// and closeDate after today (or without closeDate)
$query = $em->createQuery($queryStr);
$query->setParameter('date', $today);
if ($category) {
$query->setParameter('category', $category);
}
$pages = $query->getResult();
// Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets
// de type article avec le même procédé en les classant naturellement par date asc ou desc
$arrayPages = array();
foreach ($pages as $page) {
if ($page->getPublicationDate()) {
$key = $page->getPublicationDate()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
} else {
$key = $page->getUpdatedAt()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
}
$arrayPages[$key] = $page;
}
return $arrayPages;
} | php | public function getActivePages($displayHome = true, $category = null)
{
$em = $this->serviceLocator->get('doctrine.entitymanager.orm_default');
$today = new \DateTime("now");
//$today->format('Y-m-d H:i:s');
$today = $today->format('Y-m-d') . ' 23:59:59';
$queryStr = 'SELECT p FROM PlaygroundCms\Entity\Page p
WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)
AND (p.closeDate >= :date OR p.closeDate IS NULL)
AND p.active = 1';
if ($displayHome) {
$queryStr .= " AND p.displayHome = true";
}
if ($category) {
$queryStr .= " AND p.category = :category";
}
$queryStr .= ' ORDER BY p.publicationDate DESC';
// Page active with a startDate before today (or without startDate)
// and closeDate after today (or without closeDate)
$query = $em->createQuery($queryStr);
$query->setParameter('date', $today);
if ($category) {
$query->setParameter('category', $category);
}
$pages = $query->getResult();
// Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets
// de type article avec le même procédé en les classant naturellement par date asc ou desc
$arrayPages = array();
foreach ($pages as $page) {
if ($page->getPublicationDate()) {
$key = $page->getPublicationDate()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
} else {
$key = $page->getUpdatedAt()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
}
$arrayPages[$key] = $page;
}
return $arrayPages;
} | [
"public",
"function",
"getActivePages",
"(",
"$",
"displayHome",
"=",
"true",
",",
"$",
"category",
"=",
"null",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'doctrine.entitymanager.orm_default'",
")",
";",
"$",
"today",
"=",
"new",
"\\",
"DateTime",
"(",
"\"now\"",
")",
";",
"//$today->format('Y-m-d H:i:s');",
"$",
"today",
"=",
"$",
"today",
"->",
"format",
"(",
"'Y-m-d'",
")",
".",
"' 23:59:59'",
";",
"$",
"queryStr",
"=",
"'SELECT p FROM PlaygroundCms\\Entity\\Page p\n WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)\n AND (p.closeDate >= :date OR p.closeDate IS NULL)\n AND p.active = 1'",
";",
"if",
"(",
"$",
"displayHome",
")",
"{",
"$",
"queryStr",
".=",
"\" AND p.displayHome = true\"",
";",
"}",
"if",
"(",
"$",
"category",
")",
"{",
"$",
"queryStr",
".=",
"\" AND p.category = :category\"",
";",
"}",
"$",
"queryStr",
".=",
"' ORDER BY p.publicationDate DESC'",
";",
"// Page active with a startDate before today (or without startDate)",
"// and closeDate after today (or without closeDate)",
"$",
"query",
"=",
"$",
"em",
"->",
"createQuery",
"(",
"$",
"queryStr",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'date'",
",",
"$",
"today",
")",
";",
"if",
"(",
"$",
"category",
")",
"{",
"$",
"query",
"->",
"setParameter",
"(",
"'category'",
",",
"$",
"category",
")",
";",
"}",
"$",
"pages",
"=",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"// Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets",
"// de type article avec le même procédé en les classant naturellement par date asc ou desc",
"$",
"arrayPages",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"->",
"getPublicationDate",
"(",
")",
")",
"{",
"$",
"key",
"=",
"$",
"page",
"->",
"getPublicationDate",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
";",
"$",
"key",
".=",
"$",
"page",
"->",
"getUpdatedAt",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
".",
"'-'",
".",
"$",
"page",
"->",
"getId",
"(",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"page",
"->",
"getUpdatedAt",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
";",
"$",
"key",
".=",
"$",
"page",
"->",
"getUpdatedAt",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
".",
"'-'",
".",
"$",
"page",
"->",
"getId",
"(",
")",
";",
"}",
"$",
"arrayPages",
"[",
"$",
"key",
"]",
"=",
"$",
"page",
";",
"}",
"return",
"$",
"arrayPages",
";",
"}"
] | getActivePages
@return Array of Page\Entity\Page | [
"getActivePages"
] | train | https://github.com/gregorybesson/PlaygroundCms/blob/e929a283f2a6e82d4f248c930f7aa454ce20cbc3/src/Service/Page.php#L235-L281 |
gregorybesson/PlaygroundCms | src/Service/Page.php | Page.getActiveSliderPages | public function getActiveSliderPages()
{
$em = $this->serviceLocator->get('doctrine.entitymanager.orm_default');
$today = new \DateTime("now");
//$today->format('Y-m-d H:i:s');
$today = $today->format('Y-m-d') . ' 23:59:59';
// Page active with a startDate before today (or without startDate)
// and closeDate after today (or without closeDate)
$query = $em->createQuery(
'SELECT p FROM PlaygroundCms\Entity\Page p
WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)
AND (p.closeDate >= :date OR p.closeDate IS NULL)
AND p.active = 1 AND p.pushHome = true
ORDER BY p.publicationDate DESC'
);
$query->setParameter('date', $today);
$pages = $query->getResult();
// Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets
// de type article avec le même procédé en les classant naturellement par date asc ou desc
$arrayPages = array();
foreach ($pages as $page) {
if ($page->getPublicationDate()) {
$key = $page->getPublicationDate()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
} else {
$key = $page->getUpdatedAt()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
}
$arrayPages[$key] = $page;
}
return $arrayPages;
} | php | public function getActiveSliderPages()
{
$em = $this->serviceLocator->get('doctrine.entitymanager.orm_default');
$today = new \DateTime("now");
//$today->format('Y-m-d H:i:s');
$today = $today->format('Y-m-d') . ' 23:59:59';
// Page active with a startDate before today (or without startDate)
// and closeDate after today (or without closeDate)
$query = $em->createQuery(
'SELECT p FROM PlaygroundCms\Entity\Page p
WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)
AND (p.closeDate >= :date OR p.closeDate IS NULL)
AND p.active = 1 AND p.pushHome = true
ORDER BY p.publicationDate DESC'
);
$query->setParameter('date', $today);
$pages = $query->getResult();
// Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets
// de type article avec le même procédé en les classant naturellement par date asc ou desc
$arrayPages = array();
foreach ($pages as $page) {
if ($page->getPublicationDate()) {
$key = $page->getPublicationDate()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
} else {
$key = $page->getUpdatedAt()->format('Ymd');
$key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
}
$arrayPages[$key] = $page;
}
return $arrayPages;
} | [
"public",
"function",
"getActiveSliderPages",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'doctrine.entitymanager.orm_default'",
")",
";",
"$",
"today",
"=",
"new",
"\\",
"DateTime",
"(",
"\"now\"",
")",
";",
"//$today->format('Y-m-d H:i:s');",
"$",
"today",
"=",
"$",
"today",
"->",
"format",
"(",
"'Y-m-d'",
")",
".",
"' 23:59:59'",
";",
"// Page active with a startDate before today (or without startDate)",
"// and closeDate after today (or without closeDate)",
"$",
"query",
"=",
"$",
"em",
"->",
"createQuery",
"(",
"'SELECT p FROM PlaygroundCms\\Entity\\Page p\n WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)\n AND (p.closeDate >= :date OR p.closeDate IS NULL)\n AND p.active = 1 AND p.pushHome = true\n ORDER BY p.publicationDate DESC'",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'date'",
",",
"$",
"today",
")",
";",
"$",
"pages",
"=",
"$",
"query",
"->",
"getResult",
"(",
")",
";",
"// Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets",
"// de type article avec le même procédé en les classant naturellement par date asc ou desc",
"$",
"arrayPages",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"->",
"getPublicationDate",
"(",
")",
")",
"{",
"$",
"key",
"=",
"$",
"page",
"->",
"getPublicationDate",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
";",
"$",
"key",
".=",
"$",
"page",
"->",
"getUpdatedAt",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
".",
"'-'",
".",
"$",
"page",
"->",
"getId",
"(",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"page",
"->",
"getUpdatedAt",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
";",
"$",
"key",
".=",
"$",
"page",
"->",
"getUpdatedAt",
"(",
")",
"->",
"format",
"(",
"'Ymd'",
")",
".",
"'-'",
".",
"$",
"page",
"->",
"getId",
"(",
")",
";",
"}",
"$",
"arrayPages",
"[",
"$",
"key",
"]",
"=",
"$",
"page",
";",
"}",
"return",
"$",
"arrayPages",
";",
"}"
] | getActiveSliderGames
@return Array of Page\Entity\Game | [
"getActiveSliderGames"
] | train | https://github.com/gregorybesson/PlaygroundCms/blob/e929a283f2a6e82d4f248c930f7aa454ce20cbc3/src/Service/Page.php#L288-L323 |
gregorybesson/PlaygroundCms | src/Service/Page.php | Page.getPageMapper | public function getPageMapper()
{
if (null === $this->pageMapper) {
$this->pageMapper = $this->serviceLocator->get('playgroundcms_page_mapper');
}
return $this->pageMapper;
} | php | public function getPageMapper()
{
if (null === $this->pageMapper) {
$this->pageMapper = $this->serviceLocator->get('playgroundcms_page_mapper');
}
return $this->pageMapper;
} | [
"public",
"function",
"getPageMapper",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"pageMapper",
")",
"{",
"$",
"this",
"->",
"pageMapper",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'playgroundcms_page_mapper'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pageMapper",
";",
"}"
] | getPageMapper
@return PageMapperInterface | [
"getPageMapper"
] | train | https://github.com/gregorybesson/PlaygroundCms/blob/e929a283f2a6e82d4f248c930f7aa454ce20cbc3/src/Service/Page.php#L330-L337 |
FrenzelGmbH/cm-address | models/scopes/AddressQuery.php | AddressQuery.active | public function active()
{
if(!\Yii::$app->user->isGuest && !\Yii::$app->user->identity->isAdmin)
{
$this->andWhere(['deleted_at' => NULL]);
}
return $this;
} | php | public function active()
{
if(!\Yii::$app->user->isGuest && !\Yii::$app->user->identity->isAdmin)
{
$this->andWhere(['deleted_at' => NULL]);
}
return $this;
} | [
"public",
"function",
"active",
"(",
")",
"{",
"if",
"(",
"!",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
"&&",
"!",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
"->",
"isAdmin",
")",
"{",
"$",
"this",
"->",
"andWhere",
"(",
"[",
"'deleted_at'",
"=>",
"NULL",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | only none delted records should be returned, deleted would mean they are not null anymore within field value
@return [type] [description] | [
"only",
"none",
"delted",
"records",
"should",
"be",
"returned",
"deleted",
"would",
"mean",
"they",
"are",
"not",
"null",
"anymore",
"within",
"field",
"value"
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/scopes/AddressQuery.php#L21-L28 |
FrenzelGmbH/cm-address | models/scopes/AddressQuery.php | AddressQuery.related | public function related($entity = NULL, $enity = NULL)
{
$this->andWhere(['entity' => $entity, 'entity_id' => $this->entity_id]);
return $this;
} | php | public function related($entity = NULL, $enity = NULL)
{
$this->andWhere(['entity' => $entity, 'entity_id' => $this->entity_id]);
return $this;
} | [
"public",
"function",
"related",
"(",
"$",
"entity",
"=",
"NULL",
",",
"$",
"enity",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"andWhere",
"(",
"[",
"'entity'",
"=>",
"$",
"entity",
",",
"'entity_id'",
"=>",
"$",
"this",
"->",
"entity_id",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | find all records which are related to the same entity
@param [type] $entity [description]
@param [type] $enity [description]
@return [type] [description] | [
"find",
"all",
"records",
"which",
"are",
"related",
"to",
"the",
"same",
"entity"
] | train | https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/scopes/AddressQuery.php#L46-L50 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Graphs/Writer/Graph.php | Graph.transform | public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$type_method = 'process' . ucfirst($transformation->getSource());
$this->$type_method($project, $transformation);
} | php | public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$type_method = 'process' . ucfirst($transformation->getSource());
$this->$type_method($project, $transformation);
} | [
"public",
"function",
"transform",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"type_method",
"=",
"'process'",
".",
"ucfirst",
"(",
"$",
"transformation",
"->",
"getSource",
"(",
")",
")",
";",
"$",
"this",
"->",
"$",
"type_method",
"(",
"$",
"project",
",",
"$",
"transformation",
")",
";",
"}"
] | Invokes the query method contained in this class.
@param ProjectDescriptor $project Document containing the structure.
@param Transformation $transformation Transformation to execute.
@return void | [
"Invokes",
"the",
"query",
"method",
"contained",
"in",
"this",
"class",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L55-L59 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Graphs/Writer/Graph.php | Graph.processClass | public function processClass(ProjectDescriptor $project, Transformation $transformation)
{
try {
$this->checkIfGraphVizIsInstalled();
} catch (\Exception $e) {
echo $e->getMessage();
return;
}
if ($transformation->getParameter('font') !== null && $transformation->getParameter('font')->getValue()) {
$this->nodeFont = $transformation->getParameter('font')->getValue();
} else {
$this->nodeFont = 'Courier';
}
$filename = $this->getDestinationPath($transformation);
$graph = GraphVizGraph::create()
->setRankSep('1.0')
->setCenter('true')
->setRank('source')
->setRankDir('RL')
->setSplines('true')
->setConcentrate('true');
$this->buildNamespaceTree($graph, $project->getNamespace());
$classes = $project->getIndexes()->get('classes', new Collection())->getAll();
$interfaces = $project->getIndexes()->get('interfaces', new Collection())->getAll();
$traits = $project->getIndexes()->get('traits', new Collection())->getAll();
/** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers */
$containers = array_merge($classes, $interfaces, $traits);
foreach ($containers as $container) {
$from_name = $container->getFullyQualifiedStructuralElementName();
$parents = array();
$implemented = array();
if ($container instanceof ClassDescriptor) {
if ($container->getParent()) {
$parents[] = $container->getParent();
}
$implemented = $container->getInterfaces()->getAll();
}
if ($container instanceof InterfaceDescriptor) {
$parents = $container->getParent()->getAll();
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($parents as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setArrowHead('empty');
$graph->link($edge);
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($implemented as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setStyle('dotted');
$edge->setArrowHead('empty');
$graph->link($edge);
}
}
$graph->export('svg', $filename);
} | php | public function processClass(ProjectDescriptor $project, Transformation $transformation)
{
try {
$this->checkIfGraphVizIsInstalled();
} catch (\Exception $e) {
echo $e->getMessage();
return;
}
if ($transformation->getParameter('font') !== null && $transformation->getParameter('font')->getValue()) {
$this->nodeFont = $transformation->getParameter('font')->getValue();
} else {
$this->nodeFont = 'Courier';
}
$filename = $this->getDestinationPath($transformation);
$graph = GraphVizGraph::create()
->setRankSep('1.0')
->setCenter('true')
->setRank('source')
->setRankDir('RL')
->setSplines('true')
->setConcentrate('true');
$this->buildNamespaceTree($graph, $project->getNamespace());
$classes = $project->getIndexes()->get('classes', new Collection())->getAll();
$interfaces = $project->getIndexes()->get('interfaces', new Collection())->getAll();
$traits = $project->getIndexes()->get('traits', new Collection())->getAll();
/** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers */
$containers = array_merge($classes, $interfaces, $traits);
foreach ($containers as $container) {
$from_name = $container->getFullyQualifiedStructuralElementName();
$parents = array();
$implemented = array();
if ($container instanceof ClassDescriptor) {
if ($container->getParent()) {
$parents[] = $container->getParent();
}
$implemented = $container->getInterfaces()->getAll();
}
if ($container instanceof InterfaceDescriptor) {
$parents = $container->getParent()->getAll();
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($parents as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setArrowHead('empty');
$graph->link($edge);
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($implemented as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setStyle('dotted');
$edge->setArrowHead('empty');
$graph->link($edge);
}
}
$graph->export('svg', $filename);
} | [
"public",
"function",
"processClass",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"checkIfGraphVizIsInstalled",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"transformation",
"->",
"getParameter",
"(",
"'font'",
")",
"!==",
"null",
"&&",
"$",
"transformation",
"->",
"getParameter",
"(",
"'font'",
")",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"nodeFont",
"=",
"$",
"transformation",
"->",
"getParameter",
"(",
"'font'",
")",
"->",
"getValue",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"nodeFont",
"=",
"'Courier'",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"getDestinationPath",
"(",
"$",
"transformation",
")",
";",
"$",
"graph",
"=",
"GraphVizGraph",
"::",
"create",
"(",
")",
"->",
"setRankSep",
"(",
"'1.0'",
")",
"->",
"setCenter",
"(",
"'true'",
")",
"->",
"setRank",
"(",
"'source'",
")",
"->",
"setRankDir",
"(",
"'RL'",
")",
"->",
"setSplines",
"(",
"'true'",
")",
"->",
"setConcentrate",
"(",
"'true'",
")",
";",
"$",
"this",
"->",
"buildNamespaceTree",
"(",
"$",
"graph",
",",
"$",
"project",
"->",
"getNamespace",
"(",
")",
")",
";",
"$",
"classes",
"=",
"$",
"project",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'classes'",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"getAll",
"(",
")",
";",
"$",
"interfaces",
"=",
"$",
"project",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'interfaces'",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"getAll",
"(",
")",
";",
"$",
"traits",
"=",
"$",
"project",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'traits'",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"getAll",
"(",
")",
";",
"/** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers */",
"$",
"containers",
"=",
"array_merge",
"(",
"$",
"classes",
",",
"$",
"interfaces",
",",
"$",
"traits",
")",
";",
"foreach",
"(",
"$",
"containers",
"as",
"$",
"container",
")",
"{",
"$",
"from_name",
"=",
"$",
"container",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
";",
"$",
"parents",
"=",
"array",
"(",
")",
";",
"$",
"implemented",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"container",
"instanceof",
"ClassDescriptor",
")",
"{",
"if",
"(",
"$",
"container",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"parents",
"[",
"]",
"=",
"$",
"container",
"->",
"getParent",
"(",
")",
";",
"}",
"$",
"implemented",
"=",
"$",
"container",
"->",
"getInterfaces",
"(",
")",
"->",
"getAll",
"(",
")",
";",
"}",
"if",
"(",
"$",
"container",
"instanceof",
"InterfaceDescriptor",
")",
"{",
"$",
"parents",
"=",
"$",
"container",
"->",
"getParent",
"(",
")",
"->",
"getAll",
"(",
")",
";",
"}",
"/** @var string|ClassDescriptor|InterfaceDescriptor $parent */",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"parent",
")",
"{",
"$",
"edge",
"=",
"$",
"this",
"->",
"createEdge",
"(",
"$",
"graph",
",",
"$",
"from_name",
",",
"$",
"parent",
")",
";",
"$",
"edge",
"->",
"setArrowHead",
"(",
"'empty'",
")",
";",
"$",
"graph",
"->",
"link",
"(",
"$",
"edge",
")",
";",
"}",
"/** @var string|ClassDescriptor|InterfaceDescriptor $parent */",
"foreach",
"(",
"$",
"implemented",
"as",
"$",
"parent",
")",
"{",
"$",
"edge",
"=",
"$",
"this",
"->",
"createEdge",
"(",
"$",
"graph",
",",
"$",
"from_name",
",",
"$",
"parent",
")",
";",
"$",
"edge",
"->",
"setStyle",
"(",
"'dotted'",
")",
";",
"$",
"edge",
"->",
"setArrowHead",
"(",
"'empty'",
")",
";",
"$",
"graph",
"->",
"link",
"(",
"$",
"edge",
")",
";",
"}",
"}",
"$",
"graph",
"->",
"export",
"(",
"'svg'",
",",
"$",
"filename",
")",
";",
"}"
] | Creates a class inheritance diagram.
@param ProjectDescriptor $project
@param Transformation $transformation
@return void | [
"Creates",
"a",
"class",
"inheritance",
"diagram",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L69-L136 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Graphs/Writer/Graph.php | Graph.createEdge | protected function createEdge($graph, $from_name, $to)
{
$to_name = !is_string($to) ? $to->getFullyQualifiedStructuralElementName() : $to;
if (!isset($this->nodeCache[$from_name])) {
$this->nodeCache[$from_name] = $this->createEmptyNode($from_name, $graph);
}
if (!isset($this->nodeCache[$to_name])) {
$this->nodeCache[$to_name] = $this->createEmptyNode($to_name, $graph);
}
return Edge::create($this->nodeCache[$from_name], $this->nodeCache[$to_name]);
} | php | protected function createEdge($graph, $from_name, $to)
{
$to_name = !is_string($to) ? $to->getFullyQualifiedStructuralElementName() : $to;
if (!isset($this->nodeCache[$from_name])) {
$this->nodeCache[$from_name] = $this->createEmptyNode($from_name, $graph);
}
if (!isset($this->nodeCache[$to_name])) {
$this->nodeCache[$to_name] = $this->createEmptyNode($to_name, $graph);
}
return Edge::create($this->nodeCache[$from_name], $this->nodeCache[$to_name]);
} | [
"protected",
"function",
"createEdge",
"(",
"$",
"graph",
",",
"$",
"from_name",
",",
"$",
"to",
")",
"{",
"$",
"to_name",
"=",
"!",
"is_string",
"(",
"$",
"to",
")",
"?",
"$",
"to",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
":",
"$",
"to",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nodeCache",
"[",
"$",
"from_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"nodeCache",
"[",
"$",
"from_name",
"]",
"=",
"$",
"this",
"->",
"createEmptyNode",
"(",
"$",
"from_name",
",",
"$",
"graph",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nodeCache",
"[",
"$",
"to_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"nodeCache",
"[",
"$",
"to_name",
"]",
"=",
"$",
"this",
"->",
"createEmptyNode",
"(",
"$",
"to_name",
",",
"$",
"graph",
")",
";",
"}",
"return",
"Edge",
"::",
"create",
"(",
"$",
"this",
"->",
"nodeCache",
"[",
"$",
"from_name",
"]",
",",
"$",
"this",
"->",
"nodeCache",
"[",
"$",
"to_name",
"]",
")",
";",
"}"
] | Creates a GraphViz Edge between two nodes.
@param Graph $graph
@param string $from_name
@param string|ClassDescriptor|InterfaceDescriptor|TraitDescriptor $to
@return Edge | [
"Creates",
"a",
"GraphViz",
"Edge",
"between",
"two",
"nodes",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L147-L159 |
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Graphs/Writer/Graph.php | Graph.createEmptyNode | protected function createEmptyNode($name, $graph)
{
$node = Node::create($name);
$node->setFontColor('gray');
$node->setLabel($name);
$graph->setNode($node);
return $node;
} | php | protected function createEmptyNode($name, $graph)
{
$node = Node::create($name);
$node->setFontColor('gray');
$node->setLabel($name);
$graph->setNode($node);
return $node;
} | [
"protected",
"function",
"createEmptyNode",
"(",
"$",
"name",
",",
"$",
"graph",
")",
"{",
"$",
"node",
"=",
"Node",
"::",
"create",
"(",
"$",
"name",
")",
";",
"$",
"node",
"->",
"setFontColor",
"(",
"'gray'",
")",
";",
"$",
"node",
"->",
"setLabel",
"(",
"$",
"name",
")",
";",
"$",
"graph",
"->",
"setNode",
"(",
"$",
"node",
")",
";",
"return",
"$",
"node",
";",
"}"
] | @param string $name
@param Graph $graph
@return Node | [
"@param",
"string",
"$name",
"@param",
"Graph",
"$graph"
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L167-L175 |
JBZoo/Assets | src/Manager.php | Manager.add | public function add($alias, $source = null, $dependencies = [], $options = [])
{
if ($source !== null) {
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
}
$this->_queued[$alias] = true;
return $this;
} | php | public function add($alias, $source = null, $dependencies = [], $options = [])
{
if ($source !== null) {
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
}
$this->_queued[$alias] = true;
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"alias",
",",
"$",
"source",
"=",
"null",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"source",
"!==",
"null",
")",
"{",
"$",
"asset",
"=",
"$",
"this",
"->",
"_factory",
"->",
"create",
"(",
"$",
"alias",
",",
"$",
"source",
",",
"$",
"dependencies",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"_collection",
"->",
"add",
"(",
"$",
"asset",
")",
";",
"}",
"$",
"this",
"->",
"_queued",
"[",
"$",
"alias",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a registered asset or a new asset to the queue.
@param string $alias
@param string|null $source
@param string|array $dependencies
@param string|array $options
@return $this | [
"Adds",
"a",
"registered",
"asset",
"or",
"a",
"new",
"asset",
"to",
"the",
"queue",
"."
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L107-L117 |
JBZoo/Assets | src/Manager.php | Manager.register | public function register($alias, $source = null, $dependencies = [], $options = [])
{
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
return $this;
} | php | public function register($alias, $source = null, $dependencies = [], $options = [])
{
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
return $this;
} | [
"public",
"function",
"register",
"(",
"$",
"alias",
",",
"$",
"source",
"=",
"null",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"asset",
"=",
"$",
"this",
"->",
"_factory",
"->",
"create",
"(",
"$",
"alias",
",",
"$",
"source",
",",
"$",
"dependencies",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"_collection",
"->",
"add",
"(",
"$",
"asset",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Registers an asset.
@param string $alias
@param null|string $source
@param array $dependencies
@param string|array $options
@return $this | [
"Registers",
"an",
"asset",
"."
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L140-L146 |
JBZoo/Assets | src/Manager.php | Manager.unregister | public function unregister($alias)
{
$this->_collection->remove($alias);
$this->remove($alias);
return $this;
} | php | public function unregister($alias)
{
$this->_collection->remove($alias);
$this->remove($alias);
return $this;
} | [
"public",
"function",
"unregister",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"_collection",
"->",
"remove",
"(",
"$",
"alias",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"$",
"alias",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Unregisters an asset from collection.
@param string $alias
@return $this | [
"Unregisters",
"an",
"asset",
"from",
"collection",
"."
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L154-L159 |
JBZoo/Assets | src/Manager.php | Manager.build | public function build(array $filters = [])
{
$assets = [];
foreach (array_keys($this->_queued) as $alias) {
$this->_resolveDependencies($this->_collection->get($alias), $assets);
}
/** @var Asset $asset */
$result = [
Asset::TYPE_JS_FILE => [],
Asset::TYPE_JS_CODE => [],
Asset::TYPE_JSX_FILE => [],
Asset::TYPE_JSX_CODE => [],
Asset::TYPE_CSS_FILE => [],
Asset::TYPE_CSS_CODE => [],
Asset::TYPE_CALLBACK => [],
];
foreach ($assets as $asset) {
$source = $asset->load($filters);
if (Asset::TYPE_COLLECTION === $source[0]) {
$source = $source[1];
} else {
$source = [$source];
}
foreach ($source as $sourceItem) {
$type = $sourceItem[0];
$src = $sourceItem[1];
if ($src && !Arr::in($src, $result[$type])) {
$result[$type][] = $src;
}
}
}
return $result;
} | php | public function build(array $filters = [])
{
$assets = [];
foreach (array_keys($this->_queued) as $alias) {
$this->_resolveDependencies($this->_collection->get($alias), $assets);
}
/** @var Asset $asset */
$result = [
Asset::TYPE_JS_FILE => [],
Asset::TYPE_JS_CODE => [],
Asset::TYPE_JSX_FILE => [],
Asset::TYPE_JSX_CODE => [],
Asset::TYPE_CSS_FILE => [],
Asset::TYPE_CSS_CODE => [],
Asset::TYPE_CALLBACK => [],
];
foreach ($assets as $asset) {
$source = $asset->load($filters);
if (Asset::TYPE_COLLECTION === $source[0]) {
$source = $source[1];
} else {
$source = [$source];
}
foreach ($source as $sourceItem) {
$type = $sourceItem[0];
$src = $sourceItem[1];
if ($src && !Arr::in($src, $result[$type])) {
$result[$type][] = $src;
}
}
}
return $result;
} | [
"public",
"function",
"build",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"$",
"assets",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_queued",
")",
"as",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"_resolveDependencies",
"(",
"$",
"this",
"->",
"_collection",
"->",
"get",
"(",
"$",
"alias",
")",
",",
"$",
"assets",
")",
";",
"}",
"/** @var Asset $asset */",
"$",
"result",
"=",
"[",
"Asset",
"::",
"TYPE_JS_FILE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_JS_CODE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_JSX_FILE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_JSX_CODE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_CSS_FILE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_CSS_CODE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_CALLBACK",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"assets",
"as",
"$",
"asset",
")",
"{",
"$",
"source",
"=",
"$",
"asset",
"->",
"load",
"(",
"$",
"filters",
")",
";",
"if",
"(",
"Asset",
"::",
"TYPE_COLLECTION",
"===",
"$",
"source",
"[",
"0",
"]",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"source",
"=",
"[",
"$",
"source",
"]",
";",
"}",
"foreach",
"(",
"$",
"source",
"as",
"$",
"sourceItem",
")",
"{",
"$",
"type",
"=",
"$",
"sourceItem",
"[",
"0",
"]",
";",
"$",
"src",
"=",
"$",
"sourceItem",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"src",
"&&",
"!",
"Arr",
"::",
"in",
"(",
"$",
"src",
",",
"$",
"result",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"src",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Build assets.
@param array $filters
@return array | [
"Build",
"assets",
"."
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L187-L226 |
JBZoo/Assets | src/Manager.php | Manager._resolveDependencies | protected function _resolveDependencies(Asset $asset, &$resolved = [], &$unresolved = [])
{
$unresolved[$asset->getAlias()] = $asset;
foreach ($asset->getDependencies() as $dependency) {
if (!Arr::key($dependency, $resolved)) {
if (isset($unresolved[$dependency])) {
throw new Exception(sprintf(
'Circular asset dependency "%s > %s" detected.',
$asset->getAlias(),
$dependency
));
}
if ($dep = $this->_collection->get($dependency)) {
$this->_resolveDependencies($dep, $resolved, $unresolved);
} else {
throw new Exception("Undefined depends: $dependency");
}
}
}
$resolved[$asset->getAlias()] = $asset;
unset($unresolved[$asset->getAlias()]);
return $resolved;
} | php | protected function _resolveDependencies(Asset $asset, &$resolved = [], &$unresolved = [])
{
$unresolved[$asset->getAlias()] = $asset;
foreach ($asset->getDependencies() as $dependency) {
if (!Arr::key($dependency, $resolved)) {
if (isset($unresolved[$dependency])) {
throw new Exception(sprintf(
'Circular asset dependency "%s > %s" detected.',
$asset->getAlias(),
$dependency
));
}
if ($dep = $this->_collection->get($dependency)) {
$this->_resolveDependencies($dep, $resolved, $unresolved);
} else {
throw new Exception("Undefined depends: $dependency");
}
}
}
$resolved[$asset->getAlias()] = $asset;
unset($unresolved[$asset->getAlias()]);
return $resolved;
} | [
"protected",
"function",
"_resolveDependencies",
"(",
"Asset",
"$",
"asset",
",",
"&",
"$",
"resolved",
"=",
"[",
"]",
",",
"&",
"$",
"unresolved",
"=",
"[",
"]",
")",
"{",
"$",
"unresolved",
"[",
"$",
"asset",
"->",
"getAlias",
"(",
")",
"]",
"=",
"$",
"asset",
";",
"foreach",
"(",
"$",
"asset",
"->",
"getDependencies",
"(",
")",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"$",
"dependency",
",",
"$",
"resolved",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"unresolved",
"[",
"$",
"dependency",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Circular asset dependency \"%s > %s\" detected.'",
",",
"$",
"asset",
"->",
"getAlias",
"(",
")",
",",
"$",
"dependency",
")",
")",
";",
"}",
"if",
"(",
"$",
"dep",
"=",
"$",
"this",
"->",
"_collection",
"->",
"get",
"(",
"$",
"dependency",
")",
")",
"{",
"$",
"this",
"->",
"_resolveDependencies",
"(",
"$",
"dep",
",",
"$",
"resolved",
",",
"$",
"unresolved",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Undefined depends: $dependency\"",
")",
";",
"}",
"}",
"}",
"$",
"resolved",
"[",
"$",
"asset",
"->",
"getAlias",
"(",
")",
"]",
"=",
"$",
"asset",
";",
"unset",
"(",
"$",
"unresolved",
"[",
"$",
"asset",
"->",
"getAlias",
"(",
")",
"]",
")",
";",
"return",
"$",
"resolved",
";",
"}"
] | Resolves asset dependencies.
@param Asset|null $asset
@param Asset[] $resolved
@param Asset[] $unresolved
@return Asset[]
@throws Exception | [
"Resolves",
"asset",
"dependencies",
"."
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L237-L264 |
mslib/resource-proxy | Msl/ResourceProxy/Resource/Email/Message.php | Message.init | public function init($sourceId, $resourceId, $resource)
{
// Setting unique source and resource ids
$this->resourceId = $resourceId;
$this->sourceId = $sourceId;
// Setting message object
if (!$resource instanceof ZendMessage) {
throw new BadResourceConfigurationException(
sprintf(
'Remote resource handler is expected to be an instance of \'\Zend\Mail\Storage\Message\', but got \'%s\'.',
get_class($resource)
)
);
}
$this->message = $resource;
} | php | public function init($sourceId, $resourceId, $resource)
{
// Setting unique source and resource ids
$this->resourceId = $resourceId;
$this->sourceId = $sourceId;
// Setting message object
if (!$resource instanceof ZendMessage) {
throw new BadResourceConfigurationException(
sprintf(
'Remote resource handler is expected to be an instance of \'\Zend\Mail\Storage\Message\', but got \'%s\'.',
get_class($resource)
)
);
}
$this->message = $resource;
} | [
"public",
"function",
"init",
"(",
"$",
"sourceId",
",",
"$",
"resourceId",
",",
"$",
"resource",
")",
"{",
"// Setting unique source and resource ids",
"$",
"this",
"->",
"resourceId",
"=",
"$",
"resourceId",
";",
"$",
"this",
"->",
"sourceId",
"=",
"$",
"sourceId",
";",
"// Setting message object",
"if",
"(",
"!",
"$",
"resource",
"instanceof",
"ZendMessage",
")",
"{",
"throw",
"new",
"BadResourceConfigurationException",
"(",
"sprintf",
"(",
"'Remote resource handler is expected to be an instance of \\'\\Zend\\Mail\\Storage\\Message\\', but got \\'%s\\'.'",
",",
"get_class",
"(",
"$",
"resource",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"message",
"=",
"$",
"resource",
";",
"}"
] | Initializes a Resource object
@param string $sourceId the source id for this resource (the source being the remote server in which the resource is allocated)
@param string $resourceId the resource id for the given resource object
@param mixed $resource the remote resource handler object (e.g. \Zend\Mail\Storage\Message)
@throws BadResourceConfigurationException
@return void | [
"Initializes",
"a",
"Resource",
"object"
] | train | https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L79-L95 |
mslib/resource-proxy | Msl/ResourceProxy/Resource/Email/Message.php | Message.moveToOutputFolder | public function moveToOutputFolder($outputFolder)
{
try {
if ($this->message->isMultipart()) {
// Getting the resource content (subject + body of the email)
$contentPart = $this->message->getPart(1);
$content = $contentPart->getContent();
// Check for attachment
// Getting second part of message object
$part = $this->message->getPart(2);
// Get the attachment file name
if ($part->getHeaders()->has('Content-Disposition')) {
$fileName = $part->getHeaderField('Content-Disposition', 'filename');
// Get the attachment and decode
$attachment = base64_decode($part->getContent());
// Save the attachment
$attachmentFileName = $this->getAttachmentFileName($fileName, $outputFolder);
$finalAttOutputDirectory = $this->getAttachmentFileFolder($outputFolder);
if (!file_exists($finalAttOutputDirectory)) {
mkdir($finalAttOutputDirectory, 0775, true);
}
file_put_contents($attachmentFileName, $attachment);
}
} else {
// Getting the resource content (subject + body of the email)
$content = $this->message->getContent();
}
// Writing content to file
// Setting the file name (output folder + message sub folder + current object string representation + timestamp)
$outputFileName = $this->getContentFileName($outputFolder);
// Writing the content to the output file
$finalOutputDirectory = $this->getContentFileFolder($outputFolder);
if (!file_exists($finalOutputDirectory)) {
mkdir($finalOutputDirectory, 0775, true);
}
file_put_contents($outputFileName, $content);
} catch (\Exception $e) {
throw new Exception\ResourceMoveContentException(
sprintf(
'Error while moving the content of resource \'%s\' to the output folder \'%s\'. Error message is: \'%s\'.',
$this->toString(),
$outputFolder,
$e->getMessage()
)
);
}
return true;
} | php | public function moveToOutputFolder($outputFolder)
{
try {
if ($this->message->isMultipart()) {
// Getting the resource content (subject + body of the email)
$contentPart = $this->message->getPart(1);
$content = $contentPart->getContent();
// Check for attachment
// Getting second part of message object
$part = $this->message->getPart(2);
// Get the attachment file name
if ($part->getHeaders()->has('Content-Disposition')) {
$fileName = $part->getHeaderField('Content-Disposition', 'filename');
// Get the attachment and decode
$attachment = base64_decode($part->getContent());
// Save the attachment
$attachmentFileName = $this->getAttachmentFileName($fileName, $outputFolder);
$finalAttOutputDirectory = $this->getAttachmentFileFolder($outputFolder);
if (!file_exists($finalAttOutputDirectory)) {
mkdir($finalAttOutputDirectory, 0775, true);
}
file_put_contents($attachmentFileName, $attachment);
}
} else {
// Getting the resource content (subject + body of the email)
$content = $this->message->getContent();
}
// Writing content to file
// Setting the file name (output folder + message sub folder + current object string representation + timestamp)
$outputFileName = $this->getContentFileName($outputFolder);
// Writing the content to the output file
$finalOutputDirectory = $this->getContentFileFolder($outputFolder);
if (!file_exists($finalOutputDirectory)) {
mkdir($finalOutputDirectory, 0775, true);
}
file_put_contents($outputFileName, $content);
} catch (\Exception $e) {
throw new Exception\ResourceMoveContentException(
sprintf(
'Error while moving the content of resource \'%s\' to the output folder \'%s\'. Error message is: \'%s\'.',
$this->toString(),
$outputFolder,
$e->getMessage()
)
);
}
return true;
} | [
"public",
"function",
"moveToOutputFolder",
"(",
"$",
"outputFolder",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"message",
"->",
"isMultipart",
"(",
")",
")",
"{",
"// Getting the resource content (subject + body of the email)",
"$",
"contentPart",
"=",
"$",
"this",
"->",
"message",
"->",
"getPart",
"(",
"1",
")",
";",
"$",
"content",
"=",
"$",
"contentPart",
"->",
"getContent",
"(",
")",
";",
"// Check for attachment",
"// Getting second part of message object",
"$",
"part",
"=",
"$",
"this",
"->",
"message",
"->",
"getPart",
"(",
"2",
")",
";",
"// Get the attachment file name",
"if",
"(",
"$",
"part",
"->",
"getHeaders",
"(",
")",
"->",
"has",
"(",
"'Content-Disposition'",
")",
")",
"{",
"$",
"fileName",
"=",
"$",
"part",
"->",
"getHeaderField",
"(",
"'Content-Disposition'",
",",
"'filename'",
")",
";",
"// Get the attachment and decode",
"$",
"attachment",
"=",
"base64_decode",
"(",
"$",
"part",
"->",
"getContent",
"(",
")",
")",
";",
"// Save the attachment",
"$",
"attachmentFileName",
"=",
"$",
"this",
"->",
"getAttachmentFileName",
"(",
"$",
"fileName",
",",
"$",
"outputFolder",
")",
";",
"$",
"finalAttOutputDirectory",
"=",
"$",
"this",
"->",
"getAttachmentFileFolder",
"(",
"$",
"outputFolder",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"finalAttOutputDirectory",
")",
")",
"{",
"mkdir",
"(",
"$",
"finalAttOutputDirectory",
",",
"0775",
",",
"true",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"attachmentFileName",
",",
"$",
"attachment",
")",
";",
"}",
"}",
"else",
"{",
"// Getting the resource content (subject + body of the email)",
"$",
"content",
"=",
"$",
"this",
"->",
"message",
"->",
"getContent",
"(",
")",
";",
"}",
"// Writing content to file",
"// Setting the file name (output folder + message sub folder + current object string representation + timestamp)",
"$",
"outputFileName",
"=",
"$",
"this",
"->",
"getContentFileName",
"(",
"$",
"outputFolder",
")",
";",
"// Writing the content to the output file",
"$",
"finalOutputDirectory",
"=",
"$",
"this",
"->",
"getContentFileFolder",
"(",
"$",
"outputFolder",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"finalOutputDirectory",
")",
")",
"{",
"mkdir",
"(",
"$",
"finalOutputDirectory",
",",
"0775",
",",
"true",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"outputFileName",
",",
"$",
"content",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ResourceMoveContentException",
"(",
"sprintf",
"(",
"'Error while moving the content of resource \\'%s\\' to the output folder \\'%s\\'. Error message is: \\'%s\\'.'",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"outputFolder",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Saves the current resource to the given path. Returns true if move action was successful; false otherwise.
@param string $outputFolder the output folder path for this resource
@throws \Msl\ResourceProxy\Exception\ResourceMoveContentException
@return bool | [
"Saves",
"the",
"current",
"resource",
"to",
"the",
"given",
"path",
".",
"Returns",
"true",
"if",
"move",
"action",
"was",
"successful",
";",
"false",
"otherwise",
"."
] | train | https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L109-L161 |
mslib/resource-proxy | Msl/ResourceProxy/Resource/Email/Message.php | Message.toString | public function toString()
{
if (empty($this->stringRepresentation)) {
$this->stringRepresentation = sprintf('%s%s_%s', static::MESSAGE_TO_STRING_PREFIX, $this->getSourceId(), $this->getResourceId());
}
return $this->stringRepresentation;
} | php | public function toString()
{
if (empty($this->stringRepresentation)) {
$this->stringRepresentation = sprintf('%s%s_%s', static::MESSAGE_TO_STRING_PREFIX, $this->getSourceId(), $this->getResourceId());
}
return $this->stringRepresentation;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"stringRepresentation",
")",
")",
"{",
"$",
"this",
"->",
"stringRepresentation",
"=",
"sprintf",
"(",
"'%s%s_%s'",
",",
"static",
"::",
"MESSAGE_TO_STRING_PREFIX",
",",
"$",
"this",
"->",
"getSourceId",
"(",
")",
",",
"$",
"this",
"->",
"getResourceId",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stringRepresentation",
";",
"}"
] | Returns a string representation for the resource object (used in the output file name)
@return string | [
"Returns",
"a",
"string",
"representation",
"for",
"the",
"resource",
"object",
"(",
"used",
"in",
"the",
"output",
"file",
"name",
")"
] | train | https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L214-L220 |
mslib/resource-proxy | Msl/ResourceProxy/Resource/Email/Message.php | Message.getContentFileName | protected function getContentFileName($outputFolder)
{
// Returning the content file name (output folder + message sub folder + current object string representation + timestamp)
return sprintf(
"%s%s%s_%s",
$this->getContentFileFolder($outputFolder),
DIRECTORY_SEPARATOR,
$this->toString(),
time()
);
} | php | protected function getContentFileName($outputFolder)
{
// Returning the content file name (output folder + message sub folder + current object string representation + timestamp)
return sprintf(
"%s%s%s_%s",
$this->getContentFileFolder($outputFolder),
DIRECTORY_SEPARATOR,
$this->toString(),
time()
);
} | [
"protected",
"function",
"getContentFileName",
"(",
"$",
"outputFolder",
")",
"{",
"// Returning the content file name (output folder + message sub folder + current object string representation + timestamp)",
"return",
"sprintf",
"(",
"\"%s%s%s_%s\"",
",",
"$",
"this",
"->",
"getContentFileFolder",
"(",
"$",
"outputFolder",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"time",
"(",
")",
")",
";",
"}"
] | Returns the content file name as the concatenation of the given output folder + message sub folder + current object string representation + timestamp.
@param string $outputFolder the output folder
@return string | [
"Returns",
"the",
"content",
"file",
"name",
"as",
"the",
"concatenation",
"of",
"the",
"given",
"output",
"folder",
"+",
"message",
"sub",
"folder",
"+",
"current",
"object",
"string",
"representation",
"+",
"timestamp",
"."
] | train | https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L229-L239 |
mslib/resource-proxy | Msl/ResourceProxy/Resource/Email/Message.php | Message.getAttachmentFileName | protected function getAttachmentFileName($originalAttachmentFileName, $baseOutputFolder)
{
// Getting extension from original file name
$pathInfo = pathinfo($originalAttachmentFileName);
$extension = '';
if (isset($pathInfo['extension'])) {
$extension = $pathInfo['extension'];
}
// Returning the attachment file name (output folder + message sub folder + message attachment sub folder
// + original attachment file name + current object string representation + timestamp + extension)
$attachmentFileName = sprintf(
"%s%s%s_%s_%s.%s",
$this->getAttachmentFileFolder($baseOutputFolder),
DIRECTORY_SEPARATOR,
$pathInfo['filename'],
$this->toString(),
time(),
$extension
);
return rtrim($attachmentFileName, '.');
} | php | protected function getAttachmentFileName($originalAttachmentFileName, $baseOutputFolder)
{
// Getting extension from original file name
$pathInfo = pathinfo($originalAttachmentFileName);
$extension = '';
if (isset($pathInfo['extension'])) {
$extension = $pathInfo['extension'];
}
// Returning the attachment file name (output folder + message sub folder + message attachment sub folder
// + original attachment file name + current object string representation + timestamp + extension)
$attachmentFileName = sprintf(
"%s%s%s_%s_%s.%s",
$this->getAttachmentFileFolder($baseOutputFolder),
DIRECTORY_SEPARATOR,
$pathInfo['filename'],
$this->toString(),
time(),
$extension
);
return rtrim($attachmentFileName, '.');
} | [
"protected",
"function",
"getAttachmentFileName",
"(",
"$",
"originalAttachmentFileName",
",",
"$",
"baseOutputFolder",
")",
"{",
"// Getting extension from original file name",
"$",
"pathInfo",
"=",
"pathinfo",
"(",
"$",
"originalAttachmentFileName",
")",
";",
"$",
"extension",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"pathInfo",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"pathInfo",
"[",
"'extension'",
"]",
";",
"}",
"// Returning the attachment file name (output folder + message sub folder + message attachment sub folder",
"// + original attachment file name + current object string representation + timestamp + extension)",
"$",
"attachmentFileName",
"=",
"sprintf",
"(",
"\"%s%s%s_%s_%s.%s\"",
",",
"$",
"this",
"->",
"getAttachmentFileFolder",
"(",
"$",
"baseOutputFolder",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"pathInfo",
"[",
"'filename'",
"]",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"time",
"(",
")",
",",
"$",
"extension",
")",
";",
"return",
"rtrim",
"(",
"$",
"attachmentFileName",
",",
"'.'",
")",
";",
"}"
] | Returns the attachment file name as the concatenation of the given output folder + message sub folder + current object string representation + timestamp.
@param string $originalAttachmentFileName the base attachment file name
@param string $baseOutputFolder the base output folder
@return string | [
"Returns",
"the",
"attachment",
"file",
"name",
"as",
"the",
"concatenation",
"of",
"the",
"given",
"output",
"folder",
"+",
"message",
"sub",
"folder",
"+",
"current",
"object",
"string",
"representation",
"+",
"timestamp",
"."
] | train | https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L266-L286 |
timiTao/behat-symfony-container | src/ServiceContainer/Extension.php | Extension.load | public function load(ContainerBuilder $container, array $config)
{
$container->setParameter(self::EXTENSION_NAME . '.files', $config['configs']);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Config'));
$loader->load('services.yml');
} | php | public function load(ContainerBuilder $container, array $config)
{
$container->setParameter(self::EXTENSION_NAME . '.files', $config['configs']);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Config'));
$loader->load('services.yml');
} | [
"public",
"function",
"load",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"$",
"container",
"->",
"setParameter",
"(",
"self",
"::",
"EXTENSION_NAME",
".",
"'.files'",
",",
"$",
"config",
"[",
"'configs'",
"]",
")",
";",
"$",
"loader",
"=",
"new",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.yml'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/timiTao/behat-symfony-container/blob/f6b87583300d2e2a19b35bc66fb741a133684f7e/src/ServiceContainer/Extension.php#L46-L52 |
xiewulong/yii2-fileupload | oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php | WinCacheClassLoader.findFile | public function findFile($class)
{
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
}
return $file;
} | php | public function findFile($class)
{
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
}
return $file;
} | [
"public",
"function",
"findFile",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"file",
"=",
"wincache_ucache_get",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
")",
")",
"{",
"wincache_ucache_set",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
",",
"$",
"file",
"=",
"$",
"this",
"->",
"decorated",
"->",
"findFile",
"(",
"$",
"class",
")",
",",
"0",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] | Finds a file by class name while caching lookups to WinCache.
@param string $class A class name to resolve to file
@return string|null | [
"Finds",
"a",
"file",
"by",
"class",
"name",
"while",
"caching",
"lookups",
"to",
"WinCache",
"."
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php#L117-L124 |
trunda/SmfMenu | src/Smf/Menu/Renderer/ListRenderer.php | ListRenderer.render | public function render(ItemInterface $item, array $options = array())
{
$options = array_merge($this->defaultOptions, $options);
$options['rootLevel'] = $item->getLevel();
return $this->getMenu($item, $options) ?: '';
} | php | public function render(ItemInterface $item, array $options = array())
{
$options = array_merge($this->defaultOptions, $options);
$options['rootLevel'] = $item->getLevel();
return $this->getMenu($item, $options) ?: '';
} | [
"public",
"function",
"render",
"(",
"ItemInterface",
"$",
"item",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaultOptions",
",",
"$",
"options",
")",
";",
"$",
"options",
"[",
"'rootLevel'",
"]",
"=",
"$",
"item",
"->",
"getLevel",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getMenu",
"(",
"$",
"item",
",",
"$",
"options",
")",
"?",
":",
"''",
";",
"}"
] | Renders menu tree.
Common options:
- depth: The depth at which the item is rendered
null: no limit
0: no children
1: only direct children
- currentAsLink: whether the current item should be a link
- currentClass: class added to the current item
- ancestorClass: class added to the ancestors of the current item
- firstClass: class added to the first child
- lastClass: class added to the last child
@param ItemInterface $item Menu item
@param array $options some rendering options
@return string | [
"Renders",
"menu",
"tree",
"."
] | train | https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Renderer/ListRenderer.php#L74-L79 |
trunda/SmfMenu | src/Smf/Menu/Renderer/ListRenderer.php | ListRenderer.setParentControl | public function setParentControl(Control $parentControl = null)
{
$this->parentControl = $parentControl;
$this->matcher->setParentControl($parentControl);
} | php | public function setParentControl(Control $parentControl = null)
{
$this->parentControl = $parentControl;
$this->matcher->setParentControl($parentControl);
} | [
"public",
"function",
"setParentControl",
"(",
"Control",
"$",
"parentControl",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"parentControl",
"=",
"$",
"parentControl",
";",
"$",
"this",
"->",
"matcher",
"->",
"setParentControl",
"(",
"$",
"parentControl",
")",
";",
"}"
] | Sets the parent control - this is important for link generation
@param Control $parentControl | [
"Sets",
"the",
"parent",
"control",
"-",
"this",
"is",
"important",
"for",
"link",
"generation"
] | train | https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Renderer/ListRenderer.php#L266-L270 |
lowerends/laravel-security-checker | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
$this->app['command.security-checker.check'] = $this->app->share(
function ($app) {
return new Console\CheckCommand();
}
);
$this->commands(['command.security-checker.check']);
} | php | public function register()
{
$this->app['command.security-checker.check'] = $this->app->share(
function ($app) {
return new Console\CheckCommand();
}
);
$this->commands(['command.security-checker.check']);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'command.security-checker.check'",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Console",
"\\",
"CheckCommand",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"[",
"'command.security-checker.check'",
"]",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/lowerends/laravel-security-checker/blob/b945939d407f8c713c56567e4a2e8d6cbbabb4ea/src/ServiceProvider.php#L17-L26 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_mssql.php | ezcQueryExpressionMssql.concat | public function concat()
{
$args = func_get_args();
$cols = ezcQuerySelect::arrayFlatten( $args );
if ( count( $cols ) < 1 )
{
throw new ezcQueryVariableParameterException( 'concat', count( $args ), 1 );
}
$cols = $this->getIdentifiers( $cols );
return join( ' + ', $cols );
} | php | public function concat()
{
$args = func_get_args();
$cols = ezcQuerySelect::arrayFlatten( $args );
if ( count( $cols ) < 1 )
{
throw new ezcQueryVariableParameterException( 'concat', count( $args ), 1 );
}
$cols = $this->getIdentifiers( $cols );
return join( ' + ', $cols );
} | [
"public",
"function",
"concat",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"cols",
"=",
"ezcQuerySelect",
"::",
"arrayFlatten",
"(",
"$",
"args",
")",
";",
"if",
"(",
"count",
"(",
"$",
"cols",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"ezcQueryVariableParameterException",
"(",
"'concat'",
",",
"count",
"(",
"$",
"args",
")",
",",
"1",
")",
";",
"}",
"$",
"cols",
"=",
"$",
"this",
"->",
"getIdentifiers",
"(",
"$",
"cols",
")",
";",
"return",
"join",
"(",
"' + '",
",",
"$",
"cols",
")",
";",
"}"
] | Returns a series of strings concatinated
concat() accepts an arbitrary number of parameters. Each parameter
must contain an expression or an array with expressions.
@param string|array(string) $... strings that will be concatinated. | [
"Returns",
"a",
"series",
"of",
"strings",
"concatinated"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_mssql.php#L132-L144 |
inhere/php-librarys | src/Components/LiteErrorHandler.php | LiteErrorHandler.register | public function register()
{
$that = $this;
set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
if (!($errno & error_reporting())) {
return;
}
$options = [
'type' => $errno,
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'isError' => true,
];
$that->handle(new ErrorPayload($options));
});
set_exception_handler(function ($e) use ($that) {
/** @var \Exception|\Error $e */
$options = [
'type' => $e->getCode(),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'isException' => true,
'exception' => $e,
];
$that->handle(new ErrorPayload($options));
});
register_shutdown_function(function () use ($that) {
if (null !== ($options = error_get_last())) {
$that->handle(new ErrorPayload($options));
}
});
} | php | public function register()
{
$that = $this;
set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
if (!($errno & error_reporting())) {
return;
}
$options = [
'type' => $errno,
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'isError' => true,
];
$that->handle(new ErrorPayload($options));
});
set_exception_handler(function ($e) use ($that) {
/** @var \Exception|\Error $e */
$options = [
'type' => $e->getCode(),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'isException' => true,
'exception' => $e,
];
$that->handle(new ErrorPayload($options));
});
register_shutdown_function(function () use ($that) {
if (null !== ($options = error_get_last())) {
$that->handle(new ErrorPayload($options));
}
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"use",
"(",
"$",
"that",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"errno",
"&",
"error_reporting",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"options",
"=",
"[",
"'type'",
"=>",
"$",
"errno",
",",
"'message'",
"=>",
"$",
"errstr",
",",
"'file'",
"=>",
"$",
"errfile",
",",
"'line'",
"=>",
"$",
"errline",
",",
"'isError'",
"=>",
"true",
",",
"]",
";",
"$",
"that",
"->",
"handle",
"(",
"new",
"ErrorPayload",
"(",
"$",
"options",
")",
")",
";",
"}",
")",
";",
"set_exception_handler",
"(",
"function",
"(",
"$",
"e",
")",
"use",
"(",
"$",
"that",
")",
"{",
"/** @var \\Exception|\\Error $e */",
"$",
"options",
"=",
"[",
"'type'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'file'",
"=>",
"$",
"e",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"e",
"->",
"getLine",
"(",
")",
",",
"'isException'",
"=>",
"true",
",",
"'exception'",
"=>",
"$",
"e",
",",
"]",
";",
"$",
"that",
"->",
"handle",
"(",
"new",
"ErrorPayload",
"(",
"$",
"options",
")",
")",
";",
"}",
")",
";",
"register_shutdown_function",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"options",
"=",
"error_get_last",
"(",
")",
")",
")",
"{",
"$",
"that",
"->",
"handle",
"(",
"new",
"ErrorPayload",
"(",
"$",
"options",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Registers itself as error and exception handler. | [
"Registers",
"itself",
"as",
"error",
"and",
"exception",
"handler",
"."
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/LiteErrorHandler.php#L23-L59 |
inhere/php-librarys | src/Components/LiteErrorHandler.php | LiteErrorHandler.mapErrorsToLogType | public function mapErrorsToLogType($code)
{
switch ($code) {
case E_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
return Logger::ERROR;
case E_WARNING:
case E_USER_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
return Logger::WARNING;
case E_NOTICE:
case E_USER_NOTICE:
return Logger::NOTICE;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
return Logger::INFO;
}
return Logger::ERROR;
} | php | public function mapErrorsToLogType($code)
{
switch ($code) {
case E_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
return Logger::ERROR;
case E_WARNING:
case E_USER_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
return Logger::WARNING;
case E_NOTICE:
case E_USER_NOTICE:
return Logger::NOTICE;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
return Logger::INFO;
}
return Logger::ERROR;
} | [
"public",
"function",
"mapErrorsToLogType",
"(",
"$",
"code",
")",
"{",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"E_ERROR",
":",
"case",
"E_RECOVERABLE_ERROR",
":",
"case",
"E_CORE_ERROR",
":",
"case",
"E_COMPILE_ERROR",
":",
"case",
"E_USER_ERROR",
":",
"case",
"E_PARSE",
":",
"return",
"Logger",
"::",
"ERROR",
";",
"case",
"E_WARNING",
":",
"case",
"E_USER_WARNING",
":",
"case",
"E_CORE_WARNING",
":",
"case",
"E_COMPILE_WARNING",
":",
"return",
"Logger",
"::",
"WARNING",
";",
"case",
"E_NOTICE",
":",
"case",
"E_USER_NOTICE",
":",
"return",
"Logger",
"::",
"NOTICE",
";",
"case",
"E_STRICT",
":",
"case",
"E_DEPRECATED",
":",
"case",
"E_USER_DEPRECATED",
":",
"return",
"Logger",
"::",
"INFO",
";",
"}",
"return",
"Logger",
"::",
"ERROR",
";",
"}"
] | Maps error code to a log type.
@param integer $code
@return integer | [
"Maps",
"error",
"code",
"to",
"a",
"log",
"type",
"."
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/LiteErrorHandler.php#L146-L171 |
antaresproject/notifications | src/Widgets/NotificationSender/Controller/NotificationController.php | NotificationController.send | public function send(Request $request)
{
$afterValidate = $request->get('afterValidate');
$notifications = (array) $request->get('notifications', []);
if (! $afterValidate) {
return $this->form->get()->isValid();
}
$this->fire($this->findModel($notifications));
return new JsonResponse(['message' => trans('antares/notifications::messages.widget_notification_added_to_queue')]);
} | php | public function send(Request $request)
{
$afterValidate = $request->get('afterValidate');
$notifications = (array) $request->get('notifications', []);
if (! $afterValidate) {
return $this->form->get()->isValid();
}
$this->fire($this->findModel($notifications));
return new JsonResponse(['message' => trans('antares/notifications::messages.widget_notification_added_to_queue')]);
} | [
"public",
"function",
"send",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"afterValidate",
"=",
"$",
"request",
"->",
"get",
"(",
"'afterValidate'",
")",
";",
"$",
"notifications",
"=",
"(",
"array",
")",
"$",
"request",
"->",
"get",
"(",
"'notifications'",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"$",
"afterValidate",
")",
"{",
"return",
"$",
"this",
"->",
"form",
"->",
"get",
"(",
")",
"->",
"isValid",
"(",
")",
";",
"}",
"$",
"this",
"->",
"fire",
"(",
"$",
"this",
"->",
"findModel",
"(",
"$",
"notifications",
")",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"'message'",
"=>",
"trans",
"(",
"'antares/notifications::messages.widget_notification_added_to_queue'",
")",
"]",
")",
";",
"}"
] | Send action
@return JsonResponse | [
"Send",
"action"
] | train | https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/Controller/NotificationController.php#L87-L99 |
antaresproject/notifications | src/Widgets/NotificationSender/Controller/NotificationController.php | NotificationController.fire | protected function fire(Model $model) : array
{
$recipient = $this->getRecipient();
if ($recipient->phone === null) {
$recipient->phone = config('antares/notifications::default.sms');
}
$params = ['variables' => ['user' => $recipient], 'recipients' => [$recipient]];
return event($model->event, $params);
} | php | protected function fire(Model $model) : array
{
$recipient = $this->getRecipient();
if ($recipient->phone === null) {
$recipient->phone = config('antares/notifications::default.sms');
}
$params = ['variables' => ['user' => $recipient], 'recipients' => [$recipient]];
return event($model->event, $params);
} | [
"protected",
"function",
"fire",
"(",
"Model",
"$",
"model",
")",
":",
"array",
"{",
"$",
"recipient",
"=",
"$",
"this",
"->",
"getRecipient",
"(",
")",
";",
"if",
"(",
"$",
"recipient",
"->",
"phone",
"===",
"null",
")",
"{",
"$",
"recipient",
"->",
"phone",
"=",
"config",
"(",
"'antares/notifications::default.sms'",
")",
";",
"}",
"$",
"params",
"=",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"$",
"recipient",
"]",
",",
"'recipients'",
"=>",
"[",
"$",
"recipient",
"]",
"]",
";",
"return",
"event",
"(",
"$",
"model",
"->",
"event",
",",
"$",
"params",
")",
";",
"}"
] | Fires notification events
@param Model $model
@return array | [
"Fires",
"notification",
"events"
] | train | https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/Controller/NotificationController.php#L107-L118 |
antaresproject/notifications | src/Widgets/NotificationSender/Controller/NotificationController.php | NotificationController.getRecipient | protected function getRecipient()
{
if (Input::get('test')) {
return user();
}
$route = app('router')->getRoutes()->match(app('request')->create(url()->previous()));
return (in_array('users', $route->parameterNames()) && $uid = $route->parameter('users')) ? user()->newQuery()->findOrFail($uid) : user();
} | php | protected function getRecipient()
{
if (Input::get('test')) {
return user();
}
$route = app('router')->getRoutes()->match(app('request')->create(url()->previous()));
return (in_array('users', $route->parameterNames()) && $uid = $route->parameter('users')) ? user()->newQuery()->findOrFail($uid) : user();
} | [
"protected",
"function",
"getRecipient",
"(",
")",
"{",
"if",
"(",
"Input",
"::",
"get",
"(",
"'test'",
")",
")",
"{",
"return",
"user",
"(",
")",
";",
"}",
"$",
"route",
"=",
"app",
"(",
"'router'",
")",
"->",
"getRoutes",
"(",
")",
"->",
"match",
"(",
"app",
"(",
"'request'",
")",
"->",
"create",
"(",
"url",
"(",
")",
"->",
"previous",
"(",
")",
")",
")",
";",
"return",
"(",
"in_array",
"(",
"'users'",
",",
"$",
"route",
"->",
"parameterNames",
"(",
")",
")",
"&&",
"$",
"uid",
"=",
"$",
"route",
"->",
"parameter",
"(",
"'users'",
")",
")",
"?",
"user",
"(",
")",
"->",
"newQuery",
"(",
")",
"->",
"findOrFail",
"(",
"$",
"uid",
")",
":",
"user",
"(",
")",
";",
"}"
] | Gets recipient for notification
@return \Illuminate\Database\Eloquent\Model | [
"Gets",
"recipient",
"for",
"notification"
] | train | https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/Controller/NotificationController.php#L125-L132 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.emoticonsToHtml | public static function emoticonsToHtml($str)
{
$str = str_replace (" :)", ' <img src="/media/emot/icon_biggrin.gif" alt="big_grin" />', $str);
$str = str_replace (" :(", ' <img src="/media/emot/icon_cry.gif" alt="cry" />', $str);
$str = str_replace (" ;)", ' <img src="/media/emot/icon_wink.gif" alt="wink" />', $str);
$str = str_replace (" 8*", ' <img src="/media/emot/icon_eek.gif" alt="eek" />', $str);
return $str;
} | php | public static function emoticonsToHtml($str)
{
$str = str_replace (" :)", ' <img src="/media/emot/icon_biggrin.gif" alt="big_grin" />', $str);
$str = str_replace (" :(", ' <img src="/media/emot/icon_cry.gif" alt="cry" />', $str);
$str = str_replace (" ;)", ' <img src="/media/emot/icon_wink.gif" alt="wink" />', $str);
$str = str_replace (" 8*", ' <img src="/media/emot/icon_eek.gif" alt="eek" />', $str);
return $str;
} | [
"public",
"static",
"function",
"emoticonsToHtml",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"\" :)\"",
",",
"' <img src=\"/media/emot/icon_biggrin.gif\" alt=\"big_grin\" />'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"\" :(\"",
",",
"' <img src=\"/media/emot/icon_cry.gif\" alt=\"cry\" />'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"\" ;)\"",
",",
"' <img src=\"/media/emot/icon_wink.gif\" alt=\"wink\" />'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"\" 8*\"",
",",
"' <img src=\"/media/emot/icon_eek.gif\" alt=\"eek\" />'",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Converts emoticons shortcuts to images
@param string $str
@return string | [
"Converts",
"emoticons",
"shortcuts",
"to",
"images"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L55-L64 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.clean | public static function clean($str, $allow_email=false)
{
$str = self::typoFix($str);
$str = \sb\String\HTML::escape($str);
$str = self::convertQuotes($str);
$str = self::listsToHtml($str);
$str = self::tablesToHtml($str);
$str = self::linksToHtml($str, $allow_email);
$str = self::colorizeInstantMessages($str);
$str = self::textStyles($str);
$str = self::parseCss($str);
$str = self::addSearches($str);
$str = self::miscTags($str);
//turn any tabs into 4 spaces
$str = str_replace("\t", " ", $str);
return $str;
} | php | public static function clean($str, $allow_email=false)
{
$str = self::typoFix($str);
$str = \sb\String\HTML::escape($str);
$str = self::convertQuotes($str);
$str = self::listsToHtml($str);
$str = self::tablesToHtml($str);
$str = self::linksToHtml($str, $allow_email);
$str = self::colorizeInstantMessages($str);
$str = self::textStyles($str);
$str = self::parseCss($str);
$str = self::addSearches($str);
$str = self::miscTags($str);
//turn any tabs into 4 spaces
$str = str_replace("\t", " ", $str);
return $str;
} | [
"public",
"static",
"function",
"clean",
"(",
"$",
"str",
",",
"$",
"allow_email",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"self",
"::",
"typoFix",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"\\",
"sb",
"\\",
"String",
"\\",
"HTML",
"::",
"escape",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"convertQuotes",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"listsToHtml",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"tablesToHtml",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"linksToHtml",
"(",
"$",
"str",
",",
"$",
"allow_email",
")",
";",
"$",
"str",
"=",
"self",
"::",
"colorizeInstantMessages",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"textStyles",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"parseCss",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"addSearches",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"miscTags",
"(",
"$",
"str",
")",
";",
"//turn any tabs into 4 spaces",
"$",
"str",
"=",
"str_replace",
"(",
"\"\\t\"",
",",
"\" \"",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Clean up the text according to the textBling rules
@param string $str The text to clean
@param boolean $media Determines if media is parsed into html
@return string The cleaned text | [
"Clean",
"up",
"the",
"text",
"according",
"to",
"the",
"textBling",
"rules"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L88-L117 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.miscTags | public static function miscTags($str)
{
##hortizontal row
$str = str_replace('[hr]', '<hr style="clear:both;" />', $str);
##line break
$str = str_replace('[br]', '<br />', $str);
##puttext inside a scrolling box
$str = preg_replace( "~\[box\]\n?(.*?)\n?\[\/box\]\n{1,}?~is", "<div class=\"box\">\\1</div>", $str);
return $str;
} | php | public static function miscTags($str)
{
##hortizontal row
$str = str_replace('[hr]', '<hr style="clear:both;" />', $str);
##line break
$str = str_replace('[br]', '<br />', $str);
##puttext inside a scrolling box
$str = preg_replace( "~\[box\]\n?(.*?)\n?\[\/box\]\n{1,}?~is", "<div class=\"box\">\\1</div>", $str);
return $str;
} | [
"public",
"static",
"function",
"miscTags",
"(",
"$",
"str",
")",
"{",
"##hortizontal row",
"$",
"str",
"=",
"str_replace",
"(",
"'[hr]'",
",",
"'<hr style=\"clear:both;\" />'",
",",
"$",
"str",
")",
";",
"##line break",
"$",
"str",
"=",
"str_replace",
"(",
"'[br]'",
",",
"'<br />'",
",",
"$",
"str",
")",
";",
"##puttext inside a scrolling box",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[box\\]\\n?(.*?)\\n?\\[\\/box\\]\\n{1,}?~is\"",
",",
"\"<div class=\\\"box\\\">\\\\1</div>\"",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Parses out misc tags such as horizontal rule and a scrolling box
@param string $str
@return string $str; | [
"Parses",
"out",
"misc",
"tags",
"such",
"as",
"horizontal",
"rule",
"and",
"a",
"scrolling",
"box"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L125-L138 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.listsToHtml | public static function listsToHtml($str)
{
$str = preg_replace_callback('/(?:(?:^|\n)[#\*].*)+\n?/m', function($match){
$type = substr(trim($match[0]), 0, 1) == '#' ? 'ol' : 'ul';
$star_cnt = 1;
$lis = preg_replace_callback("~^([\*\#]+)(.*)$~m", function($innermatch){
return '<li>'.$innermatch[2].'</li>';
}, trim($match[0]));
$lis = str_replace(Array("\n</li>", "</li>\n"), "</li>", $lis);
return '<'.$type.' class="tb">'.$lis.'</'.$type.'>';
}, $str);
$str = preg_replace_callback("~\[list\](.*?)\[/list\]\n~s", function($match){
$lis = preg_replace_callback("~^\w|\s.*$~m", function($inner_match){
$li = trim($inner_match[0]);
if(!empty($li)){
return '<li class="tb">'.trim($li).'</li>';
}
return '';
}, $match[1]);
return '<ul class="tb">'.$lis.'</ul>';
}, $str);
$str = preg_replace_callback("~\[numlist\](.*?)\[/numlist\]\n?~s", function($match){
$lis = preg_replace_callback("~^\w|\s.*$~m", function($inner_match){
$li = trim($inner_match[0]);
if(!empty($li)){
return '<li class="tb">'.trim($li).'</li>';
}
return '';
}, $match[1]);
return '<ol class="tb">'.$lis.'</ol>';
}, $str);
$str = preg_replace_callback('~\n{0,}\t{0,}\[(/?(ol|ul|li))\]\n*~', function($match) {
if (!strstr($match[1], "/")) {
return '<' . $match[1] . ' class="tb">';
} else {
return '<' . $match[1] . '>';
}
}, $str);
return $str;
} | php | public static function listsToHtml($str)
{
$str = preg_replace_callback('/(?:(?:^|\n)[#\*].*)+\n?/m', function($match){
$type = substr(trim($match[0]), 0, 1) == '#' ? 'ol' : 'ul';
$star_cnt = 1;
$lis = preg_replace_callback("~^([\*\#]+)(.*)$~m", function($innermatch){
return '<li>'.$innermatch[2].'</li>';
}, trim($match[0]));
$lis = str_replace(Array("\n</li>", "</li>\n"), "</li>", $lis);
return '<'.$type.' class="tb">'.$lis.'</'.$type.'>';
}, $str);
$str = preg_replace_callback("~\[list\](.*?)\[/list\]\n~s", function($match){
$lis = preg_replace_callback("~^\w|\s.*$~m", function($inner_match){
$li = trim($inner_match[0]);
if(!empty($li)){
return '<li class="tb">'.trim($li).'</li>';
}
return '';
}, $match[1]);
return '<ul class="tb">'.$lis.'</ul>';
}, $str);
$str = preg_replace_callback("~\[numlist\](.*?)\[/numlist\]\n?~s", function($match){
$lis = preg_replace_callback("~^\w|\s.*$~m", function($inner_match){
$li = trim($inner_match[0]);
if(!empty($li)){
return '<li class="tb">'.trim($li).'</li>';
}
return '';
}, $match[1]);
return '<ol class="tb">'.$lis.'</ol>';
}, $str);
$str = preg_replace_callback('~\n{0,}\t{0,}\[(/?(ol|ul|li))\]\n*~', function($match) {
if (!strstr($match[1], "/")) {
return '<' . $match[1] . ' class="tb">';
} else {
return '<' . $match[1] . '>';
}
}, $str);
return $str;
} | [
"public",
"static",
"function",
"listsToHtml",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"'/(?:(?:^|\\n)[#\\*].*)+\\n?/m'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"$",
"type",
"=",
"substr",
"(",
"trim",
"(",
"$",
"match",
"[",
"0",
"]",
")",
",",
"0",
",",
"1",
")",
"==",
"'#'",
"?",
"'ol'",
":",
"'ul'",
";",
"$",
"star_cnt",
"=",
"1",
";",
"$",
"lis",
"=",
"preg_replace_callback",
"(",
"\"~^([\\*\\#]+)(.*)$~m\"",
",",
"function",
"(",
"$",
"innermatch",
")",
"{",
"return",
"'<li>'",
".",
"$",
"innermatch",
"[",
"2",
"]",
".",
"'</li>'",
";",
"}",
",",
"trim",
"(",
"$",
"match",
"[",
"0",
"]",
")",
")",
";",
"$",
"lis",
"=",
"str_replace",
"(",
"Array",
"(",
"\"\\n</li>\"",
",",
"\"</li>\\n\"",
")",
",",
"\"</li>\"",
",",
"$",
"lis",
")",
";",
"return",
"'<'",
".",
"$",
"type",
".",
"' class=\"tb\">'",
".",
"$",
"lis",
".",
"'</'",
".",
"$",
"type",
".",
"'>'",
";",
"}",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"\"~\\[list\\](.*?)\\[/list\\]\\n~s\"",
",",
"function",
"(",
"$",
"match",
")",
"{",
"$",
"lis",
"=",
"preg_replace_callback",
"(",
"\"~^\\w|\\s.*$~m\"",
",",
"function",
"(",
"$",
"inner_match",
")",
"{",
"$",
"li",
"=",
"trim",
"(",
"$",
"inner_match",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"li",
")",
")",
"{",
"return",
"'<li class=\"tb\">'",
".",
"trim",
"(",
"$",
"li",
")",
".",
"'</li>'",
";",
"}",
"return",
"''",
";",
"}",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"return",
"'<ul class=\"tb\">'",
".",
"$",
"lis",
".",
"'</ul>'",
";",
"}",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"\"~\\[numlist\\](.*?)\\[/numlist\\]\\n?~s\"",
",",
"function",
"(",
"$",
"match",
")",
"{",
"$",
"lis",
"=",
"preg_replace_callback",
"(",
"\"~^\\w|\\s.*$~m\"",
",",
"function",
"(",
"$",
"inner_match",
")",
"{",
"$",
"li",
"=",
"trim",
"(",
"$",
"inner_match",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"li",
")",
")",
"{",
"return",
"'<li class=\"tb\">'",
".",
"trim",
"(",
"$",
"li",
")",
".",
"'</li>'",
";",
"}",
"return",
"''",
";",
"}",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"return",
"'<ol class=\"tb\">'",
".",
"$",
"lis",
".",
"'</ol>'",
";",
"}",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"'~\\n{0,}\\t{0,}\\[(/?(ol|ul|li))\\]\\n*~'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"if",
"(",
"!",
"strstr",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"\"/\"",
")",
")",
"{",
"return",
"'<'",
".",
"$",
"match",
"[",
"1",
"]",
".",
"' class=\"tb\">'",
";",
"}",
"else",
"{",
"return",
"'<'",
".",
"$",
"match",
"[",
"1",
"]",
".",
"'>'",
";",
"}",
"}",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Converts [list][/list] to ordered lists
@param string $str
@return string
@todo combine numlist and list into one | [
"Converts",
"[",
"list",
"]",
"[",
"/",
"list",
"]",
"to",
"ordered",
"lists"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L147-L200 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.linksToHtml | public static function linksToHtml($str, $allow_email=false, $link_markup=null)
{
### Convert Email Tags ###
if(!$allow_email){
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", '<b> \\2 AT \\3 </b>', $str);
} else {
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", ' <a href="mailto:\\2@\\3">\\2@\\3</a>', $str);
}
### phrase links ###
$str = preg_replace( "~\[(?:url|link)=(http.*?)\](.*?)\[\/(?:url|link)\]~", "<a class=\"blank\" href=\"\\1\">\\2</a>", $str);
$link = $link_markup ? $link_markup : '(LINK)';
### url links ###\\2://\\3
//$str = preg_replace("#(\s|\n)([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", ' <a href="\\2://\\3" title="\\2://\\3">'.$link.'</a>', $str);
$str = preg_replace_callback("#(^|\s)([a-z]+?://[\w\-\.,\?!%\*\#:;~\\&$@\/=\+]+)#i", function($match) use($link){
$href = $match[2];
$end_punct = '';
if(preg_match("~[\.\?\!]$~", $href, $matchx)){
$end_punct = $matchx[0];
$href = substr($href,0,-1);
}
return $match[1].'<a href="'.$href.'" title="'.$href.'">'.$link.'</a>'.$end_punct;
}, $str);
return $str;
} | php | public static function linksToHtml($str, $allow_email=false, $link_markup=null)
{
### Convert Email Tags ###
if(!$allow_email){
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", '<b> \\2 AT \\3 </b>', $str);
} else {
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", ' <a href="mailto:\\2@\\3">\\2@\\3</a>', $str);
}
### phrase links ###
$str = preg_replace( "~\[(?:url|link)=(http.*?)\](.*?)\[\/(?:url|link)\]~", "<a class=\"blank\" href=\"\\1\">\\2</a>", $str);
$link = $link_markup ? $link_markup : '(LINK)';
### url links ###\\2://\\3
//$str = preg_replace("#(\s|\n)([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", ' <a href="\\2://\\3" title="\\2://\\3">'.$link.'</a>', $str);
$str = preg_replace_callback("#(^|\s)([a-z]+?://[\w\-\.,\?!%\*\#:;~\\&$@\/=\+]+)#i", function($match) use($link){
$href = $match[2];
$end_punct = '';
if(preg_match("~[\.\?\!]$~", $href, $matchx)){
$end_punct = $matchx[0];
$href = substr($href,0,-1);
}
return $match[1].'<a href="'.$href.'" title="'.$href.'">'.$link.'</a>'.$end_punct;
}, $str);
return $str;
} | [
"public",
"static",
"function",
"linksToHtml",
"(",
"$",
"str",
",",
"$",
"allow_email",
"=",
"false",
",",
"$",
"link_markup",
"=",
"null",
")",
"{",
"### Convert Email Tags ###",
"if",
"(",
"!",
"$",
"allow_email",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"\"#([\\n ])([a-z0-9\\-_.]+?)@([\\w\\-]+\\.([\\w\\-\\.]+\\.)?[\\w]+)#i\"",
",",
"'<b> \\\\2 AT \\\\3 </b>'",
",",
"$",
"str",
")",
";",
"}",
"else",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"\"#([\\n ])([a-z0-9\\-_.]+?)@([\\w\\-]+\\.([\\w\\-\\.]+\\.)?[\\w]+)#i\"",
",",
"' <a href=\"mailto:\\\\2@\\\\3\">\\\\2@\\\\3</a>'",
",",
"$",
"str",
")",
";",
"}",
"### phrase links ###",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[(?:url|link)=(http.*?)\\](.*?)\\[\\/(?:url|link)\\]~\"",
",",
"\"<a class=\\\"blank\\\" href=\\\"\\\\1\\\">\\\\2</a>\"",
",",
"$",
"str",
")",
";",
"$",
"link",
"=",
"$",
"link_markup",
"?",
"$",
"link_markup",
":",
"'(LINK)'",
";",
"### url links ###\\\\2://\\\\3",
"//$str = preg_replace(\"#(\\s|\\n)([a-z]+?)://([a-z0-9\\-\\.,\\?!%\\*_\\#:;~\\\\&$@\\/=\\+]+)#i\", ' <a href=\"\\\\2://\\\\3\" title=\"\\\\2://\\\\3\">'.$link.'</a>', $str);",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"\"#(^|\\s)([a-z]+?://[\\w\\-\\.,\\?!%\\*\\#:;~\\\\&$@\\/=\\+]+)#i\"",
",",
"function",
"(",
"$",
"match",
")",
"use",
"(",
"$",
"link",
")",
"{",
"$",
"href",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"$",
"end_punct",
"=",
"''",
";",
"if",
"(",
"preg_match",
"(",
"\"~[\\.\\?\\!]$~\"",
",",
"$",
"href",
",",
"$",
"matchx",
")",
")",
"{",
"$",
"end_punct",
"=",
"$",
"matchx",
"[",
"0",
"]",
";",
"$",
"href",
"=",
"substr",
"(",
"$",
"href",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"return",
"$",
"match",
"[",
"1",
"]",
".",
"'<a href=\"'",
".",
"$",
"href",
".",
"'\" title=\"'",
".",
"$",
"href",
".",
"'\">'",
".",
"$",
"link",
".",
"'</a>'",
".",
"$",
"end_punct",
";",
"}",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Converts email and http links to HTML links
@param string $str
@return string | [
"Converts",
"email",
"and",
"http",
"links",
"to",
"HTML",
"links"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L254-L283 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.addSearches | public static function addSearches($str)
{
### make google searches ###
preg_match_all( "/\[google\](.*?)\[\/google\]/s", $str, $matches );
$match = $matches[0];
$data = $matches[1];
$count = count($match);
for($x=0;$x<$count;$x++){
$query = str_replace(" ", "+", $data[$x]);
$query = str_replace('"', "%22", $query);
$str = str_replace($match[$x], '<a class="blank" href="http://www.google.com/search?hl=en&ie=UTF-8&q='.$query.'" title="click to search google for '.$data[$x].'" >(GOOGLE - '.$data[$x].')</a>', $str);
}
### make wikipedia searches ###
$str = preg_replace( "~\[wikipedia\](.*?)\[\/wikipedia\]~s", '<a class="blank" href="http://en.wikipedia.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wikipedia for \\1" >(WIKIPEDIA - \\1)</a>', $str );
### make wiktionary searches ###
$str = preg_replace( "~\[wiktionary\](.*?)\[\/wiktionary\]~s", '<a class="blank" href="http://en.wiktionary.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wiktionary for \\1">(WIKTIONARY - \\1)</a>', $str );
return $str;
} | php | public static function addSearches($str)
{
### make google searches ###
preg_match_all( "/\[google\](.*?)\[\/google\]/s", $str, $matches );
$match = $matches[0];
$data = $matches[1];
$count = count($match);
for($x=0;$x<$count;$x++){
$query = str_replace(" ", "+", $data[$x]);
$query = str_replace('"', "%22", $query);
$str = str_replace($match[$x], '<a class="blank" href="http://www.google.com/search?hl=en&ie=UTF-8&q='.$query.'" title="click to search google for '.$data[$x].'" >(GOOGLE - '.$data[$x].')</a>', $str);
}
### make wikipedia searches ###
$str = preg_replace( "~\[wikipedia\](.*?)\[\/wikipedia\]~s", '<a class="blank" href="http://en.wikipedia.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wikipedia for \\1" >(WIKIPEDIA - \\1)</a>', $str );
### make wiktionary searches ###
$str = preg_replace( "~\[wiktionary\](.*?)\[\/wiktionary\]~s", '<a class="blank" href="http://en.wiktionary.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wiktionary for \\1">(WIKTIONARY - \\1)</a>', $str );
return $str;
} | [
"public",
"static",
"function",
"addSearches",
"(",
"$",
"str",
")",
"{",
"### make google searches ###",
"preg_match_all",
"(",
"\"/\\[google\\](.*?)\\[\\/google\\]/s\"",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"$",
"match",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"$",
"data",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"match",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"count",
";",
"$",
"x",
"++",
")",
"{",
"$",
"query",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"+\"",
",",
"$",
"data",
"[",
"$",
"x",
"]",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"'\"'",
",",
"\"%22\"",
",",
"$",
"query",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"$",
"match",
"[",
"$",
"x",
"]",
",",
"'<a class=\"blank\" href=\"http://www.google.com/search?hl=en&ie=UTF-8&q='",
".",
"$",
"query",
".",
"'\" title=\"click to search google for '",
".",
"$",
"data",
"[",
"$",
"x",
"]",
".",
"'\" >(GOOGLE - '",
".",
"$",
"data",
"[",
"$",
"x",
"]",
".",
"')</a>'",
",",
"$",
"str",
")",
";",
"}",
"### make wikipedia searches ###",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[wikipedia\\](.*?)\\[\\/wikipedia\\]~s\"",
",",
"'<a class=\"blank\" href=\"http://en.wikipedia.org/wiki/Special:Search?search='",
".",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"\"\\\\1\"",
")",
".",
"'&go=Go\" title=\"click to search wikipedia for \\\\1\" >(WIKIPEDIA - \\\\1)</a>'",
",",
"$",
"str",
")",
";",
"### make wiktionary searches ###",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[wiktionary\\](.*?)\\[\\/wiktionary\\]~s\"",
",",
"'<a class=\"blank\" href=\"http://en.wiktionary.org/wiki/Special:Search?search='",
".",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"\"\\\\1\"",
")",
".",
"'&go=Go\" title=\"click to search wiktionary for \\\\1\">(WIKTIONARY - \\\\1)</a>'",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Adds search tags to link text to searches both on and off site
@param string $str
@return string | [
"Adds",
"search",
"tags",
"to",
"link",
"text",
"to",
"searches",
"both",
"on",
"and",
"off",
"site"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L292-L315 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.colorizeInstantMessages | public static function colorizeInstantMessages($str)
{
preg_match_all( "/\[im\](.*?)\[\/im\]/s", $str, $matches );
$count = count($matches[1]);
$str = preg_replace("~\[(im|\/im)\]~", "", $str);
for($x=0;$x<$count;$x++){
preg_match_all( "~(.*?: )~", $matches[1][$x], $ims );
$names = array_unique($ims[1]);
$num_names = count($names);
$im=0;
foreach($names as $name){
if ($im%2) {$color="red"; } else {$color="blue";}
$str = str_replace($name, '<b><i><span style="color:'.$color.'">'.$name.'</span></i></b>', $str);
$im++;
}
}
return $str;
} | php | public static function colorizeInstantMessages($str)
{
preg_match_all( "/\[im\](.*?)\[\/im\]/s", $str, $matches );
$count = count($matches[1]);
$str = preg_replace("~\[(im|\/im)\]~", "", $str);
for($x=0;$x<$count;$x++){
preg_match_all( "~(.*?: )~", $matches[1][$x], $ims );
$names = array_unique($ims[1]);
$num_names = count($names);
$im=0;
foreach($names as $name){
if ($im%2) {$color="red"; } else {$color="blue";}
$str = str_replace($name, '<b><i><span style="color:'.$color.'">'.$name.'</span></i></b>', $str);
$im++;
}
}
return $str;
} | [
"public",
"static",
"function",
"colorizeInstantMessages",
"(",
"$",
"str",
")",
"{",
"preg_match_all",
"(",
"\"/\\[im\\](.*?)\\[\\/im\\]/s\"",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[(im|\\/im)\\]~\"",
",",
"\"\"",
",",
"$",
"str",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"count",
";",
"$",
"x",
"++",
")",
"{",
"preg_match_all",
"(",
"\"~(.*?: )~\"",
",",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"x",
"]",
",",
"$",
"ims",
")",
";",
"$",
"names",
"=",
"array_unique",
"(",
"$",
"ims",
"[",
"1",
"]",
")",
";",
"$",
"num_names",
"=",
"count",
"(",
"$",
"names",
")",
";",
"$",
"im",
"=",
"0",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"im",
"%",
"2",
")",
"{",
"$",
"color",
"=",
"\"red\"",
";",
"}",
"else",
"{",
"$",
"color",
"=",
"\"blue\"",
";",
"}",
"$",
"str",
"=",
"str_replace",
"(",
"$",
"name",
",",
"'<b><i><span style=\"color:'",
".",
"$",
"color",
".",
"'\">'",
".",
"$",
"name",
".",
"'</span></i></b>'",
",",
"$",
"str",
")",
";",
"$",
"im",
"++",
";",
"}",
"}",
"return",
"$",
"str",
";",
"}"
] | Colorizes instant message conversation within [im][/im] tags
@param string $str
@return string | [
"Colorizes",
"instant",
"message",
"conversation",
"within",
"[",
"im",
"]",
"[",
"/",
"im",
"]",
"tags"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L323-L348 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.convertQuotes | public static function convertQuotes($str)
{
$r = "/\[q(?:uote)?\](.*?)\[\/q(?:uote)?\]/is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<blockquote class="quote"><p>\\1</p></blockquote>', $str);
}
return $str;
} | php | public static function convertQuotes($str)
{
$r = "/\[q(?:uote)?\](.*?)\[\/q(?:uote)?\]/is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<blockquote class="quote"><p>\\1</p></blockquote>', $str);
}
return $str;
} | [
"public",
"static",
"function",
"convertQuotes",
"(",
"$",
"str",
")",
"{",
"$",
"r",
"=",
"\"/\\[q(?:uote)?\\](.*?)\\[\\/q(?:uote)?\\]/is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<blockquote class=\"quote\"><p>\\\\1</p></blockquote>'",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Converts quotes into quoted text blocks
@param unknown_type $str | [
"Converts",
"quotes",
"into",
"quoted",
"text",
"blocks"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L355-L364 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.stripAll | public static function stripAll($str)
{
$str = stripslashes($str);
$str = strip_tags($str);
$str = \sb\Strings::unicodeUrldecode($str);
$str = self::stripBling($str);
$str = \sb\Strings::stripMicrosoftChars($str);
return $str;
} | php | public static function stripAll($str)
{
$str = stripslashes($str);
$str = strip_tags($str);
$str = \sb\Strings::unicodeUrldecode($str);
$str = self::stripBling($str);
$str = \sb\Strings::stripMicrosoftChars($str);
return $str;
} | [
"public",
"static",
"function",
"stripAll",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"stripslashes",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"strip_tags",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"\\",
"sb",
"\\",
"Strings",
"::",
"unicodeUrldecode",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"stripBling",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"\\",
"sb",
"\\",
"Strings",
"::",
"stripMicrosoftChars",
"(",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Strips everything including textBlng tags, this is useful for RSS feed and text summaries in search results
@param string $str
@return string | [
"Strips",
"everything",
"including",
"textBlng",
"tags",
"this",
"is",
"useful",
"for",
"RSS",
"feed",
"and",
"text",
"summaries",
"in",
"search",
"results"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L383-L391 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.typoFix | public static function typoFix($str)
{
//mistakes
$common_typos = array(
"adn"=>"and",
"agian"=>"again",
"ahve"=>"have",
"ahd"=>"had",
"alot"=>"a lot",
"amke"=>"make",
"arent"=>"aren't",
"beleif"=>"belief",
"beleive"=>"believe",
"broswer"=>"browser",
"cant"=>"can't",
"cheif"=>"chief",
"couldnt"=>"couldn't",
"comming"=>"coming",
"didnt"=>"didn't",
"doesnt"=>"doesn't",
"dont"=>"don't",
"ehr"=>"her",
"esle"=>"else",
"eyt"=>"yet",
"feild"=>"field",
"goign"=>"going",
"hadnt"=>"hadn't",
"hasnt"=>"hasn't",
"hda"=>"had",
"hed"=>"he'd",
"hel"=>"he'll",
"heres"=>"here's",
"hes"=>"he's",
"hows"=>"how's",
"hsa"=>"has",
"hte"=>"the",
"htere"=>"there",
"i'll"=>"I'll",
"infromation"=>"information",
"i'm"=>"I'm",
"isnt"=>"isn't",
"itll"=>"it'll",
"itsa"=>"its a",
"ive"=>"I've",
"mkae"=>"make",
"peice"=>"piece",
"seh"=>"she",
"shouldnt"=>"shouldn't",
"shouldve"=>"should've",
"shoudl"=>"should",
"somethign"=>"something",
"taht"=>"that",
"tahn"=>"than",
"Teh"=>"The",
"teh"=>"the",
"taht"=>"that",
"thier"=>"their",
"weve"=>"we've",
"workign"=>"working"
);
foreach($common_typos as $typo=>$correction){
$str = preg_replace("~\b".$typo."\b~", $correction, $str);
}
//fix ; fragments
$str = str_replace("n;t", "n't", $str);
return $str;
} | php | public static function typoFix($str)
{
//mistakes
$common_typos = array(
"adn"=>"and",
"agian"=>"again",
"ahve"=>"have",
"ahd"=>"had",
"alot"=>"a lot",
"amke"=>"make",
"arent"=>"aren't",
"beleif"=>"belief",
"beleive"=>"believe",
"broswer"=>"browser",
"cant"=>"can't",
"cheif"=>"chief",
"couldnt"=>"couldn't",
"comming"=>"coming",
"didnt"=>"didn't",
"doesnt"=>"doesn't",
"dont"=>"don't",
"ehr"=>"her",
"esle"=>"else",
"eyt"=>"yet",
"feild"=>"field",
"goign"=>"going",
"hadnt"=>"hadn't",
"hasnt"=>"hasn't",
"hda"=>"had",
"hed"=>"he'd",
"hel"=>"he'll",
"heres"=>"here's",
"hes"=>"he's",
"hows"=>"how's",
"hsa"=>"has",
"hte"=>"the",
"htere"=>"there",
"i'll"=>"I'll",
"infromation"=>"information",
"i'm"=>"I'm",
"isnt"=>"isn't",
"itll"=>"it'll",
"itsa"=>"its a",
"ive"=>"I've",
"mkae"=>"make",
"peice"=>"piece",
"seh"=>"she",
"shouldnt"=>"shouldn't",
"shouldve"=>"should've",
"shoudl"=>"should",
"somethign"=>"something",
"taht"=>"that",
"tahn"=>"than",
"Teh"=>"The",
"teh"=>"the",
"taht"=>"that",
"thier"=>"their",
"weve"=>"we've",
"workign"=>"working"
);
foreach($common_typos as $typo=>$correction){
$str = preg_replace("~\b".$typo."\b~", $correction, $str);
}
//fix ; fragments
$str = str_replace("n;t", "n't", $str);
return $str;
} | [
"public",
"static",
"function",
"typoFix",
"(",
"$",
"str",
")",
"{",
"//mistakes",
"$",
"common_typos",
"=",
"array",
"(",
"\"adn\"",
"=>",
"\"and\"",
",",
"\"agian\"",
"=>",
"\"again\"",
",",
"\"ahve\"",
"=>",
"\"have\"",
",",
"\"ahd\"",
"=>",
"\"had\"",
",",
"\"alot\"",
"=>",
"\"a lot\"",
",",
"\"amke\"",
"=>",
"\"make\"",
",",
"\"arent\"",
"=>",
"\"aren't\"",
",",
"\"beleif\"",
"=>",
"\"belief\"",
",",
"\"beleive\"",
"=>",
"\"believe\"",
",",
"\"broswer\"",
"=>",
"\"browser\"",
",",
"\"cant\"",
"=>",
"\"can't\"",
",",
"\"cheif\"",
"=>",
"\"chief\"",
",",
"\"couldnt\"",
"=>",
"\"couldn't\"",
",",
"\"comming\"",
"=>",
"\"coming\"",
",",
"\"didnt\"",
"=>",
"\"didn't\"",
",",
"\"doesnt\"",
"=>",
"\"doesn't\"",
",",
"\"dont\"",
"=>",
"\"don't\"",
",",
"\"ehr\"",
"=>",
"\"her\"",
",",
"\"esle\"",
"=>",
"\"else\"",
",",
"\"eyt\"",
"=>",
"\"yet\"",
",",
"\"feild\"",
"=>",
"\"field\"",
",",
"\"goign\"",
"=>",
"\"going\"",
",",
"\"hadnt\"",
"=>",
"\"hadn't\"",
",",
"\"hasnt\"",
"=>",
"\"hasn't\"",
",",
"\"hda\"",
"=>",
"\"had\"",
",",
"\"hed\"",
"=>",
"\"he'd\"",
",",
"\"hel\"",
"=>",
"\"he'll\"",
",",
"\"heres\"",
"=>",
"\"here's\"",
",",
"\"hes\"",
"=>",
"\"he's\"",
",",
"\"hows\"",
"=>",
"\"how's\"",
",",
"\"hsa\"",
"=>",
"\"has\"",
",",
"\"hte\"",
"=>",
"\"the\"",
",",
"\"htere\"",
"=>",
"\"there\"",
",",
"\"i'll\"",
"=>",
"\"I'll\"",
",",
"\"infromation\"",
"=>",
"\"information\"",
",",
"\"i'm\"",
"=>",
"\"I'm\"",
",",
"\"isnt\"",
"=>",
"\"isn't\"",
",",
"\"itll\"",
"=>",
"\"it'll\"",
",",
"\"itsa\"",
"=>",
"\"its a\"",
",",
"\"ive\"",
"=>",
"\"I've\"",
",",
"\"mkae\"",
"=>",
"\"make\"",
",",
"\"peice\"",
"=>",
"\"piece\"",
",",
"\"seh\"",
"=>",
"\"she\"",
",",
"\"shouldnt\"",
"=>",
"\"shouldn't\"",
",",
"\"shouldve\"",
"=>",
"\"should've\"",
",",
"\"shoudl\"",
"=>",
"\"should\"",
",",
"\"somethign\"",
"=>",
"\"something\"",
",",
"\"taht\"",
"=>",
"\"that\"",
",",
"\"tahn\"",
"=>",
"\"than\"",
",",
"\"Teh\"",
"=>",
"\"The\"",
",",
"\"teh\"",
"=>",
"\"the\"",
",",
"\"taht\"",
"=>",
"\"that\"",
",",
"\"thier\"",
"=>",
"\"their\"",
",",
"\"weve\"",
"=>",
"\"we've\"",
",",
"\"workign\"",
"=>",
"\"working\"",
")",
";",
"foreach",
"(",
"$",
"common_typos",
"as",
"$",
"typo",
"=>",
"$",
"correction",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\b\"",
".",
"$",
"typo",
".",
"\"\\b~\"",
",",
"$",
"correction",
",",
"$",
"str",
")",
";",
"}",
"//fix ; fragments",
"$",
"str",
"=",
"str_replace",
"(",
"\"n;t\"",
",",
"\"n't\"",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Fixed common typos, can be used directly as it is a static property
<code>
textBling::typoFix('Teh bird cant fly');
//returns 'The bird can't fly'
</code>
@param the text to be cleaned $str
@return string | [
"Fixed",
"common",
"typos",
"can",
"be",
"used",
"directly",
"as",
"it",
"is",
"a",
"static",
"property"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L405-L479 |
surebert/surebert-framework | src/sb/Text/Bling.php | Bling.textStyles | public static function textStyles($str)
{
##bold
$str = preg_replace("~\[b\](.*?)\[/b\]~is", '<strong class="tb_b">$1</strong>', $str);
##sup
$str = preg_replace("~\[sup\](.*?)\[/sup\]~is", '<sup class="tb_sup">$1</sup>', $str);
##sub
$str = preg_replace("~\[sub\](.*?)\[/sub\]~is", '<sub class="tb_sub">$1</sub>', $str);
##italic
$str = preg_replace("~\[i\](.*?)\[/i\]~is", '<em class="tb_i">$1</em>', $str);
##underline
$str = preg_replace("~\[u\](.*?)\[/u\]~is", '<u class="tb_u">$1</u>', $str);
##cite
$str = preg_replace("~\[cite\](.*?)\[/cite\]~is", '<cite class="tb_cite">$1</cite>', $str);
##hilite
$str = preg_replace("~\[h(?:ilite)?\](.*?)\[/h(?:ilite)?\]~is", '<span class="tb_hilite">$1</span>', $str);
##line-though
$str = preg_replace("~\[strike](.*?)\[/strike]~is", '<del class="tb_strike">$1</del>', $str);
## add small caps
$str = preg_replace("~\[caps](.*?)\[/caps]~is", '<span class="tb_caps">$1</span>', $str);
## add center
$str = preg_replace("~\[center](.*?)\[/center]~is", '<center class="tb_center">$1</center>', $str);
## add code tag
## add small caps
$str = preg_replace("~\[code](.*?)\[/code]~is", '<pre style="background-color:black;color:green;overflow:auto;">$1</pre>', $str);
## font size
$r = "~\[size=([\d(?:\.\d+)]+(?:em|px)?)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font size
$r = "~\[size=(small|medium|large)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font color
$r = "~\[color=(.*?)\](.*?)\[\/color\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="color:\\1;">\\2</span>', $str);
}
return $str;
} | php | public static function textStyles($str)
{
##bold
$str = preg_replace("~\[b\](.*?)\[/b\]~is", '<strong class="tb_b">$1</strong>', $str);
##sup
$str = preg_replace("~\[sup\](.*?)\[/sup\]~is", '<sup class="tb_sup">$1</sup>', $str);
##sub
$str = preg_replace("~\[sub\](.*?)\[/sub\]~is", '<sub class="tb_sub">$1</sub>', $str);
##italic
$str = preg_replace("~\[i\](.*?)\[/i\]~is", '<em class="tb_i">$1</em>', $str);
##underline
$str = preg_replace("~\[u\](.*?)\[/u\]~is", '<u class="tb_u">$1</u>', $str);
##cite
$str = preg_replace("~\[cite\](.*?)\[/cite\]~is", '<cite class="tb_cite">$1</cite>', $str);
##hilite
$str = preg_replace("~\[h(?:ilite)?\](.*?)\[/h(?:ilite)?\]~is", '<span class="tb_hilite">$1</span>', $str);
##line-though
$str = preg_replace("~\[strike](.*?)\[/strike]~is", '<del class="tb_strike">$1</del>', $str);
## add small caps
$str = preg_replace("~\[caps](.*?)\[/caps]~is", '<span class="tb_caps">$1</span>', $str);
## add center
$str = preg_replace("~\[center](.*?)\[/center]~is", '<center class="tb_center">$1</center>', $str);
## add code tag
## add small caps
$str = preg_replace("~\[code](.*?)\[/code]~is", '<pre style="background-color:black;color:green;overflow:auto;">$1</pre>', $str);
## font size
$r = "~\[size=([\d(?:\.\d+)]+(?:em|px)?)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font size
$r = "~\[size=(small|medium|large)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font color
$r = "~\[color=(.*?)\](.*?)\[\/color\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="color:\\1;">\\2</span>', $str);
}
return $str;
} | [
"public",
"static",
"function",
"textStyles",
"(",
"$",
"str",
")",
"{",
"##bold",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[b\\](.*?)\\[/b\\]~is\"",
",",
"'<strong class=\"tb_b\">$1</strong>'",
",",
"$",
"str",
")",
";",
"##sup",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[sup\\](.*?)\\[/sup\\]~is\"",
",",
"'<sup class=\"tb_sup\">$1</sup>'",
",",
"$",
"str",
")",
";",
"##sub",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[sub\\](.*?)\\[/sub\\]~is\"",
",",
"'<sub class=\"tb_sub\">$1</sub>'",
",",
"$",
"str",
")",
";",
"##italic",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[i\\](.*?)\\[/i\\]~is\"",
",",
"'<em class=\"tb_i\">$1</em>'",
",",
"$",
"str",
")",
";",
"##underline",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[u\\](.*?)\\[/u\\]~is\"",
",",
"'<u class=\"tb_u\">$1</u>'",
",",
"$",
"str",
")",
";",
"##cite",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[cite\\](.*?)\\[/cite\\]~is\"",
",",
"'<cite class=\"tb_cite\">$1</cite>'",
",",
"$",
"str",
")",
";",
"##hilite",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[h(?:ilite)?\\](.*?)\\[/h(?:ilite)?\\]~is\"",
",",
"'<span class=\"tb_hilite\">$1</span>'",
",",
"$",
"str",
")",
";",
"##line-though",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[strike](.*?)\\[/strike]~is\"",
",",
"'<del class=\"tb_strike\">$1</del>'",
",",
"$",
"str",
")",
";",
"## add small caps",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[caps](.*?)\\[/caps]~is\"",
",",
"'<span class=\"tb_caps\">$1</span>'",
",",
"$",
"str",
")",
";",
"## add center",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[center](.*?)\\[/center]~is\"",
",",
"'<center class=\"tb_center\">$1</center>'",
",",
"$",
"str",
")",
";",
"## add code tag",
"## add small caps",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[code](.*?)\\[/code]~is\"",
",",
"'<pre style=\"background-color:black;color:green;overflow:auto;\">$1</pre>'",
",",
"$",
"str",
")",
";",
"## font size",
"$",
"r",
"=",
"\"~\\[size=([\\d(?:\\.\\d+)]+(?:em|px)?)\\](.*?)\\[\\/size\\]~is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<span style=\"font-size:\\\\1;\">\\\\2</span>'",
",",
"$",
"str",
")",
";",
"}",
"## font size",
"$",
"r",
"=",
"\"~\\[size=(small|medium|large)\\](.*?)\\[\\/size\\]~is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<span style=\"font-size:\\\\1;\">\\\\2</span>'",
",",
"$",
"str",
")",
";",
"}",
"## font color",
"$",
"r",
"=",
"\"~\\[color=(.*?)\\](.*?)\\[\\/color\\]~is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<span style=\"color:\\\\1;\">\\\\2</span>'",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Converts text style tags
@param string $str
@return string $str; | [
"Converts",
"text",
"style",
"tags"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L487-L543 |
Erdiko/core | src/Theme.php | Theme.getContextConfig | public function getContextConfig()
{
if (empty($this->_contextConfig))
$this->_contextConfig = Helper::getConfig('application', $this->_context);
return $this->_contextConfig;
} | php | public function getContextConfig()
{
if (empty($this->_contextConfig))
$this->_contextConfig = Helper::getConfig('application', $this->_context);
return $this->_contextConfig;
} | [
"public",
"function",
"getContextConfig",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_contextConfig",
")",
")",
"$",
"this",
"->",
"_contextConfig",
"=",
"Helper",
"::",
"getConfig",
"(",
"'application'",
",",
"$",
"this",
"->",
"_context",
")",
";",
"return",
"$",
"this",
"->",
"_contextConfig",
";",
"}"
] | Get context config
This is the application config for the given context (e.g. default site)
Context is determined by environment variable ERDIKO_CONTEXT, getenv('ERDIKO_CONTEXT')
@return array $config application config | [
"Get",
"context",
"config",
"This",
"is",
"the",
"application",
"config",
"for",
"the",
"given",
"context",
"(",
"e",
".",
"g",
".",
"default",
"site",
")",
"Context",
"is",
"determined",
"by",
"environment",
"variable",
"ERDIKO_CONTEXT",
"getenv",
"(",
"ERDIKO_CONTEXT",
")"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L61-L67 |
Erdiko/core | src/Theme.php | Theme.getThemeConfig | public function getThemeConfig()
{
if (empty($this->_themeConfig)) {
$file = $this->getThemeFolder() . 'theme.json';
$this->_themeConfig = Helper::getConfigFile($file);
}
return $this->_themeConfig;
} | php | public function getThemeConfig()
{
if (empty($this->_themeConfig)) {
$file = $this->getThemeFolder() . 'theme.json';
$this->_themeConfig = Helper::getConfigFile($file);
}
return $this->_themeConfig;
} | [
"public",
"function",
"getThemeConfig",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_themeConfig",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getThemeFolder",
"(",
")",
".",
"'theme.json'",
";",
"$",
"this",
"->",
"_themeConfig",
"=",
"Helper",
"::",
"getConfigFile",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_themeConfig",
";",
"}"
] | Get Theme configuration (default theme)
@return array $config | [
"Get",
"Theme",
"configuration",
"(",
"default",
"theme",
")"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L74-L81 |
Erdiko/core | src/Theme.php | Theme.getMeta | public function getMeta()
{
if (isset($this->_contextConfig['site']['meta'])) {
return array_merge($this->_contextConfig['site']['meta'],$this->_data['meta']);
} else {
return $this->_data['meta'];
}
} | php | public function getMeta()
{
if (isset($this->_contextConfig['site']['meta'])) {
return array_merge($this->_contextConfig['site']['meta'],$this->_data['meta']);
} else {
return $this->_data['meta'];
}
} | [
"public",
"function",
"getMeta",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_contextConfig",
"[",
"'site'",
"]",
"[",
"'meta'",
"]",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"_contextConfig",
"[",
"'site'",
"]",
"[",
"'meta'",
"]",
",",
"$",
"this",
"->",
"_data",
"[",
"'meta'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"'meta'",
"]",
";",
"}",
"}"
] | Get Meta
@return string $meta | [
"Get",
"Meta"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L88-L95 |
Erdiko/core | src/Theme.php | Theme.getMetaMarkup | public function getMetaMarkup()
{
$html = "";
foreach ($this->getMeta() as $name => $content)
{
if(is_array($content)) {
foreach($content as $cont)
$html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n";
} else {
$html .= "<meta name=\"{$name}\" content=\"{$content}\">\n";
}
}
return $html;
} | php | public function getMetaMarkup()
{
$html = "";
foreach ($this->getMeta() as $name => $content)
{
if(is_array($content)) {
foreach($content as $cont)
$html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n";
} else {
$html .= "<meta name=\"{$name}\" content=\"{$content}\">\n";
}
}
return $html;
} | [
"public",
"function",
"getMetaMarkup",
"(",
")",
"{",
"$",
"html",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"getMeta",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"foreach",
"(",
"$",
"content",
"as",
"$",
"cont",
")",
"$",
"html",
".=",
"\"<meta name=\\\"{$name}\\\" content=\\\"{$cont}\\\">\\n\"",
";",
"}",
"else",
"{",
"$",
"html",
".=",
"\"<meta name=\\\"{$name}\\\" content=\\\"{$content}\\\">\\n\"",
";",
"}",
"}",
"return",
"$",
"html",
";",
"}"
] | Get SEO meta data and render as html (meta tags)
@return string html meta tags | [
"Get",
"SEO",
"meta",
"data",
"and",
"render",
"as",
"html",
"(",
"meta",
"tags",
")"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L122-L137 |
Erdiko/core | src/Theme.php | Theme.getCss | public function getCss()
{
if (isset($this->_themeConfig['css'])) {
return array_merge($this->_themeConfig['css'], $this->_data['css']);
} else {
return $this->_data['css'];
}
} | php | public function getCss()
{
if (isset($this->_themeConfig['css'])) {
return array_merge($this->_themeConfig['css'], $this->_data['css']);
} else {
return $this->_data['css'];
}
} | [
"public",
"function",
"getCss",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'css'",
"]",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'css'",
"]",
",",
"$",
"this",
"->",
"_data",
"[",
"'css'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"'css'",
"]",
";",
"}",
"}"
] | Get array of css files to include in theme
@return array css file paths
@todo sort by the 'order' value | [
"Get",
"array",
"of",
"css",
"files",
"to",
"include",
"in",
"theme"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L193-L200 |
Erdiko/core | src/Theme.php | Theme.addCss | public function addCss($name, $cssFile, $order = 10, $active = 1)
{
$this->_data['css'][$name] = array(
'file' => $cssFile,
'order' => $order,
'active' => $active
);
} | php | public function addCss($name, $cssFile, $order = 10, $active = 1)
{
$this->_data['css'][$name] = array(
'file' => $cssFile,
'order' => $order,
'active' => $active
);
} | [
"public",
"function",
"addCss",
"(",
"$",
"name",
",",
"$",
"cssFile",
",",
"$",
"order",
"=",
"10",
",",
"$",
"active",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"'css'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'file'",
"=>",
"$",
"cssFile",
",",
"'order'",
"=>",
"$",
"order",
",",
"'active'",
"=>",
"$",
"active",
")",
";",
"}"
] | Add css file to page
@note there are collisions with using addCss and data['css']
@param string $name
@param string $cssFile URL of injected css file
@param int $order
@param boolean $active defaults to 1
@todo need to resolve order of merging and/or eliminate/refactor this function | [
"Add",
"css",
"file",
"to",
"page",
"@note",
"there",
"are",
"collisions",
"with",
"using",
"addCss",
"and",
"data",
"[",
"css",
"]"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L212-L219 |
Erdiko/core | src/Theme.php | Theme.getJs | public function getJs()
{
if (isset($this->_themeConfig['js'])) {
return array_merge($this->_themeConfig['js'], $this->_data['js']);
} else {
return $this->_data['js'];
}
} | php | public function getJs()
{
if (isset($this->_themeConfig['js'])) {
return array_merge($this->_themeConfig['js'], $this->_data['js']);
} else {
return $this->_data['js'];
}
} | [
"public",
"function",
"getJs",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'js'",
"]",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'js'",
"]",
",",
"$",
"this",
"->",
"_data",
"[",
"'js'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"'js'",
"]",
";",
"}",
"}"
] | Get array of js files to include
@return array js file paths
@todo sort by the 'order' value | [
"Get",
"array",
"of",
"js",
"files",
"to",
"include"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L227-L234 |
Erdiko/core | src/Theme.php | Theme.addJs | public function addJs($name, $jsFile, $order = 10, $active = 1)
{
$this->_data['js'][$name] = array(
'file' => $jsFile,
'order' => $order,
'active' => $active
);
} | php | public function addJs($name, $jsFile, $order = 10, $active = 1)
{
$this->_data['js'][$name] = array(
'file' => $jsFile,
'order' => $order,
'active' => $active
);
} | [
"public",
"function",
"addJs",
"(",
"$",
"name",
",",
"$",
"jsFile",
",",
"$",
"order",
"=",
"10",
",",
"$",
"active",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"'js'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'file'",
"=>",
"$",
"jsFile",
",",
"'order'",
"=>",
"$",
"order",
",",
"'active'",
"=>",
"$",
"active",
")",
";",
"}"
] | Add js file to page
@param string $name
@param string $jsFile URL of js file
@param int $order
@param boolean $active defaults to 1
@todo same issue as addCss | [
"Add",
"js",
"file",
"to",
"page"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L245-L252 |
Erdiko/core | src/Theme.php | Theme.getTemplateHtml | public function getTemplateHtml($partial)
{
$config = $this->getThemeConfig();
// @todo add check here to make sure partial exists, if missing log error
$filename = $this->getTemplateFolder().$config['templates'][$partial]['file'];
$html = $this->getTemplateFile($filename, $this->getContextConfig());
return $html;
} | php | public function getTemplateHtml($partial)
{
$config = $this->getThemeConfig();
// @todo add check here to make sure partial exists, if missing log error
$filename = $this->getTemplateFolder().$config['templates'][$partial]['file'];
$html = $this->getTemplateFile($filename, $this->getContextConfig());
return $html;
} | [
"public",
"function",
"getTemplateHtml",
"(",
"$",
"partial",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getThemeConfig",
"(",
")",
";",
"// @todo add check here to make sure partial exists, if missing log error",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTemplateFolder",
"(",
")",
".",
"$",
"config",
"[",
"'templates'",
"]",
"[",
"$",
"partial",
"]",
"[",
"'file'",
"]",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getTemplateFile",
"(",
"$",
"filename",
",",
"$",
"this",
"->",
"getContextConfig",
"(",
")",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Get template file populated by the config
@usage Partial render need to be declared in theme.json
e.g. get header/footer
@param string $partial
@return string html | [
"Get",
"template",
"file",
"populated",
"by",
"the",
"config"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L344-L353 |
Erdiko/core | src/Theme.php | Theme.toHtml | public function toHtml()
{
// load the theme and context (site) configs
$this->getContextConfig();
$this->getThemeConfig();
$filename = $this->getTemplateFolder().$this->getTemplate();
$html = $this->getTemplateFile($filename, $this);
return $html;
} | php | public function toHtml()
{
// load the theme and context (site) configs
$this->getContextConfig();
$this->getThemeConfig();
$filename = $this->getTemplateFolder().$this->getTemplate();
$html = $this->getTemplateFile($filename, $this);
return $html;
} | [
"public",
"function",
"toHtml",
"(",
")",
"{",
"// load the theme and context (site) configs",
"$",
"this",
"->",
"getContextConfig",
"(",
")",
";",
"$",
"this",
"->",
"getThemeConfig",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTemplateFolder",
"(",
")",
".",
"$",
"this",
"->",
"getTemplate",
"(",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getTemplateFile",
"(",
"$",
"filename",
",",
"$",
"this",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Output content to html
@return string html | [
"Output",
"content",
"to",
"html"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L360-L370 |
derhasi/buddy | src/CommandShortcut.php | CommandShortcut.execute | public function execute($arguments)
{
// Validate on given command.
if (!isset($this->options['cmd'])) {
throw new \Exception(sprintf('No command given for "%s"', $this->name));
exit(1);
}
// If a explicit working directory is specifified, we change to that to call
// the command.
$workingDir = $this->getWorkingDir();
if (isset($workingDir)) {
chdir($workingDir);
}
// Execute the command.
$status = NULL;
$cmd = $this->options['cmd'];
// If a explicit command dir is given, we use an absolute path to the command.
$cmdDir = $this->getCmdDir();
if (isset($cmdDir)) {
$cmd = $cmdDir . '/' . $cmd;
}
$cmd = escapeshellcmd($cmd);
// Add passed arguments to the command.
foreach ($arguments as $arg) {
$cmd .= ' ' . escapeshellarg($arg);
}
passthru($cmd, $status);
exit($status);
} | php | public function execute($arguments)
{
// Validate on given command.
if (!isset($this->options['cmd'])) {
throw new \Exception(sprintf('No command given for "%s"', $this->name));
exit(1);
}
// If a explicit working directory is specifified, we change to that to call
// the command.
$workingDir = $this->getWorkingDir();
if (isset($workingDir)) {
chdir($workingDir);
}
// Execute the command.
$status = NULL;
$cmd = $this->options['cmd'];
// If a explicit command dir is given, we use an absolute path to the command.
$cmdDir = $this->getCmdDir();
if (isset($cmdDir)) {
$cmd = $cmdDir . '/' . $cmd;
}
$cmd = escapeshellcmd($cmd);
// Add passed arguments to the command.
foreach ($arguments as $arg) {
$cmd .= ' ' . escapeshellarg($arg);
}
passthru($cmd, $status);
exit($status);
} | [
"public",
"function",
"execute",
"(",
"$",
"arguments",
")",
"{",
"// Validate on given command.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'cmd'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'No command given for \"%s\"'",
",",
"$",
"this",
"->",
"name",
")",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"// If a explicit working directory is specifified, we change to that to call",
"// the command.",
"$",
"workingDir",
"=",
"$",
"this",
"->",
"getWorkingDir",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"workingDir",
")",
")",
"{",
"chdir",
"(",
"$",
"workingDir",
")",
";",
"}",
"// Execute the command.",
"$",
"status",
"=",
"NULL",
";",
"$",
"cmd",
"=",
"$",
"this",
"->",
"options",
"[",
"'cmd'",
"]",
";",
"// If a explicit command dir is given, we use an absolute path to the command.",
"$",
"cmdDir",
"=",
"$",
"this",
"->",
"getCmdDir",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"cmdDir",
")",
")",
"{",
"$",
"cmd",
"=",
"$",
"cmdDir",
".",
"'/'",
".",
"$",
"cmd",
";",
"}",
"$",
"cmd",
"=",
"escapeshellcmd",
"(",
"$",
"cmd",
")",
";",
"// Add passed arguments to the command.",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"arg",
")",
"{",
"$",
"cmd",
".=",
"' '",
".",
"escapeshellarg",
"(",
"$",
"arg",
")",
";",
"}",
"passthru",
"(",
"$",
"cmd",
",",
"$",
"status",
")",
";",
"exit",
"(",
"$",
"status",
")",
";",
"}"
] | Runs the given command.
@param array $arguments
Array of arguments and options to pass to the command.
@throws \Exception | [
"Runs",
"the",
"given",
"command",
"."
] | train | https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/CommandShortcut.php#L53-L85 |
derhasi/buddy | src/CommandShortcut.php | CommandShortcut.processDir | protected function processDir($dir) {
$dir = $this->replacePattern($dir);
// The absolute path has to be calculated relative to the configuration file
if (Path::isRelative($dir)) {
$dir = Path::makeAbsolute($dir, dirname($this->configFile));
}
return rtrim($dir, '/');
} | php | protected function processDir($dir) {
$dir = $this->replacePattern($dir);
// The absolute path has to be calculated relative to the configuration file
if (Path::isRelative($dir)) {
$dir = Path::makeAbsolute($dir, dirname($this->configFile));
}
return rtrim($dir, '/');
} | [
"protected",
"function",
"processDir",
"(",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"replacePattern",
"(",
"$",
"dir",
")",
";",
"// The absolute path has to be calculated relative to the configuration file",
"if",
"(",
"Path",
"::",
"isRelative",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"dir",
"=",
"Path",
"::",
"makeAbsolute",
"(",
"$",
"dir",
",",
"dirname",
"(",
"$",
"this",
"->",
"configFile",
")",
")",
";",
"}",
"return",
"rtrim",
"(",
"$",
"dir",
",",
"'/'",
")",
";",
"}"
] | Process given dir with replacements and makes it absolute.
@param string $dir
@return string
Absolute path with placeholders replaced. | [
"Process",
"given",
"dir",
"with",
"replacements",
"and",
"makes",
"it",
"absolute",
"."
] | train | https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/CommandShortcut.php#L117-L124 |
derhasi/buddy | src/CommandShortcut.php | CommandShortcut.replacePattern | protected function replacePattern($pattern) {
$replace = array(
'$DIR' => dirname($this->configFile),
'$CWD' => getcwd(),
);
return str_replace(array_keys($replace), array_values($replace), $pattern);
} | php | protected function replacePattern($pattern) {
$replace = array(
'$DIR' => dirname($this->configFile),
'$CWD' => getcwd(),
);
return str_replace(array_keys($replace), array_values($replace), $pattern);
} | [
"protected",
"function",
"replacePattern",
"(",
"$",
"pattern",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
"'$DIR'",
"=>",
"dirname",
"(",
"$",
"this",
"->",
"configFile",
")",
",",
"'$CWD'",
"=>",
"getcwd",
"(",
")",
",",
")",
";",
"return",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replace",
")",
",",
"array_values",
"(",
"$",
"replace",
")",
",",
"$",
"pattern",
")",
";",
"}"
] | Helper to replace certain patterns with actual values.
@param string $pattern
Pattern to be replaced
@return string | [
"Helper",
"to",
"replace",
"certain",
"patterns",
"with",
"actual",
"values",
"."
] | train | https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/CommandShortcut.php#L135-L141 |
xiewulong/yii2-fileupload | Manager.php | Manager.finalFile | public function finalFile($file, $type = 'images') {
return isset($this->oss[$type]) ? $this->putFileToOss($file['name'], $file['tmp'], $type) : $file['src'];
} | php | public function finalFile($file, $type = 'images') {
return isset($this->oss[$type]) ? $this->putFileToOss($file['name'], $file['tmp'], $type) : $file['src'];
} | [
"public",
"function",
"finalFile",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"'images'",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"oss",
"[",
"$",
"type",
"]",
")",
"?",
"$",
"this",
"->",
"putFileToOss",
"(",
"$",
"file",
"[",
"'name'",
"]",
",",
"$",
"file",
"[",
"'tmp'",
"]",
",",
"$",
"type",
")",
":",
"$",
"file",
"[",
"'src'",
"]",
";",
"}"
] | 获取最终文件路径
@method putFileToOss
@since 0.0.1
@param {array} $file 文件信息
@param {string} [$type=images] bucket别名
@return {string}
@example \Yii::$app->fileupload->finalFile($file, $type); | [
"获取最终文件路径"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L64-L66 |
xiewulong/yii2-fileupload | Manager.php | Manager.putFileToOss | public function putFileToOss($key, $file, $type = 'images') {
$src = null;
if(isset($this->oss[$type])) {
OSSClient::factory($this->oss['config'])->putObject([
'Bucket' => $this->oss[$type]['Bucket'],
'Key' => $key,
'Content' => fopen($file, 'r'),
'ContentLength' => filesize($file),
]);
$src = $this->oss[$type]['src'] . DIRECTORY_SEPARATOR . $key;
unlink($file);
}
return $src;
} | php | public function putFileToOss($key, $file, $type = 'images') {
$src = null;
if(isset($this->oss[$type])) {
OSSClient::factory($this->oss['config'])->putObject([
'Bucket' => $this->oss[$type]['Bucket'],
'Key' => $key,
'Content' => fopen($file, 'r'),
'ContentLength' => filesize($file),
]);
$src = $this->oss[$type]['src'] . DIRECTORY_SEPARATOR . $key;
unlink($file);
}
return $src;
} | [
"public",
"function",
"putFileToOss",
"(",
"$",
"key",
",",
"$",
"file",
",",
"$",
"type",
"=",
"'images'",
")",
"{",
"$",
"src",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"oss",
"[",
"$",
"type",
"]",
")",
")",
"{",
"OSSClient",
"::",
"factory",
"(",
"$",
"this",
"->",
"oss",
"[",
"'config'",
"]",
")",
"->",
"putObject",
"(",
"[",
"'Bucket'",
"=>",
"$",
"this",
"->",
"oss",
"[",
"$",
"type",
"]",
"[",
"'Bucket'",
"]",
",",
"'Key'",
"=>",
"$",
"key",
",",
"'Content'",
"=>",
"fopen",
"(",
"$",
"file",
",",
"'r'",
")",
",",
"'ContentLength'",
"=>",
"filesize",
"(",
"$",
"file",
")",
",",
"]",
")",
";",
"$",
"src",
"=",
"$",
"this",
"->",
"oss",
"[",
"$",
"type",
"]",
"[",
"'src'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"key",
";",
"unlink",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"src",
";",
"}"
] | 上传至oss
@method putFileToOss
@since 0.0.1
@param {string} $key 文件名(包括存储路径)
@param {string} $file 文件本地路径
@param {string} [$type=images] bucket别名
@return {string|boolean}
@example \Yii::$app->fileupload->putFileToOss($key, $file, $type); | [
"上传至oss"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L78-L92 |
xiewulong/yii2-fileupload | Manager.php | Manager.addSuf | public function addSuf($file, $suf) {
if(is_array($suf)) {
$suf = implode('_', $suf);
}
if(!empty($file)) {
if(is_array($file)) {
foreach($file as $type => $path) {
$file[$type] = $this->createSuf($path, $suf);
}
} else {
$file = $this->createSuf($file, $suf);
}
}
return $file;
} | php | public function addSuf($file, $suf) {
if(is_array($suf)) {
$suf = implode('_', $suf);
}
if(!empty($file)) {
if(is_array($file)) {
foreach($file as $type => $path) {
$file[$type] = $this->createSuf($path, $suf);
}
} else {
$file = $this->createSuf($file, $suf);
}
}
return $file;
} | [
"public",
"function",
"addSuf",
"(",
"$",
"file",
",",
"$",
"suf",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"suf",
")",
")",
"{",
"$",
"suf",
"=",
"implode",
"(",
"'_'",
",",
"$",
"suf",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"file",
")",
")",
"{",
"foreach",
"(",
"$",
"file",
"as",
"$",
"type",
"=>",
"$",
"path",
")",
"{",
"$",
"file",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"createSuf",
"(",
"$",
"path",
",",
"$",
"suf",
")",
";",
"}",
"}",
"else",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"createSuf",
"(",
"$",
"file",
",",
"$",
"suf",
")",
";",
"}",
"}",
"return",
"$",
"file",
";",
"}"
] | 添加后缀
@method addSuf
@since 0.0.1
@param {string|array} $file 文件名
@param {string|array} $size 尺寸
@return {array}
@example \Yii::$app->fileupload->addSuf($file, $suf); | [
"添加后缀"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L103-L118 |
xiewulong/yii2-fileupload | Manager.php | Manager.createSuf | private function createSuf($path, $suf) {
$path = explode('.', $path);
$ext = array_pop($path);
$path[count($path) - 1] .= '_' . $suf;
$path[] = $ext;
return implode('.', $path);
} | php | private function createSuf($path, $suf) {
$path = explode('.', $path);
$ext = array_pop($path);
$path[count($path) - 1] .= '_' . $suf;
$path[] = $ext;
return implode('.', $path);
} | [
"private",
"function",
"createSuf",
"(",
"$",
"path",
",",
"$",
"suf",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"$",
"ext",
"=",
"array_pop",
"(",
"$",
"path",
")",
";",
"$",
"path",
"[",
"count",
"(",
"$",
"path",
")",
"-",
"1",
"]",
".=",
"'_'",
".",
"$",
"suf",
";",
"$",
"path",
"[",
"]",
"=",
"$",
"ext",
";",
"return",
"implode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"}"
] | 创建后缀
@method addSuf
@since 0.0.1
@param {string} $path 路径
@param {string} $suf 后缀
@return {string} | [
"创建后缀"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L128-L135 |
xiewulong/yii2-fileupload | Manager.php | Manager.createFile | public function createFile($ext, $suf = null, $pre = null) {
$this->ext = $ext;
if(!empty($pre)) {
$this->pre = $pre;
}
if(!empty($suf)) {
$this->suf = $suf;
}
return [
'tmp' => $this->getTmp(),
'src' => $this->getSrc(),
'name' => $this->getPath() . DIRECTORY_SEPARATOR . $this->getName(),
];
} | php | public function createFile($ext, $suf = null, $pre = null) {
$this->ext = $ext;
if(!empty($pre)) {
$this->pre = $pre;
}
if(!empty($suf)) {
$this->suf = $suf;
}
return [
'tmp' => $this->getTmp(),
'src' => $this->getSrc(),
'name' => $this->getPath() . DIRECTORY_SEPARATOR . $this->getName(),
];
} | [
"public",
"function",
"createFile",
"(",
"$",
"ext",
",",
"$",
"suf",
"=",
"null",
",",
"$",
"pre",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"ext",
"=",
"$",
"ext",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pre",
")",
")",
"{",
"$",
"this",
"->",
"pre",
"=",
"$",
"pre",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"suf",
")",
")",
"{",
"$",
"this",
"->",
"suf",
"=",
"$",
"suf",
";",
"}",
"return",
"[",
"'tmp'",
"=>",
"$",
"this",
"->",
"getTmp",
"(",
")",
",",
"'src'",
"=>",
"$",
"this",
"->",
"getSrc",
"(",
")",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"]",
";",
"}"
] | 生成文件信息
@method createFile
@since 0.0.1
@param {string} $ext 扩展名
@param {string} [$suf=null] 后缀
@param {string} [$pre=null] 前缀
@return {array}
@example \Yii::$app->fileupload->createFile($ext, $suf, $pre); | [
"生成文件信息"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L147-L161 |
xiewulong/yii2-fileupload | Manager.php | Manager.getSrc | private function getSrc() {
return \Yii::getAlias($this->src) . DIRECTORY_SEPARATOR . $this->getPath() . DIRECTORY_SEPARATOR . $this->getName();
} | php | private function getSrc() {
return \Yii::getAlias($this->src) . DIRECTORY_SEPARATOR . $this->getPath() . DIRECTORY_SEPARATOR . $this->getName();
} | [
"private",
"function",
"getSrc",
"(",
")",
"{",
"return",
"\\",
"Yii",
"::",
"getAlias",
"(",
"$",
"this",
"->",
"src",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"}"
] | 获取网络路径
@method getSrc
@since 0.0.1
@return {string} | [
"获取网络路径"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L169-L171 |
xiewulong/yii2-fileupload | Manager.php | Manager.getTmp | private function getTmp() {
if($this->root === false) {
$this->root = \Yii::getAlias($this->tmp) . DIRECTORY_SEPARATOR . $this->getPath();
if(!file_exists($this->root)) {
mkdir($this->root, 0777, true);
}
}
return $this->root . DIRECTORY_SEPARATOR . $this->getName();
} | php | private function getTmp() {
if($this->root === false) {
$this->root = \Yii::getAlias($this->tmp) . DIRECTORY_SEPARATOR . $this->getPath();
if(!file_exists($this->root)) {
mkdir($this->root, 0777, true);
}
}
return $this->root . DIRECTORY_SEPARATOR . $this->getName();
} | [
"private",
"function",
"getTmp",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"root",
"=",
"\\",
"Yii",
"::",
"getAlias",
"(",
"$",
"this",
"->",
"tmp",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"root",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"root",
",",
"0777",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"root",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"}"
] | 获取绝对路径
@method getTmp
@since 0.0.1
@return {string} | [
"获取绝对路径"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L179-L188 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.