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
|
---|---|---|---|---|---|---|---|---|---|---|
wenbinye/PhalconX | src/Http/Request.php | Request.getFile | public function getFile($name)
{
if (!isset($this->files)) {
$files = $this->getUploadedFiles();
foreach ($files as $file) {
$key = $file->getKey();
if (isset($key)) {
$this->files[$key] = $file;
} else {
$this->files[] = $file;
}
}
}
if (isset($this->files[$name])) {
return $this->files[$name];
} else {
throw new \InvalidArgumentException("Upload file '$name' is empty");
}
} | php | public function getFile($name)
{
if (!isset($this->files)) {
$files = $this->getUploadedFiles();
foreach ($files as $file) {
$key = $file->getKey();
if (isset($key)) {
$this->files[$key] = $file;
} else {
$this->files[] = $file;
}
}
}
if (isset($this->files[$name])) {
return $this->files[$name];
} else {
throw new \InvalidArgumentException("Upload file '$name' is empty");
}
} | [
"public",
"function",
"getFile",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"files",
")",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getUploadedFiles",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"key",
"=",
"$",
"file",
"->",
"getKey",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"files",
"[",
"$",
"key",
"]",
"=",
"$",
"file",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"files",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"files",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Upload file '$name' is empty\"",
")",
";",
"}",
"}"
] | Gets upload file object by name
@return Phalcon\Http\Request\File | [
"Gets",
"upload",
"file",
"object",
"by",
"name"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Http/Request.php#L50-L68 |
wenbinye/PhalconX | src/Http/Request.php | Request.getBody | public function getBody()
{
if (!isset($this->body)) {
if (function_exists('http_get_request_body')) {
$this->body = http_get_request_body();
} else {
$this->body = @file_get_contents('php://input');
}
}
return $this->body;
} | php | public function getBody()
{
if (!isset($this->body)) {
if (function_exists('http_get_request_body')) {
$this->body = http_get_request_body();
} else {
$this->body = @file_get_contents('php://input');
}
}
return $this->body;
} | [
"public",
"function",
"getBody",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"body",
")",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'http_get_request_body'",
")",
")",
"{",
"$",
"this",
"->",
"body",
"=",
"http_get_request_body",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"body",
"=",
"@",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"body",
";",
"}"
] | Gets post body content
@return string | [
"Gets",
"post",
"body",
"content"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Http/Request.php#L75-L85 |
flowcode/AmulenUserBundle | src/Flowcode/UserBundle/Entity/UserGroup.php | UserGroup.addRole | public function addRole(\Amulen\UserBundle\Entity\Role $role)
{
$this->roles[] = $role;
return $this;
} | php | public function addRole(\Amulen\UserBundle\Entity\Role $role)
{
$this->roles[] = $role;
return $this;
} | [
"public",
"function",
"addRole",
"(",
"\\",
"Amulen",
"\\",
"UserBundle",
"\\",
"Entity",
"\\",
"Role",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"roles",
"[",
"]",
"=",
"$",
"role",
";",
"return",
"$",
"this",
";",
"}"
] | @param \Amulen\UserBundle\Entity\Role $role
@return \Amulen\UserBundle\Entity\UserGroup | [
"@param",
"\\",
"Amulen",
"\\",
"UserBundle",
"\\",
"Entity",
"\\",
"Role",
"$role"
] | train | https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Entity/UserGroup.php#L98-L103 |
mrgarry/yii2-omj-fidavista | FidavistaTransaction.php | FidavistaTransaction.populateData | private function populateData(\DOMNode $node) {
$response = false;
foreach ($node->childNodes as $child) {
if ($child->hasChildNodes()) {
$response[$child->nodeName] = $this->populateData($child);
}
else {
if ($child->nodeName == '#text') {
$response = $child->textContent;
}
else {
$response[$child->nodeName] = $child->textContent;
}
}
}
return $response;
} | php | private function populateData(\DOMNode $node) {
$response = false;
foreach ($node->childNodes as $child) {
if ($child->hasChildNodes()) {
$response[$child->nodeName] = $this->populateData($child);
}
else {
if ($child->nodeName == '#text') {
$response = $child->textContent;
}
else {
$response[$child->nodeName] = $child->textContent;
}
}
}
return $response;
} | [
"private",
"function",
"populateData",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"$",
"response",
"=",
"false",
";",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"hasChildNodes",
"(",
")",
")",
"{",
"$",
"response",
"[",
"$",
"child",
"->",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"populateData",
"(",
"$",
"child",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"child",
"->",
"nodeName",
"==",
"'#text'",
")",
"{",
"$",
"response",
"=",
"$",
"child",
"->",
"textContent",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"$",
"child",
"->",
"nodeName",
"]",
"=",
"$",
"child",
"->",
"textContent",
";",
"}",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] | array | [
"array"
] | train | https://github.com/mrgarry/yii2-omj-fidavista/blob/ee4ecadd6648b68e891352c214ff33a72622941b/FidavistaTransaction.php#L15-L33 |
ouropencode/dachi | src/Template.php | Template.initialize | protected static function initialize() {
$loader = new \Twig_Loader_Filesystem();
foreach(Modules::getAll() as $module)
if(file_exists($module->getPath() . '/Views'))
$loader->addPath($module->getPath() . '/Views', $module->getShortName());
if(file_exists('views')) {
$loader->addPath('views', 'global');
$loader->addPath('views', 'Global');
}
self::$twig = new \Twig_Environment($loader, array(
'debug' => Configuration::get('debug.template', 'false') === 'true',
'auto_reload' => Kernel::getEnvironment() === "local",
'charset' => Configuration::get('templates.charset', 'utf-8'),
'cache' => 'cache/twig',
'strict_variables' => false,
'autoescape' => true
));
self::$twig->addFilter(new \Twig_SimpleFilter('time_short', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('H:i');
}));
self::$twig->addFilter(new \Twig_SimpleFilter('date_short', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('Y-m-d');
}));
self::$twig->addFilter(new \Twig_SimpleFilter('date_long', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('jS F Y');
}));
self::$twig->addFilter(new \Twig_SimpleFilter('date_uk', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('d/m/Y');
}));
self::$twig->getExtension('core')->setDateFormat('Y-m-d H:i');
$sort_filter = function($value, $key, $direction, $absolute, $natural) {
usort($value, function($a, $b) use ($key, $direction, $absolute, $natural) {
if($key) {
$a = $a[$key];
$b = $b[$key];
}
if($absolute) {
$a = abs($a);
$b = abs($b);
}
if($direction == "desc" || $direction === true) {
if($natural)
return strnatcmp($b, $a);
if($a == $b) return 0;
return $a > $b ? -1 : 1;
}
if($direction == "asc") {
if($natural)
return strnatcmp($a, $b);
if($a == $b) return 0;
return $a > $b ? 1 : -1;
}
return 0;
});
return $value;
};
/**
* $test = array(
* array("value" => 3),
* array("value" => 1),
* array("value" => 2),
* array("value" => 5),
* array("value" => 4),
* array("value" => -3),
* array("value" => -1),
* array("value" => -2),
* array("value" => -5),
* array("value" => -4)
* );
*
* (the zero argument versions only work on simple arrays!)
*
* | sort([key, direction, absolute, natural])
* | sort() [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
* | sort("value", "asc") [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
* | sort("value", "desc") [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]
* | sort("value", true) [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]
* | sort("value", "asc", true) [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sort("value", "asc", true, true) [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sort("value", "asc", false, true) [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
*
* | sortabs([key, direction])
* | sortabs() [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sortabs("value", "asc") [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sortabs("value", "desc") [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]
*
* | natsort([key, direction])
* | natsort() [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
* | natsort("value", "asc") [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
* | natsort("value", "desc") [5, 4, 3, 2, 1, -5, -4, -3, -2, -1]
*
* | natsortabs([key, direction])
* | natsortabs() [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | natsortabs("value", "asc") [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | natsortabs("value", "desc") [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]
*/
self::$twig->addFilter(new \Twig_SimpleFilter("sort", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
$absolute = isset($options[2]) ? $options[2] : false;
$natural = isset($options[3]) ? $options[3] : false;
return $sort_filter($value, $key, $direction, $absolute, $natural);
}, array('is_variadic' => true)));
self::$twig->addFilter(new \Twig_SimpleFilter("natsort", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
return $sort_filter($value, $key, $direction, false, true);
}, array('is_variadic' => true)));
self::$twig->addFilter(new \Twig_SimpleFilter("sortabs", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
return $sort_filter($value, $key, $direction, true, false);
}, array('is_variadic' => true)));
self::$twig->addFilter(new \Twig_SimpleFilter("natsortabs", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
return $sort_filter($value, $key, $direction, true, true);
}, array('is_variadic' => true)));
} | php | protected static function initialize() {
$loader = new \Twig_Loader_Filesystem();
foreach(Modules::getAll() as $module)
if(file_exists($module->getPath() . '/Views'))
$loader->addPath($module->getPath() . '/Views', $module->getShortName());
if(file_exists('views')) {
$loader->addPath('views', 'global');
$loader->addPath('views', 'Global');
}
self::$twig = new \Twig_Environment($loader, array(
'debug' => Configuration::get('debug.template', 'false') === 'true',
'auto_reload' => Kernel::getEnvironment() === "local",
'charset' => Configuration::get('templates.charset', 'utf-8'),
'cache' => 'cache/twig',
'strict_variables' => false,
'autoescape' => true
));
self::$twig->addFilter(new \Twig_SimpleFilter('time_short', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('H:i');
}));
self::$twig->addFilter(new \Twig_SimpleFilter('date_short', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('Y-m-d');
}));
self::$twig->addFilter(new \Twig_SimpleFilter('date_long', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('jS F Y');
}));
self::$twig->addFilter(new \Twig_SimpleFilter('date_uk', function($date) {
if($date == "now") $date = new \DateTime();
return $date->format('d/m/Y');
}));
self::$twig->getExtension('core')->setDateFormat('Y-m-d H:i');
$sort_filter = function($value, $key, $direction, $absolute, $natural) {
usort($value, function($a, $b) use ($key, $direction, $absolute, $natural) {
if($key) {
$a = $a[$key];
$b = $b[$key];
}
if($absolute) {
$a = abs($a);
$b = abs($b);
}
if($direction == "desc" || $direction === true) {
if($natural)
return strnatcmp($b, $a);
if($a == $b) return 0;
return $a > $b ? -1 : 1;
}
if($direction == "asc") {
if($natural)
return strnatcmp($a, $b);
if($a == $b) return 0;
return $a > $b ? 1 : -1;
}
return 0;
});
return $value;
};
/**
* $test = array(
* array("value" => 3),
* array("value" => 1),
* array("value" => 2),
* array("value" => 5),
* array("value" => 4),
* array("value" => -3),
* array("value" => -1),
* array("value" => -2),
* array("value" => -5),
* array("value" => -4)
* );
*
* (the zero argument versions only work on simple arrays!)
*
* | sort([key, direction, absolute, natural])
* | sort() [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
* | sort("value", "asc") [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
* | sort("value", "desc") [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]
* | sort("value", true) [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]
* | sort("value", "asc", true) [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sort("value", "asc", true, true) [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sort("value", "asc", false, true) [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
*
* | sortabs([key, direction])
* | sortabs() [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sortabs("value", "asc") [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | sortabs("value", "desc") [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]
*
* | natsort([key, direction])
* | natsort() [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
* | natsort("value", "asc") [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
* | natsort("value", "desc") [5, 4, 3, 2, 1, -5, -4, -3, -2, -1]
*
* | natsortabs([key, direction])
* | natsortabs() [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | natsortabs("value", "asc") [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
* | natsortabs("value", "desc") [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]
*/
self::$twig->addFilter(new \Twig_SimpleFilter("sort", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
$absolute = isset($options[2]) ? $options[2] : false;
$natural = isset($options[3]) ? $options[3] : false;
return $sort_filter($value, $key, $direction, $absolute, $natural);
}, array('is_variadic' => true)));
self::$twig->addFilter(new \Twig_SimpleFilter("natsort", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
return $sort_filter($value, $key, $direction, false, true);
}, array('is_variadic' => true)));
self::$twig->addFilter(new \Twig_SimpleFilter("sortabs", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
return $sort_filter($value, $key, $direction, true, false);
}, array('is_variadic' => true)));
self::$twig->addFilter(new \Twig_SimpleFilter("natsortabs", function ($value, array $options = array()) use ($sort_filter) {
$key = isset($options[0]) ? $options[0] : null;
$direction = isset($options[1]) ? $options[1] : "asc";
return $sort_filter($value, $key, $direction, true, true);
}, array('is_variadic' => true)));
} | [
"protected",
"static",
"function",
"initialize",
"(",
")",
"{",
"$",
"loader",
"=",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
")",
";",
"foreach",
"(",
"Modules",
"::",
"getAll",
"(",
")",
"as",
"$",
"module",
")",
"if",
"(",
"file_exists",
"(",
"$",
"module",
"->",
"getPath",
"(",
")",
".",
"'/Views'",
")",
")",
"$",
"loader",
"->",
"addPath",
"(",
"$",
"module",
"->",
"getPath",
"(",
")",
".",
"'/Views'",
",",
"$",
"module",
"->",
"getShortName",
"(",
")",
")",
";",
"if",
"(",
"file_exists",
"(",
"'views'",
")",
")",
"{",
"$",
"loader",
"->",
"addPath",
"(",
"'views'",
",",
"'global'",
")",
";",
"$",
"loader",
"->",
"addPath",
"(",
"'views'",
",",
"'Global'",
")",
";",
"}",
"self",
"::",
"$",
"twig",
"=",
"new",
"\\",
"Twig_Environment",
"(",
"$",
"loader",
",",
"array",
"(",
"'debug'",
"=>",
"Configuration",
"::",
"get",
"(",
"'debug.template'",
",",
"'false'",
")",
"===",
"'true'",
",",
"'auto_reload'",
"=>",
"Kernel",
"::",
"getEnvironment",
"(",
")",
"===",
"\"local\"",
",",
"'charset'",
"=>",
"Configuration",
"::",
"get",
"(",
"'templates.charset'",
",",
"'utf-8'",
")",
",",
"'cache'",
"=>",
"'cache/twig'",
",",
"'strict_variables'",
"=>",
"false",
",",
"'autoescape'",
"=>",
"true",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"'time_short'",
",",
"function",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"$",
"date",
"==",
"\"now\"",
")",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"'H:i'",
")",
";",
"}",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"'date_short'",
",",
"function",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"$",
"date",
"==",
"\"now\"",
")",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d'",
")",
";",
"}",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"'date_long'",
",",
"function",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"$",
"date",
"==",
"\"now\"",
")",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"'jS F Y'",
")",
";",
"}",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"'date_uk'",
",",
"function",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"$",
"date",
"==",
"\"now\"",
")",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"'d/m/Y'",
")",
";",
"}",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"getExtension",
"(",
"'core'",
")",
"->",
"setDateFormat",
"(",
"'Y-m-d H:i'",
")",
";",
"$",
"sort_filter",
"=",
"function",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"direction",
",",
"$",
"absolute",
",",
"$",
"natural",
")",
"{",
"usort",
"(",
"$",
"value",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"key",
",",
"$",
"direction",
",",
"$",
"absolute",
",",
"$",
"natural",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"a",
"=",
"$",
"a",
"[",
"$",
"key",
"]",
";",
"$",
"b",
"=",
"$",
"b",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"absolute",
")",
"{",
"$",
"a",
"=",
"abs",
"(",
"$",
"a",
")",
";",
"$",
"b",
"=",
"abs",
"(",
"$",
"b",
")",
";",
"}",
"if",
"(",
"$",
"direction",
"==",
"\"desc\"",
"||",
"$",
"direction",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"natural",
")",
"return",
"strnatcmp",
"(",
"$",
"b",
",",
"$",
"a",
")",
";",
"if",
"(",
"$",
"a",
"==",
"$",
"b",
")",
"return",
"0",
";",
"return",
"$",
"a",
">",
"$",
"b",
"?",
"-",
"1",
":",
"1",
";",
"}",
"if",
"(",
"$",
"direction",
"==",
"\"asc\"",
")",
"{",
"if",
"(",
"$",
"natural",
")",
"return",
"strnatcmp",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"if",
"(",
"$",
"a",
"==",
"$",
"b",
")",
"return",
"0",
";",
"return",
"$",
"a",
">",
"$",
"b",
"?",
"1",
":",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"return",
"$",
"value",
";",
"}",
";",
"/**\n\t\t * $test = array(\n\t * array(\"value\" => 3),\n\t * array(\"value\" => 1),\n\t * array(\"value\" => 2),\n\t * array(\"value\" => 5),\n\t * array(\"value\" => 4),\n\t * array(\"value\" => -3),\n\t * array(\"value\" => -1),\n\t * array(\"value\" => -2),\n\t * array(\"value\" => -5),\n\t * array(\"value\" => -4)\n\t * );\n\t *\n\t * (the zero argument versions only work on simple arrays!)\n\t *\n\t * | sort([key, direction, absolute, natural])\n\t * | sort() [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]\n\t * | sort(\"value\", \"asc\") [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]\n\t * | sort(\"value\", \"desc\") [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]\n\t * | sort(\"value\", true) [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]\n\t * | sort(\"value\", \"asc\", true) [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]\n\t * | sort(\"value\", \"asc\", true, true) [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]\n\t * | sort(\"value\", \"asc\", false, true) [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]\n\t *\n\t * | sortabs([key, direction])\n\t * | sortabs() [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]\n\t * | sortabs(\"value\", \"asc\") [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]\n\t * | sortabs(\"value\", \"desc\") [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]\n\t *\n\t * | natsort([key, direction])\n\t * | natsort() [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]\n\t * | natsort(\"value\", \"asc\") [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]\n\t * | natsort(\"value\", \"desc\") [5, 4, 3, 2, 1, -5, -4, -3, -2, -1]\n\t *\n\t * | natsortabs([key, direction])\n\t * | natsortabs() [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]\n\t * | natsortabs(\"value\", \"asc\") [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]\n\t * | natsortabs(\"value\", \"desc\") [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]\n\t\t */",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"\"sort\"",
",",
"function",
"(",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"use",
"(",
"$",
"sort_filter",
")",
"{",
"$",
"key",
"=",
"isset",
"(",
"$",
"options",
"[",
"0",
"]",
")",
"?",
"$",
"options",
"[",
"0",
"]",
":",
"null",
";",
"$",
"direction",
"=",
"isset",
"(",
"$",
"options",
"[",
"1",
"]",
")",
"?",
"$",
"options",
"[",
"1",
"]",
":",
"\"asc\"",
";",
"$",
"absolute",
"=",
"isset",
"(",
"$",
"options",
"[",
"2",
"]",
")",
"?",
"$",
"options",
"[",
"2",
"]",
":",
"false",
";",
"$",
"natural",
"=",
"isset",
"(",
"$",
"options",
"[",
"3",
"]",
")",
"?",
"$",
"options",
"[",
"3",
"]",
":",
"false",
";",
"return",
"$",
"sort_filter",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"direction",
",",
"$",
"absolute",
",",
"$",
"natural",
")",
";",
"}",
",",
"array",
"(",
"'is_variadic'",
"=>",
"true",
")",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"\"natsort\"",
",",
"function",
"(",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"use",
"(",
"$",
"sort_filter",
")",
"{",
"$",
"key",
"=",
"isset",
"(",
"$",
"options",
"[",
"0",
"]",
")",
"?",
"$",
"options",
"[",
"0",
"]",
":",
"null",
";",
"$",
"direction",
"=",
"isset",
"(",
"$",
"options",
"[",
"1",
"]",
")",
"?",
"$",
"options",
"[",
"1",
"]",
":",
"\"asc\"",
";",
"return",
"$",
"sort_filter",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"direction",
",",
"false",
",",
"true",
")",
";",
"}",
",",
"array",
"(",
"'is_variadic'",
"=>",
"true",
")",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"\"sortabs\"",
",",
"function",
"(",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"use",
"(",
"$",
"sort_filter",
")",
"{",
"$",
"key",
"=",
"isset",
"(",
"$",
"options",
"[",
"0",
"]",
")",
"?",
"$",
"options",
"[",
"0",
"]",
":",
"null",
";",
"$",
"direction",
"=",
"isset",
"(",
"$",
"options",
"[",
"1",
"]",
")",
"?",
"$",
"options",
"[",
"1",
"]",
":",
"\"asc\"",
";",
"return",
"$",
"sort_filter",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"direction",
",",
"true",
",",
"false",
")",
";",
"}",
",",
"array",
"(",
"'is_variadic'",
"=>",
"true",
")",
")",
")",
";",
"self",
"::",
"$",
"twig",
"->",
"addFilter",
"(",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"\"natsortabs\"",
",",
"function",
"(",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"use",
"(",
"$",
"sort_filter",
")",
"{",
"$",
"key",
"=",
"isset",
"(",
"$",
"options",
"[",
"0",
"]",
")",
"?",
"$",
"options",
"[",
"0",
"]",
":",
"null",
";",
"$",
"direction",
"=",
"isset",
"(",
"$",
"options",
"[",
"1",
"]",
")",
"?",
"$",
"options",
"[",
"1",
"]",
":",
"\"asc\"",
";",
"return",
"$",
"sort_filter",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"direction",
",",
"true",
",",
"true",
")",
";",
"}",
",",
"array",
"(",
"'is_variadic'",
"=>",
"true",
")",
")",
")",
";",
"}"
] | Load the routing information object into memory.
@return null | [
"Load",
"the",
"routing",
"information",
"object",
"into",
"memory",
"."
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L21-L159 |
ouropencode/dachi | src/Template.php | Template.get | public static function get($template) {
if(self::$twig === null)
self::initialize();
return self::$twig->loadTemplate($template . '.twig');
} | php | public static function get($template) {
if(self::$twig === null)
self::initialize();
return self::$twig->loadTemplate($template . '.twig');
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"twig",
"===",
"null",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"return",
"self",
"::",
"$",
"twig",
"->",
"loadTemplate",
"(",
"$",
"template",
".",
"'.twig'",
")",
";",
"}"
] | Retreive a twig template object
@param string $template The template file
@return Twig_Template | [
"Retreive",
"a",
"twig",
"template",
"object"
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L166-L171 |
ouropencode/dachi | src/Template.php | Template.display | public static function display($template, $target_id) {
if(self::$twig === null)
self::initialize();
self::$render_actions[] = array(
"type" => "display_tpl",
"template" => $template,
"target_id" => $target_id
);
} | php | public static function display($template, $target_id) {
if(self::$twig === null)
self::initialize();
self::$render_actions[] = array(
"type" => "display_tpl",
"template" => $template,
"target_id" => $target_id
);
} | [
"public",
"static",
"function",
"display",
"(",
"$",
"template",
",",
"$",
"target_id",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"twig",
"===",
"null",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"self",
"::",
"$",
"render_actions",
"[",
"]",
"=",
"array",
"(",
"\"type\"",
"=>",
"\"display_tpl\"",
",",
"\"template\"",
"=>",
"$",
"template",
",",
"\"target_id\"",
"=>",
"$",
"target_id",
")",
";",
"}"
] | Append a template render action to the render queue
@param string $template The template file
@param string $target_id The dachi-ui-block to load into
@return null | [
"Append",
"a",
"template",
"render",
"action",
"to",
"the",
"render",
"queue"
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L179-L188 |
ouropencode/dachi | src/Template.php | Template.render | public static function render() {
$apiMode = Request::isAPI();
if(self::$twig === null)
self::initialize();
$data = Request::getAllData();
if(!$apiMode) {
$data["siteName"] = Configuration::get("dachi.siteName", "Unnamed Dachi Installation");
$data["timezone"] = Configuration::get("dachi.timezone", "Europe/London");
$data["domain"] = Configuration::get("dachi.domain", "localhost");
$data["baseURL"] = Configuration::get("dachi.baseURL", "/");
$data["assetsURL"] = str_replace("%v", Kernel::getGitHash(), Configuration::get("dachi.assetsURL", "/build/"));
$data["renderTPL"] = self::getRenderTemplate();
$data["URI"] = Request::getFullUri();
}
if($apiMode) {
$response = array(
"data" => $data,
"response" => Request::getResponseCode()
);
return json_echo($response);
} else if(Request::isAjax()) {
$response = array(
"render_tpl" => self::getRenderTemplate(),
"data" => $data,
"response" => Request::getResponseCode(),
"render_actions" => self::$render_actions
);
return json_echo($response);
} else {
$data["response"] = Request::getResponseCode();
$response = self::$twig->render(self::getRenderTemplate(true), $data);
foreach(array_reverse(self::$render_actions) as $action) {
switch($action["type"]) {
case "redirect":
if($action["soft"] !== true)
header("Location: " . $action["location"]);
break;
case "display_tpl":
$match = preg_match("/<dachi-ui-block id=[\"']" . preg_quote($action["target_id"]) . "[\"'][^>]*>([\s\S]*)<\/dachi-ui-block>/U", $response, $matches);
if($match) {
$replacement = "<dachi-ui-block id='" . $action["target_id"] . "'>" . self::$twig->render($action["template"] . '.twig', $data) . "</dachi-ui-block>";
$response = str_replace($matches[0], $replacement, $response);
}
break;
}
}
echo $response;
}
} | php | public static function render() {
$apiMode = Request::isAPI();
if(self::$twig === null)
self::initialize();
$data = Request::getAllData();
if(!$apiMode) {
$data["siteName"] = Configuration::get("dachi.siteName", "Unnamed Dachi Installation");
$data["timezone"] = Configuration::get("dachi.timezone", "Europe/London");
$data["domain"] = Configuration::get("dachi.domain", "localhost");
$data["baseURL"] = Configuration::get("dachi.baseURL", "/");
$data["assetsURL"] = str_replace("%v", Kernel::getGitHash(), Configuration::get("dachi.assetsURL", "/build/"));
$data["renderTPL"] = self::getRenderTemplate();
$data["URI"] = Request::getFullUri();
}
if($apiMode) {
$response = array(
"data" => $data,
"response" => Request::getResponseCode()
);
return json_echo($response);
} else if(Request::isAjax()) {
$response = array(
"render_tpl" => self::getRenderTemplate(),
"data" => $data,
"response" => Request::getResponseCode(),
"render_actions" => self::$render_actions
);
return json_echo($response);
} else {
$data["response"] = Request::getResponseCode();
$response = self::$twig->render(self::getRenderTemplate(true), $data);
foreach(array_reverse(self::$render_actions) as $action) {
switch($action["type"]) {
case "redirect":
if($action["soft"] !== true)
header("Location: " . $action["location"]);
break;
case "display_tpl":
$match = preg_match("/<dachi-ui-block id=[\"']" . preg_quote($action["target_id"]) . "[\"'][^>]*>([\s\S]*)<\/dachi-ui-block>/U", $response, $matches);
if($match) {
$replacement = "<dachi-ui-block id='" . $action["target_id"] . "'>" . self::$twig->render($action["template"] . '.twig', $data) . "</dachi-ui-block>";
$response = str_replace($matches[0], $replacement, $response);
}
break;
}
}
echo $response;
}
} | [
"public",
"static",
"function",
"render",
"(",
")",
"{",
"$",
"apiMode",
"=",
"Request",
"::",
"isAPI",
"(",
")",
";",
"if",
"(",
"self",
"::",
"$",
"twig",
"===",
"null",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"$",
"data",
"=",
"Request",
"::",
"getAllData",
"(",
")",
";",
"if",
"(",
"!",
"$",
"apiMode",
")",
"{",
"$",
"data",
"[",
"\"siteName\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.siteName\"",
",",
"\"Unnamed Dachi Installation\"",
")",
";",
"$",
"data",
"[",
"\"timezone\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.timezone\"",
",",
"\"Europe/London\"",
")",
";",
"$",
"data",
"[",
"\"domain\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.domain\"",
",",
"\"localhost\"",
")",
";",
"$",
"data",
"[",
"\"baseURL\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.baseURL\"",
",",
"\"/\"",
")",
";",
"$",
"data",
"[",
"\"assetsURL\"",
"]",
"=",
"str_replace",
"(",
"\"%v\"",
",",
"Kernel",
"::",
"getGitHash",
"(",
")",
",",
"Configuration",
"::",
"get",
"(",
"\"dachi.assetsURL\"",
",",
"\"/build/\"",
")",
")",
";",
"$",
"data",
"[",
"\"renderTPL\"",
"]",
"=",
"self",
"::",
"getRenderTemplate",
"(",
")",
";",
"$",
"data",
"[",
"\"URI\"",
"]",
"=",
"Request",
"::",
"getFullUri",
"(",
")",
";",
"}",
"if",
"(",
"$",
"apiMode",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"\"data\"",
"=>",
"$",
"data",
",",
"\"response\"",
"=>",
"Request",
"::",
"getResponseCode",
"(",
")",
")",
";",
"return",
"json_echo",
"(",
"$",
"response",
")",
";",
"}",
"else",
"if",
"(",
"Request",
"::",
"isAjax",
"(",
")",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"\"render_tpl\"",
"=>",
"self",
"::",
"getRenderTemplate",
"(",
")",
",",
"\"data\"",
"=>",
"$",
"data",
",",
"\"response\"",
"=>",
"Request",
"::",
"getResponseCode",
"(",
")",
",",
"\"render_actions\"",
"=>",
"self",
"::",
"$",
"render_actions",
")",
";",
"return",
"json_echo",
"(",
"$",
"response",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"\"response\"",
"]",
"=",
"Request",
"::",
"getResponseCode",
"(",
")",
";",
"$",
"response",
"=",
"self",
"::",
"$",
"twig",
"->",
"render",
"(",
"self",
"::",
"getRenderTemplate",
"(",
"true",
")",
",",
"$",
"data",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"self",
"::",
"$",
"render_actions",
")",
"as",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
"[",
"\"type\"",
"]",
")",
"{",
"case",
"\"redirect\"",
":",
"if",
"(",
"$",
"action",
"[",
"\"soft\"",
"]",
"!==",
"true",
")",
"header",
"(",
"\"Location: \"",
".",
"$",
"action",
"[",
"\"location\"",
"]",
")",
";",
"break",
";",
"case",
"\"display_tpl\"",
":",
"$",
"match",
"=",
"preg_match",
"(",
"\"/<dachi-ui-block id=[\\\"']\"",
".",
"preg_quote",
"(",
"$",
"action",
"[",
"\"target_id\"",
"]",
")",
".",
"\"[\\\"'][^>]*>([\\s\\S]*)<\\/dachi-ui-block>/U\"",
",",
"$",
"response",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"replacement",
"=",
"\"<dachi-ui-block id='\"",
".",
"$",
"action",
"[",
"\"target_id\"",
"]",
".",
"\"'>\"",
".",
"self",
"::",
"$",
"twig",
"->",
"render",
"(",
"$",
"action",
"[",
"\"template\"",
"]",
".",
"'.twig'",
",",
"$",
"data",
")",
".",
"\"</dachi-ui-block>\"",
";",
"$",
"response",
"=",
"str_replace",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"$",
"replacement",
",",
"$",
"response",
")",
";",
"}",
"break",
";",
"}",
"}",
"echo",
"$",
"response",
";",
"}",
"}"
] | Render the render queue to the browser
If the request is an ajax request, the render queue and data will be sent to the browser via JSON.
If the request is a standard request, the render queue will be rendered server-side and will be sent to the browser via HTML.
@internal
@see Router
@return null | [
"Render",
"the",
"render",
"queue",
"to",
"the",
"browser"
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L200-L255 |
ouropencode/dachi | src/Template.php | Template.redirect | public static function redirect($location, $soft = false) {
if(substr($location, 0, 4) !== "http")
$location = Configuration::get("dachi.baseURL") . $location;
self::$render_actions[] = array(
"type" => "redirect",
"location" => $location,
"soft" => $soft
);
} | php | public static function redirect($location, $soft = false) {
if(substr($location, 0, 4) !== "http")
$location = Configuration::get("dachi.baseURL") . $location;
self::$render_actions[] = array(
"type" => "redirect",
"location" => $location,
"soft" => $soft
);
} | [
"public",
"static",
"function",
"redirect",
"(",
"$",
"location",
",",
"$",
"soft",
"=",
"false",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"location",
",",
"0",
",",
"4",
")",
"!==",
"\"http\"",
")",
"$",
"location",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.baseURL\"",
")",
".",
"$",
"location",
";",
"self",
"::",
"$",
"render_actions",
"[",
"]",
"=",
"array",
"(",
"\"type\"",
"=>",
"\"redirect\"",
",",
"\"location\"",
"=>",
"$",
"location",
",",
"\"soft\"",
"=>",
"$",
"soft",
")",
";",
"}"
] | Append a redirect action to the render queue.
If $location does not start with "http", the dachi.baseURL configuration value will be prepended
@param string $location The location to redirect to
@return null | [
"Append",
"a",
"redirect",
"action",
"to",
"the",
"render",
"queue",
"."
] | train | https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L265-L274 |
yuncms/yii2-authentication | models/Authentication.php | Authentication.isAuthentication | public static function isAuthentication($user_id)
{
$user = static::findOne(['user_id' => $user_id]);
return $user ? $user->status == static::STATUS_AUTHENTICATED : false;
} | php | public static function isAuthentication($user_id)
{
$user = static::findOne(['user_id' => $user_id]);
return $user ? $user->status == static::STATUS_AUTHENTICATED : false;
} | [
"public",
"static",
"function",
"isAuthentication",
"(",
"$",
"user_id",
")",
"{",
"$",
"user",
"=",
"static",
"::",
"findOne",
"(",
"[",
"'user_id'",
"=>",
"$",
"user_id",
"]",
")",
";",
"return",
"$",
"user",
"?",
"$",
"user",
"->",
"status",
"==",
"static",
"::",
"STATUS_AUTHENTICATED",
":",
"false",
";",
"}"
] | 是否实名认证
@param int $user_id
@return bool | [
"是否实名认证"
] | train | https://github.com/yuncms/yii2-authentication/blob/02b70f7d2587480edb6dcc18ce256db662f1ed0d/models/Authentication.php#L217-L221 |
yuncms/yii2-authentication | models/Authentication.php | Authentication.beforeDelete | public function beforeDelete()
{
if (parent::beforeDelete()) {
$idCardPath = $this->getIdCardPath($this->user_id);
if (file_exists($idCardPath . '_passport_cover_image.jpg')) {
@unlink($idCardPath . '_passport_cover_image.jpg');
}
if (file_exists($idCardPath . '_passport_person_page_image.jpg')) {
@unlink($idCardPath . '_passport_person_page_image.jpg');
}
if (file_exists($idCardPath . '_passport_self_holding_image.jpg')) {
@unlink($idCardPath . '_passport_self_holding_image.jpg');
}
return true;
} else {
return false;
}
} | php | public function beforeDelete()
{
if (parent::beforeDelete()) {
$idCardPath = $this->getIdCardPath($this->user_id);
if (file_exists($idCardPath . '_passport_cover_image.jpg')) {
@unlink($idCardPath . '_passport_cover_image.jpg');
}
if (file_exists($idCardPath . '_passport_person_page_image.jpg')) {
@unlink($idCardPath . '_passport_person_page_image.jpg');
}
if (file_exists($idCardPath . '_passport_self_holding_image.jpg')) {
@unlink($idCardPath . '_passport_self_holding_image.jpg');
}
return true;
} else {
return false;
}
} | [
"public",
"function",
"beforeDelete",
"(",
")",
"{",
"if",
"(",
"parent",
"::",
"beforeDelete",
"(",
")",
")",
"{",
"$",
"idCardPath",
"=",
"$",
"this",
"->",
"getIdCardPath",
"(",
"$",
"this",
"->",
"user_id",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"idCardPath",
".",
"'_passport_cover_image.jpg'",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"idCardPath",
".",
"'_passport_cover_image.jpg'",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"idCardPath",
".",
"'_passport_person_page_image.jpg'",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"idCardPath",
".",
"'_passport_person_page_image.jpg'",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"idCardPath",
".",
"'_passport_self_holding_image.jpg'",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"idCardPath",
".",
"'_passport_self_holding_image.jpg'",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | 删除前先删除附件
@return bool | [
"删除前先删除附件"
] | train | https://github.com/yuncms/yii2-authentication/blob/02b70f7d2587480edb6dcc18ce256db662f1ed0d/models/Authentication.php#L227-L244 |
Laralum/Users | src/Policies/UserPolicy.php | UserPolicy.access | public function access($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.access') || $user->superAdmin();
} | php | public function access($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.access') || $user->superAdmin();
} | [
"public",
"function",
"access",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.access'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] | Determine if the current user can view users module.
@param mixed $user
@return bool | [
"Determine",
"if",
"the",
"current",
"user",
"can",
"view",
"users",
"module",
"."
] | train | https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L19-L24 |
Laralum/Users | src/Policies/UserPolicy.php | UserPolicy.view | public function view($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.view') || $user->superAdmin();
} | php | public function view($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.view') || $user->superAdmin();
} | [
"public",
"function",
"view",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.view'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] | Determine if the current user can view users.
@param mixed $user
@return bool | [
"Determine",
"if",
"the",
"current",
"user",
"can",
"view",
"users",
"."
] | train | https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L33-L38 |
Laralum/Users | src/Policies/UserPolicy.php | UserPolicy.create | public function create($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.create') || $user->superAdmin();
} | php | public function create($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.create') || $user->superAdmin();
} | [
"public",
"function",
"create",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.create'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] | Determine if the current user can create users.
@param mixed $user
@return bool | [
"Determine",
"if",
"the",
"current",
"user",
"can",
"create",
"users",
"."
] | train | https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L47-L52 |
Laralum/Users | src/Policies/UserPolicy.php | UserPolicy.update | public function update($user, User $userToManage)
{
if ($userToManage->id == $user->id || $userToManage->superAdmin()) {
return false;
}
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.update') || $user->superAdmin();
} | php | public function update($user, User $userToManage)
{
if ($userToManage->id == $user->id || $userToManage->superAdmin()) {
return false;
}
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.update') || $user->superAdmin();
} | [
"public",
"function",
"update",
"(",
"$",
"user",
",",
"User",
"$",
"userToManage",
")",
"{",
"if",
"(",
"$",
"userToManage",
"->",
"id",
"==",
"$",
"user",
"->",
"id",
"||",
"$",
"userToManage",
"->",
"superAdmin",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.update'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] | Determine if the current user can update users.
@param mixed $user
@return bool | [
"Determine",
"if",
"the",
"current",
"user",
"can",
"update",
"users",
"."
] | train | https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L61-L70 |
jasny/controller | src/Controller/ContentNegotiation.php | ContentNegotiation.negotiate | protected function negotiate(array $priorities, $type = '')
{
$header = 'Accept';
if ($type) {
$header .= '-' . ucfirst($type);
}
$header = $this->getRequest()->getHeader($header);
$header = join(', ', $header);
$negotiator = $this->getNegotiator($type);
$chosen = $negotiator->getBest($header, $priorities);
return $chosen ? $chosen->getType() : '';
} | php | protected function negotiate(array $priorities, $type = '')
{
$header = 'Accept';
if ($type) {
$header .= '-' . ucfirst($type);
}
$header = $this->getRequest()->getHeader($header);
$header = join(', ', $header);
$negotiator = $this->getNegotiator($type);
$chosen = $negotiator->getBest($header, $priorities);
return $chosen ? $chosen->getType() : '';
} | [
"protected",
"function",
"negotiate",
"(",
"array",
"$",
"priorities",
",",
"$",
"type",
"=",
"''",
")",
"{",
"$",
"header",
"=",
"'Accept'",
";",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"header",
".=",
"'-'",
".",
"ucfirst",
"(",
"$",
"type",
")",
";",
"}",
"$",
"header",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getHeader",
"(",
"$",
"header",
")",
";",
"$",
"header",
"=",
"join",
"(",
"', '",
",",
"$",
"header",
")",
";",
"$",
"negotiator",
"=",
"$",
"this",
"->",
"getNegotiator",
"(",
"$",
"type",
")",
";",
"$",
"chosen",
"=",
"$",
"negotiator",
"->",
"getBest",
"(",
"$",
"header",
",",
"$",
"priorities",
")",
";",
"return",
"$",
"chosen",
"?",
"$",
"chosen",
"->",
"getType",
"(",
")",
":",
"''",
";",
"}"
] | Generalize negotiation
@param array $priorities
@param string $type Negotiator type
@return string | [
"Generalize",
"negotiation"
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/ContentNegotiation.php#L68-L83 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.isQueryAllowed | public function isQueryAllowed( ezcDbHandler $db, $query )
{
if ( strstr( $query, 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later.
{
return false;
}
if ( substr( $query, 0, 10 ) == 'DROP TABLE' )
{
$tableName = substr($query, strlen( 'DROP TABLE "' ), -1 ); // get table name without quotes
$result = $db->query( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" )->fetchAll();
if ( $result[0]['count'] == 1 )
{
$sequences = $db->query( "SELECT sequence_name FROM user_sequences" )->fetchAll();
array_walk( $sequences, create_function( '&$item,$key', '$item = $item[0];' ) );
foreach ( $sequences as $sequenceName )
{
// try to drop sequences related to dropped table.
if ( substr( $sequenceName, 0, strlen($tableName) ) == $tableName )
{
$db->query( "DROP SEQUENCE \"{$sequenceName}\"" );
}
}
return true;
}
else
{
return false;
}
}
return true;
} | php | public function isQueryAllowed( ezcDbHandler $db, $query )
{
if ( strstr( $query, 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later.
{
return false;
}
if ( substr( $query, 0, 10 ) == 'DROP TABLE' )
{
$tableName = substr($query, strlen( 'DROP TABLE "' ), -1 ); // get table name without quotes
$result = $db->query( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" )->fetchAll();
if ( $result[0]['count'] == 1 )
{
$sequences = $db->query( "SELECT sequence_name FROM user_sequences" )->fetchAll();
array_walk( $sequences, create_function( '&$item,$key', '$item = $item[0];' ) );
foreach ( $sequences as $sequenceName )
{
// try to drop sequences related to dropped table.
if ( substr( $sequenceName, 0, strlen($tableName) ) == $tableName )
{
$db->query( "DROP SEQUENCE \"{$sequenceName}\"" );
}
}
return true;
}
else
{
return false;
}
}
return true;
} | [
"public",
"function",
"isQueryAllowed",
"(",
"ezcDbHandler",
"$",
"db",
",",
"$",
"query",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"query",
",",
"'AUTO_INCREMENT'",
")",
")",
"// detect AUTO_INCREMENT and return imediately. Will process later.",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"query",
",",
"0",
",",
"10",
")",
"==",
"'DROP TABLE'",
")",
"{",
"$",
"tableName",
"=",
"substr",
"(",
"$",
"query",
",",
"strlen",
"(",
"'DROP TABLE \"'",
")",
",",
"-",
"1",
")",
";",
"// get table name without quotes",
"$",
"result",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"$",
"result",
"[",
"0",
"]",
"[",
"'count'",
"]",
"==",
"1",
")",
"{",
"$",
"sequences",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT sequence_name FROM user_sequences\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"array_walk",
"(",
"$",
"sequences",
",",
"create_function",
"(",
"'&$item,$key'",
",",
"'$item = $item[0];'",
")",
")",
";",
"foreach",
"(",
"$",
"sequences",
"as",
"$",
"sequenceName",
")",
"{",
"// try to drop sequences related to dropped table.",
"if",
"(",
"substr",
"(",
"$",
"sequenceName",
",",
"0",
",",
"strlen",
"(",
"$",
"tableName",
")",
")",
"==",
"$",
"tableName",
")",
"{",
"$",
"db",
"->",
"query",
"(",
"\"DROP SEQUENCE \\\"{$sequenceName}\\\"\"",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if query allowed.
Perform testing if table exist for DROP TABLE query
to avoid stoping execution while try to drop not existent table.
@param ezcDbHandler $db
@param string $query
@return boolean false if query should not be executed. | [
"Checks",
"if",
"query",
"allowed",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L47-L80 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.applyDiffToDb | public function applyDiffToDb( ezcDbHandler $db, ezcDbSchemaDiff $dbSchemaDiff )
{
$db->beginTransaction();
foreach ( $this->convertDiffToDDL( $dbSchemaDiff, $db ) as $query )
{
if ( $this->isQueryAllowed( $db, $query ) )
{
$db->exec( $query );
}
else
{
if ( strstr($query, 'AUTO_INCREMENT') ) // detect AUTO_INCREMENT and emulate it by adding sequence and trigger
{
$db->commit();
$db->beginTransaction();
if ( preg_match ( "/ALTER TABLE (.*) MODIFY (.*?) (.*) AUTO_INCREMENT/" , $query, $matches ) )
{
$tableName = trim( $matches[1], '"' );
$autoIncrementFieldName = trim( $matches[2], '"' );
$autoIncrementFieldType = trim( $matches[3], '"' );
$this->addAutoIncrementField( $db, $tableName, $autoIncrementFieldName, $autoIncrementFieldType );
}
}
$db->commit();
$db->beginTransaction();
}
}
$db->commit();
} | php | public function applyDiffToDb( ezcDbHandler $db, ezcDbSchemaDiff $dbSchemaDiff )
{
$db->beginTransaction();
foreach ( $this->convertDiffToDDL( $dbSchemaDiff, $db ) as $query )
{
if ( $this->isQueryAllowed( $db, $query ) )
{
$db->exec( $query );
}
else
{
if ( strstr($query, 'AUTO_INCREMENT') ) // detect AUTO_INCREMENT and emulate it by adding sequence and trigger
{
$db->commit();
$db->beginTransaction();
if ( preg_match ( "/ALTER TABLE (.*) MODIFY (.*?) (.*) AUTO_INCREMENT/" , $query, $matches ) )
{
$tableName = trim( $matches[1], '"' );
$autoIncrementFieldName = trim( $matches[2], '"' );
$autoIncrementFieldType = trim( $matches[3], '"' );
$this->addAutoIncrementField( $db, $tableName, $autoIncrementFieldName, $autoIncrementFieldType );
}
}
$db->commit();
$db->beginTransaction();
}
}
$db->commit();
} | [
"public",
"function",
"applyDiffToDb",
"(",
"ezcDbHandler",
"$",
"db",
",",
"ezcDbSchemaDiff",
"$",
"dbSchemaDiff",
")",
"{",
"$",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"convertDiffToDDL",
"(",
"$",
"dbSchemaDiff",
",",
"$",
"db",
")",
"as",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isQueryAllowed",
"(",
"$",
"db",
",",
"$",
"query",
")",
")",
"{",
"$",
"db",
"->",
"exec",
"(",
"$",
"query",
")",
";",
"}",
"else",
"{",
"if",
"(",
"strstr",
"(",
"$",
"query",
",",
"'AUTO_INCREMENT'",
")",
")",
"// detect AUTO_INCREMENT and emulate it by adding sequence and trigger",
"{",
"$",
"db",
"->",
"commit",
"(",
")",
";",
"$",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"\"/ALTER TABLE (.*) MODIFY (.*?) (.*) AUTO_INCREMENT/\"",
",",
"$",
"query",
",",
"$",
"matches",
")",
")",
"{",
"$",
"tableName",
"=",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"'\"'",
")",
";",
"$",
"autoIncrementFieldName",
"=",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
",",
"'\"'",
")",
";",
"$",
"autoIncrementFieldType",
"=",
"trim",
"(",
"$",
"matches",
"[",
"3",
"]",
",",
"'\"'",
")",
";",
"$",
"this",
"->",
"addAutoIncrementField",
"(",
"$",
"db",
",",
"$",
"tableName",
",",
"$",
"autoIncrementFieldName",
",",
"$",
"autoIncrementFieldType",
")",
";",
"}",
"}",
"$",
"db",
"->",
"commit",
"(",
")",
";",
"$",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"}",
"$",
"db",
"->",
"commit",
"(",
")",
";",
"}"
] | Applies the differences defined in $dbSchemaDiff to the database referenced by $db.
This method uses {@link convertDiffToDDL} to create SQL for the
differences and then executes the returned SQL statements on the
database handler $db.
@todo check for failed transaction
@param ezcDbHandler $db
@param ezcDbSchemaDiff $dbSchemaDiff | [
"Applies",
"the",
"differences",
"defined",
"in",
"$dbSchemaDiff",
"to",
"the",
"database",
"referenced",
"by",
"$db",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L106-L134 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.addAutoIncrementField | private function addAutoIncrementField( $db, $tableName, $autoIncrementFieldName, $autoIncrementFieldType )
{
// fetching field info from Oracle, getting column position of autoincrement field
// @apichange This code piece would become orphan, with the new
// implementation. We still need it to drop the old sequences.
// Remove until --END-- to not take care of them.
$resultArray = $db->query( "SELECT a.column_name AS field, " .
" a.column_id AS field_pos " .
"FROM user_tab_columns a " .
"WHERE a.table_name = '{$tableName}' AND a.column_name = '{$autoIncrementFieldName}'" .
"ORDER BY a.column_id" );
$resultArray->setFetchMode( PDO::FETCH_ASSOC );
if ( count( $resultArray) != 1 )
{
return;
}
$result = $resultArray->fetch();
$fieldPos = $result['field_pos'];
// emulation of autoincrement through adding sequence, trigger and constraint
$oldName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "seq" );
$oldNameTrigger = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "trg" );
$sequence = $db->query( "SELECT sequence_name FROM user_sequences WHERE sequence_name = '{$oldName}'" )->fetchAll();
if ( count( $sequence) > 0 )
{
// assuming that if the seq exists, the trigger exists too
$db->query( "DROP SEQUENCE \"{$oldName}\"" );
$db->query( "DROP TRIGGER \"{$oldNameTrigger}\"" );
}
// --END--
// New sequence names, using field names
$newName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "seq" );
$newNameTrigger = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "seq" );
// Emulation of autoincrement through adding sequence, trigger and constraint
$sequences = $db->query( "SELECT sequence_name FROM user_sequences WHERE sequence_name = '{$newName}'" )->fetchAll();
if ( count( $sequences ) > 0 )
{
$db->query( "DROP SEQUENCE \"{$newName}\"" );
}
$db->exec( "CREATE SEQUENCE \"{$newName}\" start with 1 increment by 1 nomaxvalue" );
$db->exec( "CREATE OR REPLACE TRIGGER \"{$newNameTrigger}\" ".
"before insert on \"{$tableName}\" for each row ".
"begin ".
"select \"{$newName}\".nextval into :new.\"{$autoIncrementFieldName}\" from dual; ".
"end;" );
$constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey" );
$constraint = $db->query( "SELECT constraint_name FROM user_cons_columns WHERE constraint_name = '{$constraintName}'" )->fetchAll();
if ( count( $constraint) > 0 )
{
$db->query( "ALTER TABLE \"$tableName\" DROP CONSTRAINT \"{$constraintName}\"" );
}
$db->exec( "ALTER TABLE \"{$tableName}\" ADD CONSTRAINT \"{$constraintName}\" PRIMARY KEY ( \"{$autoIncrementFieldName}\" )" );
$this->context['skip_primary'] = true;
} | php | private function addAutoIncrementField( $db, $tableName, $autoIncrementFieldName, $autoIncrementFieldType )
{
// fetching field info from Oracle, getting column position of autoincrement field
// @apichange This code piece would become orphan, with the new
// implementation. We still need it to drop the old sequences.
// Remove until --END-- to not take care of them.
$resultArray = $db->query( "SELECT a.column_name AS field, " .
" a.column_id AS field_pos " .
"FROM user_tab_columns a " .
"WHERE a.table_name = '{$tableName}' AND a.column_name = '{$autoIncrementFieldName}'" .
"ORDER BY a.column_id" );
$resultArray->setFetchMode( PDO::FETCH_ASSOC );
if ( count( $resultArray) != 1 )
{
return;
}
$result = $resultArray->fetch();
$fieldPos = $result['field_pos'];
// emulation of autoincrement through adding sequence, trigger and constraint
$oldName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "seq" );
$oldNameTrigger = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "trg" );
$sequence = $db->query( "SELECT sequence_name FROM user_sequences WHERE sequence_name = '{$oldName}'" )->fetchAll();
if ( count( $sequence) > 0 )
{
// assuming that if the seq exists, the trigger exists too
$db->query( "DROP SEQUENCE \"{$oldName}\"" );
$db->query( "DROP TRIGGER \"{$oldNameTrigger}\"" );
}
// --END--
// New sequence names, using field names
$newName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "seq" );
$newNameTrigger = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldPos, "seq" );
// Emulation of autoincrement through adding sequence, trigger and constraint
$sequences = $db->query( "SELECT sequence_name FROM user_sequences WHERE sequence_name = '{$newName}'" )->fetchAll();
if ( count( $sequences ) > 0 )
{
$db->query( "DROP SEQUENCE \"{$newName}\"" );
}
$db->exec( "CREATE SEQUENCE \"{$newName}\" start with 1 increment by 1 nomaxvalue" );
$db->exec( "CREATE OR REPLACE TRIGGER \"{$newNameTrigger}\" ".
"before insert on \"{$tableName}\" for each row ".
"begin ".
"select \"{$newName}\".nextval into :new.\"{$autoIncrementFieldName}\" from dual; ".
"end;" );
$constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey" );
$constraint = $db->query( "SELECT constraint_name FROM user_cons_columns WHERE constraint_name = '{$constraintName}'" )->fetchAll();
if ( count( $constraint) > 0 )
{
$db->query( "ALTER TABLE \"$tableName\" DROP CONSTRAINT \"{$constraintName}\"" );
}
$db->exec( "ALTER TABLE \"{$tableName}\" ADD CONSTRAINT \"{$constraintName}\" PRIMARY KEY ( \"{$autoIncrementFieldName}\" )" );
$this->context['skip_primary'] = true;
} | [
"private",
"function",
"addAutoIncrementField",
"(",
"$",
"db",
",",
"$",
"tableName",
",",
"$",
"autoIncrementFieldName",
",",
"$",
"autoIncrementFieldType",
")",
"{",
"// fetching field info from Oracle, getting column position of autoincrement field",
"// @apichange This code piece would become orphan, with the new ",
"// implementation. We still need it to drop the old sequences.",
"// Remove until --END-- to not take care of them.",
"$",
"resultArray",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT a.column_name AS field, \"",
".",
"\" a.column_id AS field_pos \"",
".",
"\"FROM user_tab_columns a \"",
".",
"\"WHERE a.table_name = '{$tableName}' AND a.column_name = '{$autoIncrementFieldName}'\"",
".",
"\"ORDER BY a.column_id\"",
")",
";",
"$",
"resultArray",
"->",
"setFetchMode",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"if",
"(",
"count",
"(",
"$",
"resultArray",
")",
"!=",
"1",
")",
"{",
"return",
";",
"}",
"$",
"result",
"=",
"$",
"resultArray",
"->",
"fetch",
"(",
")",
";",
"$",
"fieldPos",
"=",
"$",
"result",
"[",
"'field_pos'",
"]",
";",
"// emulation of autoincrement through adding sequence, trigger and constraint",
"$",
"oldName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"tableName",
",",
"$",
"fieldPos",
",",
"\"seq\"",
")",
";",
"$",
"oldNameTrigger",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"tableName",
",",
"$",
"fieldPos",
",",
"\"trg\"",
")",
";",
"$",
"sequence",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT sequence_name FROM user_sequences WHERE sequence_name = '{$oldName}'\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"sequence",
")",
">",
"0",
")",
"{",
"// assuming that if the seq exists, the trigger exists too",
"$",
"db",
"->",
"query",
"(",
"\"DROP SEQUENCE \\\"{$oldName}\\\"\"",
")",
";",
"$",
"db",
"->",
"query",
"(",
"\"DROP TRIGGER \\\"{$oldNameTrigger}\\\"\"",
")",
";",
"}",
"// --END--",
"// New sequence names, using field names",
"$",
"newName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"tableName",
",",
"$",
"fieldPos",
",",
"\"seq\"",
")",
";",
"$",
"newNameTrigger",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"tableName",
",",
"$",
"fieldPos",
",",
"\"seq\"",
")",
";",
"// Emulation of autoincrement through adding sequence, trigger and constraint",
"$",
"sequences",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT sequence_name FROM user_sequences WHERE sequence_name = '{$newName}'\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"sequences",
")",
">",
"0",
")",
"{",
"$",
"db",
"->",
"query",
"(",
"\"DROP SEQUENCE \\\"{$newName}\\\"\"",
")",
";",
"}",
"$",
"db",
"->",
"exec",
"(",
"\"CREATE SEQUENCE \\\"{$newName}\\\" start with 1 increment by 1 nomaxvalue\"",
")",
";",
"$",
"db",
"->",
"exec",
"(",
"\"CREATE OR REPLACE TRIGGER \\\"{$newNameTrigger}\\\" \"",
".",
"\"before insert on \\\"{$tableName}\\\" for each row \"",
".",
"\"begin \"",
".",
"\"select \\\"{$newName}\\\".nextval into :new.\\\"{$autoIncrementFieldName}\\\" from dual; \"",
".",
"\"end;\"",
")",
";",
"$",
"constraintName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixedIdentName",
"(",
"array",
"(",
"$",
"tableName",
")",
",",
"\"pkey\"",
")",
";",
"$",
"constraint",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT constraint_name FROM user_cons_columns WHERE constraint_name = '{$constraintName}'\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"constraint",
")",
">",
"0",
")",
"{",
"$",
"db",
"->",
"query",
"(",
"\"ALTER TABLE \\\"$tableName\\\" DROP CONSTRAINT \\\"{$constraintName}\\\"\"",
")",
";",
"}",
"$",
"db",
"->",
"exec",
"(",
"\"ALTER TABLE \\\"{$tableName}\\\" ADD CONSTRAINT \\\"{$constraintName}\\\" PRIMARY KEY ( \\\"{$autoIncrementFieldName}\\\" )\"",
")",
";",
"$",
"this",
"->",
"context",
"[",
"'skip_primary'",
"]",
"=",
"true",
";",
"}"
] | Performs changing field in Oracle table.
(workaround for "ALTER TABLE table MODIFY field fieldType AUTO_INCREMENT " that not alowed in Oracle ).
@param ezcDbHandler $db
@param string $tableName
@param string $autoIncrementFieldName
@param string $autoIncrementFieldType | [
"Performs",
"changing",
"field",
"in",
"Oracle",
"table",
".",
"(",
"workaround",
"for",
"ALTER",
"TABLE",
"table",
"MODIFY",
"field",
"fieldType",
"AUTO_INCREMENT",
"that",
"not",
"alowed",
"in",
"Oracle",
")",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L145-L204 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.convertDiffToDDL | public function convertDiffToDDL( ezcDbSchemaDiff $dbSchemaDiff, ezcDbHandler $db = null )
{
$this->diffSchema = $dbSchemaDiff;
// reset queries
$this->queries = array();
$this->context = array();
// Find sequences which require explicit drop statesments, see bug
// #16222
if ( $db !== null )
{
$this->generateAdditionalDropSequenceStatements( $dbSchemaDiff, $db );
}
$this->generateDiffSchemaAsSql();
return $this->queries;
} | php | public function convertDiffToDDL( ezcDbSchemaDiff $dbSchemaDiff, ezcDbHandler $db = null )
{
$this->diffSchema = $dbSchemaDiff;
// reset queries
$this->queries = array();
$this->context = array();
// Find sequences which require explicit drop statesments, see bug
// #16222
if ( $db !== null )
{
$this->generateAdditionalDropSequenceStatements( $dbSchemaDiff, $db );
}
$this->generateDiffSchemaAsSql();
return $this->queries;
} | [
"public",
"function",
"convertDiffToDDL",
"(",
"ezcDbSchemaDiff",
"$",
"dbSchemaDiff",
",",
"ezcDbHandler",
"$",
"db",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"diffSchema",
"=",
"$",
"dbSchemaDiff",
";",
"// reset queries",
"$",
"this",
"->",
"queries",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"context",
"=",
"array",
"(",
")",
";",
"// Find sequences which require explicit drop statesments, see bug ",
"// #16222",
"if",
"(",
"$",
"db",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"generateAdditionalDropSequenceStatements",
"(",
"$",
"dbSchemaDiff",
",",
"$",
"db",
")",
";",
"}",
"$",
"this",
"->",
"generateDiffSchemaAsSql",
"(",
")",
";",
"return",
"$",
"this",
"->",
"queries",
";",
"}"
] | Returns the differences definition in $dbSchema as database specific SQL DDL queries.
@param ezcDbSchemaDiff $dbSchemaDiff
@param ezcDbHandler $db
@return array(string) | [
"Returns",
"the",
"differences",
"definition",
"in",
"$dbSchema",
"as",
"database",
"specific",
"SQL",
"DDL",
"queries",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L214-L231 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.generateAdditionalDropSequenceStatements | protected function generateAdditionalDropSequenceStatements( ezcDbSchemaDiff $dbSchemaDiff, ezcDbHandler $db )
{
$reader = new ezcDbSchemaOracleReader();
$schema = $reader->loadFromDb( $db )->getSchema();
foreach ( $dbSchemaDiff->removedTables as $table => $true )
{
foreach ( $schema[$table]->fields as $name => $field )
{
if ( $field->autoIncrement !== true )
{
continue;
}
$seqName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $table, $name, "seq" );
if ( strpos( $seqName, $table ) !== 0 )
{
$this->queries[] = "DROP SEQUENCE \"$seqName\"";
}
}
}
} | php | protected function generateAdditionalDropSequenceStatements( ezcDbSchemaDiff $dbSchemaDiff, ezcDbHandler $db )
{
$reader = new ezcDbSchemaOracleReader();
$schema = $reader->loadFromDb( $db )->getSchema();
foreach ( $dbSchemaDiff->removedTables as $table => $true )
{
foreach ( $schema[$table]->fields as $name => $field )
{
if ( $field->autoIncrement !== true )
{
continue;
}
$seqName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $table, $name, "seq" );
if ( strpos( $seqName, $table ) !== 0 )
{
$this->queries[] = "DROP SEQUENCE \"$seqName\"";
}
}
}
} | [
"protected",
"function",
"generateAdditionalDropSequenceStatements",
"(",
"ezcDbSchemaDiff",
"$",
"dbSchemaDiff",
",",
"ezcDbHandler",
"$",
"db",
")",
"{",
"$",
"reader",
"=",
"new",
"ezcDbSchemaOracleReader",
"(",
")",
";",
"$",
"schema",
"=",
"$",
"reader",
"->",
"loadFromDb",
"(",
"$",
"db",
")",
"->",
"getSchema",
"(",
")",
";",
"foreach",
"(",
"$",
"dbSchemaDiff",
"->",
"removedTables",
"as",
"$",
"table",
"=>",
"$",
"true",
")",
"{",
"foreach",
"(",
"$",
"schema",
"[",
"$",
"table",
"]",
"->",
"fields",
"as",
"$",
"name",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"autoIncrement",
"!==",
"true",
")",
"{",
"continue",
";",
"}",
"$",
"seqName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"table",
",",
"$",
"name",
",",
"\"seq\"",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"seqName",
",",
"$",
"table",
")",
"!==",
"0",
")",
"{",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"\"DROP SEQUENCE \\\"$seqName\\\"\"",
";",
"}",
"}",
"}",
"}"
] | Generate additional drop sequence statements
Some sequences might not be dropped automatically, this method generates
additional DROP SEQUENCE queries for those.
Since Oracle only allows sequence identifiers up to 30 characters
sequences for long table / column names may be shortened. In this case
the sequence name does not started with the table name any more, thus
does not get dropped together with the table automatically.
This method requires a DB connection to check which sequences have been
defined in the database, because the information about fields is not
available otherwise.
@param ezcDbSchemaDiff $dbSchemaDiff
@param ezcDbHandler $db
@return void | [
"Generate",
"additional",
"drop",
"sequence",
"statements"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L252-L272 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.convertFromGenericType | protected function convertFromGenericType( ezcDbSchemaField $fieldDefinition )
{
$typeAddition = '';
if ( in_array( $fieldDefinition->type, array( 'decimal', 'text' ) ) )
{
if ( $fieldDefinition->length !== false && $fieldDefinition->length !== 0 )
{
$typeAddition = "({$fieldDefinition->length})";
}
else
{
$typeAddition = "(4000)"; // default length for varchar2 in Oracle
}
}
if ( $fieldDefinition->type == 'boolean' )
{
$typeAddition = "(1)";
if ( $fieldDefinition->default )
{
$fieldDefinition->default = ( $fieldDefinition->default == 'true' ) ? '1': '0';
}
}
if ( !isset( $this->typeMap[$fieldDefinition->type] ) )
{
throw new ezcDbSchemaUnsupportedTypeException( 'Oracle', $fieldDefinition->type );
}
$type = $this->typeMap[$fieldDefinition->type];
return "$type$typeAddition";
} | php | protected function convertFromGenericType( ezcDbSchemaField $fieldDefinition )
{
$typeAddition = '';
if ( in_array( $fieldDefinition->type, array( 'decimal', 'text' ) ) )
{
if ( $fieldDefinition->length !== false && $fieldDefinition->length !== 0 )
{
$typeAddition = "({$fieldDefinition->length})";
}
else
{
$typeAddition = "(4000)"; // default length for varchar2 in Oracle
}
}
if ( $fieldDefinition->type == 'boolean' )
{
$typeAddition = "(1)";
if ( $fieldDefinition->default )
{
$fieldDefinition->default = ( $fieldDefinition->default == 'true' ) ? '1': '0';
}
}
if ( !isset( $this->typeMap[$fieldDefinition->type] ) )
{
throw new ezcDbSchemaUnsupportedTypeException( 'Oracle', $fieldDefinition->type );
}
$type = $this->typeMap[$fieldDefinition->type];
return "$type$typeAddition";
} | [
"protected",
"function",
"convertFromGenericType",
"(",
"ezcDbSchemaField",
"$",
"fieldDefinition",
")",
"{",
"$",
"typeAddition",
"=",
"''",
";",
"if",
"(",
"in_array",
"(",
"$",
"fieldDefinition",
"->",
"type",
",",
"array",
"(",
"'decimal'",
",",
"'text'",
")",
")",
")",
"{",
"if",
"(",
"$",
"fieldDefinition",
"->",
"length",
"!==",
"false",
"&&",
"$",
"fieldDefinition",
"->",
"length",
"!==",
"0",
")",
"{",
"$",
"typeAddition",
"=",
"\"({$fieldDefinition->length})\"",
";",
"}",
"else",
"{",
"$",
"typeAddition",
"=",
"\"(4000)\"",
";",
"// default length for varchar2 in Oracle",
"}",
"}",
"if",
"(",
"$",
"fieldDefinition",
"->",
"type",
"==",
"'boolean'",
")",
"{",
"$",
"typeAddition",
"=",
"\"(1)\"",
";",
"if",
"(",
"$",
"fieldDefinition",
"->",
"default",
")",
"{",
"$",
"fieldDefinition",
"->",
"default",
"=",
"(",
"$",
"fieldDefinition",
"->",
"default",
"==",
"'true'",
")",
"?",
"'1'",
":",
"'0'",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"typeMap",
"[",
"$",
"fieldDefinition",
"->",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"ezcDbSchemaUnsupportedTypeException",
"(",
"'Oracle'",
",",
"$",
"fieldDefinition",
"->",
"type",
")",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"typeMap",
"[",
"$",
"fieldDefinition",
"->",
"type",
"]",
";",
"return",
"\"$type$typeAddition\"",
";",
"}"
] | Converts the generic field type contained in $fieldDefinition to a database specific field definition.
@param ezcDbSchemaField $fieldDefinition
@return string | [
"Converts",
"the",
"generic",
"field",
"type",
"contained",
"in",
"$fieldDefinition",
"to",
"a",
"database",
"specific",
"field",
"definition",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L290-L320 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.generateCreateTableSql | protected function generateCreateTableSql( $tableName, ezcDbSchemaTable $tableDefinition )
{
$sql = '';
$sql .= "CREATE TABLE \"{$tableName}\" (\n";
$this->context['skip_primary'] = false;
// dump fields
$fieldsSQL = array();
$autoincrementSQL = array();
$fieldCounter = 1;
foreach ( $tableDefinition->fields as $fieldName => $fieldDefinition )
{
$fieldsSQL[] = "\t" . $this->generateFieldSql( $fieldName, $fieldDefinition );
if ( $fieldDefinition->autoIncrement && !$this->context['skip_primary'] )
{
$sequenceName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldName, "seq" );
$triggerName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldName, "trg" );
$constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey" );
$autoincrementSQL[] = "CREATE SEQUENCE \"{$sequenceName}\" start with 1 increment by 1 nomaxvalue";
$autoincrementSQL[] = "CREATE OR REPLACE TRIGGER \"{$triggerName}\" ".
"before insert on \"{$tableName}\" for each row ".
"begin ".
"select \"{$sequenceName}\".nextval into :new.\"{$fieldName}\" from dual; ".
"end;";
$autoincrementSQL[] = "ALTER TABLE \"{$tableName}\" ADD CONSTRAINT \"{$constraintName}\" PRIMARY KEY ( \"{$fieldName}\" )";
$this->context['skip_primary'] = true;
}
$fieldCounter++;
}
$sql .= join( ",\n", $fieldsSQL );
$sql .= "\n)";
$this->queries[] = $sql;
if ( count( $autoincrementSQL ) > 0 ) // adding autoincrement emulation queries if exists
{
$this->queries = array_merge( $this->queries, $autoincrementSQL );
}
// dump indexes
foreach ( $tableDefinition->indexes as $indexName => $indexDefinition)
{
$fieldsSQL[] = $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition );
}
} | php | protected function generateCreateTableSql( $tableName, ezcDbSchemaTable $tableDefinition )
{
$sql = '';
$sql .= "CREATE TABLE \"{$tableName}\" (\n";
$this->context['skip_primary'] = false;
// dump fields
$fieldsSQL = array();
$autoincrementSQL = array();
$fieldCounter = 1;
foreach ( $tableDefinition->fields as $fieldName => $fieldDefinition )
{
$fieldsSQL[] = "\t" . $this->generateFieldSql( $fieldName, $fieldDefinition );
if ( $fieldDefinition->autoIncrement && !$this->context['skip_primary'] )
{
$sequenceName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldName, "seq" );
$triggerName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $tableName, $fieldName, "trg" );
$constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey" );
$autoincrementSQL[] = "CREATE SEQUENCE \"{$sequenceName}\" start with 1 increment by 1 nomaxvalue";
$autoincrementSQL[] = "CREATE OR REPLACE TRIGGER \"{$triggerName}\" ".
"before insert on \"{$tableName}\" for each row ".
"begin ".
"select \"{$sequenceName}\".nextval into :new.\"{$fieldName}\" from dual; ".
"end;";
$autoincrementSQL[] = "ALTER TABLE \"{$tableName}\" ADD CONSTRAINT \"{$constraintName}\" PRIMARY KEY ( \"{$fieldName}\" )";
$this->context['skip_primary'] = true;
}
$fieldCounter++;
}
$sql .= join( ",\n", $fieldsSQL );
$sql .= "\n)";
$this->queries[] = $sql;
if ( count( $autoincrementSQL ) > 0 ) // adding autoincrement emulation queries if exists
{
$this->queries = array_merge( $this->queries, $autoincrementSQL );
}
// dump indexes
foreach ( $tableDefinition->indexes as $indexName => $indexDefinition)
{
$fieldsSQL[] = $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition );
}
} | [
"protected",
"function",
"generateCreateTableSql",
"(",
"$",
"tableName",
",",
"ezcDbSchemaTable",
"$",
"tableDefinition",
")",
"{",
"$",
"sql",
"=",
"''",
";",
"$",
"sql",
".=",
"\"CREATE TABLE \\\"{$tableName}\\\" (\\n\"",
";",
"$",
"this",
"->",
"context",
"[",
"'skip_primary'",
"]",
"=",
"false",
";",
"// dump fields",
"$",
"fieldsSQL",
"=",
"array",
"(",
")",
";",
"$",
"autoincrementSQL",
"=",
"array",
"(",
")",
";",
"$",
"fieldCounter",
"=",
"1",
";",
"foreach",
"(",
"$",
"tableDefinition",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldDefinition",
")",
"{",
"$",
"fieldsSQL",
"[",
"]",
"=",
"\"\\t\"",
".",
"$",
"this",
"->",
"generateFieldSql",
"(",
"$",
"fieldName",
",",
"$",
"fieldDefinition",
")",
";",
"if",
"(",
"$",
"fieldDefinition",
"->",
"autoIncrement",
"&&",
"!",
"$",
"this",
"->",
"context",
"[",
"'skip_primary'",
"]",
")",
"{",
"$",
"sequenceName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"tableName",
",",
"$",
"fieldName",
",",
"\"seq\"",
")",
";",
"$",
"triggerName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"tableName",
",",
"$",
"fieldName",
",",
"\"trg\"",
")",
";",
"$",
"constraintName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixedIdentName",
"(",
"array",
"(",
"$",
"tableName",
")",
",",
"\"pkey\"",
")",
";",
"$",
"autoincrementSQL",
"[",
"]",
"=",
"\"CREATE SEQUENCE \\\"{$sequenceName}\\\" start with 1 increment by 1 nomaxvalue\"",
";",
"$",
"autoincrementSQL",
"[",
"]",
"=",
"\"CREATE OR REPLACE TRIGGER \\\"{$triggerName}\\\" \"",
".",
"\"before insert on \\\"{$tableName}\\\" for each row \"",
".",
"\"begin \"",
".",
"\"select \\\"{$sequenceName}\\\".nextval into :new.\\\"{$fieldName}\\\" from dual; \"",
".",
"\"end;\"",
";",
"$",
"autoincrementSQL",
"[",
"]",
"=",
"\"ALTER TABLE \\\"{$tableName}\\\" ADD CONSTRAINT \\\"{$constraintName}\\\" PRIMARY KEY ( \\\"{$fieldName}\\\" )\"",
";",
"$",
"this",
"->",
"context",
"[",
"'skip_primary'",
"]",
"=",
"true",
";",
"}",
"$",
"fieldCounter",
"++",
";",
"}",
"$",
"sql",
".=",
"join",
"(",
"\",\\n\"",
",",
"$",
"fieldsSQL",
")",
";",
"$",
"sql",
".=",
"\"\\n)\"",
";",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"$",
"sql",
";",
"if",
"(",
"count",
"(",
"$",
"autoincrementSQL",
")",
">",
"0",
")",
"// adding autoincrement emulation queries if exists",
"{",
"$",
"this",
"->",
"queries",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"queries",
",",
"$",
"autoincrementSQL",
")",
";",
"}",
"// dump indexes",
"foreach",
"(",
"$",
"tableDefinition",
"->",
"indexes",
"as",
"$",
"indexName",
"=>",
"$",
"indexDefinition",
")",
"{",
"$",
"fieldsSQL",
"[",
"]",
"=",
"$",
"this",
"->",
"generateAddIndexSql",
"(",
"$",
"tableName",
",",
"$",
"indexName",
",",
"$",
"indexDefinition",
")",
";",
"}",
"}"
] | Adds a "create table" query for the table $tableName with
definition $tableDefinition to the internal list of queries.
Adds additional CREATE queries for sequences and triggers
to implement autoincrement fields that not supported in Oracle directly.
@param string $tableName
@param ezcDbSchemaTable $tableDefinition | [
"Adds",
"a",
"create",
"table",
"query",
"for",
"the",
"table",
"$tableName",
"with",
"definition",
"$tableDefinition",
"to",
"the",
"internal",
"list",
"of",
"queries",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L332-L379 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.generateChangeFieldSql | protected function generateChangeFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
{
if ( !$fieldDefinition->autoIncrement )
{
$this->queries[] = "ALTER TABLE \"$tableName\" MODIFY " .
$this->generateFieldSql( $fieldName, $fieldDefinition );
}
else
{ // mark query to make autoincrement emulation when executing
$this->queries[] = "ALTER TABLE \"$tableName\" MODIFY " .
$this->generateFieldSql( $fieldName, $fieldDefinition ) .
" AUTO_INCREMENT";
}
} | php | protected function generateChangeFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
{
if ( !$fieldDefinition->autoIncrement )
{
$this->queries[] = "ALTER TABLE \"$tableName\" MODIFY " .
$this->generateFieldSql( $fieldName, $fieldDefinition );
}
else
{ // mark query to make autoincrement emulation when executing
$this->queries[] = "ALTER TABLE \"$tableName\" MODIFY " .
$this->generateFieldSql( $fieldName, $fieldDefinition ) .
" AUTO_INCREMENT";
}
} | [
"protected",
"function",
"generateChangeFieldSql",
"(",
"$",
"tableName",
",",
"$",
"fieldName",
",",
"ezcDbSchemaField",
"$",
"fieldDefinition",
")",
"{",
"if",
"(",
"!",
"$",
"fieldDefinition",
"->",
"autoIncrement",
")",
"{",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"\"ALTER TABLE \\\"$tableName\\\" MODIFY \"",
".",
"$",
"this",
"->",
"generateFieldSql",
"(",
"$",
"fieldName",
",",
"$",
"fieldDefinition",
")",
";",
"}",
"else",
"{",
"// mark query to make autoincrement emulation when executing",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"\"ALTER TABLE \\\"$tableName\\\" MODIFY \"",
".",
"$",
"this",
"->",
"generateFieldSql",
"(",
"$",
"fieldName",
",",
"$",
"fieldDefinition",
")",
".",
"\" AUTO_INCREMENT\"",
";",
"}",
"}"
] | Adds a "alter table" query to change the field $fieldName to $tableName with the definition $fieldDefinition.
@param string $tableName
@param string $fieldName
@param ezcDbSchemaField $fieldDefinition | [
"Adds",
"a",
"alter",
"table",
"query",
"to",
"change",
"the",
"field",
"$fieldName",
"to",
"$tableName",
"with",
"the",
"definition",
"$fieldDefinition",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L418-L431 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php | ezcDbSchemaOracleWriter.generateDropIndexSql | protected function generateDropIndexSql( $tableName, $indexName )
{
if ( $indexName == 'primary' ) // handling primary indexes
{
$constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey");
$this->queries[] = "ALTER TABLE \"$tableName\" DROP CONSTRAINT \"{$constraintName}\"";
}
else
{
$this->queries[] = "DROP INDEX \"$indexName\"";
}
} | php | protected function generateDropIndexSql( $tableName, $indexName )
{
if ( $indexName == 'primary' ) // handling primary indexes
{
$constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey");
$this->queries[] = "ALTER TABLE \"$tableName\" DROP CONSTRAINT \"{$constraintName}\"";
}
else
{
$this->queries[] = "DROP INDEX \"$indexName\"";
}
} | [
"protected",
"function",
"generateDropIndexSql",
"(",
"$",
"tableName",
",",
"$",
"indexName",
")",
"{",
"if",
"(",
"$",
"indexName",
"==",
"'primary'",
")",
"// handling primary indexes",
"{",
"$",
"constraintName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixedIdentName",
"(",
"array",
"(",
"$",
"tableName",
")",
",",
"\"pkey\"",
")",
";",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"\"ALTER TABLE \\\"$tableName\\\" DROP CONSTRAINT \\\"{$constraintName}\\\"\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"\"DROP INDEX \\\"$indexName\\\"\"",
";",
"}",
"}"
] | Adds a "alter table" query to remote the index $indexName from the table $tableName to the internal list of queries.
@param string $tableName
@param string $indexName | [
"Adds",
"a",
"alter",
"table",
"query",
"to",
"remote",
"the",
"index",
"$indexName",
"from",
"the",
"table",
"$tableName",
"to",
"the",
"internal",
"list",
"of",
"queries",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L548-L559 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveApi | public function resolveApi()
{
return !isset($this->cache[$key = 'api'])
? $this->cache[$key] = $this->parameterResolver->resolveApi()
: $this->cache[$key];
} | php | public function resolveApi()
{
return !isset($this->cache[$key = 'api'])
? $this->cache[$key] = $this->parameterResolver->resolveApi()
: $this->cache[$key];
} | [
"public",
"function",
"resolveApi",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'api'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveApi",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L42-L47 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveCriteria | public function resolveCriteria($mandatory = false)
{
if (isset($this->cache[$key = 'criteria'])) {
$criteria = $this->cache[$key];
if (!empty($criteria) || !$mandatory) {
return $criteria;
}
}
return $this->cache[$key] = $this->parameterResolver->resolveCriteria($mandatory);
} | php | public function resolveCriteria($mandatory = false)
{
if (isset($this->cache[$key = 'criteria'])) {
$criteria = $this->cache[$key];
if (!empty($criteria) || !$mandatory) {
return $criteria;
}
}
return $this->cache[$key] = $this->parameterResolver->resolveCriteria($mandatory);
} | [
"public",
"function",
"resolveCriteria",
"(",
"$",
"mandatory",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'criteria'",
"]",
")",
")",
"{",
"$",
"criteria",
"=",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
")",
"||",
"!",
"$",
"mandatory",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveCriteria",
"(",
"$",
"mandatory",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L52-L63 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveCurrentPage | public function resolveCurrentPage()
{
return !isset($this->cache[$key = 'current_page'])
? $this->cache[$key] = $this->parameterResolver->resolveCurrentPage()
: $this->cache[$key];
} | php | public function resolveCurrentPage()
{
return !isset($this->cache[$key = 'current_page'])
? $this->cache[$key] = $this->parameterResolver->resolveCurrentPage()
: $this->cache[$key];
} | [
"public",
"function",
"resolveCurrentPage",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'current_page'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveCurrentPage",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L68-L73 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveForm | public function resolveForm(ResourceInterface $resource)
{
return !isset($this->cache[$key = 'form_'.spl_object_hash($resource)])
? $this->cache[$key] = $this->parameterResolver->resolveForm($resource)
: $this->cache[$key];
} | php | public function resolveForm(ResourceInterface $resource)
{
return !isset($this->cache[$key = 'form_'.spl_object_hash($resource)])
? $this->cache[$key] = $this->parameterResolver->resolveForm($resource)
: $this->cache[$key];
} | [
"public",
"function",
"resolveForm",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'form_'",
".",
"spl_object_hash",
"(",
"$",
"resource",
")",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveForm",
"(",
"$",
"resource",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L78-L83 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveHateoas | public function resolveHateoas()
{
return !isset($this->cache[$key = 'hateoas'])
? $this->cache[$key] = $this->parameterResolver->resolveHateoas()
: $this->cache[$key];
} | php | public function resolveHateoas()
{
return !isset($this->cache[$key = 'hateoas'])
? $this->cache[$key] = $this->parameterResolver->resolveHateoas()
: $this->cache[$key];
} | [
"public",
"function",
"resolveHateoas",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'hateoas'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveHateoas",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L98-L103 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveLocationRoute | public function resolveLocationRoute()
{
return !isset($this->cache[$key = 'location_route'])
? $this->cache[$key] = $this->parameterResolver->resolveLocationRoute()
: $this->cache[$key];
} | php | public function resolveLocationRoute()
{
return !isset($this->cache[$key = 'location_route'])
? $this->cache[$key] = $this->parameterResolver->resolveLocationRoute()
: $this->cache[$key];
} | [
"public",
"function",
"resolveLocationRoute",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'location_route'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveLocationRoute",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L108-L113 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveLocationRouteParameters | public function resolveLocationRouteParameters($object)
{
return !isset($this->cache[$key = 'location_route_parameters_'.spl_object_hash($object)])
? $this->cache[$key] = $this->parameterResolver->resolveLocationRouteParameters($object)
: $this->cache[$key];
} | php | public function resolveLocationRouteParameters($object)
{
return !isset($this->cache[$key = 'location_route_parameters_'.spl_object_hash($object)])
? $this->cache[$key] = $this->parameterResolver->resolveLocationRouteParameters($object)
: $this->cache[$key];
} | [
"public",
"function",
"resolveLocationRouteParameters",
"(",
"$",
"object",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'location_route_parameters_'",
".",
"spl_object_hash",
"(",
"$",
"object",
")",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveLocationRouteParameters",
"(",
"$",
"object",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L118-L123 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveMaxPerPage | public function resolveMaxPerPage()
{
return !isset($this->cache[$key = 'max_per_page'])
? $this->cache[$key] = $this->parameterResolver->resolveMaxPerPage()
: $this->cache[$key];
} | php | public function resolveMaxPerPage()
{
return !isset($this->cache[$key = 'max_per_page'])
? $this->cache[$key] = $this->parameterResolver->resolveMaxPerPage()
: $this->cache[$key];
} | [
"public",
"function",
"resolveMaxPerPage",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'max_per_page'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveMaxPerPage",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L128-L133 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveRedirectRoute | public function resolveRedirectRoute()
{
return !isset($this->cache[$key = 'redirect_route'])
? $this->cache[$key] = $this->parameterResolver->resolveRedirectRoute()
: $this->cache[$key];
} | php | public function resolveRedirectRoute()
{
return !isset($this->cache[$key = 'redirect_route'])
? $this->cache[$key] = $this->parameterResolver->resolveRedirectRoute()
: $this->cache[$key];
} | [
"public",
"function",
"resolveRedirectRoute",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'redirect_route'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveRedirectRoute",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L138-L143 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveRedirectRouteParameters | public function resolveRedirectRouteParameters($object = null, $forwardParameters = false)
{
$key = 'redirect_route_parameters';
if ($object !== null) {
$key .= '_'.spl_object_hash($object);
}
if ($forwardParameters) {
$key .= '_forward';
}
return isset($this->cache[$key])
? $this->cache[$key]
: $this->cache[$key] = $this->parameterResolver->resolveRedirectRouteParameters(
$object,
$forwardParameters
);
} | php | public function resolveRedirectRouteParameters($object = null, $forwardParameters = false)
{
$key = 'redirect_route_parameters';
if ($object !== null) {
$key .= '_'.spl_object_hash($object);
}
if ($forwardParameters) {
$key .= '_forward';
}
return isset($this->cache[$key])
? $this->cache[$key]
: $this->cache[$key] = $this->parameterResolver->resolveRedirectRouteParameters(
$object,
$forwardParameters
);
} | [
"public",
"function",
"resolveRedirectRouteParameters",
"(",
"$",
"object",
"=",
"null",
",",
"$",
"forwardParameters",
"=",
"false",
")",
"{",
"$",
"key",
"=",
"'redirect_route_parameters'",
";",
"if",
"(",
"$",
"object",
"!==",
"null",
")",
"{",
"$",
"key",
".=",
"'_'",
".",
"spl_object_hash",
"(",
"$",
"object",
")",
";",
"}",
"if",
"(",
"$",
"forwardParameters",
")",
"{",
"$",
"key",
".=",
"'_forward'",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveRedirectRouteParameters",
"(",
"$",
"object",
",",
"$",
"forwardParameters",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L148-L166 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveRepositoryMethod | public function resolveRepositoryMethod($action)
{
return !isset($this->cache[$key = 'repository_method_'.$action])
? $this->cache[$key] = $this->parameterResolver->resolveRepositoryMethod($action)
: $this->cache[$key];
} | php | public function resolveRepositoryMethod($action)
{
return !isset($this->cache[$key = 'repository_method_'.$action])
? $this->cache[$key] = $this->parameterResolver->resolveRepositoryMethod($action)
: $this->cache[$key];
} | [
"public",
"function",
"resolveRepositoryMethod",
"(",
"$",
"action",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'repository_method_'",
".",
"$",
"action",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveRepositoryMethod",
"(",
"$",
"action",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L181-L186 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveSerializerGroups | public function resolveSerializerGroups()
{
return !isset($this->cache[$key = 'serializer_groups'])
? $this->cache[$key] = $this->parameterResolver->resolveSerializerGroups()
: $this->cache[$key];
} | php | public function resolveSerializerGroups()
{
return !isset($this->cache[$key = 'serializer_groups'])
? $this->cache[$key] = $this->parameterResolver->resolveSerializerGroups()
: $this->cache[$key];
} | [
"public",
"function",
"resolveSerializerGroups",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'serializer_groups'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveSerializerGroups",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L191-L196 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveSerializerNull | public function resolveSerializerNull()
{
return !isset($this->cache[$key = 'serializer_null'])
? $this->cache[$key] = $this->parameterResolver->resolveSerializerNull()
: $this->cache[$key];
} | php | public function resolveSerializerNull()
{
return !isset($this->cache[$key = 'serializer_null'])
? $this->cache[$key] = $this->parameterResolver->resolveSerializerNull()
: $this->cache[$key];
} | [
"public",
"function",
"resolveSerializerNull",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'serializer_null'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveSerializerNull",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L201-L206 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveSorting | public function resolveSorting()
{
return !isset($this->cache[$key = 'sorting'])
? $this->cache[$key] = $this->parameterResolver->resolveSorting()
: $this->cache[$key];
} | php | public function resolveSorting()
{
return !isset($this->cache[$key = 'sorting'])
? $this->cache[$key] = $this->parameterResolver->resolveSorting()
: $this->cache[$key];
} | [
"public",
"function",
"resolveSorting",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'sorting'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveSorting",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L211-L216 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveStatusCode | public function resolveStatusCode($statusCode)
{
return !isset($this->cache[$key = 'status_code_'.$statusCode])
? $this->cache[$key] = $this->parameterResolver->resolveStatusCode($statusCode)
: $this->cache[$key];
} | php | public function resolveStatusCode($statusCode)
{
return !isset($this->cache[$key = 'status_code_'.$statusCode])
? $this->cache[$key] = $this->parameterResolver->resolveStatusCode($statusCode)
: $this->cache[$key];
} | [
"public",
"function",
"resolveStatusCode",
"(",
"$",
"statusCode",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'status_code_'",
".",
"$",
"statusCode",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveStatusCode",
"(",
"$",
"statusCode",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L221-L226 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveTemplate | public function resolveTemplate()
{
return !isset($this->cache[$key = 'template'])
? $this->cache[$key] = $this->parameterResolver->resolveTemplate()
: $this->cache[$key];
} | php | public function resolveTemplate()
{
return !isset($this->cache[$key = 'template'])
? $this->cache[$key] = $this->parameterResolver->resolveTemplate()
: $this->cache[$key];
} | [
"public",
"function",
"resolveTemplate",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'template'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveTemplate",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L231-L236 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveThemes | public function resolveThemes()
{
return !isset($this->cache[$key = 'themes'])
? $this->cache[$key] = $this->parameterResolver->resolveThemes()
: $this->cache[$key];
} | php | public function resolveThemes()
{
return !isset($this->cache[$key = 'themes'])
? $this->cache[$key] = $this->parameterResolver->resolveThemes()
: $this->cache[$key];
} | [
"public",
"function",
"resolveThemes",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'themes'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveThemes",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L241-L246 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveTranslationDomain | public function resolveTranslationDomain()
{
return !isset($this->cache[$key = 'translation_domain'])
? $this->cache[$key] = $this->parameterResolver->resolveTranslationDomain()
: $this->cache[$key];
} | php | public function resolveTranslationDomain()
{
return !isset($this->cache[$key = 'translation_domain'])
? $this->cache[$key] = $this->parameterResolver->resolveTranslationDomain()
: $this->cache[$key];
} | [
"public",
"function",
"resolveTranslationDomain",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'translation_domain'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveTranslationDomain",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L251-L256 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveValidationGroups | public function resolveValidationGroups()
{
return !isset($this->cache[$key = 'validation_groups'])
? $this->cache[$key] = $this->parameterResolver->resolveValidationGroups()
: $this->cache[$key];
} | php | public function resolveValidationGroups()
{
return !isset($this->cache[$key = 'validation_groups'])
? $this->cache[$key] = $this->parameterResolver->resolveValidationGroups()
: $this->cache[$key];
} | [
"public",
"function",
"resolveValidationGroups",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'validation_groups'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveValidationGroups",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L261-L266 |
php-lug/lug | src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php | CachedParameterResolver.resolveVoter | public function resolveVoter()
{
return !isset($this->cache[$key = 'voter'])
? $this->cache[$key] = $this->parameterResolver->resolveVoter()
: $this->cache[$key];
} | php | public function resolveVoter()
{
return !isset($this->cache[$key = 'voter'])
? $this->cache[$key] = $this->parameterResolver->resolveVoter()
: $this->cache[$key];
} | [
"public",
"function",
"resolveVoter",
"(",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"=",
"'voter'",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"parameterResolver",
"->",
"resolveVoter",
"(",
")",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/CachedParameterResolver.php#L271-L276 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.main | public function main()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'starting...');
try
{
/* Общая инициализация */
$this->checkEnvironment();
$this->createFileStructure();
/* Подключение старого ядра */
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Init legacy kernel');
include_once 'kernel-legacy.php';
/**
* @global Eresus Eresus
* @todo Обратная совместимость — удалить
* @deprecated с 3.01 используйте Eresus_Kernel::app()->getLegacyKernel()
*/
$GLOBALS['Eresus'] = new Eresus;
TemplateSettings::setGlobalValue('cms', $this);
$this->initConf();
$i18n = I18n::getInstance();
TemplateSettings::setGlobalValue('i18n', $i18n);
Eresus_CMS::getLegacyKernel()->init();
TemplateSettings::setGlobalValue('Eresus', Eresus_CMS::getLegacyKernel());
$this->runWeb();
}
catch (Exception $e)
{
Eresus_Kernel::logException($e);
ob_end_clean();
$this->fatalError($e, false);
}
return 0;
} | php | public function main()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'starting...');
try
{
/* Общая инициализация */
$this->checkEnvironment();
$this->createFileStructure();
/* Подключение старого ядра */
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Init legacy kernel');
include_once 'kernel-legacy.php';
/**
* @global Eresus Eresus
* @todo Обратная совместимость — удалить
* @deprecated с 3.01 используйте Eresus_Kernel::app()->getLegacyKernel()
*/
$GLOBALS['Eresus'] = new Eresus;
TemplateSettings::setGlobalValue('cms', $this);
$this->initConf();
$i18n = I18n::getInstance();
TemplateSettings::setGlobalValue('i18n', $i18n);
Eresus_CMS::getLegacyKernel()->init();
TemplateSettings::setGlobalValue('Eresus', Eresus_CMS::getLegacyKernel());
$this->runWeb();
}
catch (Exception $e)
{
Eresus_Kernel::logException($e);
ob_end_clean();
$this->fatalError($e, false);
}
return 0;
} | [
"public",
"function",
"main",
"(",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'starting...'",
")",
";",
"try",
"{",
"/* Общая инициализация */",
"$",
"this",
"->",
"checkEnvironment",
"(",
")",
";",
"$",
"this",
"->",
"createFileStructure",
"(",
")",
";",
"/* Подключение старого ядра */",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Init legacy kernel'",
")",
";",
"include_once",
"'kernel-legacy.php'",
";",
"/**\n * @global Eresus Eresus\n * @todo Обратная совместимость — удалить\n * @deprecated с 3.01 используйте Eresus_Kernel::app()->getLegacyKernel()\n */",
"$",
"GLOBALS",
"[",
"'Eresus'",
"]",
"=",
"new",
"Eresus",
";",
"TemplateSettings",
"::",
"setGlobalValue",
"(",
"'cms'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"initConf",
"(",
")",
";",
"$",
"i18n",
"=",
"I18n",
"::",
"getInstance",
"(",
")",
";",
"TemplateSettings",
"::",
"setGlobalValue",
"(",
"'i18n'",
",",
"$",
"i18n",
")",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"init",
"(",
")",
";",
"TemplateSettings",
"::",
"setGlobalValue",
"(",
"'Eresus'",
",",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
")",
";",
"$",
"this",
"->",
"runWeb",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Eresus_Kernel",
"::",
"logException",
"(",
"$",
"e",
")",
";",
"ob_end_clean",
"(",
")",
";",
"$",
"this",
"->",
"fatalError",
"(",
"$",
"e",
",",
"false",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Основной метод приложения
@return int Код завершения для консольных вызовов
@see EresusApplication#main() | [
"Основной",
"метод",
"приложения"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L91-L130 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.checkEnvironment | protected function checkEnvironment()
{
$errors = array();
/* Проверяем наличие нужных файлов */
$required = array('cfg/main.php');
foreach ($required as $filename)
{
if (!file_exists($filename))
{
$errors []= array('file' => $filename, 'problem' => 'missing');
}
}
/* Проверяем доступность для записи */
$writable = array(
'cfg/settings.php',
'var',
'data',
'templates',
'style'
);
foreach ($writable as $filename)
{
if (!is_writable($filename))
{
$errors []= array('file' => $filename, 'problem' => 'non-writable');
}
}
if ($errors)
{
if (!Eresus_Kernel::isCLI())
{
require_once 'errors.html.php';
}
else
{
die("Errors...\n"); // TODO Доделать
}
}
} | php | protected function checkEnvironment()
{
$errors = array();
/* Проверяем наличие нужных файлов */
$required = array('cfg/main.php');
foreach ($required as $filename)
{
if (!file_exists($filename))
{
$errors []= array('file' => $filename, 'problem' => 'missing');
}
}
/* Проверяем доступность для записи */
$writable = array(
'cfg/settings.php',
'var',
'data',
'templates',
'style'
);
foreach ($writable as $filename)
{
if (!is_writable($filename))
{
$errors []= array('file' => $filename, 'problem' => 'non-writable');
}
}
if ($errors)
{
if (!Eresus_Kernel::isCLI())
{
require_once 'errors.html.php';
}
else
{
die("Errors...\n"); // TODO Доделать
}
}
} | [
"protected",
"function",
"checkEnvironment",
"(",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/* Проверяем наличие нужных файлов */",
"$",
"required",
"=",
"array",
"(",
"'cfg/main.php'",
")",
";",
"foreach",
"(",
"$",
"required",
"as",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"array",
"(",
"'file'",
"=>",
"$",
"filename",
",",
"'problem'",
"=>",
"'missing'",
")",
";",
"}",
"}",
"/* Проверяем доступность для записи */",
"$",
"writable",
"=",
"array",
"(",
"'cfg/settings.php'",
",",
"'var'",
",",
"'data'",
",",
"'templates'",
",",
"'style'",
")",
";",
"foreach",
"(",
"$",
"writable",
"as",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"array",
"(",
"'file'",
"=>",
"$",
"filename",
",",
"'problem'",
"=>",
"'non-writable'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"errors",
")",
"{",
"if",
"(",
"!",
"Eresus_Kernel",
"::",
"isCLI",
"(",
")",
")",
"{",
"require_once",
"'errors.html.php'",
";",
"}",
"else",
"{",
"die",
"(",
"\"Errors...\\n\"",
")",
";",
"// TODO Доделать",
"}",
"}",
"}"
] | Проверка окружения
@return void | [
"Проверка",
"окружения"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L223-L264 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.createFileStructure | protected function createFileStructure()
{
$dirs = array(
'/var/log',
'/var/cache',
'/var/cache/templates',
);
foreach ($dirs as $dir)
{
if (!file_exists($this->getFsRoot() . $dir))
{
$umask = umask(0000);
mkdir($this->getFsRoot() . $dir, 0777);
umask($umask);
}
// TODO Сделать проверку на запись в созданные директории
}
} | php | protected function createFileStructure()
{
$dirs = array(
'/var/log',
'/var/cache',
'/var/cache/templates',
);
foreach ($dirs as $dir)
{
if (!file_exists($this->getFsRoot() . $dir))
{
$umask = umask(0000);
mkdir($this->getFsRoot() . $dir, 0777);
umask($umask);
}
// TODO Сделать проверку на запись в созданные директории
}
} | [
"protected",
"function",
"createFileStructure",
"(",
")",
"{",
"$",
"dirs",
"=",
"array",
"(",
"'/var/log'",
",",
"'/var/cache'",
",",
"'/var/cache/templates'",
",",
")",
";",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"getFsRoot",
"(",
")",
".",
"$",
"dir",
")",
")",
"{",
"$",
"umask",
"=",
"umask",
"(",
"0000",
")",
";",
"mkdir",
"(",
"$",
"this",
"->",
"getFsRoot",
"(",
")",
".",
"$",
"dir",
",",
"0777",
")",
";",
"umask",
"(",
"$",
"umask",
")",
";",
"}",
"// TODO Сделать проверку на запись в созданные директории",
"}",
"}"
] | Создание файловой структуры
@return void | [
"Создание",
"файловой",
"структуры"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L271-L289 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.runWeb | protected function runWeb()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
$request = new Eresus_CMS_Request(Eresus_HTTP_Request::createFromGlobals());
$request->setSiteRoot($this->detectWebRoot());
// TODO Удалить где-нибудь в 3.03-04
TemplateSettings::setGlobalValue('siteRoot', $request->getSiteRoot());
$this->initSite();
if (substr($request->getPath(), 0, 8) == '/ext-3rd')
{
$this->call3rdPartyExtension($request);
}
else
{
if ($request->getDirectory() == '/admin' || $request->getPath() == '/admin.php')
{
$controller = new Eresus_Admin_FrontController($request);
}
else
{
$controller = new Eresus_Client_FrontController($request);
}
$this->page = $controller->getPage();
/**
* @global
* @deprecated с 3.01 используйте Eresus_Kernel::app()->getPage()
*/
$GLOBALS['page'] = $this->page;
TemplateSettings::setGlobalValue('page', $this->page);
$response = $controller->dispatch();
$response->send();
}
} | php | protected function runWeb()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
$request = new Eresus_CMS_Request(Eresus_HTTP_Request::createFromGlobals());
$request->setSiteRoot($this->detectWebRoot());
// TODO Удалить где-нибудь в 3.03-04
TemplateSettings::setGlobalValue('siteRoot', $request->getSiteRoot());
$this->initSite();
if (substr($request->getPath(), 0, 8) == '/ext-3rd')
{
$this->call3rdPartyExtension($request);
}
else
{
if ($request->getDirectory() == '/admin' || $request->getPath() == '/admin.php')
{
$controller = new Eresus_Admin_FrontController($request);
}
else
{
$controller = new Eresus_Client_FrontController($request);
}
$this->page = $controller->getPage();
/**
* @global
* @deprecated с 3.01 используйте Eresus_Kernel::app()->getPage()
*/
$GLOBALS['page'] = $this->page;
TemplateSettings::setGlobalValue('page', $this->page);
$response = $controller->dispatch();
$response->send();
}
} | [
"protected",
"function",
"runWeb",
"(",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'()'",
")",
";",
"$",
"request",
"=",
"new",
"Eresus_CMS_Request",
"(",
"Eresus_HTTP_Request",
"::",
"createFromGlobals",
"(",
")",
")",
";",
"$",
"request",
"->",
"setSiteRoot",
"(",
"$",
"this",
"->",
"detectWebRoot",
"(",
")",
")",
";",
"// TODO Удалить где-нибудь в 3.03-04",
"TemplateSettings",
"::",
"setGlobalValue",
"(",
"'siteRoot'",
",",
"$",
"request",
"->",
"getSiteRoot",
"(",
")",
")",
";",
"$",
"this",
"->",
"initSite",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"request",
"->",
"getPath",
"(",
")",
",",
"0",
",",
"8",
")",
"==",
"'/ext-3rd'",
")",
"{",
"$",
"this",
"->",
"call3rdPartyExtension",
"(",
"$",
"request",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"request",
"->",
"getDirectory",
"(",
")",
"==",
"'/admin'",
"||",
"$",
"request",
"->",
"getPath",
"(",
")",
"==",
"'/admin.php'",
")",
"{",
"$",
"controller",
"=",
"new",
"Eresus_Admin_FrontController",
"(",
"$",
"request",
")",
";",
"}",
"else",
"{",
"$",
"controller",
"=",
"new",
"Eresus_Client_FrontController",
"(",
"$",
"request",
")",
";",
"}",
"$",
"this",
"->",
"page",
"=",
"$",
"controller",
"->",
"getPage",
"(",
")",
";",
"/**\n * @global\n * @deprecated с 3.01 используйте Eresus_Kernel::app()->getPage()\n */",
"$",
"GLOBALS",
"[",
"'page'",
"]",
"=",
"$",
"this",
"->",
"page",
";",
"TemplateSettings",
"::",
"setGlobalValue",
"(",
"'page'",
",",
"$",
"this",
"->",
"page",
")",
";",
"$",
"response",
"=",
"$",
"controller",
"->",
"dispatch",
"(",
")",
";",
"$",
"response",
"->",
"send",
"(",
")",
";",
"}",
"}"
] | Выполнение в режиме Web | [
"Выполнение",
"в",
"режиме",
"Web"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L294-L330 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.detectWebRoot | protected function detectWebRoot()
{
$webServer = WebServer::getInstance();
$documentRoot = $webServer->getDocumentRoot();
$suffix = $this->getFsRoot();
$suffix = substr($suffix, strlen($documentRoot));
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'detected root: %s', $suffix);
return $suffix;
} | php | protected function detectWebRoot()
{
$webServer = WebServer::getInstance();
$documentRoot = $webServer->getDocumentRoot();
$suffix = $this->getFsRoot();
$suffix = substr($suffix, strlen($documentRoot));
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'detected root: %s', $suffix);
return $suffix;
} | [
"protected",
"function",
"detectWebRoot",
"(",
")",
"{",
"$",
"webServer",
"=",
"WebServer",
"::",
"getInstance",
"(",
")",
";",
"$",
"documentRoot",
"=",
"$",
"webServer",
"->",
"getDocumentRoot",
"(",
")",
";",
"$",
"suffix",
"=",
"$",
"this",
"->",
"getFsRoot",
"(",
")",
";",
"$",
"suffix",
"=",
"substr",
"(",
"$",
"suffix",
",",
"strlen",
"(",
"$",
"documentRoot",
")",
")",
";",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'detected root: %s'",
",",
"$",
"suffix",
")",
";",
"return",
"$",
"suffix",
";",
"}"
] | Определяет и возвращает корневой адрес сайта
@return string | [
"Определяет",
"и",
"возвращает",
"корневой",
"адрес",
"сайта"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L337-L345 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.initConf | protected function initConf()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
/*
* Переменную $Eresus приходится делать глобальной, чтобы файл конфигурации
* мог записывать в неё свои значения.
* TODO Избавиться от глобальной переменной
*/
/** @noinspection PhpUnusedLocalVariableInspection */
global $Eresus;
$filename = $this->getFsRoot() . '/cfg/main.php';
if (file_exists($filename))
{
/** @noinspection PhpIncludeInspection */
include $filename;
// TODO: Сделать проверку успешного подключения файла
}
else
{
$this->fatalError("Main config file '$filename' not found!");
}
} | php | protected function initConf()
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');
/*
* Переменную $Eresus приходится делать глобальной, чтобы файл конфигурации
* мог записывать в неё свои значения.
* TODO Избавиться от глобальной переменной
*/
/** @noinspection PhpUnusedLocalVariableInspection */
global $Eresus;
$filename = $this->getFsRoot() . '/cfg/main.php';
if (file_exists($filename))
{
/** @noinspection PhpIncludeInspection */
include $filename;
// TODO: Сделать проверку успешного подключения файла
}
else
{
$this->fatalError("Main config file '$filename' not found!");
}
} | [
"protected",
"function",
"initConf",
"(",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'()'",
")",
";",
"/*\n * Переменную $Eresus приходится делать глобальной, чтобы файл конфигурации\n * мог записывать в неё свои значения.\n * TODO Избавиться от глобальной переменной\n */",
"/** @noinspection PhpUnusedLocalVariableInspection */",
"global",
"$",
"Eresus",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFsRoot",
"(",
")",
".",
"'/cfg/main.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"include",
"$",
"filename",
";",
"// TODO: Сделать проверку успешного подключения файла",
"}",
"else",
"{",
"$",
"this",
"->",
"fatalError",
"(",
"\"Main config file '$filename' not found!\"",
")",
";",
"}",
"}"
] | Инициализация конфигурации | [
"Инициализация",
"конфигурации"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L350-L373 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.call3rdPartyExtension | protected function call3rdPartyExtension(Eresus_CMS_Request $request)
{
$extension = substr($request->getDirectory(), 9);
if (($p = strpos($extension, '/')) !== false)
{
$extension = substr($extension, 0, $p);
}
$filename = $this->getFsRoot() . '/ext-3rd/' . $extension . '/eresus-connector.php';
if ($extension && is_file($filename))
{
/** @noinspection PhpIncludeInspection */
include_once $filename;
$className = $extension . 'Connector';
/** @var EresusExtensionConnector $connector */
$connector = new $className;
$connector->proxy();
}
else
{
header('404 Not Found', true, 404);
echo '404 Not Found';
}
} | php | protected function call3rdPartyExtension(Eresus_CMS_Request $request)
{
$extension = substr($request->getDirectory(), 9);
if (($p = strpos($extension, '/')) !== false)
{
$extension = substr($extension, 0, $p);
}
$filename = $this->getFsRoot() . '/ext-3rd/' . $extension . '/eresus-connector.php';
if ($extension && is_file($filename))
{
/** @noinspection PhpIncludeInspection */
include_once $filename;
$className = $extension . 'Connector';
/** @var EresusExtensionConnector $connector */
$connector = new $className;
$connector->proxy();
}
else
{
header('404 Not Found', true, 404);
echo '404 Not Found';
}
} | [
"protected",
"function",
"call3rdPartyExtension",
"(",
"Eresus_CMS_Request",
"$",
"request",
")",
"{",
"$",
"extension",
"=",
"substr",
"(",
"$",
"request",
"->",
"getDirectory",
"(",
")",
",",
"9",
")",
";",
"if",
"(",
"(",
"$",
"p",
"=",
"strpos",
"(",
"$",
"extension",
",",
"'/'",
")",
")",
"!==",
"false",
")",
"{",
"$",
"extension",
"=",
"substr",
"(",
"$",
"extension",
",",
"0",
",",
"$",
"p",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFsRoot",
"(",
")",
".",
"'/ext-3rd/'",
".",
"$",
"extension",
".",
"'/eresus-connector.php'",
";",
"if",
"(",
"$",
"extension",
"&&",
"is_file",
"(",
"$",
"filename",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"include_once",
"$",
"filename",
";",
"$",
"className",
"=",
"$",
"extension",
".",
"'Connector'",
";",
"/** @var EresusExtensionConnector $connector */",
"$",
"connector",
"=",
"new",
"$",
"className",
";",
"$",
"connector",
"->",
"proxy",
"(",
")",
";",
"}",
"else",
"{",
"header",
"(",
"'404 Not Found'",
",",
"true",
",",
"404",
")",
";",
"echo",
"'404 Not Found'",
";",
"}",
"}"
] | Обрабатывает запрос к стороннему расширению
Вызов производится через коннектор этого расширения
@param Eresus_CMS_Request $request
@return void | [
"Обрабатывает",
"запрос",
"к",
"стороннему",
"расширению"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L384-L407 |
Eresus/EresusCMS | src/core/CMS.php | Eresus_CMS.initSite | private function initSite()
{
$this->site = new Eresus_Site($this->getLegacyKernel());
$this->site->setTitle(siteTitle);
$this->site->setDescription(siteDescription);
$this->site->setKeywords(siteKeywords);
TemplateSettings::setGlobalValue('site', $this->site);
} | php | private function initSite()
{
$this->site = new Eresus_Site($this->getLegacyKernel());
$this->site->setTitle(siteTitle);
$this->site->setDescription(siteDescription);
$this->site->setKeywords(siteKeywords);
TemplateSettings::setGlobalValue('site', $this->site);
} | [
"private",
"function",
"initSite",
"(",
")",
"{",
"$",
"this",
"->",
"site",
"=",
"new",
"Eresus_Site",
"(",
"$",
"this",
"->",
"getLegacyKernel",
"(",
")",
")",
";",
"$",
"this",
"->",
"site",
"->",
"setTitle",
"(",
"siteTitle",
")",
";",
"$",
"this",
"->",
"site",
"->",
"setDescription",
"(",
"siteDescription",
")",
";",
"$",
"this",
"->",
"site",
"->",
"setKeywords",
"(",
"siteKeywords",
")",
";",
"TemplateSettings",
"::",
"setGlobalValue",
"(",
"'site'",
",",
"$",
"this",
"->",
"site",
")",
";",
"}"
] | Инициализирует сайт
@return void
@since 3.01 | [
"Инициализирует",
"сайт"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/CMS.php#L416-L423 |
novaway/open-graph | src/OpenGraphGeneratorBuilder.php | OpenGraphGeneratorBuilder.build | public function build()
{
$annotationReader = $this->annotationReader;
if (null === $annotationReader) {
$annotationReader = new AnnotationReader();
if (null !== $this->cacheDirectory) {
$cacheDirectory = sprintf('%s/annotations', $this->cacheDirectory);
$this->createDirectory($cacheDirectory);
$annotationReader = new CachedReader($annotationReader, new FilesystemCache($cacheDirectory));
}
}
$metadataDriver = $this->driverFactory->createDriver($this->metadataDirectories, $annotationReader);
$metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
$metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
if (null !== $this->cacheDirectory) {
$directory = sprintf('%s/metadata', $this->cacheDirectory);
$this->createDirectory($directory);
$metadataFactory->setCache(new FileCache($directory));
}
return new OpenGraphGenerator($metadataFactory);
} | php | public function build()
{
$annotationReader = $this->annotationReader;
if (null === $annotationReader) {
$annotationReader = new AnnotationReader();
if (null !== $this->cacheDirectory) {
$cacheDirectory = sprintf('%s/annotations', $this->cacheDirectory);
$this->createDirectory($cacheDirectory);
$annotationReader = new CachedReader($annotationReader, new FilesystemCache($cacheDirectory));
}
}
$metadataDriver = $this->driverFactory->createDriver($this->metadataDirectories, $annotationReader);
$metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
$metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
if (null !== $this->cacheDirectory) {
$directory = sprintf('%s/metadata', $this->cacheDirectory);
$this->createDirectory($directory);
$metadataFactory->setCache(new FileCache($directory));
}
return new OpenGraphGenerator($metadataFactory);
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"annotationReader",
"=",
"$",
"this",
"->",
"annotationReader",
";",
"if",
"(",
"null",
"===",
"$",
"annotationReader",
")",
"{",
"$",
"annotationReader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"cacheDirectory",
")",
"{",
"$",
"cacheDirectory",
"=",
"sprintf",
"(",
"'%s/annotations'",
",",
"$",
"this",
"->",
"cacheDirectory",
")",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"cacheDirectory",
")",
";",
"$",
"annotationReader",
"=",
"new",
"CachedReader",
"(",
"$",
"annotationReader",
",",
"new",
"FilesystemCache",
"(",
"$",
"cacheDirectory",
")",
")",
";",
"}",
"}",
"$",
"metadataDriver",
"=",
"$",
"this",
"->",
"driverFactory",
"->",
"createDriver",
"(",
"$",
"this",
"->",
"metadataDirectories",
",",
"$",
"annotationReader",
")",
";",
"$",
"metadataFactory",
"=",
"new",
"MetadataFactory",
"(",
"$",
"metadataDriver",
",",
"null",
",",
"$",
"this",
"->",
"debug",
")",
";",
"$",
"metadataFactory",
"->",
"setIncludeInterfaces",
"(",
"$",
"this",
"->",
"includeInterfaceMetadata",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"cacheDirectory",
")",
"{",
"$",
"directory",
"=",
"sprintf",
"(",
"'%s/metadata'",
",",
"$",
"this",
"->",
"cacheDirectory",
")",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"directory",
")",
";",
"$",
"metadataFactory",
"->",
"setCache",
"(",
"new",
"FileCache",
"(",
"$",
"directory",
")",
")",
";",
"}",
"return",
"new",
"OpenGraphGenerator",
"(",
"$",
"metadataFactory",
")",
";",
"}"
] | Create open graph object | [
"Create",
"open",
"graph",
"object"
] | train | https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGeneratorBuilder.php#L59-L85 |
novaway/open-graph | src/OpenGraphGeneratorBuilder.php | OpenGraphGeneratorBuilder.setCacheDirectory | public function setCacheDirectory($directory)
{
if (!is_dir($directory)) {
$this->createDirectory($directory);
}
if (!is_writable($directory)) {
throw new \InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir));
}
$this->cacheDirectory = $directory;
return $this;
} | php | public function setCacheDirectory($directory)
{
if (!is_dir($directory)) {
$this->createDirectory($directory);
}
if (!is_writable($directory)) {
throw new \InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir));
}
$this->cacheDirectory = $directory;
return $this;
} | [
"public",
"function",
"setCacheDirectory",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"directory",
")",
";",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The cache directory \"%s\" is not writable.'",
",",
"$",
"dir",
")",
")",
";",
"}",
"$",
"this",
"->",
"cacheDirectory",
"=",
"$",
"directory",
";",
"return",
"$",
"this",
";",
"}"
] | Set cache directory
@param string $directory
@return OpenGraphGeneratorBuilder | [
"Set",
"cache",
"directory"
] | train | https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGeneratorBuilder.php#L132-L145 |
novaway/open-graph | src/OpenGraphGeneratorBuilder.php | OpenGraphGeneratorBuilder.createDirectory | private function createDirectory($directory)
{
if (is_dir($directory)) {
return;
}
if (false === @mkdir($directory, 0777, true)) {
throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir));
}
} | php | private function createDirectory($directory)
{
if (is_dir($directory)) {
return;
}
if (false === @mkdir($directory, 0777, true)) {
throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir));
}
} | [
"private",
"function",
"createDirectory",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"false",
"===",
"@",
"mkdir",
"(",
"$",
"directory",
",",
"0777",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Could not create directory \"%s\".'",
",",
"$",
"dir",
")",
")",
";",
"}",
"}"
] | Create directory
@param string $directory | [
"Create",
"directory"
] | train | https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGeneratorBuilder.php#L233-L242 |
mainio/c5pkg_symfony_forms | src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/BaseSelectorType.php | BaseSelectorType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
// Store number by default. If the extending class wants to provide
// e.g. object storage, override this method in the extending class.
$builder->addViewTransformer(new NumberToLocalizedStringTransformer(
null,
false,
NumberToLocalizedStringTransformer::ROUND_FLOOR
));
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
// Store number by default. If the extending class wants to provide
// e.g. object storage, override this method in the extending class.
$builder->addViewTransformer(new NumberToLocalizedStringTransformer(
null,
false,
NumberToLocalizedStringTransformer::ROUND_FLOOR
));
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"// Store number by default. If the extending class wants to provide",
"// e.g. object storage, override this method in the extending class.",
"$",
"builder",
"->",
"addViewTransformer",
"(",
"new",
"NumberToLocalizedStringTransformer",
"(",
"null",
",",
"false",
",",
"NumberToLocalizedStringTransformer",
"::",
"ROUND_FLOOR",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/BaseSelectorType.php#L22-L31 |
spalax/msgfmt | src/Msgfmt/Generate.php | Generate.parsePoFile | protected function parsePoFile($poFile)
{
// read .po file
$fc= file_get_contents($poFile);
// normalize newlines
$fc= str_replace(array (
"\r\n",
"\r"
), array (
"\n",
"\n"
), $fc);
// results array
$hash= array ();
// temporary array
$temp= array ();
// state
$state= null;
$fuzzy= false;
// iterate over lines
foreach (explode("\n", $fc) as $line) {
$line= trim($line);
if ($line === '')
continue;
$result = explode(' ', $line, 2);
if (count($result) < 2) {
$key = $result[0];
} else {
list ($key, $data) = $result;
}
switch ($key) {
case '#,' : // flag...
$fuzzy= in_array('fuzzy', preg_split('/,\s*/', $data));
case '#' : // translator-comments
case '#.' : // extracted-comments
case '#:' : // reference...
case '#|' : // msgid previous-untranslated-string
// start a new entry
if (sizeof($temp) && array_key_exists('msgid', $temp) && array_key_exists('msgstr', $temp)) {
if (!$fuzzy)
$hash[]= $temp;
$temp= array ();
$state= null;
$fuzzy= false;
}
break;
case 'msgctxt' :
// context
case 'msgid' :
// untranslated-string
case 'msgid_plural' :
// untranslated-string-plural
$state= $key;
$temp[$state]= $data;
break;
case 'msgstr' :
// translated-string
$state= 'msgstr';
$temp[$state][]= $data;
break;
default :
if (strpos($key, 'msgstr[') !== FALSE) {
// translated-string-case-n
$state= 'msgstr';
$temp[$state][]= $data;
} else {
// continued lines
switch ($state) {
case 'msgctxt' :
case 'msgid' :
case 'msgid_plural' :
$temp[$state] .= "\n" . $line;
break;
case 'msgstr' :
$temp[$state][sizeof($temp[$state]) - 1] .= "\n" . $line;
break;
default :
// parse error
return FALSE;
}
}
break;
}
}
// add final entry
if ($state == 'msgstr')
$hash[]= $temp;
// Cleanup data, merge multiline entries, reindex hash for ksort
$temp= $hash;
$hash= array ();
foreach ($temp as $entry) {
foreach ($entry as & $v) {
$v= $this->cleanHelper($v);
if ($v === FALSE) {
// parse error
return FALSE;
}
}
$hash[$entry['msgid']]= $entry;
}
return $hash;
} | php | protected function parsePoFile($poFile)
{
// read .po file
$fc= file_get_contents($poFile);
// normalize newlines
$fc= str_replace(array (
"\r\n",
"\r"
), array (
"\n",
"\n"
), $fc);
// results array
$hash= array ();
// temporary array
$temp= array ();
// state
$state= null;
$fuzzy= false;
// iterate over lines
foreach (explode("\n", $fc) as $line) {
$line= trim($line);
if ($line === '')
continue;
$result = explode(' ', $line, 2);
if (count($result) < 2) {
$key = $result[0];
} else {
list ($key, $data) = $result;
}
switch ($key) {
case '#,' : // flag...
$fuzzy= in_array('fuzzy', preg_split('/,\s*/', $data));
case '#' : // translator-comments
case '#.' : // extracted-comments
case '#:' : // reference...
case '#|' : // msgid previous-untranslated-string
// start a new entry
if (sizeof($temp) && array_key_exists('msgid', $temp) && array_key_exists('msgstr', $temp)) {
if (!$fuzzy)
$hash[]= $temp;
$temp= array ();
$state= null;
$fuzzy= false;
}
break;
case 'msgctxt' :
// context
case 'msgid' :
// untranslated-string
case 'msgid_plural' :
// untranslated-string-plural
$state= $key;
$temp[$state]= $data;
break;
case 'msgstr' :
// translated-string
$state= 'msgstr';
$temp[$state][]= $data;
break;
default :
if (strpos($key, 'msgstr[') !== FALSE) {
// translated-string-case-n
$state= 'msgstr';
$temp[$state][]= $data;
} else {
// continued lines
switch ($state) {
case 'msgctxt' :
case 'msgid' :
case 'msgid_plural' :
$temp[$state] .= "\n" . $line;
break;
case 'msgstr' :
$temp[$state][sizeof($temp[$state]) - 1] .= "\n" . $line;
break;
default :
// parse error
return FALSE;
}
}
break;
}
}
// add final entry
if ($state == 'msgstr')
$hash[]= $temp;
// Cleanup data, merge multiline entries, reindex hash for ksort
$temp= $hash;
$hash= array ();
foreach ($temp as $entry) {
foreach ($entry as & $v) {
$v= $this->cleanHelper($v);
if ($v === FALSE) {
// parse error
return FALSE;
}
}
$hash[$entry['msgid']]= $entry;
}
return $hash;
} | [
"protected",
"function",
"parsePoFile",
"(",
"$",
"poFile",
")",
"{",
"// read .po file",
"$",
"fc",
"=",
"file_get_contents",
"(",
"$",
"poFile",
")",
";",
"// normalize newlines",
"$",
"fc",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\r\"",
")",
",",
"array",
"(",
"\"\\n\"",
",",
"\"\\n\"",
")",
",",
"$",
"fc",
")",
";",
"// results array",
"$",
"hash",
"=",
"array",
"(",
")",
";",
"// temporary array",
"$",
"temp",
"=",
"array",
"(",
")",
";",
"// state",
"$",
"state",
"=",
"null",
";",
"$",
"fuzzy",
"=",
"false",
";",
"// iterate over lines",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"fc",
")",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"line",
"===",
"''",
")",
"continue",
";",
"$",
"result",
"=",
"explode",
"(",
"' '",
",",
"$",
"line",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
"<",
"2",
")",
"{",
"$",
"key",
"=",
"$",
"result",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"data",
")",
"=",
"$",
"result",
";",
"}",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'#,'",
":",
"// flag...",
"$",
"fuzzy",
"=",
"in_array",
"(",
"'fuzzy'",
",",
"preg_split",
"(",
"'/,\\s*/'",
",",
"$",
"data",
")",
")",
";",
"case",
"'#'",
":",
"// translator-comments",
"case",
"'#.'",
":",
"// extracted-comments",
"case",
"'#:'",
":",
"// reference...",
"case",
"'#|'",
":",
"// msgid previous-untranslated-string",
"// start a new entry",
"if",
"(",
"sizeof",
"(",
"$",
"temp",
")",
"&&",
"array_key_exists",
"(",
"'msgid'",
",",
"$",
"temp",
")",
"&&",
"array_key_exists",
"(",
"'msgstr'",
",",
"$",
"temp",
")",
")",
"{",
"if",
"(",
"!",
"$",
"fuzzy",
")",
"$",
"hash",
"[",
"]",
"=",
"$",
"temp",
";",
"$",
"temp",
"=",
"array",
"(",
")",
";",
"$",
"state",
"=",
"null",
";",
"$",
"fuzzy",
"=",
"false",
";",
"}",
"break",
";",
"case",
"'msgctxt'",
":",
"// context",
"case",
"'msgid'",
":",
"// untranslated-string",
"case",
"'msgid_plural'",
":",
"// untranslated-string-plural",
"$",
"state",
"=",
"$",
"key",
";",
"$",
"temp",
"[",
"$",
"state",
"]",
"=",
"$",
"data",
";",
"break",
";",
"case",
"'msgstr'",
":",
"// translated-string",
"$",
"state",
"=",
"'msgstr'",
";",
"$",
"temp",
"[",
"$",
"state",
"]",
"[",
"]",
"=",
"$",
"data",
";",
"break",
";",
"default",
":",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'msgstr['",
")",
"!==",
"FALSE",
")",
"{",
"// translated-string-case-n",
"$",
"state",
"=",
"'msgstr'",
";",
"$",
"temp",
"[",
"$",
"state",
"]",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"else",
"{",
"// continued lines",
"switch",
"(",
"$",
"state",
")",
"{",
"case",
"'msgctxt'",
":",
"case",
"'msgid'",
":",
"case",
"'msgid_plural'",
":",
"$",
"temp",
"[",
"$",
"state",
"]",
".=",
"\"\\n\"",
".",
"$",
"line",
";",
"break",
";",
"case",
"'msgstr'",
":",
"$",
"temp",
"[",
"$",
"state",
"]",
"[",
"sizeof",
"(",
"$",
"temp",
"[",
"$",
"state",
"]",
")",
"-",
"1",
"]",
".=",
"\"\\n\"",
".",
"$",
"line",
";",
"break",
";",
"default",
":",
"// parse error",
"return",
"FALSE",
";",
"}",
"}",
"break",
";",
"}",
"}",
"// add final entry",
"if",
"(",
"$",
"state",
"==",
"'msgstr'",
")",
"$",
"hash",
"[",
"]",
"=",
"$",
"temp",
";",
"// Cleanup data, merge multiline entries, reindex hash for ksort",
"$",
"temp",
"=",
"$",
"hash",
";",
"$",
"hash",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"temp",
"as",
"$",
"entry",
")",
"{",
"foreach",
"(",
"$",
"entry",
"as",
"&",
"$",
"v",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"cleanHelper",
"(",
"$",
"v",
")",
";",
"if",
"(",
"$",
"v",
"===",
"FALSE",
")",
"{",
"// parse error",
"return",
"FALSE",
";",
"}",
"}",
"$",
"hash",
"[",
"$",
"entry",
"[",
"'msgid'",
"]",
"]",
"=",
"$",
"entry",
";",
"}",
"return",
"$",
"hash",
";",
"}"
] | @param string $poFile
@return array|bool | [
"@param",
"string",
"$poFile"
] | train | https://github.com/spalax/msgfmt/blob/4f5e1ffc94fd86b54130a94aec6180cb8faf25e0/src/Msgfmt/Generate.php#L42-L150 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/utilities_sqlite.php | ezcDbUtilitiesSqlite.cleanup | public function cleanup()
{
$this->db->begin();
$rslt = $this->db->query( 'SELECT * FROM SQLITE_MASTER' );
$rslt->setFetchMode( PDO::FETCH_NUM );
$rows = $rslt->fetchAll();
foreach ( $rows as $row )
{
$table = $row[0];
$this->db->exec( "DROP TABLE `$table`" );
}
$this->db->commit();
} | php | public function cleanup()
{
$this->db->begin();
$rslt = $this->db->query( 'SELECT * FROM SQLITE_MASTER' );
$rslt->setFetchMode( PDO::FETCH_NUM );
$rows = $rslt->fetchAll();
foreach ( $rows as $row )
{
$table = $row[0];
$this->db->exec( "DROP TABLE `$table`" );
}
$this->db->commit();
} | [
"public",
"function",
"cleanup",
"(",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"begin",
"(",
")",
";",
"$",
"rslt",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SELECT * FROM SQLITE_MASTER'",
")",
";",
"$",
"rslt",
"->",
"setFetchMode",
"(",
"PDO",
"::",
"FETCH_NUM",
")",
";",
"$",
"rows",
"=",
"$",
"rslt",
"->",
"fetchAll",
"(",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"table",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"db",
"->",
"exec",
"(",
"\"DROP TABLE `$table`\"",
")",
";",
"}",
"$",
"this",
"->",
"db",
"->",
"commit",
"(",
")",
";",
"}"
] | Remove all tables from the database. | [
"Remove",
"all",
"tables",
"from",
"the",
"database",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/utilities_sqlite.php#L41-L53 |
mothership-ec/composer | src/Composer/Repository/Vcs/PerforceDriver.php | PerforceDriver.initialize | public function initialize()
{
$this->depot = $this->repoConfig['depot'];
$this->branch = '';
if (!empty($this->repoConfig['branch'])) {
$this->branch = $this->repoConfig['branch'];
}
$this->initPerforce($this->repoConfig);
$this->perforce->p4Login($this->io);
$this->perforce->checkStream($this->depot);
$this->perforce->writeP4ClientSpec();
$this->perforce->connectClient();
return true;
} | php | public function initialize()
{
$this->depot = $this->repoConfig['depot'];
$this->branch = '';
if (!empty($this->repoConfig['branch'])) {
$this->branch = $this->repoConfig['branch'];
}
$this->initPerforce($this->repoConfig);
$this->perforce->p4Login($this->io);
$this->perforce->checkStream($this->depot);
$this->perforce->writeP4ClientSpec();
$this->perforce->connectClient();
return true;
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"this",
"->",
"depot",
"=",
"$",
"this",
"->",
"repoConfig",
"[",
"'depot'",
"]",
";",
"$",
"this",
"->",
"branch",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"repoConfig",
"[",
"'branch'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"branch",
"=",
"$",
"this",
"->",
"repoConfig",
"[",
"'branch'",
"]",
";",
"}",
"$",
"this",
"->",
"initPerforce",
"(",
"$",
"this",
"->",
"repoConfig",
")",
";",
"$",
"this",
"->",
"perforce",
"->",
"p4Login",
"(",
"$",
"this",
"->",
"io",
")",
";",
"$",
"this",
"->",
"perforce",
"->",
"checkStream",
"(",
"$",
"this",
"->",
"depot",
")",
";",
"$",
"this",
"->",
"perforce",
"->",
"writeP4ClientSpec",
"(",
")",
";",
"$",
"this",
"->",
"perforce",
"->",
"connectClient",
"(",
")",
";",
"return",
"true",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/PerforceDriver.php#L34-L50 |
mothership-ec/composer | src/Composer/Repository/Vcs/PerforceDriver.php | PerforceDriver.getComposerInformation | public function getComposerInformation($identifier)
{
if (!empty($this->composerInfoIdentifier)) {
if (strcmp($identifier, $this->composerInfoIdentifier) === 0) {
return $this->composerInfo;
}
}
$composer_info = $this->perforce->getComposerInformation($identifier);
return $composer_info;
} | php | public function getComposerInformation($identifier)
{
if (!empty($this->composerInfoIdentifier)) {
if (strcmp($identifier, $this->composerInfoIdentifier) === 0) {
return $this->composerInfo;
}
}
$composer_info = $this->perforce->getComposerInformation($identifier);
return $composer_info;
} | [
"public",
"function",
"getComposerInformation",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"composerInfoIdentifier",
")",
")",
"{",
"if",
"(",
"strcmp",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"composerInfoIdentifier",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"composerInfo",
";",
"}",
"}",
"$",
"composer_info",
"=",
"$",
"this",
"->",
"perforce",
"->",
"getComposerInformation",
"(",
"$",
"identifier",
")",
";",
"return",
"$",
"composer_info",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/PerforceDriver.php#L65-L75 |
jasny/controller | src/Controller/Session.php | Session.useSession | public function useSession()
{
$this->session = $this->getRequest()->getAttribute('session');
if (!isset($this->session)) {
$this->session =& $_SESSION;
}
} | php | public function useSession()
{
$this->session = $this->getRequest()->getAttribute('session');
if (!isset($this->session)) {
$this->session =& $_SESSION;
}
} | [
"public",
"function",
"useSession",
"(",
")",
"{",
"$",
"this",
"->",
"session",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getAttribute",
"(",
"'session'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"session",
")",
")",
"{",
"$",
"this",
"->",
"session",
"=",
"&",
"$",
"_SESSION",
";",
"}",
"}"
] | Link the session to the session property in the controller | [
"Link",
"the",
"session",
"to",
"the",
"session",
"property",
"in",
"the",
"controller"
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session.php#L36-L43 |
jasny/controller | src/Controller/Session.php | Session.flash | public function flash($type = null, $message = null)
{
if (!isset($this->flash)) {
$this->flash = new Flash($this->session);
}
if ($type) {
$this->flash->set($type, $message);
}
return $this->flash;
} | php | public function flash($type = null, $message = null)
{
if (!isset($this->flash)) {
$this->flash = new Flash($this->session);
}
if ($type) {
$this->flash->set($type, $message);
}
return $this->flash;
} | [
"public",
"function",
"flash",
"(",
"$",
"type",
"=",
"null",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"flash",
")",
")",
"{",
"$",
"this",
"->",
"flash",
"=",
"new",
"Flash",
"(",
"$",
"this",
"->",
"session",
")",
";",
"}",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"flash",
"->",
"set",
"(",
"$",
"type",
",",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
"->",
"flash",
";",
"}"
] | Get an/or set the flash message.
@param mixed $type flash type, eg. 'error', 'notice' or 'success'
@param mixed $message flash message
@return Flash | [
"Get",
"an",
"/",
"or",
"set",
"the",
"flash",
"message",
"."
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session.php#L53-L64 |
zhouyl/mellivora | Mellivora/Database/Seeder.php | Seeder.call | public function call($class)
{
$this->command->getOutput()->writeln("<info>Seeding:</info> $class");
$seeder = new $class($this->container, $this->command);
return $seeder->__invoke();
} | php | public function call($class)
{
$this->command->getOutput()->writeln("<info>Seeding:</info> $class");
$seeder = new $class($this->container, $this->command);
return $seeder->__invoke();
} | [
"public",
"function",
"call",
"(",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"\"<info>Seeding:</info> $class\"",
")",
";",
"$",
"seeder",
"=",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"this",
"->",
"command",
")",
";",
"return",
"$",
"seeder",
"->",
"__invoke",
"(",
")",
";",
"}"
] | Seed the given connection from the given path.
@param string $class
@return void | [
"Seed",
"the",
"given",
"connection",
"from",
"the",
"given",
"path",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Seeder.php#L44-L51 |
sciactive/nymph-server | src/Entity.php | Entity.factory | public static function factory() {
$className = get_called_class();
$args = func_get_args();
$reflector = new \ReflectionClass($className);
$entity = $reflector->newInstanceArgs($args);
// Use hook functionality when available.
if (class_exists('\SciActive\Hook')) {
\SciActive\Hook::hookObject($entity, $className.'->', false);
}
return $entity;
} | php | public static function factory() {
$className = get_called_class();
$args = func_get_args();
$reflector = new \ReflectionClass($className);
$entity = $reflector->newInstanceArgs($args);
// Use hook functionality when available.
if (class_exists('\SciActive\Hook')) {
\SciActive\Hook::hookObject($entity, $className.'->', false);
}
return $entity;
} | [
"public",
"static",
"function",
"factory",
"(",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"entity",
"=",
"$",
"reflector",
"->",
"newInstanceArgs",
"(",
"$",
"args",
")",
";",
"// Use hook functionality when available.",
"if",
"(",
"class_exists",
"(",
"'\\SciActive\\Hook'",
")",
")",
"{",
"\\",
"SciActive",
"\\",
"Hook",
"::",
"hookObject",
"(",
"$",
"entity",
",",
"$",
"className",
".",
"'->'",
",",
"false",
")",
";",
"}",
"return",
"$",
"entity",
";",
"}"
] | Create a new instance.
@return \Nymph\Entity The new instance. | [
"Create",
"a",
"new",
"instance",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L288-L298 |
sciactive/nymph-server | src/Entity.php | Entity.factoryReference | public static function factoryReference($reference) {
$className = $reference[2];
if (!class_exists($className)) {
throw new Exceptions\EntityClassNotFoundException(
"factoryReference called for a class that can't be found, $className."
);
}
$entity = call_user_func([$className, 'factory']);
$entity->referenceSleep($reference);
return $entity;
} | php | public static function factoryReference($reference) {
$className = $reference[2];
if (!class_exists($className)) {
throw new Exceptions\EntityClassNotFoundException(
"factoryReference called for a class that can't be found, $className."
);
}
$entity = call_user_func([$className, 'factory']);
$entity->referenceSleep($reference);
return $entity;
} | [
"public",
"static",
"function",
"factoryReference",
"(",
"$",
"reference",
")",
"{",
"$",
"className",
"=",
"$",
"reference",
"[",
"2",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"(",
"\"factoryReference called for a class that can't be found, $className.\"",
")",
";",
"}",
"$",
"entity",
"=",
"call_user_func",
"(",
"[",
"$",
"className",
",",
"'factory'",
"]",
")",
";",
"$",
"entity",
"->",
"referenceSleep",
"(",
"$",
"reference",
")",
";",
"return",
"$",
"entity",
";",
"}"
] | Create a new sleeping reference instance.
Sleeping references won't retrieve their data from the database until it
is actually used.
@param array $reference The Nymph Entity Reference to use to wake.
@return \Nymph\Entity The new instance. | [
"Create",
"a",
"new",
"sleeping",
"reference",
"instance",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L309-L319 |
sciactive/nymph-server | src/Entity.php | Entity.& | public function &__get($name) {
if ($name === 'guid') {
return $this->$name;
}
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return $this->$name;
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
// Check for an entity first.
if (isset($this->entityCache[$name])) {
if ($this->data[$name][0] === 'nymph_entity_reference') {
if ($this->entityCache[$name] === 0) {
// The entity hasn't been loaded yet, so load it now.
$className = $this->data[$name][2];
if (!class_exists($className)) {
throw new Exceptions\EntityCorruptedException(
"Entity reference refers to a class that can't be found, ".
"$className."
);
}
$this->entityCache[$name] =
$className::factoryReference($this->data[$name]);
$this->entityCache[$name]->useSkipAc($this->useSkipAc);
}
return $this->entityCache[$name];
} else {
throw new Exceptions\EntityCorruptedException(
"Entity data has become corrupt and cannot be determined."
);
}
}
// Check if it's set.
if (!isset($this->data[$name])) {
// Since we must return by reference, we have to use a constant here. If
// we return $this->data[$name], an entry will be created in data.
return $this->NULL_CONST;
}
// If it's not an entity, return the regular value.
try {
if (is_array($this->data[$name])) {
// But, if it's an array, check all the values for entity references,
// and change them.
array_walk($this->data[$name], [$this, 'referenceToEntity']);
} elseif (is_object($this->data[$name])
&& !(
(
is_a($this->data[$name], '\Nymph\Entity')
|| is_a($this->data[$name], '\SciActive\HookOverride')
)
&& is_callable([$this->data[$name], 'toReference'])
)) {
// Only do this for non-entity objects.
foreach ($this->data[$name] as &$curProperty) {
$this->referenceToEntity($curProperty, null);
}
unset($curProperty);
}
} catch (Exceptions\EntityClassNotFoundException $e) {
throw new Exceptions\EntityCorruptedException($e->getMessage());
}
return $this->data[$name];
} | php | public function &__get($name) {
if ($name === 'guid') {
return $this->$name;
}
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return $this->$name;
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
// Check for an entity first.
if (isset($this->entityCache[$name])) {
if ($this->data[$name][0] === 'nymph_entity_reference') {
if ($this->entityCache[$name] === 0) {
// The entity hasn't been loaded yet, so load it now.
$className = $this->data[$name][2];
if (!class_exists($className)) {
throw new Exceptions\EntityCorruptedException(
"Entity reference refers to a class that can't be found, ".
"$className."
);
}
$this->entityCache[$name] =
$className::factoryReference($this->data[$name]);
$this->entityCache[$name]->useSkipAc($this->useSkipAc);
}
return $this->entityCache[$name];
} else {
throw new Exceptions\EntityCorruptedException(
"Entity data has become corrupt and cannot be determined."
);
}
}
// Check if it's set.
if (!isset($this->data[$name])) {
// Since we must return by reference, we have to use a constant here. If
// we return $this->data[$name], an entry will be created in data.
return $this->NULL_CONST;
}
// If it's not an entity, return the regular value.
try {
if (is_array($this->data[$name])) {
// But, if it's an array, check all the values for entity references,
// and change them.
array_walk($this->data[$name], [$this, 'referenceToEntity']);
} elseif (is_object($this->data[$name])
&& !(
(
is_a($this->data[$name], '\Nymph\Entity')
|| is_a($this->data[$name], '\SciActive\HookOverride')
)
&& is_callable([$this->data[$name], 'toReference'])
)) {
// Only do this for non-entity objects.
foreach ($this->data[$name] as &$curProperty) {
$this->referenceToEntity($curProperty, null);
}
unset($curProperty);
}
} catch (Exceptions\EntityClassNotFoundException $e) {
throw new Exceptions\EntityCorruptedException($e->getMessage());
}
return $this->data[$name];
} | [
"public",
"function",
"&",
"__get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'guid'",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"name",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"'cdate'",
"||",
"$",
"name",
"===",
"'mdate'",
"||",
"$",
"name",
"===",
"'tags'",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"name",
";",
"}",
"// Unserialize.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"unserialize",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"}",
"// Check for an entity first.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"[",
"0",
"]",
"===",
"'nymph_entity_reference'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
"===",
"0",
")",
"{",
"// The entity hasn't been loaded yet, so load it now.",
"$",
"className",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"[",
"2",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityCorruptedException",
"(",
"\"Entity reference refers to a class that can't be found, \"",
".",
"\"$className.\"",
")",
";",
"}",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
"=",
"$",
"className",
"::",
"factoryReference",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
";",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
"->",
"useSkipAc",
"(",
"$",
"this",
"->",
"useSkipAc",
")",
";",
"}",
"return",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityCorruptedException",
"(",
"\"Entity data has become corrupt and cannot be determined.\"",
")",
";",
"}",
"}",
"// Check if it's set.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// Since we must return by reference, we have to use a constant here. If",
"// we return $this->data[$name], an entry will be created in data.",
"return",
"$",
"this",
"->",
"NULL_CONST",
";",
"}",
"// If it's not an entity, return the regular value.",
"try",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// But, if it's an array, check all the values for entity references,",
"// and change them.",
"array_walk",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"[",
"$",
"this",
",",
"'referenceToEntity'",
"]",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"(",
"(",
"is_a",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"'toReference'",
"]",
")",
")",
")",
"{",
"// Only do this for non-entity objects.",
"foreach",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"as",
"&",
"$",
"curProperty",
")",
"{",
"$",
"this",
"->",
"referenceToEntity",
"(",
"$",
"curProperty",
",",
"null",
")",
";",
"}",
"unset",
"(",
"$",
"curProperty",
")",
";",
"}",
"}",
"catch",
"(",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityCorruptedException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
";",
"}"
] | Retrieve a variable.
You do not need to explicitly call this method. It is called by PHP when
you access the variable normally.
@param string $name The name of the variable.
@return mixed The value of the variable or null if it doesn't exist. | [
"Retrieve",
"a",
"variable",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L330-L401 |
sciactive/nymph-server | src/Entity.php | Entity.__isset | public function __isset($name) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'guid'
|| $name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return isset($this->$name);
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
return isset($this->data[$name]);
} | php | public function __isset($name) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'guid'
|| $name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return isset($this->$name);
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
return isset($this->data[$name]);
} | [
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"'guid'",
"||",
"$",
"name",
"===",
"'cdate'",
"||",
"$",
"name",
"===",
"'mdate'",
"||",
"$",
"name",
"===",
"'tags'",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"$",
"name",
")",
";",
"}",
"// Unserialize.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"unserialize",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Checks whether a variable is set.
You do not need to explicitly call this method. It is called by PHP when
you access the variable normally.
@param string $name The name of the variable.
@return bool
@todo Check that a referenced entity has not been deleted. | [
"Checks",
"whether",
"a",
"variable",
"is",
"set",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L413-L430 |
sciactive/nymph-server | src/Entity.php | Entity.entityToReference | private function entityToReference(&$item, $key) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& isset($item->guid) && is_callable([$item, 'toReference'])) {
// This is an entity, so we should put it in the entity cache.
if (!isset($this->entityCache["referenceGuid__{$item->guid}"])) {
$this->entityCache["referenceGuid__{$item->guid}"] = clone $item;
}
// Make a reference to the entity (its GUID and the class the entity was
// loaded as).
$item = $item->toReference();
}
} | php | private function entityToReference(&$item, $key) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& isset($item->guid) && is_callable([$item, 'toReference'])) {
// This is an entity, so we should put it in the entity cache.
if (!isset($this->entityCache["referenceGuid__{$item->guid}"])) {
$this->entityCache["referenceGuid__{$item->guid}"] = clone $item;
}
// Make a reference to the entity (its GUID and the class the entity was
// loaded as).
$item = $item->toReference();
}
} | [
"private",
"function",
"entityToReference",
"(",
"&",
"$",
"item",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"(",
"is_a",
"(",
"$",
"item",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"item",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"isset",
"(",
"$",
"item",
"->",
"guid",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"item",
",",
"'toReference'",
"]",
")",
")",
"{",
"// This is an entity, so we should put it in the entity cache.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item->guid}\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item->guid}\"",
"]",
"=",
"clone",
"$",
"item",
";",
"}",
"// Make a reference to the entity (its GUID and the class the entity was",
"// loaded as).",
"$",
"item",
"=",
"$",
"item",
"->",
"toReference",
"(",
")",
";",
"}",
"}"
] | Check if an item is an entity, and if it is, convert it to a reference.
@param mixed &$item The item to check.
@param mixed $key Unused, but can't be removed because array_walk_recursive
will fail.
@access private | [
"Check",
"if",
"an",
"item",
"is",
"an",
"entity",
"and",
"if",
"it",
"is",
"convert",
"it",
"to",
"a",
"reference",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L605-L619 |
sciactive/nymph-server | src/Entity.php | Entity.getDataReference | private function getDataReference($item) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& is_callable([$item, 'toReference'])) {
// Convert entities to references.
return $item->toReference();
} elseif (is_array($item)) {
// Recurse into lower arrays.
return array_map([$this, 'getDataReference'], $item);
} elseif (is_object($item)) {
foreach ($item as &$curProperty) {
$curProperty = $this->getDataReference($curProperty);
}
unset($curProperty);
}
// Not an entity or array, just return it.
return $item;
} | php | private function getDataReference($item) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& is_callable([$item, 'toReference'])) {
// Convert entities to references.
return $item->toReference();
} elseif (is_array($item)) {
// Recurse into lower arrays.
return array_map([$this, 'getDataReference'], $item);
} elseif (is_object($item)) {
foreach ($item as &$curProperty) {
$curProperty = $this->getDataReference($curProperty);
}
unset($curProperty);
}
// Not an entity or array, just return it.
return $item;
} | [
"private",
"function",
"getDataReference",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"(",
"is_a",
"(",
"$",
"item",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"item",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"item",
",",
"'toReference'",
"]",
")",
")",
"{",
"// Convert entities to references.",
"return",
"$",
"item",
"->",
"toReference",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"// Recurse into lower arrays.",
"return",
"array_map",
"(",
"[",
"$",
"this",
",",
"'getDataReference'",
"]",
",",
"$",
"item",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"&",
"$",
"curProperty",
")",
"{",
"$",
"curProperty",
"=",
"$",
"this",
"->",
"getDataReference",
"(",
"$",
"curProperty",
")",
";",
"}",
"unset",
"(",
"$",
"curProperty",
")",
";",
"}",
"// Not an entity or array, just return it.",
"return",
"$",
"item",
";",
"}"
] | Convert entities to references and return the result.
@param mixed $item The item to convert.
@return mixed The resulting item. | [
"Convert",
"entities",
"to",
"references",
"and",
"return",
"the",
"result",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L673-L692 |
sciactive/nymph-server | src/Entity.php | Entity.referenceSleep | public function referenceSleep($reference) {
if (count($reference) !== 3
|| $reference[0] !== 'nymph_entity_reference'
|| !is_int($reference[1])
|| !is_string($reference[2])) {
throw new Exceptions\InvalidParametersException(
'referenceSleep expects parameter 1 to be a valid Nymph entity '.
'reference.'
);
}
$thisClass = get_class($this);
if ($reference[2] !== $thisClass) {
throw new Exceptions\InvalidParametersException(
"referenceSleep can only be called with an entity reference of the ".
"same class. Given class: {$reference[2]}; this class: $thisClass."
);
}
$this->isASleepingReference = true;
$this->guid = $reference[1];
$this->sleepingReference = $reference;
} | php | public function referenceSleep($reference) {
if (count($reference) !== 3
|| $reference[0] !== 'nymph_entity_reference'
|| !is_int($reference[1])
|| !is_string($reference[2])) {
throw new Exceptions\InvalidParametersException(
'referenceSleep expects parameter 1 to be a valid Nymph entity '.
'reference.'
);
}
$thisClass = get_class($this);
if ($reference[2] !== $thisClass) {
throw new Exceptions\InvalidParametersException(
"referenceSleep can only be called with an entity reference of the ".
"same class. Given class: {$reference[2]}; this class: $thisClass."
);
}
$this->isASleepingReference = true;
$this->guid = $reference[1];
$this->sleepingReference = $reference;
} | [
"public",
"function",
"referenceSleep",
"(",
"$",
"reference",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"reference",
")",
"!==",
"3",
"||",
"$",
"reference",
"[",
"0",
"]",
"!==",
"'nymph_entity_reference'",
"||",
"!",
"is_int",
"(",
"$",
"reference",
"[",
"1",
"]",
")",
"||",
"!",
"is_string",
"(",
"$",
"reference",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidParametersException",
"(",
"'referenceSleep expects parameter 1 to be a valid Nymph entity '",
".",
"'reference.'",
")",
";",
"}",
"$",
"thisClass",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"reference",
"[",
"2",
"]",
"!==",
"$",
"thisClass",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidParametersException",
"(",
"\"referenceSleep can only be called with an entity reference of the \"",
".",
"\"same class. Given class: {$reference[2]}; this class: $thisClass.\"",
")",
";",
"}",
"$",
"this",
"->",
"isASleepingReference",
"=",
"true",
";",
"$",
"this",
"->",
"guid",
"=",
"$",
"reference",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"sleepingReference",
"=",
"$",
"reference",
";",
"}"
] | Set up a sleeping reference.
@param array $reference The reference to use to wake. | [
"Set",
"up",
"a",
"sleeping",
"reference",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L927-L947 |
sciactive/nymph-server | src/Entity.php | Entity.referenceToEntity | private function referenceToEntity(&$item, $key) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if (is_array($item)) {
if (isset($item[0]) && $item[0] === 'nymph_entity_reference') {
if (!isset($this->entityCache["referenceGuid__{$item[1]}"])) {
if (!class_exists($item[2])) {
throw new Exceptions\EntityClassNotFoundException(
"Tried to load entity reference that refers to a class that ".
"can't be found, {$item[2]}."
);
}
$this->entityCache["referenceGuid__{$item[1]}"] =
call_user_func([$item[2], 'factoryReference'], $item);
}
$item = $this->entityCache["referenceGuid__{$item[1]}"];
} else {
array_walk($item, [$this, 'referenceToEntity']);
}
} elseif (is_object($item)
&& !(
(
is_a($item, '\Nymph\Entity')
|| is_a($item, '\SciActive\HookOverride')
)
&& is_callable([$item, 'toReference'])
)) {
// Only do this for non-entity objects.
foreach ($item as &$curProperty) {
$this->referenceToEntity($curProperty, null);
}
unset($curProperty);
}
} | php | private function referenceToEntity(&$item, $key) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if (is_array($item)) {
if (isset($item[0]) && $item[0] === 'nymph_entity_reference') {
if (!isset($this->entityCache["referenceGuid__{$item[1]}"])) {
if (!class_exists($item[2])) {
throw new Exceptions\EntityClassNotFoundException(
"Tried to load entity reference that refers to a class that ".
"can't be found, {$item[2]}."
);
}
$this->entityCache["referenceGuid__{$item[1]}"] =
call_user_func([$item[2], 'factoryReference'], $item);
}
$item = $this->entityCache["referenceGuid__{$item[1]}"];
} else {
array_walk($item, [$this, 'referenceToEntity']);
}
} elseif (is_object($item)
&& !(
(
is_a($item, '\Nymph\Entity')
|| is_a($item, '\SciActive\HookOverride')
)
&& is_callable([$item, 'toReference'])
)) {
// Only do this for non-entity objects.
foreach ($item as &$curProperty) {
$this->referenceToEntity($curProperty, null);
}
unset($curProperty);
}
} | [
"private",
"function",
"referenceToEntity",
"(",
"&",
"$",
"item",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"0",
"]",
")",
"&&",
"$",
"item",
"[",
"0",
"]",
"===",
"'nymph_entity_reference'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item[1]}\"",
"]",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"item",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"(",
"\"Tried to load entity reference that refers to a class that \"",
".",
"\"can't be found, {$item[2]}.\"",
")",
";",
"}",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item[1]}\"",
"]",
"=",
"call_user_func",
"(",
"[",
"$",
"item",
"[",
"2",
"]",
",",
"'factoryReference'",
"]",
",",
"$",
"item",
")",
";",
"}",
"$",
"item",
"=",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item[1]}\"",
"]",
";",
"}",
"else",
"{",
"array_walk",
"(",
"$",
"item",
",",
"[",
"$",
"this",
",",
"'referenceToEntity'",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"!",
"(",
"(",
"is_a",
"(",
"$",
"item",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"item",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"item",
",",
"'toReference'",
"]",
")",
")",
")",
"{",
"// Only do this for non-entity objects.",
"foreach",
"(",
"$",
"item",
"as",
"&",
"$",
"curProperty",
")",
"{",
"$",
"this",
"->",
"referenceToEntity",
"(",
"$",
"curProperty",
",",
"null",
")",
";",
"}",
"unset",
"(",
"$",
"curProperty",
")",
";",
"}",
"}"
] | Check if an item is a reference, and if it is, convert it to an entity.
This function will recurse into deeper arrays.
@param mixed &$item The item to check.
@param mixed $key Unused, but can't be removed because array_walk will
fail.
@access private | [
"Check",
"if",
"an",
"item",
"is",
"a",
"reference",
"and",
"if",
"it",
"is",
"convert",
"it",
"to",
"an",
"entity",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L959-L993 |
sciactive/nymph-server | src/Entity.php | Entity.referenceWake | private function referenceWake() {
if (!$this->isASleepingReference) {
return true;
}
if (!class_exists($this->sleepingReference[2])) {
throw new Exceptions\EntityClassNotFoundException(
"Tried to wake sleeping reference entity that refers to a class ".
"that can't be found, {$this->sleepingReference[2]}."
);
}
$entity = Nymph::getEntity(
['class' => $this->sleepingReference[2], 'skip_ac' => $this->useSkipAc],
['&', 'guid' => $this->sleepingReference[1]]
);
if (!isset($entity)) {
return false;
}
$this->isASleepingReference = false;
$this->sleepingReference = null;
$this->guid = $entity->guid;
$this->tags = $entity->tags;
$this->cdate = $entity->cdate;
$this->mdate = $entity->mdate;
$this->putData($entity->getData(), $entity->getSData());
return true;
} | php | private function referenceWake() {
if (!$this->isASleepingReference) {
return true;
}
if (!class_exists($this->sleepingReference[2])) {
throw new Exceptions\EntityClassNotFoundException(
"Tried to wake sleeping reference entity that refers to a class ".
"that can't be found, {$this->sleepingReference[2]}."
);
}
$entity = Nymph::getEntity(
['class' => $this->sleepingReference[2], 'skip_ac' => $this->useSkipAc],
['&', 'guid' => $this->sleepingReference[1]]
);
if (!isset($entity)) {
return false;
}
$this->isASleepingReference = false;
$this->sleepingReference = null;
$this->guid = $entity->guid;
$this->tags = $entity->tags;
$this->cdate = $entity->cdate;
$this->mdate = $entity->mdate;
$this->putData($entity->getData(), $entity->getSData());
return true;
} | [
"private",
"function",
"referenceWake",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"sleepingReference",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"(",
"\"Tried to wake sleeping reference entity that refers to a class \"",
".",
"\"that can't be found, {$this->sleepingReference[2]}.\"",
")",
";",
"}",
"$",
"entity",
"=",
"Nymph",
"::",
"getEntity",
"(",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"sleepingReference",
"[",
"2",
"]",
",",
"'skip_ac'",
"=>",
"$",
"this",
"->",
"useSkipAc",
"]",
",",
"[",
"'&'",
",",
"'guid'",
"=>",
"$",
"this",
"->",
"sleepingReference",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"isASleepingReference",
"=",
"false",
";",
"$",
"this",
"->",
"sleepingReference",
"=",
"null",
";",
"$",
"this",
"->",
"guid",
"=",
"$",
"entity",
"->",
"guid",
";",
"$",
"this",
"->",
"tags",
"=",
"$",
"entity",
"->",
"tags",
";",
"$",
"this",
"->",
"cdate",
"=",
"$",
"entity",
"->",
"cdate",
";",
"$",
"this",
"->",
"mdate",
"=",
"$",
"entity",
"->",
"mdate",
";",
"$",
"this",
"->",
"putData",
"(",
"$",
"entity",
"->",
"getData",
"(",
")",
",",
"$",
"entity",
"->",
"getSData",
"(",
")",
")",
";",
"return",
"true",
";",
"}"
] | Wake from a sleeping reference.
@return bool True on success, false on failure. | [
"Wake",
"from",
"a",
"sleeping",
"reference",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L1000-L1025 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php | ezcMailFileParser.openFile | private function openFile( $fileName )
{
// The filename is now relative, we need to extend it with the absolute path.
// To provide uniqueness we put the file in a directory based on processID and rand.
$dirName = ezcMailParser::getTmpDir() . getmypid() . '-' . self::$counter++ . '/';
if ( !is_dir( $dirName ) )
{
mkdir( $dirName, 0700 );
}
// remove the directory and the file when PHP shuts down
ezcMailParserShutdownHandler::registerForRemoval( $dirName );
$this->fileName = $dirName . $fileName;
$fp = fopen( $this->fileName, 'w' );
if ( $this->fp === false )
{
throw new ezcBaseFileNotFoundException( $this->fileName );
}
return $fp;
} | php | private function openFile( $fileName )
{
// The filename is now relative, we need to extend it with the absolute path.
// To provide uniqueness we put the file in a directory based on processID and rand.
$dirName = ezcMailParser::getTmpDir() . getmypid() . '-' . self::$counter++ . '/';
if ( !is_dir( $dirName ) )
{
mkdir( $dirName, 0700 );
}
// remove the directory and the file when PHP shuts down
ezcMailParserShutdownHandler::registerForRemoval( $dirName );
$this->fileName = $dirName . $fileName;
$fp = fopen( $this->fileName, 'w' );
if ( $this->fp === false )
{
throw new ezcBaseFileNotFoundException( $this->fileName );
}
return $fp;
} | [
"private",
"function",
"openFile",
"(",
"$",
"fileName",
")",
"{",
"// The filename is now relative, we need to extend it with the absolute path.",
"// To provide uniqueness we put the file in a directory based on processID and rand.",
"$",
"dirName",
"=",
"ezcMailParser",
"::",
"getTmpDir",
"(",
")",
".",
"getmypid",
"(",
")",
".",
"'-'",
".",
"self",
"::",
"$",
"counter",
"++",
".",
"'/'",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirName",
")",
")",
"{",
"mkdir",
"(",
"$",
"dirName",
",",
"0700",
")",
";",
"}",
"// remove the directory and the file when PHP shuts down",
"ezcMailParserShutdownHandler",
"::",
"registerForRemoval",
"(",
"$",
"dirName",
")",
";",
"$",
"this",
"->",
"fileName",
"=",
"$",
"dirName",
".",
"$",
"fileName",
";",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"fileName",
",",
"'w'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"fp",
"===",
"false",
")",
"{",
"throw",
"new",
"ezcBaseFileNotFoundException",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"}",
"return",
"$",
"fp",
";",
"}"
] | Returns the filepointer of the opened file $fileName in a unique directory..
This method will create a new unique folder in the temporary directory specified in ezcMailParser.
The fileName property of this class will be set to the location of the new file.
@throws ezcBaseFileNotFoundException
if the file could not be opened.
@param string $fileName
@return resource | [
"Returns",
"the",
"filepointer",
"of",
"the",
"opened",
"file",
"$fileName",
"in",
"a",
"unique",
"directory",
".."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L140-L160 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php | ezcMailFileParser.appendStreamFilters | private function appendStreamFilters( $line )
{
// append the correct decoding filter
switch ( strtolower( $this->headers['Content-Transfer-Encoding'] ) )
{
case 'base64':
stream_filter_append( $this->fp, 'convert.base64-decode' );
break;
case 'quoted-printable':
// fetch the type of linebreak
preg_match( "/(\r\n|\r|\n)$/", $line, $matches );
$lb = count( $matches ) > 0 ? $matches[0] : ezcMailTools::lineBreak();
$param = array( 'line-break-chars' => $lb );
stream_filter_append( $this->fp, 'convert.quoted-printable-decode',
STREAM_FILTER_WRITE, $param );
break;
case '7bit':
case '8bit':
// do nothing here, file is already just binary
break;
default:
// 7bit default
break;
}
} | php | private function appendStreamFilters( $line )
{
// append the correct decoding filter
switch ( strtolower( $this->headers['Content-Transfer-Encoding'] ) )
{
case 'base64':
stream_filter_append( $this->fp, 'convert.base64-decode' );
break;
case 'quoted-printable':
// fetch the type of linebreak
preg_match( "/(\r\n|\r|\n)$/", $line, $matches );
$lb = count( $matches ) > 0 ? $matches[0] : ezcMailTools::lineBreak();
$param = array( 'line-break-chars' => $lb );
stream_filter_append( $this->fp, 'convert.quoted-printable-decode',
STREAM_FILTER_WRITE, $param );
break;
case '7bit':
case '8bit':
// do nothing here, file is already just binary
break;
default:
// 7bit default
break;
}
} | [
"private",
"function",
"appendStreamFilters",
"(",
"$",
"line",
")",
"{",
"// append the correct decoding filter",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"headers",
"[",
"'Content-Transfer-Encoding'",
"]",
")",
")",
"{",
"case",
"'base64'",
":",
"stream_filter_append",
"(",
"$",
"this",
"->",
"fp",
",",
"'convert.base64-decode'",
")",
";",
"break",
";",
"case",
"'quoted-printable'",
":",
"// fetch the type of linebreak",
"preg_match",
"(",
"\"/(\\r\\n|\\r|\\n)$/\"",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"$",
"lb",
"=",
"count",
"(",
"$",
"matches",
")",
">",
"0",
"?",
"$",
"matches",
"[",
"0",
"]",
":",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
";",
"$",
"param",
"=",
"array",
"(",
"'line-break-chars'",
"=>",
"$",
"lb",
")",
";",
"stream_filter_append",
"(",
"$",
"this",
"->",
"fp",
",",
"'convert.quoted-printable-decode'",
",",
"STREAM_FILTER_WRITE",
",",
"$",
"param",
")",
";",
"break",
";",
"case",
"'7bit'",
":",
"case",
"'8bit'",
":",
"// do nothing here, file is already just binary",
"break",
";",
"default",
":",
"// 7bit default",
"break",
";",
"}",
"}"
] | Sets the correct stream filters for the attachment.
$line should contain one line of data that should be written to file.
It is used to correctly determine the type of linebreak used in the mail.
@param string $line | [
"Sets",
"the",
"correct",
"stream",
"filters",
"for",
"the",
"attachment",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L190-L215 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php | ezcMailFileParser.parseBody | public function parseBody( $line )
{
if ( $line !== '' )
{
if ( $this->dataWritten === false )
{
$this->appendStreamFilters( $line );
$this->dataWritten = true;
}
fwrite( $this->fp, $line );
}
} | php | public function parseBody( $line )
{
if ( $line !== '' )
{
if ( $this->dataWritten === false )
{
$this->appendStreamFilters( $line );
$this->dataWritten = true;
}
fwrite( $this->fp, $line );
}
} | [
"public",
"function",
"parseBody",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
"!==",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dataWritten",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"appendStreamFilters",
"(",
"$",
"line",
")",
";",
"$",
"this",
"->",
"dataWritten",
"=",
"true",
";",
"}",
"fwrite",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"line",
")",
";",
"}",
"}"
] | Parse the body of a message line by line.
This method is called by the parent part on a push basis. When there
are no more lines the parent part will call finish() to retrieve the
mailPart.
The file will be decoded and saved to the given temporary directory within
a directory based on the process ID and the time.
@param string $line | [
"Parse",
"the",
"body",
"of",
"a",
"message",
"line",
"by",
"line",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L230-L242 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php | ezcMailFileParser.finish | public function finish()
{
fclose( $this->fp );
$this->fp = null;
// FIXME: DIRTY PGP HACK
// When we have PGP support these lines should be removed. They are here now to hide
// PGP parts since they will show up as file attachments if not.
if ( $this->mainType == "application" &&
( $this->subType == 'pgp-signature'
|| $this->subType == 'pgp-keys'
|| $this->subType == 'pgp-encrypted' ) )
{
return null;
}
// END DIRTY PGP HACK
$filePart = new self::$fileClass( $this->fileName );
// set content type
$filePart->setHeaders( $this->headers->getCaseSensitiveArray() );
ezcMailPartParser::parsePartHeaders( $this->headers, $filePart );
switch ( strtolower( $this->mainType ) )
{
case 'image':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_IMAGE;
break;
case 'audio':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_AUDIO;
break;
case 'video':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_VIDEO;
break;
case 'application':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_APPLICATION;
break;
}
// set mime type
$filePart->mimeType = $this->subType;
// set inline disposition mode if set.
$matches = array();
if ( preg_match( '/^\s*inline;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_INLINE;
}
if ( preg_match( '/^\s*attachment;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_ATTACHMENT;
}
$filePart->size = filesize( $this->fileName );
return $filePart;
} | php | public function finish()
{
fclose( $this->fp );
$this->fp = null;
// FIXME: DIRTY PGP HACK
// When we have PGP support these lines should be removed. They are here now to hide
// PGP parts since they will show up as file attachments if not.
if ( $this->mainType == "application" &&
( $this->subType == 'pgp-signature'
|| $this->subType == 'pgp-keys'
|| $this->subType == 'pgp-encrypted' ) )
{
return null;
}
// END DIRTY PGP HACK
$filePart = new self::$fileClass( $this->fileName );
// set content type
$filePart->setHeaders( $this->headers->getCaseSensitiveArray() );
ezcMailPartParser::parsePartHeaders( $this->headers, $filePart );
switch ( strtolower( $this->mainType ) )
{
case 'image':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_IMAGE;
break;
case 'audio':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_AUDIO;
break;
case 'video':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_VIDEO;
break;
case 'application':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_APPLICATION;
break;
}
// set mime type
$filePart->mimeType = $this->subType;
// set inline disposition mode if set.
$matches = array();
if ( preg_match( '/^\s*inline;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_INLINE;
}
if ( preg_match( '/^\s*attachment;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_ATTACHMENT;
}
$filePart->size = filesize( $this->fileName );
return $filePart;
} | [
"public",
"function",
"finish",
"(",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"// FIXME: DIRTY PGP HACK",
"// When we have PGP support these lines should be removed. They are here now to hide",
"// PGP parts since they will show up as file attachments if not.",
"if",
"(",
"$",
"this",
"->",
"mainType",
"==",
"\"application\"",
"&&",
"(",
"$",
"this",
"->",
"subType",
"==",
"'pgp-signature'",
"||",
"$",
"this",
"->",
"subType",
"==",
"'pgp-keys'",
"||",
"$",
"this",
"->",
"subType",
"==",
"'pgp-encrypted'",
")",
")",
"{",
"return",
"null",
";",
"}",
"// END DIRTY PGP HACK",
"$",
"filePart",
"=",
"new",
"self",
"::",
"$",
"fileClass",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"// set content type",
"$",
"filePart",
"->",
"setHeaders",
"(",
"$",
"this",
"->",
"headers",
"->",
"getCaseSensitiveArray",
"(",
")",
")",
";",
"ezcMailPartParser",
"::",
"parsePartHeaders",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"filePart",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"mainType",
")",
")",
"{",
"case",
"'image'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_IMAGE",
";",
"break",
";",
"case",
"'audio'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_AUDIO",
";",
"break",
";",
"case",
"'video'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_VIDEO",
";",
"break",
";",
"case",
"'application'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_APPLICATION",
";",
"break",
";",
"}",
"// set mime type",
"$",
"filePart",
"->",
"mimeType",
"=",
"$",
"this",
"->",
"subType",
";",
"// set inline disposition mode if set.",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^\\s*inline;?/i'",
",",
"$",
"this",
"->",
"headers",
"[",
"'Content-Disposition'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"filePart",
"->",
"dispositionType",
"=",
"ezcMailFile",
"::",
"DISPLAY_INLINE",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^\\s*attachment;?/i'",
",",
"$",
"this",
"->",
"headers",
"[",
"'Content-Disposition'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"filePart",
"->",
"dispositionType",
"=",
"ezcMailFile",
"::",
"DISPLAY_ATTACHMENT",
";",
"}",
"$",
"filePart",
"->",
"size",
"=",
"filesize",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"filePart",
";",
"}"
] | Return the result of the parsed file part.
This method is called automatically by the parent part.
@return ezcMailFile | [
"Return",
"the",
"result",
"of",
"the",
"parsed",
"file",
"part",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L251-L307 |
infusephp/infuse | src/Application.php | Application.map | public function map($method, $route, $handler)
{
$this['router']->map($method, $route, $handler);
return $this;
} | php | public function map($method, $route, $handler)
{
$this['router']->map($method, $route, $handler);
return $this;
} | [
"public",
"function",
"map",
"(",
"$",
"method",
",",
"$",
"route",
",",
"$",
"handler",
")",
"{",
"$",
"this",
"[",
"'router'",
"]",
"->",
"map",
"(",
"$",
"method",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a handler to the routing table for a given route.
@param string $method HTTP method
@param string $route path pattern
@param mixed $handler route handler
@return self | [
"Adds",
"a",
"handler",
"to",
"the",
"routing",
"table",
"for",
"a",
"given",
"route",
"."
] | train | https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L232-L237 |
infusephp/infuse | src/Application.php | Application.handleRequest | public function handleRequest(Request $req)
{
// set host name from request if not already set
$config = $this['config'];
if (!$config->get('app.hostname')) {
$config->set('app.hostname', $req->host());
}
$res = new Response();
try {
// determine route by dispatching to router
$routeInfo = $this['router']->dispatch($req->method(), $req->path());
$this['routeInfo'] = $routeInfo;
// set any route arguments on the request
if (isset($routeInfo[2])) {
$req->setParams($routeInfo[2]);
}
// the dispatch middleware is the final step
$dispatch = new DispatchMiddleware();
$dispatch->setApp($this);
$this->middleware($dispatch);
// the request is handled by returning the response
// generated by the middleware chain
return $this->runMiddleware($req, $res);
} catch (\Exception $e) {
return $this['exception_handler']($req, $res, $e);
} catch (\Error $e) {
return $this['php_error_handler']($req, $res, $e);
}
} | php | public function handleRequest(Request $req)
{
// set host name from request if not already set
$config = $this['config'];
if (!$config->get('app.hostname')) {
$config->set('app.hostname', $req->host());
}
$res = new Response();
try {
// determine route by dispatching to router
$routeInfo = $this['router']->dispatch($req->method(), $req->path());
$this['routeInfo'] = $routeInfo;
// set any route arguments on the request
if (isset($routeInfo[2])) {
$req->setParams($routeInfo[2]);
}
// the dispatch middleware is the final step
$dispatch = new DispatchMiddleware();
$dispatch->setApp($this);
$this->middleware($dispatch);
// the request is handled by returning the response
// generated by the middleware chain
return $this->runMiddleware($req, $res);
} catch (\Exception $e) {
return $this['exception_handler']($req, $res, $e);
} catch (\Error $e) {
return $this['php_error_handler']($req, $res, $e);
}
} | [
"public",
"function",
"handleRequest",
"(",
"Request",
"$",
"req",
")",
"{",
"// set host name from request if not already set",
"$",
"config",
"=",
"$",
"this",
"[",
"'config'",
"]",
";",
"if",
"(",
"!",
"$",
"config",
"->",
"get",
"(",
"'app.hostname'",
")",
")",
"{",
"$",
"config",
"->",
"set",
"(",
"'app.hostname'",
",",
"$",
"req",
"->",
"host",
"(",
")",
")",
";",
"}",
"$",
"res",
"=",
"new",
"Response",
"(",
")",
";",
"try",
"{",
"// determine route by dispatching to router",
"$",
"routeInfo",
"=",
"$",
"this",
"[",
"'router'",
"]",
"->",
"dispatch",
"(",
"$",
"req",
"->",
"method",
"(",
")",
",",
"$",
"req",
"->",
"path",
"(",
")",
")",
";",
"$",
"this",
"[",
"'routeInfo'",
"]",
"=",
"$",
"routeInfo",
";",
"// set any route arguments on the request",
"if",
"(",
"isset",
"(",
"$",
"routeInfo",
"[",
"2",
"]",
")",
")",
"{",
"$",
"req",
"->",
"setParams",
"(",
"$",
"routeInfo",
"[",
"2",
"]",
")",
";",
"}",
"// the dispatch middleware is the final step",
"$",
"dispatch",
"=",
"new",
"DispatchMiddleware",
"(",
")",
";",
"$",
"dispatch",
"->",
"setApp",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"middleware",
"(",
"$",
"dispatch",
")",
";",
"// the request is handled by returning the response",
"// generated by the middleware chain",
"return",
"$",
"this",
"->",
"runMiddleware",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"[",
"'exception_handler'",
"]",
"(",
"$",
"req",
",",
"$",
"res",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"\\",
"Error",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"[",
"'php_error_handler'",
"]",
"(",
"$",
"req",
",",
"$",
"res",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Builds a response to an incoming request by routing
it through the application.
@param Request $req
@return Response | [
"Builds",
"a",
"response",
"to",
"an",
"incoming",
"request",
"by",
"routing",
"it",
"through",
"the",
"application",
"."
] | train | https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L265-L297 |
infusephp/infuse | src/Application.php | Application.runMiddleware | public function runMiddleware(Request $req, Response $res)
{
$this->initMiddleware()->rewind();
return $this->nextMiddleware($req, $res);
} | php | public function runMiddleware(Request $req, Response $res)
{
$this->initMiddleware()->rewind();
return $this->nextMiddleware($req, $res);
} | [
"public",
"function",
"runMiddleware",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"this",
"->",
"initMiddleware",
"(",
")",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"this",
"->",
"nextMiddleware",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}"
] | Runs the middleware chain.
@param Request $req
@param Response $res
@return Response $res | [
"Runs",
"the",
"middleware",
"chain",
"."
] | train | https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L335-L340 |
infusephp/infuse | src/Application.php | Application.nextMiddleware | public function nextMiddleware(Request $req, Response $res)
{
$middleware = $this->middleware->current();
// base case - no middleware left
if (!$middleware) {
return $res;
}
// otherwise, call next middleware
$this->middleware->next();
return $middleware($req, $res, [$this, 'nextMiddleware']);
} | php | public function nextMiddleware(Request $req, Response $res)
{
$middleware = $this->middleware->current();
// base case - no middleware left
if (!$middleware) {
return $res;
}
// otherwise, call next middleware
$this->middleware->next();
return $middleware($req, $res, [$this, 'nextMiddleware']);
} | [
"public",
"function",
"nextMiddleware",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"middleware",
"=",
"$",
"this",
"->",
"middleware",
"->",
"current",
"(",
")",
";",
"// base case - no middleware left",
"if",
"(",
"!",
"$",
"middleware",
")",
"{",
"return",
"$",
"res",
";",
"}",
"// otherwise, call next middleware",
"$",
"this",
"->",
"middleware",
"->",
"next",
"(",
")",
";",
"return",
"$",
"middleware",
"(",
"$",
"req",
",",
"$",
"res",
",",
"[",
"$",
"this",
",",
"'nextMiddleware'",
"]",
")",
";",
"}"
] | Calls the next middleware in the chain.
DO NOT call directly.
@param Request $req
@param Response $res
@return Response | [
"Calls",
"the",
"next",
"middleware",
"in",
"the",
"chain",
".",
"DO",
"NOT",
"call",
"directly",
"."
] | train | https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L366-L379 |
infusephp/infuse | src/Application.php | Application.handle | public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
{
$bridge = new SymfonyHttpBridge();
$req = $bridge->convertSymfonyRequest($request);
return $bridge->convertInfuseResponse($this->handleRequest($req));
} | php | public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
{
$bridge = new SymfonyHttpBridge();
$req = $bridge->convertSymfonyRequest($request);
return $bridge->convertInfuseResponse($this->handleRequest($req));
} | [
"public",
"function",
"handle",
"(",
"SymfonyRequest",
"$",
"request",
",",
"$",
"type",
"=",
"self",
"::",
"MASTER_REQUEST",
",",
"$",
"catch",
"=",
"true",
")",
"{",
"$",
"bridge",
"=",
"new",
"SymfonyHttpBridge",
"(",
")",
";",
"$",
"req",
"=",
"$",
"bridge",
"->",
"convertSymfonyRequest",
"(",
"$",
"request",
")",
";",
"return",
"$",
"bridge",
"->",
"convertInfuseResponse",
"(",
"$",
"this",
"->",
"handleRequest",
"(",
"$",
"req",
")",
")",
";",
"}"
] | ////////////////////// | [
"//////////////////////"
] | train | https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L413-L419 |
traderinteractive/filter-dates-php | src/Filter/DateTimeZone.php | DateTimeZone.filter | public static function filter($value, bool $allowNull = false)
{
if (self::valueIsNullAndValid($allowNull, $value)) {
return null;
}
if ($value instanceof \DateTimeZone) {
return $value;
}
if (!is_string($value) || trim($value) == '') {
throw new FilterException('$value not a non-empty string');
}
try {
return new \DateTimeZone($value);
} catch (\Exception $e) {
throw new FilterException($e->getMessage(), $e->getCode(), $e);
}
} | php | public static function filter($value, bool $allowNull = false)
{
if (self::valueIsNullAndValid($allowNull, $value)) {
return null;
}
if ($value instanceof \DateTimeZone) {
return $value;
}
if (!is_string($value) || trim($value) == '') {
throw new FilterException('$value not a non-empty string');
}
try {
return new \DateTimeZone($value);
} catch (\Exception $e) {
throw new FilterException($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"static",
"function",
"filter",
"(",
"$",
"value",
",",
"bool",
"$",
"allowNull",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"valueIsNullAndValid",
"(",
"$",
"allowNull",
",",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTimeZone",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"||",
"trim",
"(",
"$",
"value",
")",
"==",
"''",
")",
"{",
"throw",
"new",
"FilterException",
"(",
"'$value not a non-empty string'",
")",
";",
"}",
"try",
"{",
"return",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"FilterException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Filters the given value into a \DateTimeZone object.
@param mixed $value The value to be filtered.
@param boolean $allowNull True to allow nulls through, and false (default) if nulls should not be allowed.
@return \DateTimeZone|null
@throws FilterException if the value did not pass validation. | [
"Filters",
"the",
"given",
"value",
"into",
"a",
"\\",
"DateTimeZone",
"object",
"."
] | train | https://github.com/traderinteractive/filter-dates-php/blob/f9e60f139da3ebb565317c5d62a6fb0c347be4ee/src/Filter/DateTimeZone.php#L22-L41 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Helper/Convert.php | Convert.logEntry | public static function logEntry($entry)
{
$parts = explode("|", $entry, 5);
$array = array();
if(count($parts) != 5)
{
$array["timestamp"] = 0;
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
$array["channel"] = "ParamParser";
$array["server_id"] = "";
$array["msg"] = Str::factory("convert error (" . trim($entry) . ")");
$array["msg_plain"] = $entry;
$array["malformed"] = TRUE;
}
else
{
$array["timestamp"] = strtotime(trim($parts[0]));
$array["level"] = self::logLevel(trim($parts[1]));
$array["channel"] = trim($parts[2]);
$array["server_id"] = trim($parts[3]);
$array["msg"] = Str::factory(trim($parts[4]));
$array["msg_plain"] = $entry;
$array["malformed"] = FALSE;
}
return $array;
} | php | public static function logEntry($entry)
{
$parts = explode("|", $entry, 5);
$array = array();
if(count($parts) != 5)
{
$array["timestamp"] = 0;
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
$array["channel"] = "ParamParser";
$array["server_id"] = "";
$array["msg"] = Str::factory("convert error (" . trim($entry) . ")");
$array["msg_plain"] = $entry;
$array["malformed"] = TRUE;
}
else
{
$array["timestamp"] = strtotime(trim($parts[0]));
$array["level"] = self::logLevel(trim($parts[1]));
$array["channel"] = trim($parts[2]);
$array["server_id"] = trim($parts[3]);
$array["msg"] = Str::factory(trim($parts[4]));
$array["msg_plain"] = $entry;
$array["malformed"] = FALSE;
}
return $array;
} | [
"public",
"static",
"function",
"logEntry",
"(",
"$",
"entry",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\"|\"",
",",
"$",
"entry",
",",
"5",
")",
";",
"$",
"array",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"!=",
"5",
")",
"{",
"$",
"array",
"[",
"\"timestamp\"",
"]",
"=",
"0",
";",
"$",
"array",
"[",
"\"level\"",
"]",
"=",
"TeamSpeak3",
"::",
"LOGLEVEL_ERROR",
";",
"$",
"array",
"[",
"\"channel\"",
"]",
"=",
"\"ParamParser\"",
";",
"$",
"array",
"[",
"\"server_id\"",
"]",
"=",
"\"\"",
";",
"$",
"array",
"[",
"\"msg\"",
"]",
"=",
"Str",
"::",
"factory",
"(",
"\"convert error (\"",
".",
"trim",
"(",
"$",
"entry",
")",
".",
"\")\"",
")",
";",
"$",
"array",
"[",
"\"msg_plain\"",
"]",
"=",
"$",
"entry",
";",
"$",
"array",
"[",
"\"malformed\"",
"]",
"=",
"TRUE",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"\"timestamp\"",
"]",
"=",
"strtotime",
"(",
"trim",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
")",
";",
"$",
"array",
"[",
"\"level\"",
"]",
"=",
"self",
"::",
"logLevel",
"(",
"trim",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
";",
"$",
"array",
"[",
"\"channel\"",
"]",
"=",
"trim",
"(",
"$",
"parts",
"[",
"2",
"]",
")",
";",
"$",
"array",
"[",
"\"server_id\"",
"]",
"=",
"trim",
"(",
"$",
"parts",
"[",
"3",
"]",
")",
";",
"$",
"array",
"[",
"\"msg\"",
"]",
"=",
"Str",
"::",
"factory",
"(",
"trim",
"(",
"$",
"parts",
"[",
"4",
"]",
")",
")",
";",
"$",
"array",
"[",
"\"msg_plain\"",
"]",
"=",
"$",
"entry",
";",
"$",
"array",
"[",
"\"malformed\"",
"]",
"=",
"FALSE",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Converts a specified log entry string into an array containing the data.
@param string $entry
@return array | [
"Converts",
"a",
"specified",
"log",
"entry",
"string",
"into",
"an",
"array",
"containing",
"the",
"data",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Convert.php#L258-L285 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.startWithNode | public static function startWithNode(
string $variable = null,
array $labels = []
): self {
$path = new self;
$path->elements = $path->elements->add(
new Node($variable, $labels)
);
$path->lastOperation = Node::class;
return $path;
} | php | public static function startWithNode(
string $variable = null,
array $labels = []
): self {
$path = new self;
$path->elements = $path->elements->add(
new Node($variable, $labels)
);
$path->lastOperation = Node::class;
return $path;
} | [
"public",
"static",
"function",
"startWithNode",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"path",
"->",
"elements",
"->",
"add",
"(",
"new",
"Node",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
")",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"Node",
"::",
"class",
";",
"return",
"$",
"path",
";",
"}"
] | Start the path with the given node
@param string $variable
@param array $labels
@return self | [
"Start",
"the",
"path",
"with",
"the",
"given",
"node"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L35-L46 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.linkedTo | public function linkedTo(string $variable = null, array $labels = []): self
{
$path = new self;
$path->elements = $this
->elements
->add(Relationship::both())
->add(new Node($variable, $labels));
$path->lastOperation = Node::class;
return $path;
} | php | public function linkedTo(string $variable = null, array $labels = []): self
{
$path = new self;
$path->elements = $this
->elements
->add(Relationship::both())
->add(new Node($variable, $labels));
$path->lastOperation = Node::class;
return $path;
} | [
"public",
"function",
"linkedTo",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"add",
"(",
"Relationship",
"::",
"both",
"(",
")",
")",
"->",
"add",
"(",
"new",
"Node",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
")",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"Node",
"::",
"class",
";",
"return",
"$",
"path",
";",
"}"
] | Create a relationship to the given node
@param string $variable
@param array $labels
@return self | [
"Create",
"a",
"relationship",
"to",
"the",
"given",
"node"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L56-L66 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.through | public function through(
string $variable = null,
string $type = null,
string $direction = 'BOTH'
): self {
if ($this->elements->size() < 3) {
throw new LogicException;
}
$direction = \strtolower($direction);
$path = new self;
$path->elements = $this
->elements
->dropEnd(2)
->add(Relationship::$direction($variable, $type))
->add($this->elements->last());
$path->lastOperation = Relationship::class;
return $path;
} | php | public function through(
string $variable = null,
string $type = null,
string $direction = 'BOTH'
): self {
if ($this->elements->size() < 3) {
throw new LogicException;
}
$direction = \strtolower($direction);
$path = new self;
$path->elements = $this
->elements
->dropEnd(2)
->add(Relationship::$direction($variable, $type))
->add($this->elements->last());
$path->lastOperation = Relationship::class;
return $path;
} | [
"public",
"function",
"through",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"string",
"$",
"type",
"=",
"null",
",",
"string",
"$",
"direction",
"=",
"'BOTH'",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"size",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"LogicException",
";",
"}",
"$",
"direction",
"=",
"\\",
"strtolower",
"(",
"$",
"direction",
")",
";",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"Relationship",
"::",
"$",
"direction",
"(",
"$",
"variable",
",",
"$",
"type",
")",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"Relationship",
"::",
"class",
";",
"return",
"$",
"path",
";",
"}"
] | Type the last declared relationship in the path
@param string $variable
@param string $type
@param string $direction
@throws LogicException If no relationship in the path
@return self | [
"Type",
"the",
"last",
"declared",
"relationship",
"in",
"the",
"path"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L79-L99 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.withADistanceBetween | public function withADistanceBetween(int $min, int $max): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withADistanceBetween($min, $max)
)
->add($this->elements->last());
return $path;
} | php | public function withADistanceBetween(int $min, int $max): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withADistanceBetween($min, $max)
)
->add($this->elements->last());
return $path;
} | [
"public",
"function",
"withADistanceBetween",
"(",
"int",
"$",
"min",
",",
"int",
"$",
"max",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"size",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"LogicException",
";",
"}",
"$",
"path",
"=",
"clone",
"$",
"this",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
"->",
"withADistanceBetween",
"(",
"$",
"min",
",",
"$",
"max",
")",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Define the deepness range of the relationship
@param int $min
@param int $max
@throws LogicException If no relationship in the path
@return self | [
"Define",
"the",
"deepness",
"range",
"of",
"the",
"relationship"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L138-L154 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.withADistanceOfAtLeast | public function withADistanceOfAtLeast(int $distance): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withADistanceOfAtLeast($distance)
)
->add($this->elements->last());
return $path;
} | php | public function withADistanceOfAtLeast(int $distance): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withADistanceOfAtLeast($distance)
)
->add($this->elements->last());
return $path;
} | [
"public",
"function",
"withADistanceOfAtLeast",
"(",
"int",
"$",
"distance",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"size",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"LogicException",
";",
"}",
"$",
"path",
"=",
"clone",
"$",
"this",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
"->",
"withADistanceOfAtLeast",
"(",
"$",
"distance",
")",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Define the minimum deepness of the relationship
@param int $distance
@throws LogicException If no relationship in the path
@return self | [
"Define",
"the",
"minimum",
"deepness",
"of",
"the",
"relationship"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L165-L181 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.withAnyDistance | public function withAnyDistance(): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withAnyDistance()
)
->add($this->elements->last());
return $path;
} | php | public function withAnyDistance(): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withAnyDistance()
)
->add($this->elements->last());
return $path;
} | [
"public",
"function",
"withAnyDistance",
"(",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"size",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"LogicException",
";",
"}",
"$",
"path",
"=",
"clone",
"$",
"this",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
"->",
"withAnyDistance",
"(",
")",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Define any deepness of the relationship
@param int $distance
@throws LogicException If no relationship in the path
@return self | [
"Define",
"any",
"deepness",
"of",
"the",
"relationship"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L219-L235 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.withParameter | public function withParameter(string $key, $value): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withParameter($key, $value);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
} | php | public function withParameter(string $key, $value): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withParameter($key, $value);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
} | [
"public",
"function",
"withParameter",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
";",
"}",
"else",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
";",
"}",
"$",
"element",
"=",
"$",
"element",
"->",
"withParameter",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"$",
"this",
"->",
"lastOperation",
";",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"element",
")",
";",
"}",
"else",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"element",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Add the given parameter to the last operation
@param string $key
@param mixed $value
@return self | [
"Add",
"the",
"given",
"parameter",
"to",
"the",
"last",
"operation"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L245-L271 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.withProperty | public function withProperty(string $property, string $cypher): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withProperty($property, $cypher);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
} | php | public function withProperty(string $property, string $cypher): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withProperty($property, $cypher);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
} | [
"public",
"function",
"withProperty",
"(",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
";",
"}",
"else",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
";",
"}",
"$",
"element",
"=",
"$",
"element",
"->",
"withProperty",
"(",
"$",
"property",
",",
"$",
"cypher",
")",
";",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"$",
"this",
"->",
"lastOperation",
";",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"element",
")",
";",
"}",
"else",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"element",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Add the given property to the last operation
@param string $property
@param string $cypher
@return self | [
"Add",
"the",
"given",
"property",
"to",
"the",
"last",
"operation"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L281-L307 |
Innmind/neo4j-dbal | src/Clause/Expression/Path.php | Path.parameters | public function parameters(): MapInterface
{
if ($this->parameters) {
return $this->parameters;
}
return $this->parameters = $this->elements->reduce(
new Map('string', Parameter::class),
function(Map $carry, $element): Map {
return $carry->merge($element->parameters());
}
);
} | php | public function parameters(): MapInterface
{
if ($this->parameters) {
return $this->parameters;
}
return $this->parameters = $this->elements->reduce(
new Map('string', Parameter::class),
function(Map $carry, $element): Map {
return $carry->merge($element->parameters());
}
);
} | [
"public",
"function",
"parameters",
"(",
")",
":",
"MapInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"parameters",
";",
"}",
"return",
"$",
"this",
"->",
"parameters",
"=",
"$",
"this",
"->",
"elements",
"->",
"reduce",
"(",
"new",
"Map",
"(",
"'string'",
",",
"Parameter",
"::",
"class",
")",
",",
"function",
"(",
"Map",
"$",
"carry",
",",
"$",
"element",
")",
":",
"Map",
"{",
"return",
"$",
"carry",
"->",
"merge",
"(",
"$",
"element",
"->",
"parameters",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] | Return all the parameters of the path
@return MapInterface<string, Parameter> | [
"Return",
"all",
"the",
"parameters",
"of",
"the",
"path"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L314-L326 |
OKTOTV/OktolabMediaBundle | Model/EncodeEpisodeJob.php | EncodeEpisodeJob.perform | public function perform() {
$this->oktolab_media = $this->getContainer()->get('oktolab_media');
$episode = $this->oktolab_media->getEpisode($this->args['uniqID']);
$this->logbook = $this->getContainer()->get('bprs_logbook');
$this->logbook->info(
'oktolab_media.episode_start_encodevideo',
[],
$this->args['uniqID']
);
if ($episode) {
$this->encodeEpisode($episode);
} else { // no episode found
$this->logbook->error(
'oktolab_media.episode_encodenoepisode',
[],
$this->args['uniqID']
);
}
$this->logbook->info(
'oktolab_media.episode_end_encodevideo',
[],
$this->args['uniqID']
);
} | php | public function perform() {
$this->oktolab_media = $this->getContainer()->get('oktolab_media');
$episode = $this->oktolab_media->getEpisode($this->args['uniqID']);
$this->logbook = $this->getContainer()->get('bprs_logbook');
$this->logbook->info(
'oktolab_media.episode_start_encodevideo',
[],
$this->args['uniqID']
);
if ($episode) {
$this->encodeEpisode($episode);
} else { // no episode found
$this->logbook->error(
'oktolab_media.episode_encodenoepisode',
[],
$this->args['uniqID']
);
}
$this->logbook->info(
'oktolab_media.episode_end_encodevideo',
[],
$this->args['uniqID']
);
} | [
"public",
"function",
"perform",
"(",
")",
"{",
"$",
"this",
"->",
"oktolab_media",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'oktolab_media'",
")",
";",
"$",
"episode",
"=",
"$",
"this",
"->",
"oktolab_media",
"->",
"getEpisode",
"(",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"$",
"this",
"->",
"logbook",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'bprs_logbook'",
")",
";",
"$",
"this",
"->",
"logbook",
"->",
"info",
"(",
"'oktolab_media.episode_start_encodevideo'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"if",
"(",
"$",
"episode",
")",
"{",
"$",
"this",
"->",
"encodeEpisode",
"(",
"$",
"episode",
")",
";",
"}",
"else",
"{",
"// no episode found",
"$",
"this",
"->",
"logbook",
"->",
"error",
"(",
"'oktolab_media.episode_encodenoepisode'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"logbook",
"->",
"info",
"(",
"'oktolab_media.episode_end_encodevideo'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L25-L51 |
OKTOTV/OktolabMediaBundle | Model/EncodeEpisodeJob.php | EncodeEpisodeJob.executeFFmpegForMedia | private function executeFFmpegForMedia($cmd, $format, $resolution, $media) {
$ffmpeg_start = microtime(true);
$this->getContainer()->get('oktolab_media_ffmpeg')
->executeFFmpegForMedia(
$resolution['encoder'],
$cmd,
$media
)
;
$ffmpeg_stop = microtime(true);
$media->setStatus(Media::OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED);
$media->setPublic($resolution['public']);
$this->em->persist($media);
$this->em->flush();
$this->logbook->info(
'oktolab_media.episode_end_saving_media',
[
'%format%' => $format,
'%seconds%' => round($ffmpeg_stop - $ffmpeg_start)
],
$this->args['uniqID']
);
// move encoded media from "cache" to config adapter or adapter of the original file
$this->getContainer()->get('bprs.asset')->moveAsset(
$media->getAsset(),
$resolution['adapter'] ? $resolution['adapter'] : $media->getEpisode()->getVideo()->getAdapter()
);
// add finalize episode job, set new episode status
if (!$this->added_finalize) {
$this->finalizeEpisode($media->getEpisode());
$this->added_finalize = true;
}
} | php | private function executeFFmpegForMedia($cmd, $format, $resolution, $media) {
$ffmpeg_start = microtime(true);
$this->getContainer()->get('oktolab_media_ffmpeg')
->executeFFmpegForMedia(
$resolution['encoder'],
$cmd,
$media
)
;
$ffmpeg_stop = microtime(true);
$media->setStatus(Media::OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED);
$media->setPublic($resolution['public']);
$this->em->persist($media);
$this->em->flush();
$this->logbook->info(
'oktolab_media.episode_end_saving_media',
[
'%format%' => $format,
'%seconds%' => round($ffmpeg_stop - $ffmpeg_start)
],
$this->args['uniqID']
);
// move encoded media from "cache" to config adapter or adapter of the original file
$this->getContainer()->get('bprs.asset')->moveAsset(
$media->getAsset(),
$resolution['adapter'] ? $resolution['adapter'] : $media->getEpisode()->getVideo()->getAdapter()
);
// add finalize episode job, set new episode status
if (!$this->added_finalize) {
$this->finalizeEpisode($media->getEpisode());
$this->added_finalize = true;
}
} | [
"private",
"function",
"executeFFmpegForMedia",
"(",
"$",
"cmd",
",",
"$",
"format",
",",
"$",
"resolution",
",",
"$",
"media",
")",
"{",
"$",
"ffmpeg_start",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'oktolab_media_ffmpeg'",
")",
"->",
"executeFFmpegForMedia",
"(",
"$",
"resolution",
"[",
"'encoder'",
"]",
",",
"$",
"cmd",
",",
"$",
"media",
")",
";",
"$",
"ffmpeg_stop",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"media",
"->",
"setStatus",
"(",
"Media",
"::",
"OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED",
")",
";",
"$",
"media",
"->",
"setPublic",
"(",
"$",
"resolution",
"[",
"'public'",
"]",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"media",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"logbook",
"->",
"info",
"(",
"'oktolab_media.episode_end_saving_media'",
",",
"[",
"'%format%'",
"=>",
"$",
"format",
",",
"'%seconds%'",
"=>",
"round",
"(",
"$",
"ffmpeg_stop",
"-",
"$",
"ffmpeg_start",
")",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"// move encoded media from \"cache\" to config adapter or adapter of the original file",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'bprs.asset'",
")",
"->",
"moveAsset",
"(",
"$",
"media",
"->",
"getAsset",
"(",
")",
",",
"$",
"resolution",
"[",
"'adapter'",
"]",
"?",
"$",
"resolution",
"[",
"'adapter'",
"]",
":",
"$",
"media",
"->",
"getEpisode",
"(",
")",
"->",
"getVideo",
"(",
")",
"->",
"getAdapter",
"(",
")",
")",
";",
"// add finalize episode job, set new episode status",
"if",
"(",
"!",
"$",
"this",
"->",
"added_finalize",
")",
"{",
"$",
"this",
"->",
"finalizeEpisode",
"(",
"$",
"media",
"->",
"getEpisode",
"(",
")",
")",
";",
"$",
"this",
"->",
"added_finalize",
"=",
"true",
";",
"}",
"}"
] | creates a media object and runs the ffmpeg command for the given resolution.
the command will be tracked to update the progress from 0 - 100 in realtime.
will move the asset from the cache adapter to the adapter in the resolution if defined.
triggers the finalize episode function once for the whole job | [
"creates",
"a",
"media",
"object",
"and",
"runs",
"the",
"ffmpeg",
"command",
"for",
"the",
"given",
"resolution",
".",
"the",
"command",
"will",
"be",
"tracked",
"to",
"update",
"the",
"progress",
"from",
"0",
"-",
"100",
"in",
"realtime",
".",
"will",
"move",
"the",
"asset",
"from",
"the",
"cache",
"adapter",
"to",
"the",
"adapter",
"in",
"the",
"resolution",
"if",
"defined",
".",
"triggers",
"the",
"finalize",
"episode",
"function",
"once",
"for",
"the",
"whole",
"job"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L251-L287 |
OKTOTV/OktolabMediaBundle | Model/EncodeEpisodeJob.php | EncodeEpisodeJob.finalizeEpisode | private function finalizeEpisode($episode) {
$event = new EncodedEpisodeEvent($episode);
$this->getContainer()->get('event_dispatcher')->dispatch(
OktolabMediaEvent::ENCODED_EPISODE,
$event
);
$this->oktolab_media->addFinalizeEpisodeJob(
$episode->getUniqID(),
false,
true
);
} | php | private function finalizeEpisode($episode) {
$event = new EncodedEpisodeEvent($episode);
$this->getContainer()->get('event_dispatcher')->dispatch(
OktolabMediaEvent::ENCODED_EPISODE,
$event
);
$this->oktolab_media->addFinalizeEpisodeJob(
$episode->getUniqID(),
false,
true
);
} | [
"private",
"function",
"finalizeEpisode",
"(",
"$",
"episode",
")",
"{",
"$",
"event",
"=",
"new",
"EncodedEpisodeEvent",
"(",
"$",
"episode",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'event_dispatcher'",
")",
"->",
"dispatch",
"(",
"OktolabMediaEvent",
"::",
"ENCODED_EPISODE",
",",
"$",
"event",
")",
";",
"$",
"this",
"->",
"oktolab_media",
"->",
"addFinalizeEpisodeJob",
"(",
"$",
"episode",
"->",
"getUniqID",
"(",
")",
",",
"false",
",",
"true",
")",
";",
"}"
] | adds finalize job
and dispatches encoded_episode event | [
"adds",
"finalize",
"job",
"and",
"dispatches",
"encoded_episode",
"event"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L312-L324 |
OKTOTV/OktolabMediaBundle | Model/EncodeEpisodeJob.php | EncodeEpisodeJob.createNewCacheAssetForResolution | private function createNewCacheAssetForResolution($episode, $resolution) {
$asset = $this->getContainer()->get('bprs.asset')->createAsset();
$asset->setFilekey(
sprintf('%s.%s',$asset->getFilekey(), $resolution['container'])
);
$asset->setAdapter(
$this->getContainer()->getParameter(
'oktolab_media.encoding_filesystem'
)
);
$asset->setName($episode->getVideo()->getName());
$asset->setMimetype($resolution['mimetype']);
return $asset;
} | php | private function createNewCacheAssetForResolution($episode, $resolution) {
$asset = $this->getContainer()->get('bprs.asset')->createAsset();
$asset->setFilekey(
sprintf('%s.%s',$asset->getFilekey(), $resolution['container'])
);
$asset->setAdapter(
$this->getContainer()->getParameter(
'oktolab_media.encoding_filesystem'
)
);
$asset->setName($episode->getVideo()->getName());
$asset->setMimetype($resolution['mimetype']);
return $asset;
} | [
"private",
"function",
"createNewCacheAssetForResolution",
"(",
"$",
"episode",
",",
"$",
"resolution",
")",
"{",
"$",
"asset",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'bprs.asset'",
")",
"->",
"createAsset",
"(",
")",
";",
"$",
"asset",
"->",
"setFilekey",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"asset",
"->",
"getFilekey",
"(",
")",
",",
"$",
"resolution",
"[",
"'container'",
"]",
")",
")",
";",
"$",
"asset",
"->",
"setAdapter",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'oktolab_media.encoding_filesystem'",
")",
")",
";",
"$",
"asset",
"->",
"setName",
"(",
"$",
"episode",
"->",
"getVideo",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"$",
"asset",
"->",
"setMimetype",
"(",
"$",
"resolution",
"[",
"'mimetype'",
"]",
")",
";",
"return",
"$",
"asset",
";",
"}"
] | returns an empty asset to be used in an encoding situation.
the filekey, mimetype and adapter are already set for ffmpeg | [
"returns",
"an",
"empty",
"asset",
"to",
"be",
"used",
"in",
"an",
"encoding",
"situation",
".",
"the",
"filekey",
"mimetype",
"and",
"adapter",
"are",
"already",
"set",
"for",
"ffmpeg"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L330-L344 |
OKTOTV/OktolabMediaBundle | Model/EncodeEpisodeJob.php | EncodeEpisodeJob.deleteOriginalIfConfigured | private function deleteOriginalIfConfigured() {
$episode = $this->oktolab_media->getEpisode($this->args['uniqID']);
if (!$this->getContainer()->getParameter('oktolab_media.keep_original')) {
$this->logbook->info(
'oktolab_media.episode_encode_remove_old_media',
[],
$this->args['uniqID']
);
if (count($episode->getMedia())) {
// check if any media is incomplete.
$all_media_ok = true;
foreach ($episode->getMedia() as $media) {
if ($media->getProgress() < 100) {
$all_media_ok = false;
}
}
if ($all_media_ok) { // if all media ok, replace original file
$this->getContainer()->get('oktolab_media_helper')->deleteVideo($episode);
$best_media = $episode->getMedia()[0];
foreach ($episode->getMedia() as $media) {
if ($media->getSortNumber() > $best_media->getSortNumber()) {
$best_media = $media;
}
}
$episode->setVideo($best_media->getAsset());
} else { // some media were not okay. keep original for further encoding.
$episode->setTechnicalStatus(Episode::STATE_PROGRESS_FAILED);
$this->logbook->info(
'oktolab_media.episode_encode_media_failed',
[],
$this->args['uniqID']
);
}
$this->em->persist($episode);
$this->em->flush();
}
}
} | php | private function deleteOriginalIfConfigured() {
$episode = $this->oktolab_media->getEpisode($this->args['uniqID']);
if (!$this->getContainer()->getParameter('oktolab_media.keep_original')) {
$this->logbook->info(
'oktolab_media.episode_encode_remove_old_media',
[],
$this->args['uniqID']
);
if (count($episode->getMedia())) {
// check if any media is incomplete.
$all_media_ok = true;
foreach ($episode->getMedia() as $media) {
if ($media->getProgress() < 100) {
$all_media_ok = false;
}
}
if ($all_media_ok) { // if all media ok, replace original file
$this->getContainer()->get('oktolab_media_helper')->deleteVideo($episode);
$best_media = $episode->getMedia()[0];
foreach ($episode->getMedia() as $media) {
if ($media->getSortNumber() > $best_media->getSortNumber()) {
$best_media = $media;
}
}
$episode->setVideo($best_media->getAsset());
} else { // some media were not okay. keep original for further encoding.
$episode->setTechnicalStatus(Episode::STATE_PROGRESS_FAILED);
$this->logbook->info(
'oktolab_media.episode_encode_media_failed',
[],
$this->args['uniqID']
);
}
$this->em->persist($episode);
$this->em->flush();
}
}
} | [
"private",
"function",
"deleteOriginalIfConfigured",
"(",
")",
"{",
"$",
"episode",
"=",
"$",
"this",
"->",
"oktolab_media",
"->",
"getEpisode",
"(",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'oktolab_media.keep_original'",
")",
")",
"{",
"$",
"this",
"->",
"logbook",
"->",
"info",
"(",
"'oktolab_media.episode_encode_remove_old_media'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"episode",
"->",
"getMedia",
"(",
")",
")",
")",
"{",
"// check if any media is incomplete.",
"$",
"all_media_ok",
"=",
"true",
";",
"foreach",
"(",
"$",
"episode",
"->",
"getMedia",
"(",
")",
"as",
"$",
"media",
")",
"{",
"if",
"(",
"$",
"media",
"->",
"getProgress",
"(",
")",
"<",
"100",
")",
"{",
"$",
"all_media_ok",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"all_media_ok",
")",
"{",
"// if all media ok, replace original file",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'oktolab_media_helper'",
")",
"->",
"deleteVideo",
"(",
"$",
"episode",
")",
";",
"$",
"best_media",
"=",
"$",
"episode",
"->",
"getMedia",
"(",
")",
"[",
"0",
"]",
";",
"foreach",
"(",
"$",
"episode",
"->",
"getMedia",
"(",
")",
"as",
"$",
"media",
")",
"{",
"if",
"(",
"$",
"media",
"->",
"getSortNumber",
"(",
")",
">",
"$",
"best_media",
"->",
"getSortNumber",
"(",
")",
")",
"{",
"$",
"best_media",
"=",
"$",
"media",
";",
"}",
"}",
"$",
"episode",
"->",
"setVideo",
"(",
"$",
"best_media",
"->",
"getAsset",
"(",
")",
")",
";",
"}",
"else",
"{",
"// some media were not okay. keep original for further encoding.",
"$",
"episode",
"->",
"setTechnicalStatus",
"(",
"Episode",
"::",
"STATE_PROGRESS_FAILED",
")",
";",
"$",
"this",
"->",
"logbook",
"->",
"info",
"(",
"'oktolab_media.episode_encode_media_failed'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"episode",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"}",
"}"
] | if the configuration flag keep_original is set to false and encoding
of all media was successful (100%), the uploaded original video
will be replaced with the media with the highest sortnumber
directly after encoding | [
"if",
"the",
"configuration",
"flag",
"keep_original",
"is",
"set",
"to",
"false",
"and",
"encoding",
"of",
"all",
"media",
"was",
"successful",
"(",
"100%",
")",
"the",
"uploaded",
"original",
"video",
"will",
"be",
"replaced",
"with",
"the",
"media",
"with",
"the",
"highest",
"sortnumber",
"directly",
"after",
"encoding"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L352-L389 |
expectation-php/expect | src/matcher/ToBeAnInstanceOf.php | ToBeAnInstanceOf.match | public function match($actual)
{
$result = false;
$this->actual = $actual;
if (is_object($this->actual)) {
$this->className = get_class($this->actual);
$result = $this->actual instanceof $this->expected;
} else {
$this->className = $actual;
}
return $result;
} | php | public function match($actual)
{
$result = false;
$this->actual = $actual;
if (is_object($this->actual)) {
$this->className = get_class($this->actual);
$result = $this->actual instanceof $this->expected;
} else {
$this->className = $actual;
}
return $result;
} | [
"public",
"function",
"match",
"(",
"$",
"actual",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"this",
"->",
"actual",
"=",
"$",
"actual",
";",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"actual",
")",
")",
"{",
"$",
"this",
"->",
"className",
"=",
"get_class",
"(",
"$",
"this",
"->",
"actual",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"actual",
"instanceof",
"$",
"this",
"->",
"expected",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"className",
"=",
"$",
"actual",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeAnInstanceOf.php#L58-L71 |
expectation-php/expect | src/matcher/ToBeAnInstanceOf.php | ToBeAnInstanceOf.reportFailed | public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendText($this->className)
->appendText(' to be an instance of ')
->appendText($this->expected)
->appendText("\n\n")
->appendText(' expected: ')
->appendText($this->expected)
->appendText("\n")
->appendText(' got: ')
->appendText($this->className);
} | php | public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendText($this->className)
->appendText(' to be an instance of ')
->appendText($this->expected)
->appendText("\n\n")
->appendText(' expected: ')
->appendText($this->expected)
->appendText("\n")
->appendText(' got: ')
->appendText($this->className);
} | [
"public",
"function",
"reportFailed",
"(",
"FailedMessage",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"appendText",
"(",
"'Expected '",
")",
"->",
"appendText",
"(",
"$",
"this",
"->",
"className",
")",
"->",
"appendText",
"(",
"' to be an instance of '",
")",
"->",
"appendText",
"(",
"$",
"this",
"->",
"expected",
")",
"->",
"appendText",
"(",
"\"\\n\\n\"",
")",
"->",
"appendText",
"(",
"' expected: '",
")",
"->",
"appendText",
"(",
"$",
"this",
"->",
"expected",
")",
"->",
"appendText",
"(",
"\"\\n\"",
")",
"->",
"appendText",
"(",
"' got: '",
")",
"->",
"appendText",
"(",
"$",
"this",
"->",
"className",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeAnInstanceOf.php#L76-L88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.