id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
20,500 |
Innmind/neo4j-dbal
|
src/Transactions.php
|
Transactions.commit
|
public function commit(): self
{
($this->fulfill)(
new Request(
$this->current()->commitEndpoint(),
Method::post(),
new ProtocolVersion(1, 1),
$this->headers,
$this->body
)
);
$this->transactions = $this->transactions->dropEnd(1);
return $this;
}
|
php
|
public function commit(): self
{
($this->fulfill)(
new Request(
$this->current()->commitEndpoint(),
Method::post(),
new ProtocolVersion(1, 1),
$this->headers,
$this->body
)
);
$this->transactions = $this->transactions->dropEnd(1);
return $this;
}
|
[
"public",
"function",
"commit",
"(",
")",
":",
"self",
"{",
"(",
"$",
"this",
"->",
"fulfill",
")",
"(",
"new",
"Request",
"(",
"$",
"this",
"->",
"current",
"(",
")",
"->",
"commitEndpoint",
"(",
")",
",",
"Method",
"::",
"post",
"(",
")",
",",
"new",
"ProtocolVersion",
"(",
"1",
",",
"1",
")",
",",
"$",
"this",
"->",
"headers",
",",
"$",
"this",
"->",
"body",
")",
")",
";",
"$",
"this",
"->",
"transactions",
"=",
"$",
"this",
"->",
"transactions",
"->",
"dropEnd",
"(",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Commit the current transaction
@return self
|
[
"Commit",
"the",
"current",
"transaction"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Transactions.php#L120-L134
|
20,501 |
Innmind/neo4j-dbal
|
src/Transactions.php
|
Transactions.rollback
|
public function rollback(): self
{
($this->fulfill)(
new Request(
$this->current()->endpoint(),
Method::delete(),
new ProtocolVersion(1, 1)
)
);
$this->transactions = $this->transactions->dropEnd(1);
return $this;
}
|
php
|
public function rollback(): self
{
($this->fulfill)(
new Request(
$this->current()->endpoint(),
Method::delete(),
new ProtocolVersion(1, 1)
)
);
$this->transactions = $this->transactions->dropEnd(1);
return $this;
}
|
[
"public",
"function",
"rollback",
"(",
")",
":",
"self",
"{",
"(",
"$",
"this",
"->",
"fulfill",
")",
"(",
"new",
"Request",
"(",
"$",
"this",
"->",
"current",
"(",
")",
"->",
"endpoint",
"(",
")",
",",
"Method",
"::",
"delete",
"(",
")",
",",
"new",
"ProtocolVersion",
"(",
"1",
",",
"1",
")",
")",
")",
";",
"$",
"this",
"->",
"transactions",
"=",
"$",
"this",
"->",
"transactions",
"->",
"dropEnd",
"(",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Rollback the current transaction
@return self
|
[
"Rollback",
"the",
"current",
"transaction"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Transactions.php#L141-L153
|
20,502 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.rem_dir_opt
|
private function rem_dir_opt($d){
$sub_files = bbn\file\dir::scan($d);
$files = [];
foreach ( $sub_files as $sub ){
if ( is_file($sub) ){
// Add it to files to be closed
array_push($files, $this->real_to_url($sub));
// Remove file's options
$this->options->remove($this->options->from_code($this->real_to_id($sub), $this->_files_pref()));
}
else {
$f = $this->rem_dir_opt($sub);
if ( !empty($f) ){
$files = array_merge($files, $f);
}
}
}
return $files;
}
|
php
|
private function rem_dir_opt($d){
$sub_files = bbn\file\dir::scan($d);
$files = [];
foreach ( $sub_files as $sub ){
if ( is_file($sub) ){
// Add it to files to be closed
array_push($files, $this->real_to_url($sub));
// Remove file's options
$this->options->remove($this->options->from_code($this->real_to_id($sub), $this->_files_pref()));
}
else {
$f = $this->rem_dir_opt($sub);
if ( !empty($f) ){
$files = array_merge($files, $f);
}
}
}
return $files;
}
|
[
"private",
"function",
"rem_dir_opt",
"(",
"$",
"d",
")",
"{",
"$",
"sub_files",
"=",
"bbn",
"\\",
"file",
"\\",
"dir",
"::",
"scan",
"(",
"$",
"d",
")",
";",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"sub_files",
"as",
"$",
"sub",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"sub",
")",
")",
"{",
"// Add it to files to be closed",
"array_push",
"(",
"$",
"files",
",",
"$",
"this",
"->",
"real_to_url",
"(",
"$",
"sub",
")",
")",
";",
"// Remove file's options",
"$",
"this",
"->",
"options",
"->",
"remove",
"(",
"$",
"this",
"->",
"options",
"->",
"from_code",
"(",
"$",
"this",
"->",
"real_to_id",
"(",
"$",
"sub",
")",
",",
"$",
"this",
"->",
"_files_pref",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"f",
"=",
"$",
"this",
"->",
"rem_dir_opt",
"(",
"$",
"sub",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"f",
")",
")",
"{",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"files",
",",
"$",
"f",
")",
";",
"}",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] |
Deletes all files' options of a folder and returns an array of these files.
@param string $d The folder's path
@return array
|
[
"Deletes",
"all",
"files",
"options",
"of",
"a",
"folder",
"and",
"returns",
"an",
"array",
"of",
"these",
"files",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L125-L143
|
20,503 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.superior_sctrl
|
private function superior_sctrl($tab, $path=''){
if ( ($pos = strpos($tab, '_ctrl')) ){
// Fix the right path
$bits = explode('/', $path);
$count = \strlen(substr($tab, 0, $pos));
if ( !empty($bits) ){
while ( $count >= 0 ){
array_pop($bits);
$count--;
}
$path = implode('/', $bits).(!empty($bits) ? '/' : '');
}
// Fix the tab's name
$tab = '_ctrl';
}
return [
'tab' => $tab,
'path' => $path
];
}
|
php
|
private function superior_sctrl($tab, $path=''){
if ( ($pos = strpos($tab, '_ctrl')) ){
// Fix the right path
$bits = explode('/', $path);
$count = \strlen(substr($tab, 0, $pos));
if ( !empty($bits) ){
while ( $count >= 0 ){
array_pop($bits);
$count--;
}
$path = implode('/', $bits).(!empty($bits) ? '/' : '');
}
// Fix the tab's name
$tab = '_ctrl';
}
return [
'tab' => $tab,
'path' => $path
];
}
|
[
"private",
"function",
"superior_sctrl",
"(",
"$",
"tab",
",",
"$",
"path",
"=",
"''",
")",
"{",
"if",
"(",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"tab",
",",
"'_ctrl'",
")",
")",
")",
"{",
"// Fix the right path",
"$",
"bits",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"count",
"=",
"\\",
"strlen",
"(",
"substr",
"(",
"$",
"tab",
",",
"0",
",",
"$",
"pos",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"bits",
")",
")",
"{",
"while",
"(",
"$",
"count",
">=",
"0",
")",
"{",
"array_pop",
"(",
"$",
"bits",
")",
";",
"$",
"count",
"--",
";",
"}",
"$",
"path",
"=",
"implode",
"(",
"'/'",
",",
"$",
"bits",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"bits",
")",
"?",
"'/'",
":",
"''",
")",
";",
"}",
"// Fix the tab's name",
"$",
"tab",
"=",
"'_ctrl'",
";",
"}",
"return",
"[",
"'tab'",
"=>",
"$",
"tab",
",",
"'path'",
"=>",
"$",
"path",
"]",
";",
"}"
] |
Checks if the file is a superior super-controller and returns the corrected name and path
@param string $tab The tab'name from file's URL
@param string $path The file's path from file's URL
@return array
|
[
"Checks",
"if",
"the",
"file",
"is",
"a",
"superior",
"super",
"-",
"controller",
"and",
"returns",
"the",
"corrected",
"name",
"and",
"path"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L152-L171
|
20,504 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.real_to_id
|
public function real_to_id($file){
$timer = new bbn\util\timer();
$timer->start('real_to_id');
$url = self::real_to_url($file);
$dir = self::dir(self::dir_from_url($url));
if ( !empty($dir) &&
\defined($dir['bbn_path'])
){
$bbn_p = constant($dir['bbn_path']);
if ( strpos($file, $bbn_p) === 0 ){
$f = substr($file, \strlen($bbn_p));
$timer->stop('real_to_id');
bbn\x::log($timer->results(), "directories");
return bbn\str::parse_path($dir['bbn_path'].'/'.$f);
}
}
// OLD VERSION
/*
$dirs = $this->dirs();
$len = 0;
$bbn_path = '';
$f = '';
foreach ( $dirs as $i => $d ){
if ( !empty($d['bbn_path']) ){
$bbn_p = constant($d['bbn_path']);
if ( strpos($file, $bbn_p) === 0 ){
$p = substr($file, \strlen($bbn_p));
if ( strpos($p, $d['code']) === 0 ){
die(var_dump($file, $bbn_p, $p));
$len_tmp = \count(explode('/', $d['code']));
if ( $len_tmp > $len ){
$len = $len_tmp;
$bbn_path = $d['bbn_path'];
$f = $p;
}
}
}
}
}
return bbn\str::parse_path($bbn_path.'/'.$f);
*/
}
|
php
|
public function real_to_id($file){
$timer = new bbn\util\timer();
$timer->start('real_to_id');
$url = self::real_to_url($file);
$dir = self::dir(self::dir_from_url($url));
if ( !empty($dir) &&
\defined($dir['bbn_path'])
){
$bbn_p = constant($dir['bbn_path']);
if ( strpos($file, $bbn_p) === 0 ){
$f = substr($file, \strlen($bbn_p));
$timer->stop('real_to_id');
bbn\x::log($timer->results(), "directories");
return bbn\str::parse_path($dir['bbn_path'].'/'.$f);
}
}
// OLD VERSION
/*
$dirs = $this->dirs();
$len = 0;
$bbn_path = '';
$f = '';
foreach ( $dirs as $i => $d ){
if ( !empty($d['bbn_path']) ){
$bbn_p = constant($d['bbn_path']);
if ( strpos($file, $bbn_p) === 0 ){
$p = substr($file, \strlen($bbn_p));
if ( strpos($p, $d['code']) === 0 ){
die(var_dump($file, $bbn_p, $p));
$len_tmp = \count(explode('/', $d['code']));
if ( $len_tmp > $len ){
$len = $len_tmp;
$bbn_path = $d['bbn_path'];
$f = $p;
}
}
}
}
}
return bbn\str::parse_path($bbn_path.'/'.$f);
*/
}
|
[
"public",
"function",
"real_to_id",
"(",
"$",
"file",
")",
"{",
"$",
"timer",
"=",
"new",
"bbn",
"\\",
"util",
"\\",
"timer",
"(",
")",
";",
"$",
"timer",
"->",
"start",
"(",
"'real_to_id'",
")",
";",
"$",
"url",
"=",
"self",
"::",
"real_to_url",
"(",
"$",
"file",
")",
";",
"$",
"dir",
"=",
"self",
"::",
"dir",
"(",
"self",
"::",
"dir_from_url",
"(",
"$",
"url",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir",
")",
"&&",
"\\",
"defined",
"(",
"$",
"dir",
"[",
"'bbn_path'",
"]",
")",
")",
"{",
"$",
"bbn_p",
"=",
"constant",
"(",
"$",
"dir",
"[",
"'bbn_path'",
"]",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"file",
",",
"$",
"bbn_p",
")",
"===",
"0",
")",
"{",
"$",
"f",
"=",
"substr",
"(",
"$",
"file",
",",
"\\",
"strlen",
"(",
"$",
"bbn_p",
")",
")",
";",
"$",
"timer",
"->",
"stop",
"(",
"'real_to_id'",
")",
";",
"bbn",
"\\",
"x",
"::",
"log",
"(",
"$",
"timer",
"->",
"results",
"(",
")",
",",
"\"directories\"",
")",
";",
"return",
"bbn",
"\\",
"str",
"::",
"parse_path",
"(",
"$",
"dir",
"[",
"'bbn_path'",
"]",
".",
"'/'",
".",
"$",
"f",
")",
";",
"}",
"}",
"// OLD VERSION",
"/*\n $dirs = $this->dirs();\n $len = 0;\n $bbn_path = '';\n $f = '';\n foreach ( $dirs as $i => $d ){\n if ( !empty($d['bbn_path']) ){\n $bbn_p = constant($d['bbn_path']);\n if ( strpos($file, $bbn_p) === 0 ){\n $p = substr($file, \\strlen($bbn_p));\n if ( strpos($p, $d['code']) === 0 ){\n die(var_dump($file, $bbn_p, $p));\n $len_tmp = \\count(explode('/', $d['code']));\n if ( $len_tmp > $len ){\n $len = $len_tmp;\n $bbn_path = $d['bbn_path'];\n $f = $p;\n }\n }\n }\n }\n }\n return bbn\\str::parse_path($bbn_path.'/'.$f);\n */",
"}"
] |
Returns the file's ID from the real file's path.
@param string $file The real file's path
@todo Fix the slowness!
@return bool|string
|
[
"Returns",
"the",
"file",
"s",
"ID",
"from",
"the",
"real",
"file",
"s",
"path",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L289-L331
|
20,505 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.url_to_real
|
public function url_to_real($url){
if ( ($dn = $this->dir_from_url($url)) &&
($dir = $this->dir($dn)) &&
($res = $this->get_root_path($dn))
){
$bits = explode('/', substr($url, \strlen($dn), \strlen($url)));
if ( !empty($dir['tabs']) && !empty($bits) ){
// Tab's nane
$tab = array_pop($bits);
// File's name
$fn = array_pop($bits);
// File's path
$fp = implode('/', $bits).'/';
// Check if the file is a superior super-controller
$ssc = $this->superior_sctrl($tab, $fp);
$tab = $ssc['tab'];
$fp = $ssc['path'];
if ( !empty($dir['tabs'][$tab]) ){
$tab = $dir['tabs'][$tab];
$res .= $tab['path'];
if ( !empty($tab['fixed']) ){
$res .= $fp . $tab['fixed'];
}
else {
$res .= $fp . $fn;
$ext_ok = false;
foreach ( $tab['extensions'] as $e ){
$ext = '.' . $e['ext'];
if ( is_file($res . $ext) ){
$res .= $ext;
$ext_ok = true;
break;
}
}
if ( empty($ext_ok) ){
$res .= '.' . $tab['extensions'][0]['ext'];
}
}
}
else {
return false;
}
}
else {
// Remove the last element of the path if it's 'code' (it's the tab's URL in a non MVC architecture)
if ( end($bits) === 'code' ){
array_pop($bits);
}
$res .= implode('/', $bits);
}
return bbn\str::parse_path($res);
}
return false;
}
|
php
|
public function url_to_real($url){
if ( ($dn = $this->dir_from_url($url)) &&
($dir = $this->dir($dn)) &&
($res = $this->get_root_path($dn))
){
$bits = explode('/', substr($url, \strlen($dn), \strlen($url)));
if ( !empty($dir['tabs']) && !empty($bits) ){
// Tab's nane
$tab = array_pop($bits);
// File's name
$fn = array_pop($bits);
// File's path
$fp = implode('/', $bits).'/';
// Check if the file is a superior super-controller
$ssc = $this->superior_sctrl($tab, $fp);
$tab = $ssc['tab'];
$fp = $ssc['path'];
if ( !empty($dir['tabs'][$tab]) ){
$tab = $dir['tabs'][$tab];
$res .= $tab['path'];
if ( !empty($tab['fixed']) ){
$res .= $fp . $tab['fixed'];
}
else {
$res .= $fp . $fn;
$ext_ok = false;
foreach ( $tab['extensions'] as $e ){
$ext = '.' . $e['ext'];
if ( is_file($res . $ext) ){
$res .= $ext;
$ext_ok = true;
break;
}
}
if ( empty($ext_ok) ){
$res .= '.' . $tab['extensions'][0]['ext'];
}
}
}
else {
return false;
}
}
else {
// Remove the last element of the path if it's 'code' (it's the tab's URL in a non MVC architecture)
if ( end($bits) === 'code' ){
array_pop($bits);
}
$res .= implode('/', $bits);
}
return bbn\str::parse_path($res);
}
return false;
}
|
[
"public",
"function",
"url_to_real",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"(",
"$",
"dn",
"=",
"$",
"this",
"->",
"dir_from_url",
"(",
"$",
"url",
")",
")",
"&&",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"dir",
"(",
"$",
"dn",
")",
")",
"&&",
"(",
"$",
"res",
"=",
"$",
"this",
"->",
"get_root_path",
"(",
"$",
"dn",
")",
")",
")",
"{",
"$",
"bits",
"=",
"explode",
"(",
"'/'",
",",
"substr",
"(",
"$",
"url",
",",
"\\",
"strlen",
"(",
"$",
"dn",
")",
",",
"\\",
"strlen",
"(",
"$",
"url",
")",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir",
"[",
"'tabs'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"bits",
")",
")",
"{",
"// Tab's nane",
"$",
"tab",
"=",
"array_pop",
"(",
"$",
"bits",
")",
";",
"// File's name",
"$",
"fn",
"=",
"array_pop",
"(",
"$",
"bits",
")",
";",
"// File's path",
"$",
"fp",
"=",
"implode",
"(",
"'/'",
",",
"$",
"bits",
")",
".",
"'/'",
";",
"// Check if the file is a superior super-controller",
"$",
"ssc",
"=",
"$",
"this",
"->",
"superior_sctrl",
"(",
"$",
"tab",
",",
"$",
"fp",
")",
";",
"$",
"tab",
"=",
"$",
"ssc",
"[",
"'tab'",
"]",
";",
"$",
"fp",
"=",
"$",
"ssc",
"[",
"'path'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir",
"[",
"'tabs'",
"]",
"[",
"$",
"tab",
"]",
")",
")",
"{",
"$",
"tab",
"=",
"$",
"dir",
"[",
"'tabs'",
"]",
"[",
"$",
"tab",
"]",
";",
"$",
"res",
".=",
"$",
"tab",
"[",
"'path'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tab",
"[",
"'fixed'",
"]",
")",
")",
"{",
"$",
"res",
".=",
"$",
"fp",
".",
"$",
"tab",
"[",
"'fixed'",
"]",
";",
"}",
"else",
"{",
"$",
"res",
".=",
"$",
"fp",
".",
"$",
"fn",
";",
"$",
"ext_ok",
"=",
"false",
";",
"foreach",
"(",
"$",
"tab",
"[",
"'extensions'",
"]",
"as",
"$",
"e",
")",
"{",
"$",
"ext",
"=",
"'.'",
".",
"$",
"e",
"[",
"'ext'",
"]",
";",
"if",
"(",
"is_file",
"(",
"$",
"res",
".",
"$",
"ext",
")",
")",
"{",
"$",
"res",
".=",
"$",
"ext",
";",
"$",
"ext_ok",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"ext_ok",
")",
")",
"{",
"$",
"res",
".=",
"'.'",
".",
"$",
"tab",
"[",
"'extensions'",
"]",
"[",
"0",
"]",
"[",
"'ext'",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"// Remove the last element of the path if it's 'code' (it's the tab's URL in a non MVC architecture)",
"if",
"(",
"end",
"(",
"$",
"bits",
")",
"===",
"'code'",
")",
"{",
"array_pop",
"(",
"$",
"bits",
")",
";",
"}",
"$",
"res",
".=",
"implode",
"(",
"'/'",
",",
"$",
"bits",
")",
";",
"}",
"return",
"bbn",
"\\",
"str",
"::",
"parse_path",
"(",
"$",
"res",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Gets the real file's path from an URL
@param string $url The file's URL
@return bool|string
|
[
"Gets",
"the",
"real",
"file",
"s",
"path",
"from",
"an",
"URL"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L339-L392
|
20,506 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.dir_from_url
|
public function dir_from_url($url){
$dir = false;
foreach ( $this->dirs() as $i => $d ){
if ( (strpos($url, $i) === 0) &&
(\strlen($i) > \strlen($dir) )
){
$dir = $i;
break;
}
}
return $dir;
}
|
php
|
public function dir_from_url($url){
$dir = false;
foreach ( $this->dirs() as $i => $d ){
if ( (strpos($url, $i) === 0) &&
(\strlen($i) > \strlen($dir) )
){
$dir = $i;
break;
}
}
return $dir;
}
|
[
"public",
"function",
"dir_from_url",
"(",
"$",
"url",
")",
"{",
"$",
"dir",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"dirs",
"(",
")",
"as",
"$",
"i",
"=>",
"$",
"d",
")",
"{",
"if",
"(",
"(",
"strpos",
"(",
"$",
"url",
",",
"$",
"i",
")",
"===",
"0",
")",
"&&",
"(",
"\\",
"strlen",
"(",
"$",
"i",
")",
">",
"\\",
"strlen",
"(",
"$",
"dir",
")",
")",
")",
"{",
"$",
"dir",
"=",
"$",
"i",
";",
"break",
";",
"}",
"}",
"return",
"$",
"dir",
";",
"}"
] |
Returns the dir's name from an URL
@param string $url
@return bool|int|string
|
[
"Returns",
"the",
"dir",
"s",
"name",
"from",
"an",
"URL"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L400-L411
|
20,507 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.url_to_id
|
public function url_to_id($url){
if ( $file = $this->url_to_real($url) ){
return $this->real_to_id($file);
}
return false;
}
|
php
|
public function url_to_id($url){
if ( $file = $this->url_to_real($url) ){
return $this->real_to_id($file);
}
return false;
}
|
[
"public",
"function",
"url_to_id",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"url_to_real",
"(",
"$",
"url",
")",
")",
"{",
"return",
"$",
"this",
"->",
"real_to_id",
"(",
"$",
"file",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns the file's ID from its URL
@param string $url The file's URL
@return bool|string
|
[
"Returns",
"the",
"file",
"s",
"ID",
"from",
"its",
"URL"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L429-L434
|
20,508 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.id_to_url
|
public function id_to_url($id){
if ( $file = $this->id_to_real($id) ){
return $this->real_to_url($file);
}
return false;
}
|
php
|
public function id_to_url($id){
if ( $file = $this->id_to_real($id) ){
return $this->real_to_url($file);
}
return false;
}
|
[
"public",
"function",
"id_to_url",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"id_to_real",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"real_to_url",
"(",
"$",
"file",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns the file's URL from its ID
@param string $id The file's ID
@return bool|string
|
[
"Returns",
"the",
"file",
"s",
"URL",
"from",
"its",
"ID"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L442-L447
|
20,509 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.get_root_path
|
public function get_root_path($code){
/** @var array $dir The directory configuration */
$dir = $this->dir($code);
if ( $dir ){
$path = $this->decipher_path(bbn\str::parse_path($dir['bbn_path'].(!empty($dir['path']) ? '/' . $dir['path'] : '')));
$r = bbn\str::parse_path($path.'/');
return $r;
}
return false;
}
|
php
|
public function get_root_path($code){
/** @var array $dir The directory configuration */
$dir = $this->dir($code);
if ( $dir ){
$path = $this->decipher_path(bbn\str::parse_path($dir['bbn_path'].(!empty($dir['path']) ? '/' . $dir['path'] : '')));
$r = bbn\str::parse_path($path.'/');
return $r;
}
return false;
}
|
[
"public",
"function",
"get_root_path",
"(",
"$",
"code",
")",
"{",
"/** @var array $dir The directory configuration */",
"$",
"dir",
"=",
"$",
"this",
"->",
"dir",
"(",
"$",
"code",
")",
";",
"if",
"(",
"$",
"dir",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"decipher_path",
"(",
"bbn",
"\\",
"str",
"::",
"parse_path",
"(",
"$",
"dir",
"[",
"'bbn_path'",
"]",
".",
"(",
"!",
"empty",
"(",
"$",
"dir",
"[",
"'path'",
"]",
")",
"?",
"'/'",
".",
"$",
"dir",
"[",
"'path'",
"]",
":",
"''",
")",
")",
")",
";",
"$",
"r",
"=",
"bbn",
"\\",
"str",
"::",
"parse_path",
"(",
"$",
"path",
".",
"'/'",
")",
";",
"return",
"$",
"r",
";",
"}",
"return",
"false",
";",
"}"
] |
Gets the real root path from a directory's id as recorded in the options.
@param string $code The dir's name (code)
@return bool|string
|
[
"Gets",
"the",
"real",
"root",
"path",
"from",
"a",
"directory",
"s",
"id",
"as",
"recorded",
"in",
"the",
"options",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L455-L465
|
20,510 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.dirs
|
public function dirs($code=false){
$all = $this->options->full_soptions(self::_dev_path());
$cats = [];
$r = [];
foreach ( $all as $a ){
if ( \defined($a['bbn_path']) ){
$k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']);
if ( !isset($cats[$a['id_alias']]) ){
unset($a['alias']['cfg']);
$cats[$a['id_alias']] = $a['alias'];
}
unset($a['cfg']);
unset($a['alias']);
$r[$k] = $a;
$r[$k]['title'] = $r[$k]['text'];
$r[$k]['alias_code'] = $cats[$a['id_alias']]['code'];
if ( !empty($cats[$a['id_alias']]['tabs']) ){
$r[$k]['tabs'] = $cats[$a['id_alias']]['tabs'];
}
else{
$r[$k]['extensions'] = $cats[$a['id_alias']]['extensions'];
}
unset($r[$k]['alias']);
}
}
if ( $code ){
return isset($r[$code]) ? $r[$code] : false;
}
return $r;
}
|
php
|
public function dirs($code=false){
$all = $this->options->full_soptions(self::_dev_path());
$cats = [];
$r = [];
foreach ( $all as $a ){
if ( \defined($a['bbn_path']) ){
$k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']);
if ( !isset($cats[$a['id_alias']]) ){
unset($a['alias']['cfg']);
$cats[$a['id_alias']] = $a['alias'];
}
unset($a['cfg']);
unset($a['alias']);
$r[$k] = $a;
$r[$k]['title'] = $r[$k]['text'];
$r[$k]['alias_code'] = $cats[$a['id_alias']]['code'];
if ( !empty($cats[$a['id_alias']]['tabs']) ){
$r[$k]['tabs'] = $cats[$a['id_alias']]['tabs'];
}
else{
$r[$k]['extensions'] = $cats[$a['id_alias']]['extensions'];
}
unset($r[$k]['alias']);
}
}
if ( $code ){
return isset($r[$code]) ? $r[$code] : false;
}
return $r;
}
|
[
"public",
"function",
"dirs",
"(",
"$",
"code",
"=",
"false",
")",
"{",
"$",
"all",
"=",
"$",
"this",
"->",
"options",
"->",
"full_soptions",
"(",
"self",
"::",
"_dev_path",
"(",
")",
")",
";",
"$",
"cats",
"=",
"[",
"]",
";",
"$",
"r",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"all",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"\\",
"defined",
"(",
"$",
"a",
"[",
"'bbn_path'",
"]",
")",
")",
"{",
"$",
"k",
"=",
"$",
"a",
"[",
"'bbn_path'",
"]",
".",
"'/'",
".",
"(",
"$",
"a",
"[",
"'code'",
"]",
"===",
"'/'",
"?",
"''",
":",
"$",
"a",
"[",
"'code'",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cats",
"[",
"$",
"a",
"[",
"'id_alias'",
"]",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"a",
"[",
"'alias'",
"]",
"[",
"'cfg'",
"]",
")",
";",
"$",
"cats",
"[",
"$",
"a",
"[",
"'id_alias'",
"]",
"]",
"=",
"$",
"a",
"[",
"'alias'",
"]",
";",
"}",
"unset",
"(",
"$",
"a",
"[",
"'cfg'",
"]",
")",
";",
"unset",
"(",
"$",
"a",
"[",
"'alias'",
"]",
")",
";",
"$",
"r",
"[",
"$",
"k",
"]",
"=",
"$",
"a",
";",
"$",
"r",
"[",
"$",
"k",
"]",
"[",
"'title'",
"]",
"=",
"$",
"r",
"[",
"$",
"k",
"]",
"[",
"'text'",
"]",
";",
"$",
"r",
"[",
"$",
"k",
"]",
"[",
"'alias_code'",
"]",
"=",
"$",
"cats",
"[",
"$",
"a",
"[",
"'id_alias'",
"]",
"]",
"[",
"'code'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cats",
"[",
"$",
"a",
"[",
"'id_alias'",
"]",
"]",
"[",
"'tabs'",
"]",
")",
")",
"{",
"$",
"r",
"[",
"$",
"k",
"]",
"[",
"'tabs'",
"]",
"=",
"$",
"cats",
"[",
"$",
"a",
"[",
"'id_alias'",
"]",
"]",
"[",
"'tabs'",
"]",
";",
"}",
"else",
"{",
"$",
"r",
"[",
"$",
"k",
"]",
"[",
"'extensions'",
"]",
"=",
"$",
"cats",
"[",
"$",
"a",
"[",
"'id_alias'",
"]",
"]",
"[",
"'extensions'",
"]",
";",
"}",
"unset",
"(",
"$",
"r",
"[",
"$",
"k",
"]",
"[",
"'alias'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"code",
")",
"{",
"return",
"isset",
"(",
"$",
"r",
"[",
"$",
"code",
"]",
")",
"?",
"$",
"r",
"[",
"$",
"code",
"]",
":",
"false",
";",
"}",
"return",
"$",
"r",
";",
"}"
] |
Make dirs' configurations
@param string|bool $code The dir's name (code)
@return array|bool
|
[
"Make",
"dirs",
"configurations"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L552-L581
|
20,511 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.set_preferences
|
public function set_preferences($id_user, $id_file, $md5, array $cfg = null, bbn\user\preferences $pref = null){
if ( !empty($id_user) && !empty($id_file) && !empty($pref) ){
$change['md5'] = $md5;
if ( !empty($cfg['selections']) ){
$change['selections'] = $cfg['selections'];
}
if ( isset($cfg, $cfg['marks']) ){
$change['marks'] = $cfg['marks'];
}
if ( !empty($change) ){
$id_option = $this->option_id($id_file);
if ( $pref->set($id_option, $change, $id_user) ){
return true;
}
}
}
return false;
}
|
php
|
public function set_preferences($id_user, $id_file, $md5, array $cfg = null, bbn\user\preferences $pref = null){
if ( !empty($id_user) && !empty($id_file) && !empty($pref) ){
$change['md5'] = $md5;
if ( !empty($cfg['selections']) ){
$change['selections'] = $cfg['selections'];
}
if ( isset($cfg, $cfg['marks']) ){
$change['marks'] = $cfg['marks'];
}
if ( !empty($change) ){
$id_option = $this->option_id($id_file);
if ( $pref->set($id_option, $change, $id_user) ){
return true;
}
}
}
return false;
}
|
[
"public",
"function",
"set_preferences",
"(",
"$",
"id_user",
",",
"$",
"id_file",
",",
"$",
"md5",
",",
"array",
"$",
"cfg",
"=",
"null",
",",
"bbn",
"\\",
"user",
"\\",
"preferences",
"$",
"pref",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"id_user",
")",
"&&",
"!",
"empty",
"(",
"$",
"id_file",
")",
"&&",
"!",
"empty",
"(",
"$",
"pref",
")",
")",
"{",
"$",
"change",
"[",
"'md5'",
"]",
"=",
"$",
"md5",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'selections'",
"]",
")",
")",
"{",
"$",
"change",
"[",
"'selections'",
"]",
"=",
"$",
"cfg",
"[",
"'selections'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"cfg",
",",
"$",
"cfg",
"[",
"'marks'",
"]",
")",
")",
"{",
"$",
"change",
"[",
"'marks'",
"]",
"=",
"$",
"cfg",
"[",
"'marks'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"change",
")",
")",
"{",
"$",
"id_option",
"=",
"$",
"this",
"->",
"option_id",
"(",
"$",
"id_file",
")",
";",
"if",
"(",
"$",
"pref",
"->",
"set",
"(",
"$",
"id_option",
",",
"$",
"change",
",",
"$",
"id_user",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Sets user's preferences for a file.
@param string $id_user The user's id
@param string $id_file The file's id
@param string $md5 The file's md5
@param array|null $cfg
@param bbn\user\preferences|null $pref
@return bool
|
[
"Sets",
"user",
"s",
"preferences",
"for",
"a",
"file",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L944-L961
|
20,512 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.change_ext
|
public function change_ext($ext, $file){
if ( !empty($ext) &&
!empty($file) &&
file_exists($file)
){
$pi = pathinfo($file);
$new = $pi['dirname'].'/'.$pi['filename'].'.'.$ext;
bbn\file\dir::move($file, $new, true);
return [
'file' => $new,
'file_url' => $this->real_to_url($new)
];
}
$this->error("Error.");
}
|
php
|
public function change_ext($ext, $file){
if ( !empty($ext) &&
!empty($file) &&
file_exists($file)
){
$pi = pathinfo($file);
$new = $pi['dirname'].'/'.$pi['filename'].'.'.$ext;
bbn\file\dir::move($file, $new, true);
return [
'file' => $new,
'file_url' => $this->real_to_url($new)
];
}
$this->error("Error.");
}
|
[
"public",
"function",
"change_ext",
"(",
"$",
"ext",
",",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"ext",
")",
"&&",
"!",
"empty",
"(",
"$",
"file",
")",
"&&",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"pi",
"=",
"pathinfo",
"(",
"$",
"file",
")",
";",
"$",
"new",
"=",
"$",
"pi",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"pi",
"[",
"'filename'",
"]",
".",
"'.'",
".",
"$",
"ext",
";",
"bbn",
"\\",
"file",
"\\",
"dir",
"::",
"move",
"(",
"$",
"file",
",",
"$",
"new",
",",
"true",
")",
";",
"return",
"[",
"'file'",
"=>",
"$",
"new",
",",
"'file_url'",
"=>",
"$",
"this",
"->",
"real_to_url",
"(",
"$",
"new",
")",
"]",
";",
"}",
"$",
"this",
"->",
"error",
"(",
"\"Error.\"",
")",
";",
"}"
] |
Changes the extension to a file.
@param string $ext The new extension
@param string $file The file to change
@return array
|
[
"Changes",
"the",
"extension",
"to",
"a",
"file",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L1576-L1590
|
20,513 |
nabab/bbn
|
src/bbn/ide/directories.php
|
directories.history
|
public function history($url){
if ( !empty($url) &&
( $dir = $this->dir_from_url($url) ) &&
( $dir_cfg = $this->dir($dir) ) &&
\defined('BBN_USER_PATH')
){
$res = [];
$all = [];
// IDE backup path
$path = BBN_USER_PATH."ide/backup/$dir";
// Remove dir name from url
$file = substr($url, \strlen($dir), \strlen($url));
// MVC
if ( !empty($dir_cfg['tabs']) ){
foreach ( $dir_cfg['tabs'] as $t ){
if ( empty($t['fixed']) ){
// The file's backup path of the MVC's tab
$p = $path . $t['path'] . $file . '/';
// Get history
$all = self::get_history($p, $t, $all, true);
}
}
}
else {
// The file's backup path of the MVC's tab
$p = $path . $file . '/';
// Get history
$all = self::get_history($p, $dir_cfg, $all);
}
if ( !empty($all) ){
foreach ( $all as $i => $a ){
if ( !empty($dir_cfg['tabs']) ){
$tmp = [];
foreach ( $a as $k => $b ){
array_push($tmp, [
'text' => $k,
'items' => $b
]);
}
}
array_push($res, [
'text' => $i,
'items' => !empty($tmp) ? $tmp : $a
]);
}
}
return ['list' => $res];
}
}
|
php
|
public function history($url){
if ( !empty($url) &&
( $dir = $this->dir_from_url($url) ) &&
( $dir_cfg = $this->dir($dir) ) &&
\defined('BBN_USER_PATH')
){
$res = [];
$all = [];
// IDE backup path
$path = BBN_USER_PATH."ide/backup/$dir";
// Remove dir name from url
$file = substr($url, \strlen($dir), \strlen($url));
// MVC
if ( !empty($dir_cfg['tabs']) ){
foreach ( $dir_cfg['tabs'] as $t ){
if ( empty($t['fixed']) ){
// The file's backup path of the MVC's tab
$p = $path . $t['path'] . $file . '/';
// Get history
$all = self::get_history($p, $t, $all, true);
}
}
}
else {
// The file's backup path of the MVC's tab
$p = $path . $file . '/';
// Get history
$all = self::get_history($p, $dir_cfg, $all);
}
if ( !empty($all) ){
foreach ( $all as $i => $a ){
if ( !empty($dir_cfg['tabs']) ){
$tmp = [];
foreach ( $a as $k => $b ){
array_push($tmp, [
'text' => $k,
'items' => $b
]);
}
}
array_push($res, [
'text' => $i,
'items' => !empty($tmp) ? $tmp : $a
]);
}
}
return ['list' => $res];
}
}
|
[
"public",
"function",
"history",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
"&&",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"dir_from_url",
"(",
"$",
"url",
")",
")",
"&&",
"(",
"$",
"dir_cfg",
"=",
"$",
"this",
"->",
"dir",
"(",
"$",
"dir",
")",
")",
"&&",
"\\",
"defined",
"(",
"'BBN_USER_PATH'",
")",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"$",
"all",
"=",
"[",
"]",
";",
"// IDE backup path",
"$",
"path",
"=",
"BBN_USER_PATH",
".",
"\"ide/backup/$dir\"",
";",
"// Remove dir name from url",
"$",
"file",
"=",
"substr",
"(",
"$",
"url",
",",
"\\",
"strlen",
"(",
"$",
"dir",
")",
",",
"\\",
"strlen",
"(",
"$",
"url",
")",
")",
";",
"// MVC",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir_cfg",
"[",
"'tabs'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"dir_cfg",
"[",
"'tabs'",
"]",
"as",
"$",
"t",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"t",
"[",
"'fixed'",
"]",
")",
")",
"{",
"// The file's backup path of the MVC's tab",
"$",
"p",
"=",
"$",
"path",
".",
"$",
"t",
"[",
"'path'",
"]",
".",
"$",
"file",
".",
"'/'",
";",
"// Get history",
"$",
"all",
"=",
"self",
"::",
"get_history",
"(",
"$",
"p",
",",
"$",
"t",
",",
"$",
"all",
",",
"true",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// The file's backup path of the MVC's tab",
"$",
"p",
"=",
"$",
"path",
".",
"$",
"file",
".",
"'/'",
";",
"// Get history",
"$",
"all",
"=",
"self",
"::",
"get_history",
"(",
"$",
"p",
",",
"$",
"dir_cfg",
",",
"$",
"all",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"all",
")",
")",
"{",
"foreach",
"(",
"$",
"all",
"as",
"$",
"i",
"=>",
"$",
"a",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir_cfg",
"[",
"'tabs'",
"]",
")",
")",
"{",
"$",
"tmp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"a",
"as",
"$",
"k",
"=>",
"$",
"b",
")",
"{",
"array_push",
"(",
"$",
"tmp",
",",
"[",
"'text'",
"=>",
"$",
"k",
",",
"'items'",
"=>",
"$",
"b",
"]",
")",
";",
"}",
"}",
"array_push",
"(",
"$",
"res",
",",
"[",
"'text'",
"=>",
"$",
"i",
",",
"'items'",
"=>",
"!",
"empty",
"(",
"$",
"tmp",
")",
"?",
"$",
"tmp",
":",
"$",
"a",
"]",
")",
";",
"}",
"}",
"return",
"[",
"'list'",
"=>",
"$",
"res",
"]",
";",
"}",
"}"
] |
Returns all backup history of a file.
@param string $url The file's URL
@return array|bool
|
[
"Returns",
"all",
"backup",
"history",
"of",
"a",
"file",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/ide/directories.php#L1819-L1867
|
20,514 |
willhoffmann/domuserp-php
|
src/DataReceiver.php
|
DataReceiver.payload
|
public function payload(array $data)
{
foreach ($data as $key => $value) {
$this->data->{$key} = $value;
}
return $this;
}
|
php
|
public function payload(array $data)
{
foreach ($data as $key => $value) {
$this->data->{$key} = $value;
}
return $this;
}
|
[
"public",
"function",
"payload",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Payload the request
@param array $data
@return $this
|
[
"Payload",
"the",
"request"
] |
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
|
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/DataReceiver.php#L44-L51
|
20,515 |
willhoffmann/domuserp-php
|
src/DataReceiver.php
|
DataReceiver.toArray
|
public function toArray()
{
$this->data->id = $this->id;
return json_decode(json_encode($this->data), true);
}
|
php
|
public function toArray()
{
$this->data->id = $this->id;
return json_decode(json_encode($this->data), true);
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"id",
"=",
"$",
"this",
"->",
"id",
";",
"return",
"json_decode",
"(",
"json_encode",
"(",
"$",
"this",
"->",
"data",
")",
",",
"true",
")",
";",
"}"
] |
Get the request data
@return array
|
[
"Get",
"the",
"request",
"data"
] |
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
|
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/DataReceiver.php#L58-L63
|
20,516 |
Innmind/neo4j-dbal
|
src/Result/Result.php
|
Result.fromRaw
|
public static function fromRaw(array $response): self
{
$data = $response['data'] ?? [];
return new self(
self::buildNodes($data),
self::buildRelationships($data),
self::buildRows($response)
);
}
|
php
|
public static function fromRaw(array $response): self
{
$data = $response['data'] ?? [];
return new self(
self::buildNodes($data),
self::buildRelationships($data),
self::buildRows($response)
);
}
|
[
"public",
"static",
"function",
"fromRaw",
"(",
"array",
"$",
"response",
")",
":",
"self",
"{",
"$",
"data",
"=",
"$",
"response",
"[",
"'data'",
"]",
"??",
"[",
"]",
";",
"return",
"new",
"self",
"(",
"self",
"::",
"buildNodes",
"(",
"$",
"data",
")",
",",
"self",
"::",
"buildRelationships",
"(",
"$",
"data",
")",
",",
"self",
"::",
"buildRows",
"(",
"$",
"response",
")",
")",
";",
"}"
] |
Build a result object out of a standard neo4j rest api response
@param array $response
@return self
|
[
"Build",
"a",
"result",
"object",
"out",
"of",
"a",
"standard",
"neo4j",
"rest",
"api",
"response"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Result/Result.php#L38-L47
|
20,517 |
willhoffmann/domuserp-php
|
src/Resources/Categories/Secondary/Subcategories.php
|
Subcategories.getList
|
public function getList(array $query = [])
{
$list = $this->pagination(
self::DOMUSERP_API_OPERACIONAL . '/categorias/' . $this->categoryId . '/subcategorias',
$query
);
return $list;
}
|
php
|
public function getList(array $query = [])
{
$list = $this->pagination(
self::DOMUSERP_API_OPERACIONAL . '/categorias/' . $this->categoryId . '/subcategorias',
$query
);
return $list;
}
|
[
"public",
"function",
"getList",
"(",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"pagination",
"(",
"self",
"::",
"DOMUSERP_API_OPERACIONAL",
".",
"'/categorias/'",
".",
"$",
"this",
"->",
"categoryId",
".",
"'/subcategorias'",
",",
"$",
"query",
")",
";",
"return",
"$",
"list",
";",
"}"
] |
List of subcategories
@param array $query
@return array|string
@throws \GuzzleHttp\Exception\GuzzleException
|
[
"List",
"of",
"subcategories"
] |
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
|
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Categories/Secondary/Subcategories.php#L35-L43
|
20,518 |
alevilar/ristorantino-vendor
|
Risto/Utility/WsPaxaposConnect.php
|
WsPaxaposConnect.__convertLindoArray
|
public static function __convertLindoArray($mesa){
$mesanew = $mesa['Mesa'];
unset($mesa['Mesa']);
foreach ( $mesa as $mkey=>$mvalue) {
$mesanew[$mkey] = $mvalue;
}
return $mesanew;
}
|
php
|
public static function __convertLindoArray($mesa){
$mesanew = $mesa['Mesa'];
unset($mesa['Mesa']);
foreach ( $mesa as $mkey=>$mvalue) {
$mesanew[$mkey] = $mvalue;
}
return $mesanew;
}
|
[
"public",
"static",
"function",
"__convertLindoArray",
"(",
"$",
"mesa",
")",
"{",
"$",
"mesanew",
"=",
"$",
"mesa",
"[",
"'Mesa'",
"]",
";",
"unset",
"(",
"$",
"mesa",
"[",
"'Mesa'",
"]",
")",
";",
"foreach",
"(",
"$",
"mesa",
"as",
"$",
"mkey",
"=>",
"$",
"mvalue",
")",
"{",
"$",
"mesanew",
"[",
"$",
"mkey",
"]",
"=",
"$",
"mvalue",
";",
"}",
"return",
"$",
"mesanew",
";",
"}"
] |
Hace un array para que sea compatible con la versin anterior del ristorantino
donde se enviaba un js con interval
|
[
"Hace",
"un",
"array",
"para",
"que",
"sea",
"compatible",
"con",
"la",
"versin",
"anterior",
"del",
"ristorantino",
"donde",
"se",
"enviaba",
"un",
"js",
"con",
"interval"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Utility/WsPaxaposConnect.php#L18-L28
|
20,519 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php
|
ezcMailMultipartRelated.getRelatedParts
|
public function getRelatedParts()
{
if ( is_null( $this->getMainPart() ) )
{
return array_slice( $this->parts, 0 );
}
return array_slice( $this->parts, 1 );
}
|
php
|
public function getRelatedParts()
{
if ( is_null( $this->getMainPart() ) )
{
return array_slice( $this->parts, 0 );
}
return array_slice( $this->parts, 1 );
}
|
[
"public",
"function",
"getRelatedParts",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getMainPart",
"(",
")",
")",
")",
"{",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"parts",
",",
"0",
")",
";",
"}",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"parts",
",",
"1",
")",
";",
"}"
] |
Returns the mail parts associated with this multipart.
@return array(ezcMailPart)
|
[
"Returns",
"the",
"mail",
"parts",
"associated",
"with",
"this",
"multipart",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php#L125-L132
|
20,520 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php
|
ezcMailMultipartRelated.getRelatedPartByID
|
public function getRelatedPartByID( $cid )
{
$parts = $this->getRelatedParts();
foreach ( $parts as $part )
{
if ( ( $part->getHeader( 'Content-ID' ) !== '' ) &&
( $part->getHeader( 'Content-ID' ) == "<$cid>" ) )
{
return $part;
}
}
return false;
}
|
php
|
public function getRelatedPartByID( $cid )
{
$parts = $this->getRelatedParts();
foreach ( $parts as $part )
{
if ( ( $part->getHeader( 'Content-ID' ) !== '' ) &&
( $part->getHeader( 'Content-ID' ) == "<$cid>" ) )
{
return $part;
}
}
return false;
}
|
[
"public",
"function",
"getRelatedPartByID",
"(",
"$",
"cid",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"getRelatedParts",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"(",
"$",
"part",
"->",
"getHeader",
"(",
"'Content-ID'",
")",
"!==",
"''",
")",
"&&",
"(",
"$",
"part",
"->",
"getHeader",
"(",
"'Content-ID'",
")",
"==",
"\"<$cid>\"",
")",
")",
"{",
"return",
"$",
"part",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns the part associated with the passed Content-ID.
@param string $cid
@return ezcMailPart
|
[
"Returns",
"the",
"part",
"associated",
"with",
"the",
"passed",
"Content",
"-",
"ID",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/multiparts/multipart_related.php#L140-L152
|
20,521 |
dflydev/dflydev-stack-firewall
|
src/Dflydev/Stack/Firewall/Matcher.php
|
Matcher.match
|
public function match(Request $request)
{
foreach ($this->firewalls as $firewall) {
if ($firewall['method'] !== null && $request->getMethod() !== $firewall['method']) {
continue;
}
if ($firewall['exact_match']) {
if ($request->getPathInfo() === $firewall['path']) {
return $firewall;
}
} elseif (0 === strpos($request->getPathInfo(), $firewall['path'])) {
return $firewall;
}
}
return null;
}
|
php
|
public function match(Request $request)
{
foreach ($this->firewalls as $firewall) {
if ($firewall['method'] !== null && $request->getMethod() !== $firewall['method']) {
continue;
}
if ($firewall['exact_match']) {
if ($request->getPathInfo() === $firewall['path']) {
return $firewall;
}
} elseif (0 === strpos($request->getPathInfo(), $firewall['path'])) {
return $firewall;
}
}
return null;
}
|
[
"public",
"function",
"match",
"(",
"Request",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"firewalls",
"as",
"$",
"firewall",
")",
"{",
"if",
"(",
"$",
"firewall",
"[",
"'method'",
"]",
"!==",
"null",
"&&",
"$",
"request",
"->",
"getMethod",
"(",
")",
"!==",
"$",
"firewall",
"[",
"'method'",
"]",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"firewall",
"[",
"'exact_match'",
"]",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
"===",
"$",
"firewall",
"[",
"'path'",
"]",
")",
"{",
"return",
"$",
"firewall",
";",
"}",
"}",
"elseif",
"(",
"0",
"===",
"strpos",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
",",
"$",
"firewall",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
"$",
"firewall",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Find the matching path
|
[
"Find",
"the",
"matching",
"path"
] |
eecaf0f2cd63104c726539bf713c72659142a81e
|
https://github.com/dflydev/dflydev-stack-firewall/blob/eecaf0f2cd63104c726539bf713c72659142a81e/src/Dflydev/Stack/Firewall/Matcher.php#L45-L62
|
20,522 |
kossmoss/yii2-google-maps-api
|
GoogleMaps.php
|
GoogleMaps.map
|
public static function map($options = null)
{
if (empty(self::$_google)) {
self::$_google = new GoogleMapAPI();
self::$_google->_minify_js = false;
// Apply options
if (is_array($options)) {
foreach ($options as $key => $value) {
self::$_google->$key = $value;
}
};
}
return self::$_google;
}
|
php
|
public static function map($options = null)
{
if (empty(self::$_google)) {
self::$_google = new GoogleMapAPI();
self::$_google->_minify_js = false;
// Apply options
if (is_array($options)) {
foreach ($options as $key => $value) {
self::$_google->$key = $value;
}
};
}
return self::$_google;
}
|
[
"public",
"static",
"function",
"map",
"(",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_google",
")",
")",
"{",
"self",
"::",
"$",
"_google",
"=",
"new",
"GoogleMapAPI",
"(",
")",
";",
"self",
"::",
"$",
"_google",
"->",
"_minify_js",
"=",
"false",
";",
"// Apply options\r",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"self",
"::",
"$",
"_google",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
";",
"}",
"return",
"self",
"::",
"$",
"_google",
";",
"}"
] |
Returns GoogleMaps instance to work with
@param mixed $options Map options array
@return GoogleMapAPI
|
[
"Returns",
"GoogleMaps",
"instance",
"to",
"work",
"with"
] |
8a994c173031d7ece3cfedd30b971258616579d2
|
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/GoogleMaps.php#L57-L72
|
20,523 |
kossmoss/yii2-google-maps-api
|
GoogleMaps.php
|
GoogleMaps.coordsByAddress
|
public static function coordsByAddress($searchString)
{
$result = false;
try {
// we must be sure we don't send queries too frequently to avoid be banned by Google Maps API
if (self::$_googleTimeout != 0) {
$timeToWait = self::$_lastGoogleSearchTime + self::$_googleTimeout - time();
if ($timeToWait > 0) {
sleep($timeToWait);
}
}
$searchResult = self::map()->geoGetCoordsFull($searchString);
self::$_lastGoogleSearchTime = time();
if ($searchResult && $searchResult->status == 'OK') {
$result = [
'latitude' => $searchResult->results[0]->geometry->location->lat,
'longitude' => $searchResult->results[0]->geometry->location->lng,
];
}
} catch (ErrorException $e) {
\Yii::error('Can\'t load coordinates from Google Maps API: ' . $e->getMessage());
}
return $result;
}
|
php
|
public static function coordsByAddress($searchString)
{
$result = false;
try {
// we must be sure we don't send queries too frequently to avoid be banned by Google Maps API
if (self::$_googleTimeout != 0) {
$timeToWait = self::$_lastGoogleSearchTime + self::$_googleTimeout - time();
if ($timeToWait > 0) {
sleep($timeToWait);
}
}
$searchResult = self::map()->geoGetCoordsFull($searchString);
self::$_lastGoogleSearchTime = time();
if ($searchResult && $searchResult->status == 'OK') {
$result = [
'latitude' => $searchResult->results[0]->geometry->location->lat,
'longitude' => $searchResult->results[0]->geometry->location->lng,
];
}
} catch (ErrorException $e) {
\Yii::error('Can\'t load coordinates from Google Maps API: ' . $e->getMessage());
}
return $result;
}
|
[
"public",
"static",
"function",
"coordsByAddress",
"(",
"$",
"searchString",
")",
"{",
"$",
"result",
"=",
"false",
";",
"try",
"{",
"// we must be sure we don't send queries too frequently to avoid be banned by Google Maps API\r",
"if",
"(",
"self",
"::",
"$",
"_googleTimeout",
"!=",
"0",
")",
"{",
"$",
"timeToWait",
"=",
"self",
"::",
"$",
"_lastGoogleSearchTime",
"+",
"self",
"::",
"$",
"_googleTimeout",
"-",
"time",
"(",
")",
";",
"if",
"(",
"$",
"timeToWait",
">",
"0",
")",
"{",
"sleep",
"(",
"$",
"timeToWait",
")",
";",
"}",
"}",
"$",
"searchResult",
"=",
"self",
"::",
"map",
"(",
")",
"->",
"geoGetCoordsFull",
"(",
"$",
"searchString",
")",
";",
"self",
"::",
"$",
"_lastGoogleSearchTime",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"searchResult",
"&&",
"$",
"searchResult",
"->",
"status",
"==",
"'OK'",
")",
"{",
"$",
"result",
"=",
"[",
"'latitude'",
"=>",
"$",
"searchResult",
"->",
"results",
"[",
"0",
"]",
"->",
"geometry",
"->",
"location",
"->",
"lat",
",",
"'longitude'",
"=>",
"$",
"searchResult",
"->",
"results",
"[",
"0",
"]",
"->",
"geometry",
"->",
"location",
"->",
"lng",
",",
"]",
";",
"}",
"}",
"catch",
"(",
"ErrorException",
"$",
"e",
")",
"{",
"\\",
"Yii",
"::",
"error",
"(",
"'Can\\'t load coordinates from Google Maps API: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Search coordinates by address
@param string $searchString search query with address
@return array|bool
|
[
"Search",
"coordinates",
"by",
"address"
] |
8a994c173031d7ece3cfedd30b971258616579d2
|
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/GoogleMaps.php#L80-L106
|
20,524 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.callEvent
|
public function callEvent($event_name)
{
$classname = get_called_class();
if (!isset(static::$callbacks[$classname][$event_name])) {
return;
}
foreach (static::$callbacks[$classname][$event_name] as $callback) {
$callback($this);
}
}
|
php
|
public function callEvent($event_name)
{
$classname = get_called_class();
if (!isset(static::$callbacks[$classname][$event_name])) {
return;
}
foreach (static::$callbacks[$classname][$event_name] as $callback) {
$callback($this);
}
}
|
[
"public",
"function",
"callEvent",
"(",
"$",
"event_name",
")",
"{",
"$",
"classname",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"callbacks",
"[",
"$",
"classname",
"]",
"[",
"$",
"event_name",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"callbacks",
"[",
"$",
"classname",
"]",
"[",
"$",
"event_name",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"this",
")",
";",
"}",
"}"
] |
Call an event on this entity, calling the registering
callbacks.
@param string $event_name
|
[
"Call",
"an",
"event",
"on",
"this",
"entity",
"calling",
"the",
"registering",
"callbacks",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L184-L194
|
20,525 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.getRelation
|
public function getRelation($name)
{
if (array_key_exists($name, $this->relation_objects)) {
return $this->relation_objects[$name];
}
$relation = self::getRelationDefinition($name);
$this->relation_objects[$name] = $this->fetchRelation($relation);
return $this->relation_objects[$name];
}
|
php
|
public function getRelation($name)
{
if (array_key_exists($name, $this->relation_objects)) {
return $this->relation_objects[$name];
}
$relation = self::getRelationDefinition($name);
$this->relation_objects[$name] = $this->fetchRelation($relation);
return $this->relation_objects[$name];
}
|
[
"public",
"function",
"getRelation",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"relation_objects",
")",
")",
"{",
"return",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"relation",
"=",
"self",
"::",
"getRelationDefinition",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"fetchRelation",
"(",
"$",
"relation",
")",
";",
"return",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
";",
"}"
] |
Get the named related object. If the database has not been
queried it will be fetched automatically. If the database has
been queried the original result will be returned.
@param string $name The name of the relation
|
[
"Get",
"the",
"named",
"related",
"object",
".",
"If",
"the",
"database",
"has",
"not",
"been",
"queried",
"it",
"will",
"be",
"fetched",
"automatically",
".",
"If",
"the",
"database",
"has",
"been",
"queried",
"the",
"original",
"result",
"will",
"be",
"returned",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L262-L273
|
20,526 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.fetchRelation
|
protected function fetchRelation(array $relation)
{
/* a relation is of the form
* [$type, $foreign_class, $foreign_column, $column]
*/
list($type, $foreign_class, $foreign_column, $column) = $relation;
switch ($type) {
case 'has_one':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'belongs_to':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'has_many':
return $this->fetchOneToMany($foreign_class, $foreign_column, $column);
default:
}
}
|
php
|
protected function fetchRelation(array $relation)
{
/* a relation is of the form
* [$type, $foreign_class, $foreign_column, $column]
*/
list($type, $foreign_class, $foreign_column, $column) = $relation;
switch ($type) {
case 'has_one':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'belongs_to':
return $this->fetchOneToOne($foreign_class, $foreign_column, $column);
case 'has_many':
return $this->fetchOneToMany($foreign_class, $foreign_column, $column);
default:
}
}
|
[
"protected",
"function",
"fetchRelation",
"(",
"array",
"$",
"relation",
")",
"{",
"/* a relation is of the form\n * [$type, $foreign_class, $foreign_column, $column]\n */",
"list",
"(",
"$",
"type",
",",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"=",
"$",
"relation",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'has_one'",
":",
"return",
"$",
"this",
"->",
"fetchOneToOne",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
";",
"case",
"'belongs_to'",
":",
"return",
"$",
"this",
"->",
"fetchOneToOne",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
";",
"case",
"'has_many'",
":",
"return",
"$",
"this",
"->",
"fetchOneToMany",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
";",
"default",
":",
"}",
"}"
] |
Fetch a related entity from the database.
@param array $relation The relation to fetch.
|
[
"Fetch",
"a",
"related",
"entity",
"from",
"the",
"database",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L327-L343
|
20,527 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.fetchOneToOne
|
protected function fetchOneToOne($foreign_class, $foreign_column, $column)
{
return $foreign_class::selectOne($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
}
|
php
|
protected function fetchOneToOne($foreign_class, $foreign_column, $column)
{
return $foreign_class::selectOne($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
}
|
[
"protected",
"function",
"fetchOneToOne",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"{",
"return",
"$",
"foreign_class",
"::",
"selectOne",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"where",
"(",
"$",
"foreign_column",
",",
"'='",
",",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"column",
")",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Query the database for a one to one relationship.
@param string $foreign_class The class name of the related entity
@param string $foreign_column The name of the column on the other table
@param string $column The name of column on this table
|
[
"Query",
"the",
"database",
"for",
"a",
"one",
"to",
"one",
"relationship",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L352-L357
|
20,528 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.fetchOneToMany
|
protected function fetchOneToMany($foreign_class, $foreign_column, $column)
{
return $foreign_class::select($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
}
|
php
|
protected function fetchOneToMany($foreign_class, $foreign_column, $column)
{
return $foreign_class::select($this->connection)
->where($foreign_column, '=', $this->getRaw($column))
->execute();
}
|
[
"protected",
"function",
"fetchOneToMany",
"(",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"{",
"return",
"$",
"foreign_class",
"::",
"select",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"where",
"(",
"$",
"foreign_column",
",",
"'='",
",",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"column",
")",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Query the database for a one to many relationship.
@param string $foreign_class The class name of the related entity
@param string $foreign_column The name of the column on the other table
@param string $column The name of column on this table
|
[
"Query",
"the",
"database",
"for",
"a",
"one",
"to",
"many",
"relationship",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L366-L371
|
20,529 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.getValues
|
public function getValues()
{
$return = array();
foreach ($this->values as $k => $v) {
$return[$k] = $this->get($k);
}
return $return;
}
|
php
|
public function getValues()
{
$return = array();
foreach ($this->values as $k => $v) {
$return[$k] = $this->get($k);
}
return $return;
}
|
[
"public",
"function",
"getValues",
"(",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"return",
"[",
"$",
"k",
"]",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"k",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Get all values. Getter methods will be called on the values.
@return array The values
|
[
"Get",
"all",
"values",
".",
"Getter",
"methods",
"will",
"be",
"called",
"on",
"the",
"values",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L378-L386
|
20,530 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.setRelation
|
public function setRelation($name, $related_object)
{
//if no related object is supplied, set it to false (an array
//value of null will not pass an isset() check on the
//relation_objects array).
if (!$related_object) {
$related_object = false;
}
$this->relation_objects[$name] = $related_object;
}
|
php
|
public function setRelation($name, $related_object)
{
//if no related object is supplied, set it to false (an array
//value of null will not pass an isset() check on the
//relation_objects array).
if (!$related_object) {
$related_object = false;
}
$this->relation_objects[$name] = $related_object;
}
|
[
"public",
"function",
"setRelation",
"(",
"$",
"name",
",",
"$",
"related_object",
")",
"{",
"//if no related object is supplied, set it to false (an array",
"//value of null will not pass an isset() check on the",
"//relation_objects array).",
"if",
"(",
"!",
"$",
"related_object",
")",
"{",
"$",
"related_object",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"$",
"related_object",
";",
"}"
] |
Set the named related object.
@param string $name The name of the relation
@param mixed $related_object The related object
|
[
"Set",
"the",
"named",
"related",
"object",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L451-L461
|
20,531 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.unsetRelation
|
public function unsetRelation($name, $value)
{
list($type, $foreign_class, $foreign_column, $column) = static::getRelationDefinition($name);
//no need to get the relation, the column is on this object.
if ($type === 'belongs_to') {
$this->setRaw($column, $value);
$this->relation_objects[$name] = false;
return;
}
$related_object = $this->getRelation($name);
if (!$related_object) {
return;
}
//has one, the related object column is set to the value.
if ($type === 'has_one') {
$related_object->setRaw($foreign_column, $value);
$this->relation_objects[$name] = false;
}
//has many, the columns on the entities in the related
//collection are set to the value.
if ($type === 'has_many') {
$related_object->setColumnRaw($foreign_column, $value);
$this->relation_objects[$name] = $foreign_class::newCollection();
}
return;
}
|
php
|
public function unsetRelation($name, $value)
{
list($type, $foreign_class, $foreign_column, $column) = static::getRelationDefinition($name);
//no need to get the relation, the column is on this object.
if ($type === 'belongs_to') {
$this->setRaw($column, $value);
$this->relation_objects[$name] = false;
return;
}
$related_object = $this->getRelation($name);
if (!$related_object) {
return;
}
//has one, the related object column is set to the value.
if ($type === 'has_one') {
$related_object->setRaw($foreign_column, $value);
$this->relation_objects[$name] = false;
}
//has many, the columns on the entities in the related
//collection are set to the value.
if ($type === 'has_many') {
$related_object->setColumnRaw($foreign_column, $value);
$this->relation_objects[$name] = $foreign_class::newCollection();
}
return;
}
|
[
"public",
"function",
"unsetRelation",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"type",
",",
"$",
"foreign_class",
",",
"$",
"foreign_column",
",",
"$",
"column",
")",
"=",
"static",
"::",
"getRelationDefinition",
"(",
"$",
"name",
")",
";",
"//no need to get the relation, the column is on this object.",
"if",
"(",
"$",
"type",
"===",
"'belongs_to'",
")",
"{",
"$",
"this",
"->",
"setRaw",
"(",
"$",
"column",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"false",
";",
"return",
";",
"}",
"$",
"related_object",
"=",
"$",
"this",
"->",
"getRelation",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"related_object",
")",
"{",
"return",
";",
"}",
"//has one, the related object column is set to the value.",
"if",
"(",
"$",
"type",
"===",
"'has_one'",
")",
"{",
"$",
"related_object",
"->",
"setRaw",
"(",
"$",
"foreign_column",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"false",
";",
"}",
"//has many, the columns on the entities in the related",
"//collection are set to the value.",
"if",
"(",
"$",
"type",
"===",
"'has_many'",
")",
"{",
"$",
"related_object",
"->",
"setColumnRaw",
"(",
"$",
"foreign_column",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"relation_objects",
"[",
"$",
"name",
"]",
"=",
"$",
"foreign_class",
"::",
"newCollection",
"(",
")",
";",
"}",
"return",
";",
"}"
] |
Unset a related object and assign the joining column a
value. If the related object has not been fetched, it will be
fetched and the joining column changed.
@param string $name The name of the relation
@param mixed $value The value to assign to the joining column
|
[
"Unset",
"a",
"related",
"object",
"and",
"assign",
"the",
"joining",
"column",
"a",
"value",
".",
"If",
"the",
"related",
"object",
"has",
"not",
"been",
"fetched",
"it",
"will",
"be",
"fetched",
"and",
"the",
"joining",
"column",
"changed",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L500-L532
|
20,532 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.setValues
|
public function setValues(array $values = array())
{
foreach ($values as $k => $v) {
$this->set($k, $v);
}
return $this;
}
|
php
|
public function setValues(array $values = array())
{
foreach ($values as $k => $v) {
$this->set($k, $v);
}
return $this;
}
|
[
"public",
"function",
"setValues",
"(",
"array",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set an array of values. Setter methods will be called if they
exist.
@param array $values The array of values to set
|
[
"Set",
"an",
"array",
"of",
"values",
".",
"Setter",
"methods",
"will",
"be",
"called",
"if",
"they",
"exist",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L540-L547
|
20,533 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.setValuesRaw
|
public function setValuesRaw($values = array())
{
foreach ($values as $key => $value) {
$this->setRaw($key, $value);
}
return $this;
}
|
php
|
public function setValuesRaw($values = array())
{
foreach ($values as $key => $value) {
$this->setRaw($key, $value);
}
return $this;
}
|
[
"public",
"function",
"setValuesRaw",
"(",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setRaw",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set an array of values. Setter methods will not be called.
@param array $values The array of values to set
|
[
"Set",
"an",
"array",
"of",
"values",
".",
"Setter",
"methods",
"will",
"not",
"be",
"called",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L554-L561
|
20,534 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.insert
|
public function insert()
{
if ($this->stored) {
throw new \LogicException("You may not insert an already stored entity");
}
$this->callEvent('insert');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$this->connection->insert(static::$table, $values, static::$types);
//this will only work with some database vendors for now.
$this->values[static::$primary_key] = $this->connection->lastInsertId();
$this->setStored();
}
|
php
|
public function insert()
{
if ($this->stored) {
throw new \LogicException("You may not insert an already stored entity");
}
$this->callEvent('insert');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$this->connection->insert(static::$table, $values, static::$types);
//this will only work with some database vendors for now.
$this->values[static::$primary_key] = $this->connection->lastInsertId();
$this->setStored();
}
|
[
"public",
"function",
"insert",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stored",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"You may not insert an already stored entity\"",
")",
";",
"}",
"$",
"this",
"->",
"callEvent",
"(",
"'insert'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"modified",
")",
")",
"{",
"return",
";",
"}",
"$",
"values",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"this",
"->",
"modified",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"insert",
"(",
"static",
"::",
"$",
"table",
",",
"$",
"values",
",",
"static",
"::",
"$",
"types",
")",
";",
"//this will only work with some database vendors for now.",
"$",
"this",
"->",
"values",
"[",
"static",
"::",
"$",
"primary_key",
"]",
"=",
"$",
"this",
"->",
"connection",
"->",
"lastInsertId",
"(",
")",
";",
"$",
"this",
"->",
"setStored",
"(",
")",
";",
"}"
] |
Persist this entity to the database using an insert query.
|
[
"Persist",
"this",
"entity",
"to",
"the",
"database",
"using",
"an",
"insert",
"query",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L603-L620
|
20,535 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.getPrimaryKey
|
protected function getPrimaryKey()
{
if (!isset($this->values[static::$primary_key])) {
throw new \LogicException('Primary key not set');
}
return $this->current_index ?: $this->values[static::$primary_key];
}
|
php
|
protected function getPrimaryKey()
{
if (!isset($this->values[static::$primary_key])) {
throw new \LogicException('Primary key not set');
}
return $this->current_index ?: $this->values[static::$primary_key];
}
|
[
"protected",
"function",
"getPrimaryKey",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"static",
"::",
"$",
"primary_key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Primary key not set'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"current_index",
"?",
":",
"$",
"this",
"->",
"values",
"[",
"static",
"::",
"$",
"primary_key",
"]",
";",
"}"
] |
Get the primary key for this entity as it is stored in the
database. If the key has been updated but not saved, the
original value will be returned.
@return string The primary key of the entity
|
[
"Get",
"the",
"primary",
"key",
"for",
"this",
"entity",
"as",
"it",
"is",
"stored",
"in",
"the",
"database",
".",
"If",
"the",
"key",
"has",
"been",
"updated",
"but",
"not",
"saved",
"the",
"original",
"value",
"will",
"be",
"returned",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L629-L636
|
20,536 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.update
|
public function update()
{
$this->callEvent('update');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->update(static::$table, $values, $where, static::$types);
$this->setStored();
}
|
php
|
public function update()
{
$this->callEvent('update');
if (empty($this->modified)) {
return;
}
$values = array_intersect_key($this->values, $this->modified);
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->update(static::$table, $values, $where, static::$types);
$this->setStored();
}
|
[
"public",
"function",
"update",
"(",
")",
"{",
"$",
"this",
"->",
"callEvent",
"(",
"'update'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"modified",
")",
")",
"{",
"return",
";",
"}",
"$",
"values",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"this",
"->",
"modified",
")",
";",
"$",
"where",
"=",
"[",
"static",
"::",
"$",
"primary_key",
"=>",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
";",
"$",
"this",
"->",
"connection",
"->",
"update",
"(",
"static",
"::",
"$",
"table",
",",
"$",
"values",
",",
"$",
"where",
",",
"static",
"::",
"$",
"types",
")",
";",
"$",
"this",
"->",
"setStored",
"(",
")",
";",
"}"
] |
Update this entity in the database.
|
[
"Update",
"this",
"entity",
"in",
"the",
"database",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L649-L660
|
20,537 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.setStored
|
public function setStored($stored = true)
{
$this->stored = (bool) $stored;
$this->modified = $stored ? [] : $this->values;
return $this;
}
|
php
|
public function setStored($stored = true)
{
$this->stored = (bool) $stored;
$this->modified = $stored ? [] : $this->values;
return $this;
}
|
[
"public",
"function",
"setStored",
"(",
"$",
"stored",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"stored",
"=",
"(",
"bool",
")",
"$",
"stored",
";",
"$",
"this",
"->",
"modified",
"=",
"$",
"stored",
"?",
"[",
"]",
":",
"$",
"this",
"->",
"values",
";",
"return",
"$",
"this",
";",
"}"
] |
Set whether this entity is stored in the database or not.
@param bool $stored True if stored, false if not
|
[
"Set",
"whether",
"this",
"entity",
"is",
"stored",
"in",
"the",
"database",
"or",
"not",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L667-L673
|
20,538 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.delete
|
public function delete()
{
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->delete(static::$table, $where);
$this->setStored(false);
return $this;
}
|
php
|
public function delete()
{
$where = [static::$primary_key => $this->getPrimaryKey()];
$this->connection->delete(static::$table, $where);
$this->setStored(false);
return $this;
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"where",
"=",
"[",
"static",
"::",
"$",
"primary_key",
"=>",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
";",
"$",
"this",
"->",
"connection",
"->",
"delete",
"(",
"static",
"::",
"$",
"table",
",",
"$",
"where",
")",
";",
"$",
"this",
"->",
"setStored",
"(",
"false",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Delete this entity from the database.
@return Entity This entity
|
[
"Delete",
"this",
"entity",
"from",
"the",
"database",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L699-L707
|
20,539 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.create
|
public static function create(Connection $connection, $amount = 0)
{
$entities = [];
for ($i = 0; $i < (int) $amount; $i++) {
$entities[] = new static($connection);
}
return static::newCollection($entities);
}
|
php
|
public static function create(Connection $connection, $amount = 0)
{
$entities = [];
for ($i = 0; $i < (int) $amount; $i++) {
$entities[] = new static($connection);
}
return static::newCollection($entities);
}
|
[
"public",
"static",
"function",
"create",
"(",
"Connection",
"$",
"connection",
",",
"$",
"amount",
"=",
"0",
")",
"{",
"$",
"entities",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"int",
")",
"$",
"amount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"entities",
"[",
"]",
"=",
"new",
"static",
"(",
"$",
"connection",
")",
";",
"}",
"return",
"static",
"::",
"newCollection",
"(",
"$",
"entities",
")",
";",
"}"
] |
Create a new collection with an amount of empty entities.
@param Connection $connection A connection instance
@param int $amount The amount of new Entities to create
|
[
"Create",
"a",
"new",
"collection",
"with",
"an",
"amount",
"of",
"empty",
"entities",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L737-L745
|
20,540 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.selectSQL
|
public static function selectSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$results = array();
while ($result = $stmt->fetch()) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$obj = new static($connection, $result);
$obj->setStored();
$results[] = $obj;
}
$collection = static::newCollection();
$collection->setEntities($results);
return $collection;
}
|
php
|
public static function selectSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$results = array();
while ($result = $stmt->fetch()) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$obj = new static($connection, $result);
$obj->setStored();
$results[] = $obj;
}
$collection = static::newCollection();
$collection->setEntities($results);
return $collection;
}
|
[
"public",
"static",
"function",
"selectSQL",
"(",
"Connection",
"$",
"connection",
",",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"field_mapping",
"=",
"[",
"]",
")",
"{",
"$",
"stmt",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"result",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"field_mapping",
"as",
"$",
"result_column",
"=>",
"$",
"entity_field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"entity_field",
"]",
"=",
"$",
"result",
"[",
"$",
"result_column",
"]",
";",
"unset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"types",
"as",
"$",
"column",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"column",
"]",
"=",
"$",
"connection",
"->",
"convertToPHPValue",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
",",
"$",
"type",
")",
";",
"}",
"}",
"$",
"obj",
"=",
"new",
"static",
"(",
"$",
"connection",
",",
"$",
"result",
")",
";",
"$",
"obj",
"->",
"setStored",
"(",
")",
";",
"$",
"results",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"$",
"collection",
"=",
"static",
"::",
"newCollection",
"(",
")",
";",
"$",
"collection",
"->",
"setEntities",
"(",
"$",
"results",
")",
";",
"return",
"$",
"collection",
";",
"}"
] |
Select all entities matching an SQL query, and return the
results as a collection.
@param Connection $connection A connection instance
@param string $sql The SQL query
@param array $parameters Any bound parameters required for the query
@param array $field_mapping An array of result columns => entity fields
@return EntityCollection A collection containing the selected entities
|
[
"Select",
"all",
"entities",
"matching",
"an",
"SQL",
"query",
"and",
"return",
"the",
"results",
"as",
"a",
"collection",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L758-L786
|
20,541 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.selectOneSQL
|
public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$result = $stmt->fetch();
if ($result) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$entity = new static($connection, $result);
return $entity->setStored();
}
return null;
}
|
php
|
public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
{
$stmt = $connection->prepare($sql);
$stmt->execute($parameters);
$result = $stmt->fetch();
if ($result) {
foreach ($field_mapping as $result_column => $entity_field) {
if (!isset($result[$result_column])) {
continue;
}
$result[$entity_field] = $result[$result_column];
unset($result[$result_column]);
}
foreach (static::$types as $column => $type) {
if (isset($result[$column])) {
$result[$column] = $connection->convertToPHPValue($result[$column], $type);
}
}
$entity = new static($connection, $result);
return $entity->setStored();
}
return null;
}
|
[
"public",
"static",
"function",
"selectOneSQL",
"(",
"Connection",
"$",
"connection",
",",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"field_mapping",
"=",
"[",
"]",
")",
"{",
"$",
"stmt",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"$",
"result",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"foreach",
"(",
"$",
"field_mapping",
"as",
"$",
"result_column",
"=>",
"$",
"entity_field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"$",
"entity_field",
"]",
"=",
"$",
"result",
"[",
"$",
"result_column",
"]",
";",
"unset",
"(",
"$",
"result",
"[",
"$",
"result_column",
"]",
")",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"types",
"as",
"$",
"column",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"column",
"]",
"=",
"$",
"connection",
"->",
"convertToPHPValue",
"(",
"$",
"result",
"[",
"$",
"column",
"]",
",",
"$",
"type",
")",
";",
"}",
"}",
"$",
"entity",
"=",
"new",
"static",
"(",
"$",
"connection",
",",
"$",
"result",
")",
";",
"return",
"$",
"entity",
"->",
"setStored",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Select a single entity matching an SQL query. If more than one
row is matched by the query, only the first entity will be
returned.
@param Connection $connection A connection instance
@param string $sql The SQL query
@param array $parameters Any bound parameters required for the query
@param array $field_mapping An array of result columns => entity fields
@return Entity|null The selected Entity, or null if no entity was found
|
[
"Select",
"a",
"single",
"entity",
"matching",
"an",
"SQL",
"query",
".",
"If",
"more",
"than",
"one",
"row",
"is",
"matched",
"by",
"the",
"query",
"only",
"the",
"first",
"entity",
"will",
"be",
"returned",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L800-L825
|
20,542 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.select
|
public static function select(Connection $connection)
{
return new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
}
|
php
|
public static function select(Connection $connection)
{
return new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
}
|
[
"public",
"static",
"function",
"select",
"(",
"Connection",
"$",
"connection",
")",
"{",
"return",
"new",
"EntitySelector",
"(",
"AbstractSelector",
"::",
"fromConnection",
"(",
"$",
"connection",
",",
"static",
"::",
"$",
"table",
",",
"static",
"::",
"$",
"types",
")",
",",
"get_called_class",
"(",
")",
")",
";",
"}"
] |
Select entities using an EntitySelector instance.
@param Connection $connection A connection instance
@return EntitySelector A selector instance
|
[
"Select",
"entities",
"using",
"an",
"EntitySelector",
"instance",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L833-L836
|
20,543 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.selectOne
|
public static function selectOne(Connection $connection)
{
$selector = new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
return $selector->one();
}
|
php
|
public static function selectOne(Connection $connection)
{
$selector = new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());
return $selector->one();
}
|
[
"public",
"static",
"function",
"selectOne",
"(",
"Connection",
"$",
"connection",
")",
"{",
"$",
"selector",
"=",
"new",
"EntitySelector",
"(",
"AbstractSelector",
"::",
"fromConnection",
"(",
"$",
"connection",
",",
"static",
"::",
"$",
"table",
",",
"static",
"::",
"$",
"types",
")",
",",
"get_called_class",
"(",
")",
")",
";",
"return",
"$",
"selector",
"->",
"one",
"(",
")",
";",
"}"
] |
Select a single entity using an EntitySelector instance.
@param Connection $connection A connection instance
@return EntitySelector A selector instance
|
[
"Select",
"a",
"single",
"entity",
"using",
"an",
"EntitySelector",
"instance",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L844-L849
|
20,544 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/Entity.php
|
Entity.selectPrimaryKey
|
public static function selectPrimaryKey(Connection $connection, $primary_key)
{
return static::selectOne($connection)
->where(static::$primary_key, $primary_key)
->execute();
}
|
php
|
public static function selectPrimaryKey(Connection $connection, $primary_key)
{
return static::selectOne($connection)
->where(static::$primary_key, $primary_key)
->execute();
}
|
[
"public",
"static",
"function",
"selectPrimaryKey",
"(",
"Connection",
"$",
"connection",
",",
"$",
"primary_key",
")",
"{",
"return",
"static",
"::",
"selectOne",
"(",
"$",
"connection",
")",
"->",
"where",
"(",
"static",
"::",
"$",
"primary_key",
",",
"$",
"primary_key",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Select a single entity matching a primary key.
@param Connection $connection A connection instance
@param mixed $primary_key The primary key
@return Entity|null The entity, or null if not found
|
[
"Select",
"a",
"single",
"entity",
"matching",
"a",
"primary",
"key",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/Entity.php#L858-L863
|
20,545 |
alevilar/ristorantino-vendor
|
Mesa/Controller/MozosController.php
|
MozosController.mesas_abiertas
|
public function mesas_abiertas( $microtime = 0 ) {
$lastAccess = null;
$type = 'created';
if ( $microtime != 0 ) {
$type = 'modified';
$lastAccess = $this->Session->read('lastAccess');
// setear el nuevo lastAccess
$nowTime = date('Y-m-d H:i:s', strtotime('now'));
$this->Session->write('lastAccess', $nowTime );
// ver las borradas o con checkout
$borradas = $this->Mozo->mesasBorradas( null, $lastAccess);
if ( !empty($borradas) ) {
$mesas['borradas'] = $borradas;
}
}
$mesas[$type] = $this->Mozo->mesasAbiertas( null, $lastAccess);
$this->set('mesasLastUpdatedTime', 1 );
$this->set('modified', $lastAccess );
$this->set('mesas', $mesas );
}
|
php
|
public function mesas_abiertas( $microtime = 0 ) {
$lastAccess = null;
$type = 'created';
if ( $microtime != 0 ) {
$type = 'modified';
$lastAccess = $this->Session->read('lastAccess');
// setear el nuevo lastAccess
$nowTime = date('Y-m-d H:i:s', strtotime('now'));
$this->Session->write('lastAccess', $nowTime );
// ver las borradas o con checkout
$borradas = $this->Mozo->mesasBorradas( null, $lastAccess);
if ( !empty($borradas) ) {
$mesas['borradas'] = $borradas;
}
}
$mesas[$type] = $this->Mozo->mesasAbiertas( null, $lastAccess);
$this->set('mesasLastUpdatedTime', 1 );
$this->set('modified', $lastAccess );
$this->set('mesas', $mesas );
}
|
[
"public",
"function",
"mesas_abiertas",
"(",
"$",
"microtime",
"=",
"0",
")",
"{",
"$",
"lastAccess",
"=",
"null",
";",
"$",
"type",
"=",
"'created'",
";",
"if",
"(",
"$",
"microtime",
"!=",
"0",
")",
"{",
"$",
"type",
"=",
"'modified'",
";",
"$",
"lastAccess",
"=",
"$",
"this",
"->",
"Session",
"->",
"read",
"(",
"'lastAccess'",
")",
";",
"// setear el nuevo lastAccess",
"$",
"nowTime",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"strtotime",
"(",
"'now'",
")",
")",
";",
"$",
"this",
"->",
"Session",
"->",
"write",
"(",
"'lastAccess'",
",",
"$",
"nowTime",
")",
";",
"// ver las borradas o con checkout",
"$",
"borradas",
"=",
"$",
"this",
"->",
"Mozo",
"->",
"mesasBorradas",
"(",
"null",
",",
"$",
"lastAccess",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"borradas",
")",
")",
"{",
"$",
"mesas",
"[",
"'borradas'",
"]",
"=",
"$",
"borradas",
";",
"}",
"}",
"$",
"mesas",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"Mozo",
"->",
"mesasAbiertas",
"(",
"null",
",",
"$",
"lastAccess",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'mesasLastUpdatedTime'",
",",
"1",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'modified'",
",",
"$",
"lastAccess",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'mesas'",
",",
"$",
"mesas",
")",
";",
"}"
] |
Me devuelve las mesas abiertas de cada mozo
@param boolean $microtime microtime desde donde yo quiero tomar omo referencia a la hora de traer las mesas
|
[
"Me",
"devuelve",
"las",
"mesas",
"abiertas",
"de",
"cada",
"mozo"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Controller/MozosController.php#L108-L137
|
20,546 |
ouropencode/dachi
|
src/Logger.php
|
Logger.handle_error
|
public static function handle_error($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno))
return false;
self::error(sprintf("%s [%s] %s. Line: %s. File: %s", human_error_code($errno), $errno, $errstr, $errline, $errfile));
return true;
}
|
php
|
public static function handle_error($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno))
return false;
self::error(sprintf("%s [%s] %s. Line: %s. File: %s", human_error_code($errno), $errno, $errstr, $errline, $errfile));
return true;
}
|
[
"public",
"static",
"function",
"handle_error",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"if",
"(",
"!",
"(",
"error_reporting",
"(",
")",
"&",
"$",
"errno",
")",
")",
"return",
"false",
";",
"self",
"::",
"error",
"(",
"sprintf",
"(",
"\"%s [%s] %s. Line: %s. File: %s\"",
",",
"human_error_code",
"(",
"$",
"errno",
")",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errline",
",",
"$",
"errfile",
")",
")",
";",
"return",
"true",
";",
"}"
] |
This function is called when a PHP error occurs. It is unadivsed to call
this function manually.
@internal
@param int $errno The error number
@param string $errstr The error message
@param string $errfile The file that caused the error
@param int $errline The line that caused the error
@return bool
|
[
"This",
"function",
"is",
"called",
"when",
"a",
"PHP",
"error",
"occurs",
".",
"It",
"is",
"unadivsed",
"to",
"call",
"this",
"function",
"manually",
"."
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Logger.php#L93-L99
|
20,547 |
ouropencode/dachi
|
src/Logger.php
|
Logger.filament
|
private static function filament($type, $arguments) {
$uniqId = md5($type . json_encode($arguments));
if(isset(self::$log[$uniqId]))
return ++self::$log[$uniqId]["count"];
self::$log[$uniqId] = array(
"count" => 1,
"type" => $type,
"arguments" => $arguments
);
return true;
}
|
php
|
private static function filament($type, $arguments) {
$uniqId = md5($type . json_encode($arguments));
if(isset(self::$log[$uniqId]))
return ++self::$log[$uniqId]["count"];
self::$log[$uniqId] = array(
"count" => 1,
"type" => $type,
"arguments" => $arguments
);
return true;
}
|
[
"private",
"static",
"function",
"filament",
"(",
"$",
"type",
",",
"$",
"arguments",
")",
"{",
"$",
"uniqId",
"=",
"md5",
"(",
"$",
"type",
".",
"json_encode",
"(",
"$",
"arguments",
")",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"log",
"[",
"$",
"uniqId",
"]",
")",
")",
"return",
"++",
"self",
"::",
"$",
"log",
"[",
"$",
"uniqId",
"]",
"[",
"\"count\"",
"]",
";",
"self",
"::",
"$",
"log",
"[",
"$",
"uniqId",
"]",
"=",
"array",
"(",
"\"count\"",
"=>",
"1",
",",
"\"type\"",
"=>",
"$",
"type",
",",
"\"arguments\"",
"=>",
"$",
"arguments",
")",
";",
"return",
"true",
";",
"}"
] |
Add a log entry to the filament log. This log is sent to the filament
server after script execution.
@internal
@param string $type The log message.
@param array $arguments An array of the log arguments.
@return bool
|
[
"Add",
"a",
"log",
"entry",
"to",
"the",
"filament",
"log",
".",
"This",
"log",
"is",
"sent",
"to",
"the",
"filament",
"server",
"after",
"script",
"execution",
"."
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Logger.php#L128-L140
|
20,548 |
hametuha/wpametu
|
src/WPametu/Utility/StringHelper.php
|
StringHelper.hyphen_to_camel
|
public function hyphen_to_camel( $string, $upper_first = false ) {
$str = preg_replace_callback( '/-(.)/u', function ( $match ) {
return strtoupper( $match[1] );
}, strtolower( $string ) );
if ( $upper_first ) {
$str = ucfirst( $str );
}
return $str;
}
|
php
|
public function hyphen_to_camel( $string, $upper_first = false ) {
$str = preg_replace_callback( '/-(.)/u', function ( $match ) {
return strtoupper( $match[1] );
}, strtolower( $string ) );
if ( $upper_first ) {
$str = ucfirst( $str );
}
return $str;
}
|
[
"public",
"function",
"hyphen_to_camel",
"(",
"$",
"string",
",",
"$",
"upper_first",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"'/-(.)/u'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"strtoupper",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
",",
"strtolower",
"(",
"$",
"string",
")",
")",
";",
"if",
"(",
"$",
"upper_first",
")",
"{",
"$",
"str",
"=",
"ucfirst",
"(",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Make hyphenated string to camel case
@param string $string
@param bool $upper_first Retuns Uppercase first letter if true. Defalt false.
@return string
|
[
"Make",
"hyphenated",
"string",
"to",
"camel",
"case"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L36-L45
|
20,549 |
hametuha/wpametu
|
src/WPametu/Utility/StringHelper.php
|
StringHelper.post_type_label
|
public function post_type_label( $singular_name, $multiple_name = '', $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'add_new' => $this->__( 'Add new' ),
'add_new_item' => sprintf( $this->__( 'Add new %s' ), $singular_name ),
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'new_item' => sprintf( $this->__( 'New %s' ), $singular_name ),
'view_item' => sprintf( $this->__( 'Vew %s' ), $singular_name ),
'search_items' => sprintf( $this->__( 'Search %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'not_found_in_trash' => sprintf( $this->__( 'No %s in trash.' ), $singular_name ),
'parent_item_colon' => sprintf( $this->__( 'Parent %s:' ), $singular_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'menu_name' => $singular_name,
'name_admin_bar' => $singular_name,
];
return $as_object ? (object) $labels : $labels;
}
|
php
|
public function post_type_label( $singular_name, $multiple_name = '', $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'add_new' => $this->__( 'Add new' ),
'add_new_item' => sprintf( $this->__( 'Add new %s' ), $singular_name ),
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'new_item' => sprintf( $this->__( 'New %s' ), $singular_name ),
'view_item' => sprintf( $this->__( 'Vew %s' ), $singular_name ),
'search_items' => sprintf( $this->__( 'Search %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'not_found_in_trash' => sprintf( $this->__( 'No %s in trash.' ), $singular_name ),
'parent_item_colon' => sprintf( $this->__( 'Parent %s:' ), $singular_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'menu_name' => $singular_name,
'name_admin_bar' => $singular_name,
];
return $as_object ? (object) $labels : $labels;
}
|
[
"public",
"function",
"post_type_label",
"(",
"$",
"singular_name",
",",
"$",
"multiple_name",
"=",
"''",
",",
"$",
"as_object",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"multiple_name",
")",
"{",
"$",
"multiple_name",
"=",
"$",
"singular_name",
";",
"}",
"$",
"labels",
"=",
"[",
"'name'",
"=>",
"$",
"multiple_name",
",",
"'singular_name'",
"=>",
"$",
"singular_name",
",",
"'add_new'",
"=>",
"$",
"this",
"->",
"__",
"(",
"'Add new'",
")",
",",
"'add_new_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add new %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'edit_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Edit %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'new_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'New %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'view_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Vew %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'search_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Search %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'not_found'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'No %s found.'",
")",
",",
"$",
"multiple_name",
")",
",",
"'not_found_in_trash'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'No %s in trash.'",
")",
",",
"$",
"singular_name",
")",
",",
"'parent_item_colon'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Parent %s:'",
")",
",",
"$",
"singular_name",
")",
",",
"'all_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'All %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'menu_name'",
"=>",
"$",
"singular_name",
",",
"'name_admin_bar'",
"=>",
"$",
"singular_name",
",",
"]",
";",
"return",
"$",
"as_object",
"?",
"(",
"object",
")",
"$",
"labels",
":",
"$",
"labels",
";",
"}"
] |
Returns post type label shorthand.
@param string $singular_name
@param string $multiple_name Optional.
@param bool $as_object
@return array|\stdClass
|
[
"Returns",
"post",
"type",
"label",
"shorthand",
"."
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L107-L129
|
20,550 |
hametuha/wpametu
|
src/WPametu/Utility/StringHelper.php
|
StringHelper.get_taxonomy_label
|
public function get_taxonomy_label( $singular_name, $multiple_name = '', $hierarchical = false, $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'search_items' => sprintf( $this->__( 'Search %s' ), $singular_name ),
'popular_items' => sprintf( $this->__( 'Popular %s' ), $multiple_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'parent_item' => $hierarchical ? sprintf( $this->__( 'Parent %s' ), $singular_name ) : null,
'parent_item_colon' => $hierarchical ? sprintf( $this->__( 'Parent %s:' ), $singular_name ) : null,
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'update_item' => sprintf( $this->__( 'Update %s' ), $singular_name ),
'add_new_item' => sprintf( $this->__( 'Add New %s' ), $singular_name ),
'new_item_name' => sprintf( $this->__( 'New %s Name' ), $singular_name ),
'separate_items_with_commas' => sprintf( $this->__( 'Separate %s with commas' ), $multiple_name ),
'add_or_remove_items' => sprintf( $this->__( 'Add or remove %s' ), $multiple_name ),
'choose_from_most_used' => sprintf( $this->__( 'Choose from the most used %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'menu_name' => $multiple_name,
];
return $as_object ? (object) $labels : $labels;
}
|
php
|
public function get_taxonomy_label( $singular_name, $multiple_name = '', $hierarchical = false, $as_object = false ) {
if ( ! $multiple_name ) {
$multiple_name = $singular_name;
}
$labels = [
'name' => $multiple_name,
'singular_name' => $singular_name,
'search_items' => sprintf( $this->__( 'Search %s' ), $singular_name ),
'popular_items' => sprintf( $this->__( 'Popular %s' ), $multiple_name ),
'all_items' => sprintf( $this->__( 'All %s' ), $multiple_name ),
'parent_item' => $hierarchical ? sprintf( $this->__( 'Parent %s' ), $singular_name ) : null,
'parent_item_colon' => $hierarchical ? sprintf( $this->__( 'Parent %s:' ), $singular_name ) : null,
'edit_item' => sprintf( $this->__( 'Edit %s' ), $singular_name ),
'update_item' => sprintf( $this->__( 'Update %s' ), $singular_name ),
'add_new_item' => sprintf( $this->__( 'Add New %s' ), $singular_name ),
'new_item_name' => sprintf( $this->__( 'New %s Name' ), $singular_name ),
'separate_items_with_commas' => sprintf( $this->__( 'Separate %s with commas' ), $multiple_name ),
'add_or_remove_items' => sprintf( $this->__( 'Add or remove %s' ), $multiple_name ),
'choose_from_most_used' => sprintf( $this->__( 'Choose from the most used %s' ), $multiple_name ),
'not_found' => sprintf( $this->__( 'No %s found.' ), $multiple_name ),
'menu_name' => $multiple_name,
];
return $as_object ? (object) $labels : $labels;
}
|
[
"public",
"function",
"get_taxonomy_label",
"(",
"$",
"singular_name",
",",
"$",
"multiple_name",
"=",
"''",
",",
"$",
"hierarchical",
"=",
"false",
",",
"$",
"as_object",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"multiple_name",
")",
"{",
"$",
"multiple_name",
"=",
"$",
"singular_name",
";",
"}",
"$",
"labels",
"=",
"[",
"'name'",
"=>",
"$",
"multiple_name",
",",
"'singular_name'",
"=>",
"$",
"singular_name",
",",
"'search_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Search %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'popular_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Popular %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'all_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'All %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'parent_item'",
"=>",
"$",
"hierarchical",
"?",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Parent %s'",
")",
",",
"$",
"singular_name",
")",
":",
"null",
",",
"'parent_item_colon'",
"=>",
"$",
"hierarchical",
"?",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Parent %s:'",
")",
",",
"$",
"singular_name",
")",
":",
"null",
",",
"'edit_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Edit %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'update_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Update %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'add_new_item'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add New %s'",
")",
",",
"$",
"singular_name",
")",
",",
"'new_item_name'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'New %s Name'",
")",
",",
"$",
"singular_name",
")",
",",
"'separate_items_with_commas'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Separate %s with commas'",
")",
",",
"$",
"multiple_name",
")",
",",
"'add_or_remove_items'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Add or remove %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'choose_from_most_used'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'Choose from the most used %s'",
")",
",",
"$",
"multiple_name",
")",
",",
"'not_found'",
"=>",
"sprintf",
"(",
"$",
"this",
"->",
"__",
"(",
"'No %s found.'",
")",
",",
"$",
"multiple_name",
")",
",",
"'menu_name'",
"=>",
"$",
"multiple_name",
",",
"]",
";",
"return",
"$",
"as_object",
"?",
"(",
"object",
")",
"$",
"labels",
":",
"$",
"labels",
";",
"}"
] |
Returns taxonomy label shorthand.
@param string $singular_name
@param string $multiple_name If empty, singular_name will be used.
@param bool $hierarchical Default false.
@param bool $as_object Default false. If true, returns as Object
@return array|\stdClass
|
[
"Returns",
"taxonomy",
"label",
"shorthand",
"."
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L142-L166
|
20,551 |
hametuha/wpametu
|
src/WPametu/Utility/StringHelper.php
|
StringHelper.extract_host
|
public function extract_host( $url ) {
$string = (string) $url;
if ( preg_match( '@https?://([^/\?#]+)@u', $url, $match ) ) {
return $match[1];
} else {
return $url;
}
}
|
php
|
public function extract_host( $url ) {
$string = (string) $url;
if ( preg_match( '@https?://([^/\?#]+)@u', $url, $match ) ) {
return $match[1];
} else {
return $url;
}
}
|
[
"public",
"function",
"extract_host",
"(",
"$",
"url",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"url",
";",
"if",
"(",
"preg_match",
"(",
"'@https?://([^/\\?#]+)@u'",
",",
"$",
"url",
",",
"$",
"match",
")",
")",
"{",
"return",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"url",
";",
"}",
"}"
] |
Extract host value from url
@param string $url
@return string
|
[
"Extract",
"host",
"value",
"from",
"url"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/StringHelper.php#L175-L182
|
20,552 |
ekuiter/feature-php
|
FeaturePhp/Model/Model.php
|
Model.getFeature
|
public function getFeature($featureName, $permissive = false) {
$feature = Feature::findByName($this->features, $featureName, $permissive);
if (!$feature)
throw new ModelException("the model has no feature named \"$featureName\"");
return $feature;
}
|
php
|
public function getFeature($featureName, $permissive = false) {
$feature = Feature::findByName($this->features, $featureName, $permissive);
if (!$feature)
throw new ModelException("the model has no feature named \"$featureName\"");
return $feature;
}
|
[
"public",
"function",
"getFeature",
"(",
"$",
"featureName",
",",
"$",
"permissive",
"=",
"false",
")",
"{",
"$",
"feature",
"=",
"Feature",
"::",
"findByName",
"(",
"$",
"this",
"->",
"features",
",",
"$",
"featureName",
",",
"$",
"permissive",
")",
";",
"if",
"(",
"!",
"$",
"feature",
")",
"throw",
"new",
"ModelException",
"(",
"\"the model has no feature named \\\"$featureName\\\"\"",
")",
";",
"return",
"$",
"feature",
";",
"}"
] |
Returns a feature in the feature model with a given name.
@param string $featureName
@param bool $permissive
@return Feature
|
[
"Returns",
"a",
"feature",
"in",
"the",
"feature",
"model",
"with",
"a",
"given",
"name",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Model.php#L72-L77
|
20,553 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php
|
ezcQuerySelectOracle.prepare
|
public function prepare()
{
if ( $this->fromString == null || $this->fromString == '' )
{
$this->from( $this->getDummyTableName() );
}
return parent::prepare();
}
|
php
|
public function prepare()
{
if ( $this->fromString == null || $this->fromString == '' )
{
$this->from( $this->getDummyTableName() );
}
return parent::prepare();
}
|
[
"public",
"function",
"prepare",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fromString",
"==",
"null",
"||",
"$",
"this",
"->",
"fromString",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"from",
"(",
"$",
"this",
"->",
"getDummyTableName",
"(",
")",
")",
";",
"}",
"return",
"parent",
"::",
"prepare",
"(",
")",
";",
"}"
] |
Handles preparing query.
Overrides ezcQuery->prepare()
Adds "FROM dual" to the select if no FROM clause specified
i.e. fixes queries like "SELECT 1+1" to work in Oracle.
@return PDOStatement
|
[
"Handles",
"preparing",
"query",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_oracle.php#L170-L177
|
20,554 |
hametuha/wpametu
|
src/WPametu/Utility/Formatter.php
|
Formatter.to_string
|
public static function to_string( \DOMDocument $dom ) {
$html5 = new HTML5();
preg_match( '/<body>(.*)<\/body>/s', $html5->saveHTML( $dom ), $match );
return $match[1];
}
|
php
|
public static function to_string( \DOMDocument $dom ) {
$html5 = new HTML5();
preg_match( '/<body>(.*)<\/body>/s', $html5->saveHTML( $dom ), $match );
return $match[1];
}
|
[
"public",
"static",
"function",
"to_string",
"(",
"\\",
"DOMDocument",
"$",
"dom",
")",
"{",
"$",
"html5",
"=",
"new",
"HTML5",
"(",
")",
";",
"preg_match",
"(",
"'/<body>(.*)<\\/body>/s'",
",",
"$",
"html5",
"->",
"saveHTML",
"(",
"$",
"dom",
")",
",",
"$",
"match",
")",
";",
"return",
"$",
"match",
"[",
"1",
"]",
";",
"}"
] |
Return body as string
@param \DOMDocument $dom
@return mixed
|
[
"Return",
"body",
"as",
"string"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/Formatter.php#L45-L50
|
20,555 |
ekuiter/feature-php
|
FeaturePhp/Collaboration/ClassComposer.php
|
ClassComposer.refine
|
public function refine($role) {
$fileSource = $role->getFileSpecification()->getSource();
$parser = (new fphp\Helper\PhpParser())->parseFile($fileSource);
$ast = $parser->getAst();
$class = $parser->getExactlyOneClass($fileSource);
if (!$this->targetClass) { // not refining, but defining the target class
$this->targetClass = $class->name;
$this->mangleClassName($class, $role);
} else { // refining
if ($class->name !== $this->targetClass)
throw new ClassComposerException("\"$fileSource\" refines \"$class->name\" (expected \"$this->targetClass\")");
if ($class->extends)
throw new ClassComposerException("refining role at \"$fileSource\" may not extend a class");
$this->mangleClassName($class, $role);
$this->extendClass($class);
}
return new ClassComposer($this->targetClass, $class->name, array_merge($this->ast, $ast));
}
|
php
|
public function refine($role) {
$fileSource = $role->getFileSpecification()->getSource();
$parser = (new fphp\Helper\PhpParser())->parseFile($fileSource);
$ast = $parser->getAst();
$class = $parser->getExactlyOneClass($fileSource);
if (!$this->targetClass) { // not refining, but defining the target class
$this->targetClass = $class->name;
$this->mangleClassName($class, $role);
} else { // refining
if ($class->name !== $this->targetClass)
throw new ClassComposerException("\"$fileSource\" refines \"$class->name\" (expected \"$this->targetClass\")");
if ($class->extends)
throw new ClassComposerException("refining role at \"$fileSource\" may not extend a class");
$this->mangleClassName($class, $role);
$this->extendClass($class);
}
return new ClassComposer($this->targetClass, $class->name, array_merge($this->ast, $ast));
}
|
[
"public",
"function",
"refine",
"(",
"$",
"role",
")",
"{",
"$",
"fileSource",
"=",
"$",
"role",
"->",
"getFileSpecification",
"(",
")",
"->",
"getSource",
"(",
")",
";",
"$",
"parser",
"=",
"(",
"new",
"fphp",
"\\",
"Helper",
"\\",
"PhpParser",
"(",
")",
")",
"->",
"parseFile",
"(",
"$",
"fileSource",
")",
";",
"$",
"ast",
"=",
"$",
"parser",
"->",
"getAst",
"(",
")",
";",
"$",
"class",
"=",
"$",
"parser",
"->",
"getExactlyOneClass",
"(",
"$",
"fileSource",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"targetClass",
")",
"{",
"// not refining, but defining the target class",
"$",
"this",
"->",
"targetClass",
"=",
"$",
"class",
"->",
"name",
";",
"$",
"this",
"->",
"mangleClassName",
"(",
"$",
"class",
",",
"$",
"role",
")",
";",
"}",
"else",
"{",
"// refining",
"if",
"(",
"$",
"class",
"->",
"name",
"!==",
"$",
"this",
"->",
"targetClass",
")",
"throw",
"new",
"ClassComposerException",
"(",
"\"\\\"$fileSource\\\" refines \\\"$class->name\\\" (expected \\\"$this->targetClass\\\")\"",
")",
";",
"if",
"(",
"$",
"class",
"->",
"extends",
")",
"throw",
"new",
"ClassComposerException",
"(",
"\"refining role at \\\"$fileSource\\\" may not extend a class\"",
")",
";",
"$",
"this",
"->",
"mangleClassName",
"(",
"$",
"class",
",",
"$",
"role",
")",
";",
"$",
"this",
"->",
"extendClass",
"(",
"$",
"class",
")",
";",
"}",
"return",
"new",
"ClassComposer",
"(",
"$",
"this",
"->",
"targetClass",
",",
"$",
"class",
"->",
"name",
",",
"array_merge",
"(",
"$",
"this",
"->",
"ast",
",",
"$",
"ast",
")",
")",
";",
"}"
] |
Returns a new class composer containing a role's refinements.
@param Role $role
@return ClassComposer
|
[
"Returns",
"a",
"new",
"class",
"composer",
"containing",
"a",
"role",
"s",
"refinements",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Collaboration/ClassComposer.php#L90-L110
|
20,556 |
ekuiter/feature-php
|
FeaturePhp/Collaboration/ClassComposer.php
|
ClassComposer.getContent
|
public function getContent() {
$class = new \PhpParser\Node\Stmt\Class_($this->targetClass);
$this->extendClass($class);
$ast = array_merge($this->ast, array($class));
$code = fphp\Helper\PhpParser::astToString($ast);
return new fphp\File\TextFileContent($code);
}
|
php
|
public function getContent() {
$class = new \PhpParser\Node\Stmt\Class_($this->targetClass);
$this->extendClass($class);
$ast = array_merge($this->ast, array($class));
$code = fphp\Helper\PhpParser::astToString($ast);
return new fphp\File\TextFileContent($code);
}
|
[
"public",
"function",
"getContent",
"(",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"PhpParser",
"\\",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
"(",
"$",
"this",
"->",
"targetClass",
")",
";",
"$",
"this",
"->",
"extendClass",
"(",
"$",
"class",
")",
";",
"$",
"ast",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"ast",
",",
"array",
"(",
"$",
"class",
")",
")",
";",
"$",
"code",
"=",
"fphp",
"\\",
"Helper",
"\\",
"PhpParser",
"::",
"astToString",
"(",
"$",
"ast",
")",
";",
"return",
"new",
"fphp",
"\\",
"File",
"\\",
"TextFileContent",
"(",
"$",
"code",
")",
";",
"}"
] |
Returns the refined file's content.
@return \FeaturePhp\File\TextFileContent
|
[
"Returns",
"the",
"refined",
"file",
"s",
"content",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Collaboration/ClassComposer.php#L116-L122
|
20,557 |
surebert/surebert-framework
|
src/sb/Controller/Toolkit.php
|
Toolkit.grabFile
|
protected function grabFile($file, $root)
{
$data = '';
if (is_file($root . '/' . $file)) {
$this->loaded_files[] = $file;
$file = $root . '/' . $file;
$data = file_get_contents($file);
if (!strstr($file, 'sb.js')) {
preg_match_all("~sb\.include\([\"'](.*?)[\"']~", $data, $includes);
if ($includes[1]) {
$precludes = '';
foreach ($includes[1] as $include) {
$include = \str_replace('.', '/', $include) . '.js';
if (!\in_array($include, $this->loaded_files)) {
$precludes .= $this->grabFile($include, $root);
}
}
$data = $precludes . "\n" . $data;
}
}
} else {
echo"\nthrow('ERROR: " . $file . " Surebert module \""
. \basename($file) . "\" could not be located by /surebert/load ');";
}
return $data;
}
|
php
|
protected function grabFile($file, $root)
{
$data = '';
if (is_file($root . '/' . $file)) {
$this->loaded_files[] = $file;
$file = $root . '/' . $file;
$data = file_get_contents($file);
if (!strstr($file, 'sb.js')) {
preg_match_all("~sb\.include\([\"'](.*?)[\"']~", $data, $includes);
if ($includes[1]) {
$precludes = '';
foreach ($includes[1] as $include) {
$include = \str_replace('.', '/', $include) . '.js';
if (!\in_array($include, $this->loaded_files)) {
$precludes .= $this->grabFile($include, $root);
}
}
$data = $precludes . "\n" . $data;
}
}
} else {
echo"\nthrow('ERROR: " . $file . " Surebert module \""
. \basename($file) . "\" could not be located by /surebert/load ');";
}
return $data;
}
|
[
"protected",
"function",
"grabFile",
"(",
"$",
"file",
",",
"$",
"root",
")",
"{",
"$",
"data",
"=",
"''",
";",
"if",
"(",
"is_file",
"(",
"$",
"root",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"loaded_files",
"[",
"]",
"=",
"$",
"file",
";",
"$",
"file",
"=",
"$",
"root",
".",
"'/'",
".",
"$",
"file",
";",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"strstr",
"(",
"$",
"file",
",",
"'sb.js'",
")",
")",
"{",
"preg_match_all",
"(",
"\"~sb\\.include\\([\\\"'](.*?)[\\\"']~\"",
",",
"$",
"data",
",",
"$",
"includes",
")",
";",
"if",
"(",
"$",
"includes",
"[",
"1",
"]",
")",
"{",
"$",
"precludes",
"=",
"''",
";",
"foreach",
"(",
"$",
"includes",
"[",
"1",
"]",
"as",
"$",
"include",
")",
"{",
"$",
"include",
"=",
"\\",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"include",
")",
".",
"'.js'",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"include",
",",
"$",
"this",
"->",
"loaded_files",
")",
")",
"{",
"$",
"precludes",
".=",
"$",
"this",
"->",
"grabFile",
"(",
"$",
"include",
",",
"$",
"root",
")",
";",
"}",
"}",
"$",
"data",
"=",
"$",
"precludes",
".",
"\"\\n\"",
".",
"$",
"data",
";",
"}",
"}",
"}",
"else",
"{",
"echo",
"\"\\nthrow('ERROR: \"",
".",
"$",
"file",
".",
"\" Surebert module \\\"\"",
".",
"\\",
"basename",
"(",
"$",
"file",
")",
".",
"\"\\\" could not be located by /surebert/load ');\"",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Grabs a file
@param string $file The file to load
@param string $root The root to load
@return string The file data
|
[
"Grabs",
"a",
"file"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Toolkit.php#L134-L166
|
20,558 |
surebert/surebert-framework
|
src/sb/Controller/Toolkit.php
|
Toolkit.basic
|
public function basic()
{
if (!isset($this->request->get['noexpire'])) {
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 259200));
}
header("Content-type: application/x-javascript");
$version = '';
if (isset($this->request->get['v'])) {
if (is_numeric($this->request->get['v'])) {
$version = $this->request->get['v'];
}
}
/**
* This file loads multiple surebert toolkit modules and javascript files
* and puts them all into one large file for faster load times
*/
$surebert = Array(
"sb",
"browser.\$_GET",
"math.rand",
"cookies",
"browser.removeSelection",
"browser.getScrollPosition",
"browser.scrollTo",
"Element.prototype.show",
"Element.prototype.hide",
"Element.prototype.toggle",
"Element.prototype.getDimensions",
"Element.prototype.mv",
"Element.prototype.getPosition",
"Element.prototype.getNextSibling",
"Element.prototype.getPreviousSibling",
"Element.prototype.isOrHasParentOfClassName",
"Element.prototype.containsElement",
"Element.prototype.isWithin",
"Element.prototype.getContaining",
"Element.prototype.cssTransition",
"css.rules",
"swf",
"css.styleSheet",
"events.observer",
"events.classListener",
"events.idListener",
"widget.notifier",
"json.rpc2"
);
$protocol = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';
$str = "if(!sbBase){var sbBase = '" . $protocol . "://" . \sb\Gateway::$http_host . "/surebert/load/';}\n";
$surebert = \array_merge($surebert, $this->request->args);
$str .= $this->concatFiles($surebert, $version);
return $str;
}
|
php
|
public function basic()
{
if (!isset($this->request->get['noexpire'])) {
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 259200));
}
header("Content-type: application/x-javascript");
$version = '';
if (isset($this->request->get['v'])) {
if (is_numeric($this->request->get['v'])) {
$version = $this->request->get['v'];
}
}
/**
* This file loads multiple surebert toolkit modules and javascript files
* and puts them all into one large file for faster load times
*/
$surebert = Array(
"sb",
"browser.\$_GET",
"math.rand",
"cookies",
"browser.removeSelection",
"browser.getScrollPosition",
"browser.scrollTo",
"Element.prototype.show",
"Element.prototype.hide",
"Element.prototype.toggle",
"Element.prototype.getDimensions",
"Element.prototype.mv",
"Element.prototype.getPosition",
"Element.prototype.getNextSibling",
"Element.prototype.getPreviousSibling",
"Element.prototype.isOrHasParentOfClassName",
"Element.prototype.containsElement",
"Element.prototype.isWithin",
"Element.prototype.getContaining",
"Element.prototype.cssTransition",
"css.rules",
"swf",
"css.styleSheet",
"events.observer",
"events.classListener",
"events.idListener",
"widget.notifier",
"json.rpc2"
);
$protocol = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';
$str = "if(!sbBase){var sbBase = '" . $protocol . "://" . \sb\Gateway::$http_host . "/surebert/load/';}\n";
$surebert = \array_merge($surebert, $this->request->args);
$str .= $this->concatFiles($surebert, $version);
return $str;
}
|
[
"public",
"function",
"basic",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'noexpire'",
"]",
")",
")",
"{",
"header",
"(",
"'Expires: '",
".",
"gmdate",
"(",
"'D, d M Y H:i:s \\G\\M\\T'",
",",
"time",
"(",
")",
"+",
"259200",
")",
")",
";",
"}",
"header",
"(",
"\"Content-type: application/x-javascript\"",
")",
";",
"$",
"version",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'v'",
"]",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'v'",
"]",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"[",
"'v'",
"]",
";",
"}",
"}",
"/**\n * This file loads multiple surebert toolkit modules and javascript files\n * and puts them all into one large file for faster load times\n */",
"$",
"surebert",
"=",
"Array",
"(",
"\"sb\"",
",",
"\"browser.\\$_GET\"",
",",
"\"math.rand\"",
",",
"\"cookies\"",
",",
"\"browser.removeSelection\"",
",",
"\"browser.getScrollPosition\"",
",",
"\"browser.scrollTo\"",
",",
"\"Element.prototype.show\"",
",",
"\"Element.prototype.hide\"",
",",
"\"Element.prototype.toggle\"",
",",
"\"Element.prototype.getDimensions\"",
",",
"\"Element.prototype.mv\"",
",",
"\"Element.prototype.getPosition\"",
",",
"\"Element.prototype.getNextSibling\"",
",",
"\"Element.prototype.getPreviousSibling\"",
",",
"\"Element.prototype.isOrHasParentOfClassName\"",
",",
"\"Element.prototype.containsElement\"",
",",
"\"Element.prototype.isWithin\"",
",",
"\"Element.prototype.getContaining\"",
",",
"\"Element.prototype.cssTransition\"",
",",
"\"css.rules\"",
",",
"\"swf\"",
",",
"\"css.styleSheet\"",
",",
"\"events.observer\"",
",",
"\"events.classListener\"",
",",
"\"events.idListener\"",
",",
"\"widget.notifier\"",
",",
"\"json.rpc2\"",
")",
";",
"$",
"protocol",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
"==",
"443",
"?",
"'https'",
":",
"'http'",
";",
"$",
"str",
"=",
"\"if(!sbBase){var sbBase = '\"",
".",
"$",
"protocol",
".",
"\"://\"",
".",
"\\",
"sb",
"\\",
"Gateway",
"::",
"$",
"http_host",
".",
"\"/surebert/load/';}\\n\"",
";",
"$",
"surebert",
"=",
"\\",
"array_merge",
"(",
"$",
"surebert",
",",
"$",
"this",
"->",
"request",
"->",
"args",
")",
";",
"$",
"str",
".=",
"$",
"this",
"->",
"concatFiles",
"(",
"$",
"surebert",
",",
"$",
"version",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Serves out the most common surebert toolkit files
@servable true
|
[
"Serves",
"out",
"the",
"most",
"common",
"surebert",
"toolkit",
"files"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Toolkit.php#L204-L261
|
20,559 |
tigron/skeleton-file
|
lib/Skeleton/File/Util.php
|
Util.detect_mime_type
|
public static function detect_mime_type($path) {
$handle = finfo_open(FILEINFO_MIME);
$mime_type = finfo_file($handle, $path);
if (strpos($mime_type, ';')) {
$mime_type = preg_replace('/;.*/', ' ', $mime_type);
}
return trim($mime_type);
}
|
php
|
public static function detect_mime_type($path) {
$handle = finfo_open(FILEINFO_MIME);
$mime_type = finfo_file($handle, $path);
if (strpos($mime_type, ';')) {
$mime_type = preg_replace('/;.*/', ' ', $mime_type);
}
return trim($mime_type);
}
|
[
"public",
"static",
"function",
"detect_mime_type",
"(",
"$",
"path",
")",
"{",
"$",
"handle",
"=",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"mime_type",
"=",
"finfo_file",
"(",
"$",
"handle",
",",
"$",
"path",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"mime_type",
",",
"';'",
")",
")",
"{",
"$",
"mime_type",
"=",
"preg_replace",
"(",
"'/;.*/'",
",",
"' '",
",",
"$",
"mime_type",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"mime_type",
")",
";",
"}"
] |
Get the mime_type of a file
@access public
@param string $file The path to the file
@return string $mime_type
|
[
"Get",
"the",
"mime_type",
"of",
"a",
"file"
] |
97978d49f179f07c76380ddc8919b8a7d56dee61
|
https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/lib/Skeleton/File/Util.php#L99-L108
|
20,560 |
LeaseCloud/leasecloud-php-sdk
|
src/Order.php
|
Order.status
|
public static function status($orderId)
{
$url = static::classUrl();
$url = $url . '/' . $orderId . '/status';
list($ret) = parent::staticRequest('get', $url, []);
return $ret;
}
|
php
|
public static function status($orderId)
{
$url = static::classUrl();
$url = $url . '/' . $orderId . '/status';
list($ret) = parent::staticRequest('get', $url, []);
return $ret;
}
|
[
"public",
"static",
"function",
"status",
"(",
"$",
"orderId",
")",
"{",
"$",
"url",
"=",
"static",
"::",
"classUrl",
"(",
")",
";",
"$",
"url",
"=",
"$",
"url",
".",
"'/'",
".",
"$",
"orderId",
".",
"'/status'",
";",
"list",
"(",
"$",
"ret",
")",
"=",
"parent",
"::",
"staticRequest",
"(",
"'get'",
",",
"$",
"url",
",",
"[",
"]",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Get status information about an order
@param string $orderId
@return mixed
|
[
"Get",
"status",
"information",
"about",
"an",
"order"
] |
091b073dd4f79ba915a68c0ed151bd9bfa61e7ca
|
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/Order.php#L27-L34
|
20,561 |
LeaseCloud/leasecloud-php-sdk
|
src/Order.php
|
Order.shipped
|
public static function shipped($orderId, $shippedAt = 0)
{
$url = static::classUrl();
$url = $url . '/' . $orderId . '/shipped';
list($ret, $code) = parent::staticRequest('post', $url, [
'shippedAt' => date('c', $shippedAt ? $shippedAt : time()),
]);
return (object)[
'code' => $code,
'status' => $code === 204? 'success' : 'failed'
];
}
|
php
|
public static function shipped($orderId, $shippedAt = 0)
{
$url = static::classUrl();
$url = $url . '/' . $orderId . '/shipped';
list($ret, $code) = parent::staticRequest('post', $url, [
'shippedAt' => date('c', $shippedAt ? $shippedAt : time()),
]);
return (object)[
'code' => $code,
'status' => $code === 204? 'success' : 'failed'
];
}
|
[
"public",
"static",
"function",
"shipped",
"(",
"$",
"orderId",
",",
"$",
"shippedAt",
"=",
"0",
")",
"{",
"$",
"url",
"=",
"static",
"::",
"classUrl",
"(",
")",
";",
"$",
"url",
"=",
"$",
"url",
".",
"'/'",
".",
"$",
"orderId",
".",
"'/shipped'",
";",
"list",
"(",
"$",
"ret",
",",
"$",
"code",
")",
"=",
"parent",
"::",
"staticRequest",
"(",
"'post'",
",",
"$",
"url",
",",
"[",
"'shippedAt'",
"=>",
"date",
"(",
"'c'",
",",
"$",
"shippedAt",
"?",
"$",
"shippedAt",
":",
"time",
"(",
")",
")",
",",
"]",
")",
";",
"return",
"(",
"object",
")",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'status'",
"=>",
"$",
"code",
"===",
"204",
"?",
"'success'",
":",
"'failed'",
"]",
";",
"}"
] |
Tell LeaseCloud that an order is shipped
@param string $orderId
@param int $shippedAt Unix timestamp
@return object
|
[
"Tell",
"LeaseCloud",
"that",
"an",
"order",
"is",
"shipped"
] |
091b073dd4f79ba915a68c0ed151bd9bfa61e7ca
|
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/Order.php#L61-L73
|
20,562 |
ntd/silverstripe-carousel
|
code/CarouselPage.php
|
CarouselImageExtension.getCarouselEditFields
|
public function getCarouselEditFields()
{
// This is *required* otherwise TinyMCE in SilverStripe 3.3 will
// not be enabled and the <textarea> will simply disappear
// without apparent reasons
if (method_exists('HtmlEditorConfig', 'require_js')) {
HtmlEditorConfig::require_js();
}
$fields = FieldList::create();
$fields->push(CarouselCaptionField::create('Content', _t('CarouselPage.Caption')));
return $fields;
}
|
php
|
public function getCarouselEditFields()
{
// This is *required* otherwise TinyMCE in SilverStripe 3.3 will
// not be enabled and the <textarea> will simply disappear
// without apparent reasons
if (method_exists('HtmlEditorConfig', 'require_js')) {
HtmlEditorConfig::require_js();
}
$fields = FieldList::create();
$fields->push(CarouselCaptionField::create('Content', _t('CarouselPage.Caption')));
return $fields;
}
|
[
"public",
"function",
"getCarouselEditFields",
"(",
")",
"{",
"// This is *required* otherwise TinyMCE in SilverStripe 3.3 will",
"// not be enabled and the <textarea> will simply disappear",
"// without apparent reasons",
"if",
"(",
"method_exists",
"(",
"'HtmlEditorConfig'",
",",
"'require_js'",
")",
")",
"{",
"HtmlEditorConfig",
"::",
"require_js",
"(",
")",
";",
"}",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
")",
";",
"$",
"fields",
"->",
"push",
"(",
"CarouselCaptionField",
"::",
"create",
"(",
"'Content'",
",",
"_t",
"(",
"'CarouselPage.Caption'",
")",
")",
")",
";",
"return",
"$",
"fields",
";",
"}"
] |
Retrieve the fields used by SortableUploadField internal form.
@return FieldList
|
[
"Retrieve",
"the",
"fields",
"used",
"by",
"SortableUploadField",
"internal",
"form",
"."
] |
1475f48f404b702b58480eacb2fea01011b30e55
|
https://github.com/ntd/silverstripe-carousel/blob/1475f48f404b702b58480eacb2fea01011b30e55/code/CarouselPage.php#L59-L71
|
20,563 |
ntd/silverstripe-carousel
|
code/CarouselPage.php
|
CarouselPage.getCMSFields
|
public function getCMSFields()
{
$fields = parent::getCMSFields();
$field = SortableUploadField::create('Images', _t('CarouselPage.db_Images'));
$field->setFolderName($this->getClassFolder());
$field->setFileEditFields('getCarouselEditFields');
$root = $fields->fieldByName('Root');
$tab = $root->fieldByName('Images');
if (! $tab) {
$tab = Tab::create('Images');
$tab->setTitle(_t('CarouselPage.db_Images'));
$root->insertAfter($tab, 'Main');
}
$tab->push($field);
return $fields;
}
|
php
|
public function getCMSFields()
{
$fields = parent::getCMSFields();
$field = SortableUploadField::create('Images', _t('CarouselPage.db_Images'));
$field->setFolderName($this->getClassFolder());
$field->setFileEditFields('getCarouselEditFields');
$root = $fields->fieldByName('Root');
$tab = $root->fieldByName('Images');
if (! $tab) {
$tab = Tab::create('Images');
$tab->setTitle(_t('CarouselPage.db_Images'));
$root->insertAfter($tab, 'Main');
}
$tab->push($field);
return $fields;
}
|
[
"public",
"function",
"getCMSFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getCMSFields",
"(",
")",
";",
"$",
"field",
"=",
"SortableUploadField",
"::",
"create",
"(",
"'Images'",
",",
"_t",
"(",
"'CarouselPage.db_Images'",
")",
")",
";",
"$",
"field",
"->",
"setFolderName",
"(",
"$",
"this",
"->",
"getClassFolder",
"(",
")",
")",
";",
"$",
"field",
"->",
"setFileEditFields",
"(",
"'getCarouselEditFields'",
")",
";",
"$",
"root",
"=",
"$",
"fields",
"->",
"fieldByName",
"(",
"'Root'",
")",
";",
"$",
"tab",
"=",
"$",
"root",
"->",
"fieldByName",
"(",
"'Images'",
")",
";",
"if",
"(",
"!",
"$",
"tab",
")",
"{",
"$",
"tab",
"=",
"Tab",
"::",
"create",
"(",
"'Images'",
")",
";",
"$",
"tab",
"->",
"setTitle",
"(",
"_t",
"(",
"'CarouselPage.db_Images'",
")",
")",
";",
"$",
"root",
"->",
"insertAfter",
"(",
"$",
"tab",
",",
"'Main'",
")",
";",
"}",
"$",
"tab",
"->",
"push",
"(",
"$",
"field",
")",
";",
"return",
"$",
"fields",
";",
"}"
] |
Add the "Images" tab to the content form of the page.
The images are linked to the page with a many-many relationship,
so if an image is shared among different carousels there is no
need to upload it multiple times.
@return FieldList
|
[
"Add",
"the",
"Images",
"tab",
"to",
"the",
"content",
"form",
"of",
"the",
"page",
"."
] |
1475f48f404b702b58480eacb2fea01011b30e55
|
https://github.com/ntd/silverstripe-carousel/blob/1475f48f404b702b58480eacb2fea01011b30e55/code/CarouselPage.php#L184-L202
|
20,564 |
ntd/silverstripe-carousel
|
code/CarouselPage.php
|
CarouselPage.getSettingsFields
|
public function getSettingsFields()
{
$fields = parent::getSettingsFields();
$settings = FieldGroup::create(
FieldGroup::create(
NumericField::create('Width', _t('CarouselPage.db_Width')),
NumericField::create('Height', _t('CarouselPage.db_Height')),
CheckboxField::create('Captions', _t('CarouselPage.db_Captions'))
)
);
$settings->setName('Carousel');
$settings->setTitle(_t('CarouselPage.SINGULARNAME'));
$fields->addFieldToTab('Root.Settings', $settings);
return $fields;
}
|
php
|
public function getSettingsFields()
{
$fields = parent::getSettingsFields();
$settings = FieldGroup::create(
FieldGroup::create(
NumericField::create('Width', _t('CarouselPage.db_Width')),
NumericField::create('Height', _t('CarouselPage.db_Height')),
CheckboxField::create('Captions', _t('CarouselPage.db_Captions'))
)
);
$settings->setName('Carousel');
$settings->setTitle(_t('CarouselPage.SINGULARNAME'));
$fields->addFieldToTab('Root.Settings', $settings);
return $fields;
}
|
[
"public",
"function",
"getSettingsFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getSettingsFields",
"(",
")",
";",
"$",
"settings",
"=",
"FieldGroup",
"::",
"create",
"(",
"FieldGroup",
"::",
"create",
"(",
"NumericField",
"::",
"create",
"(",
"'Width'",
",",
"_t",
"(",
"'CarouselPage.db_Width'",
")",
")",
",",
"NumericField",
"::",
"create",
"(",
"'Height'",
",",
"_t",
"(",
"'CarouselPage.db_Height'",
")",
")",
",",
"CheckboxField",
"::",
"create",
"(",
"'Captions'",
",",
"_t",
"(",
"'CarouselPage.db_Captions'",
")",
")",
")",
")",
";",
"$",
"settings",
"->",
"setName",
"(",
"'Carousel'",
")",
";",
"$",
"settings",
"->",
"setTitle",
"(",
"_t",
"(",
"'CarouselPage.SINGULARNAME'",
")",
")",
";",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.Settings'",
",",
"$",
"settings",
")",
";",
"return",
"$",
"fields",
";",
"}"
] |
Add carousel related fields to the page settings.
Every CarouselPage instance can have its own settings, that is
different pages can own carousels of different sizes.
@return FieldList
|
[
"Add",
"carousel",
"related",
"fields",
"to",
"the",
"page",
"settings",
"."
] |
1475f48f404b702b58480eacb2fea01011b30e55
|
https://github.com/ntd/silverstripe-carousel/blob/1475f48f404b702b58480eacb2fea01011b30e55/code/CarouselPage.php#L212-L228
|
20,565 |
unclecheese/silverstripe-blubber
|
code/CSSBlubberFile.php
|
CSSBlubberFile.parse
|
public function parse() {
$css = new Parser(file_get_contents($this->path));
$this->leanCSS = $css->parse();
$this->blubberCSS = clone $this->leanCSS;
}
|
php
|
public function parse() {
$css = new Parser(file_get_contents($this->path));
$this->leanCSS = $css->parse();
$this->blubberCSS = clone $this->leanCSS;
}
|
[
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"css",
"=",
"new",
"Parser",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
")",
";",
"$",
"this",
"->",
"leanCSS",
"=",
"$",
"css",
"->",
"parse",
"(",
")",
";",
"$",
"this",
"->",
"blubberCSS",
"=",
"clone",
"$",
"this",
"->",
"leanCSS",
";",
"}"
] |
Begins parsing the CSS file
|
[
"Begins",
"parsing",
"the",
"CSS",
"file"
] |
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
|
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberFile.php#L44-L49
|
20,566 |
unclecheese/silverstripe-blubber
|
code/CSSBlubberFile.php
|
CSSBlubberFile.saveBlubber
|
public function saveBlubber() {
$fh = fopen($this->getDirname().'/'.$this->getBlubberName(),'w');
fwrite($fh, $this->blubberCSS->render());
}
|
php
|
public function saveBlubber() {
$fh = fopen($this->getDirname().'/'.$this->getBlubberName(),'w');
fwrite($fh, $this->blubberCSS->render());
}
|
[
"public",
"function",
"saveBlubber",
"(",
")",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"this",
"->",
"getDirname",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getBlubberName",
"(",
")",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"this",
"->",
"blubberCSS",
"->",
"render",
"(",
")",
")",
";",
"}"
] |
Saves the "blubber" CSS to the filesystem
|
[
"Saves",
"the",
"blubber",
"CSS",
"to",
"the",
"filesystem"
] |
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
|
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberFile.php#L102-L105
|
20,567 |
unclecheese/silverstripe-blubber
|
code/CSSBlubberFile.php
|
CSSBlubberFile.saveLean
|
public function saveLean() {
$fh = fopen($this->getDirname().'/'.$this->getLeanName(),'w');
fwrite($fh, $this->leanCSS->render());
}
|
php
|
public function saveLean() {
$fh = fopen($this->getDirname().'/'.$this->getLeanName(),'w');
fwrite($fh, $this->leanCSS->render());
}
|
[
"public",
"function",
"saveLean",
"(",
")",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"this",
"->",
"getDirname",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getLeanName",
"(",
")",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"this",
"->",
"leanCSS",
"->",
"render",
"(",
")",
")",
";",
"}"
] |
Saves the "lean" CSS to the filesystem
|
[
"Saves",
"the",
"lean",
"CSS",
"to",
"the",
"filesystem"
] |
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
|
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberFile.php#L110-L113
|
20,568 |
dlehren/omnipay-cardknox
|
src/Message/AbstractRequest.php
|
AbstractRequest.getBaseData
|
protected function getBaseData()
{
$data = array();
$data['xKey'] = $this->getCardknoxKey();
$data['xVersion'] = '4.5.4';
$data['xSoftwareName'] = 'omnipay';
$data['xSoftwareVersion'] = '1';
$data['xCommand'] = $this->action;
return $data;
}
|
php
|
protected function getBaseData()
{
$data = array();
$data['xKey'] = $this->getCardknoxKey();
$data['xVersion'] = '4.5.4';
$data['xSoftwareName'] = 'omnipay';
$data['xSoftwareVersion'] = '1';
$data['xCommand'] = $this->action;
return $data;
}
|
[
"protected",
"function",
"getBaseData",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'xKey'",
"]",
"=",
"$",
"this",
"->",
"getCardknoxKey",
"(",
")",
";",
"$",
"data",
"[",
"'xVersion'",
"]",
"=",
"'4.5.4'",
";",
"$",
"data",
"[",
"'xSoftwareName'",
"]",
"=",
"'omnipay'",
";",
"$",
"data",
"[",
"'xSoftwareVersion'",
"]",
"=",
"'1'",
";",
"$",
"data",
"[",
"'xCommand'",
"]",
"=",
"$",
"this",
"->",
"action",
";",
"return",
"$",
"data",
";",
"}"
] |
Base data used only for the API.
|
[
"Base",
"data",
"used",
"only",
"for",
"the",
"API",
"."
] |
69af1f5bffafa6e27957a7114bd6c9c454854985
|
https://github.com/dlehren/omnipay-cardknox/blob/69af1f5bffafa6e27957a7114bd6c9c454854985/src/Message/AbstractRequest.php#L81-L91
|
20,569 |
canax/database-query-builder
|
src/DatabaseQueryBuilder/QueryBuilderTrait.php
|
QueryBuilderTrait.build
|
protected function build()
{
$sql = $this->start . "\n"
. ($this->from ? $this->from . "\n" : null)
. ($this->join ? $this->join : null)
. ($this->set ? $this->set . "\n" : null)
. ($this->where ? $this->where . "\n" : null)
. ($this->groupby ? $this->groupby . "\n" : null)
. ($this->orderby ? $this->orderby . "\n" : null)
. ($this->limit ? $this->limit . "\n" : null)
. ($this->offset ? $this->offset . "\n" : null)
. ";";
return $sql;
}
|
php
|
protected function build()
{
$sql = $this->start . "\n"
. ($this->from ? $this->from . "\n" : null)
. ($this->join ? $this->join : null)
. ($this->set ? $this->set . "\n" : null)
. ($this->where ? $this->where . "\n" : null)
. ($this->groupby ? $this->groupby . "\n" : null)
. ($this->orderby ? $this->orderby . "\n" : null)
. ($this->limit ? $this->limit . "\n" : null)
. ($this->offset ? $this->offset . "\n" : null)
. ";";
return $sql;
}
|
[
"protected",
"function",
"build",
"(",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"start",
".",
"\"\\n\"",
".",
"(",
"$",
"this",
"->",
"from",
"?",
"$",
"this",
"->",
"from",
".",
"\"\\n\"",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"join",
"?",
"$",
"this",
"->",
"join",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"set",
"?",
"$",
"this",
"->",
"set",
".",
"\"\\n\"",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"where",
"?",
"$",
"this",
"->",
"where",
".",
"\"\\n\"",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"groupby",
"?",
"$",
"this",
"->",
"groupby",
".",
"\"\\n\"",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"orderby",
"?",
"$",
"this",
"->",
"orderby",
".",
"\"\\n\"",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"limit",
"?",
"$",
"this",
"->",
"limit",
".",
"\"\\n\"",
":",
"null",
")",
".",
"(",
"$",
"this",
"->",
"offset",
"?",
"$",
"this",
"->",
"offset",
".",
"\"\\n\"",
":",
"null",
")",
".",
"\";\"",
";",
"return",
"$",
"sql",
";",
"}"
] |
Build the SQL query from its parts.
@return string as SQL query
|
[
"Build",
"the",
"SQL",
"query",
"from",
"its",
"parts",
"."
] |
c26a8a1537a8d8c2dcee305167980a57384b4e77
|
https://github.com/canax/database-query-builder/blob/c26a8a1537a8d8c2dcee305167980a57384b4e77/src/DatabaseQueryBuilder/QueryBuilderTrait.php#L64-L78
|
20,570 |
canax/database-query-builder
|
src/DatabaseQueryBuilder/QueryBuilderTrait.php
|
QueryBuilderTrait.rightJoin
|
public function rightJoin($table, $condition)
{
if ($this->dialect == 'sqlite') {
throw new BuildException("SQLite does not support RIGHT JOIN");
}
return $this->createJoin($table, $condition, 'RIGHT OUTER');
}
|
php
|
public function rightJoin($table, $condition)
{
if ($this->dialect == 'sqlite') {
throw new BuildException("SQLite does not support RIGHT JOIN");
}
return $this->createJoin($table, $condition, 'RIGHT OUTER');
}
|
[
"public",
"function",
"rightJoin",
"(",
"$",
"table",
",",
"$",
"condition",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dialect",
"==",
"'sqlite'",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"SQLite does not support RIGHT JOIN\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createJoin",
"(",
"$",
"table",
",",
"$",
"condition",
",",
"'RIGHT OUTER'",
")",
";",
"}"
] |
Build the right join part.
@param string $table name of table.
@param string $condition to join.
@throws \Anax\Database\BuildException when dialect does not support.
@return $this
|
[
"Build",
"the",
"right",
"join",
"part",
"."
] |
c26a8a1537a8d8c2dcee305167980a57384b4e77
|
https://github.com/canax/database-query-builder/blob/c26a8a1537a8d8c2dcee305167980a57384b4e77/src/DatabaseQueryBuilder/QueryBuilderTrait.php#L390-L397
|
20,571 |
alevilar/ristorantino-vendor
|
Stats/Model/CustomQuery.php
|
CustomQuery.paginateCount
|
function paginateCount($conditions, $recursive){
$sql = $this->sql;
return count($this->query($sql));
}
|
php
|
function paginateCount($conditions, $recursive){
$sql = $this->sql;
return count($this->query($sql));
}
|
[
"function",
"paginateCount",
"(",
"$",
"conditions",
",",
"$",
"recursive",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"sql",
";",
"return",
"count",
"(",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
")",
")",
";",
"}"
] |
Esta funcion sobreescribe a la del paginador. Como son
consultas guardadas en la tabla query, tengo que calcular
la cantidad de registros para que pagine bien.
@param $conditions, $recursive
@return cantidad de registro.
|
[
"Esta",
"funcion",
"sobreescribe",
"a",
"la",
"del",
"paginador",
".",
"Como",
"son",
"consultas",
"guardadas",
"en",
"la",
"tabla",
"query",
"tengo",
"que",
"calcular",
"la",
"cantidad",
"de",
"registros",
"para",
"que",
"pagine",
"bien",
"."
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Stats/Model/CustomQuery.php#L25-L29
|
20,572 |
alevilar/ristorantino-vendor
|
Stats/Model/CustomQuery.php
|
CustomQuery.paginate
|
function paginate($conditions, $fields, $order, $limit, $page, $recursive){
$sql = $this->sql;
$sql .= " LIMIT " . $this->limit . " ";
$sql .= " OFFSET " . (($page - 1) * $this->limit);
return $this->query($sql);
}
|
php
|
function paginate($conditions, $fields, $order, $limit, $page, $recursive){
$sql = $this->sql;
$sql .= " LIMIT " . $this->limit . " ";
$sql .= " OFFSET " . (($page - 1) * $this->limit);
return $this->query($sql);
}
|
[
"function",
"paginate",
"(",
"$",
"conditions",
",",
"$",
"fields",
",",
"$",
"order",
",",
"$",
"limit",
",",
"$",
"page",
",",
"$",
"recursive",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"sql",
";",
"$",
"sql",
".=",
"\" LIMIT \"",
".",
"$",
"this",
"->",
"limit",
".",
"\" \"",
";",
"$",
"sql",
".=",
"\" OFFSET \"",
".",
"(",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"}"
] |
Esta funcion sobreescribe a la del paginador. Como son
consultas guardadas en la tabla query, tengo que
reescribir el limit y el offset para poder mostrar por pantalla
@param $conditions, $recursive
@return registros paginados.
|
[
"Esta",
"funcion",
"sobreescribe",
"a",
"la",
"del",
"paginador",
".",
"Como",
"son",
"consultas",
"guardadas",
"en",
"la",
"tabla",
"query",
"tengo",
"que",
"reescribir",
"el",
"limit",
"y",
"el",
"offset",
"para",
"poder",
"mostrar",
"por",
"pantalla"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Stats/Model/CustomQuery.php#L39-L46
|
20,573 |
jnaxo/country-codes
|
src/Store/ApiManager.php
|
ApiManager.respondWithItem
|
protected function respondWithItem(
$item,
$resource_name = '',
array $links = [],
array $included = []
) {
$resource = new Item($item, $resource_name, $links, $included);
return $this->respondWithArray($resource->toArray());
}
|
php
|
protected function respondWithItem(
$item,
$resource_name = '',
array $links = [],
array $included = []
) {
$resource = new Item($item, $resource_name, $links, $included);
return $this->respondWithArray($resource->toArray());
}
|
[
"protected",
"function",
"respondWithItem",
"(",
"$",
"item",
",",
"$",
"resource_name",
"=",
"''",
",",
"array",
"$",
"links",
"=",
"[",
"]",
",",
"array",
"$",
"included",
"=",
"[",
"]",
")",
"{",
"$",
"resource",
"=",
"new",
"Item",
"(",
"$",
"item",
",",
"$",
"resource_name",
",",
"$",
"links",
",",
"$",
"included",
")",
";",
"return",
"$",
"this",
"->",
"respondWithArray",
"(",
"$",
"resource",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] |
Response with item
@param Object $item
@param $resource_name
@param array $links
@param array $included
@return Json Object
|
[
"Response",
"with",
"item"
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/ApiManager.php#L20-L28
|
20,574 |
mainio/c5pkg_symfony_forms
|
src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/PageToIntegerTransformer.php
|
PageToIntegerTransformer.transform
|
public function transform($value)
{
if ($value === null || $value == '') {
return null;
}
if (!($value instanceof Page)) {
throw new TransformationFailedException('Expected an instance of a concrete5 page object.');
}
return intval($value->getCollectionID());
}
|
php
|
public function transform($value)
{
if ($value === null || $value == '') {
return null;
}
if (!($value instanceof Page)) {
throw new TransformationFailedException('Expected an instance of a concrete5 page object.');
}
return intval($value->getCollectionID());
}
|
[
"public",
"function",
"transform",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"==",
"''",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"value",
"instanceof",
"Page",
")",
")",
"{",
"throw",
"new",
"TransformationFailedException",
"(",
"'Expected an instance of a concrete5 page object.'",
")",
";",
"}",
"return",
"intval",
"(",
"$",
"value",
"->",
"getCollectionID",
"(",
")",
")",
";",
"}"
] |
Converts a concrete5 page object to an integer.
@param \Concrete\Core\Page\Page $value The page object value
@return int The integer value
@throws TransformationFailedException If the given value is not an
instance of Concrete\Core\Page\Page.
|
[
"Converts",
"a",
"concrete5",
"page",
"object",
"to",
"an",
"integer",
"."
] |
41a93c293d986574ec5cade8a7c8700e083dbaaa
|
https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/PageToIntegerTransformer.php#L33-L42
|
20,575 |
Opifer/EavBundle
|
DependencyInjection/OpiferEavExtension.php
|
OpiferEavExtension.getParameters
|
public function getParameters(array $config)
{
$params = [
'opifer_eav.attribute_class' => $config['attribute_class'],
'opifer_eav.media_class' => $config['media_class'],
'opifer_eav.nestable_class' => $config['nestable_class'],
'opifer_eav.option_class' => $config['option_class'],
'opifer_eav.schema_class' => $config['schema_class'],
'opifer_eav.valueset_class' => $config['valueset_class'],
];
foreach ($config['entities'] as $label => $entity) {
$params['opifer_eav.entities'][$label] = $entity;
}
return $params;
}
|
php
|
public function getParameters(array $config)
{
$params = [
'opifer_eav.attribute_class' => $config['attribute_class'],
'opifer_eav.media_class' => $config['media_class'],
'opifer_eav.nestable_class' => $config['nestable_class'],
'opifer_eav.option_class' => $config['option_class'],
'opifer_eav.schema_class' => $config['schema_class'],
'opifer_eav.valueset_class' => $config['valueset_class'],
];
foreach ($config['entities'] as $label => $entity) {
$params['opifer_eav.entities'][$label] = $entity;
}
return $params;
}
|
[
"public",
"function",
"getParameters",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"params",
"=",
"[",
"'opifer_eav.attribute_class'",
"=>",
"$",
"config",
"[",
"'attribute_class'",
"]",
",",
"'opifer_eav.media_class'",
"=>",
"$",
"config",
"[",
"'media_class'",
"]",
",",
"'opifer_eav.nestable_class'",
"=>",
"$",
"config",
"[",
"'nestable_class'",
"]",
",",
"'opifer_eav.option_class'",
"=>",
"$",
"config",
"[",
"'option_class'",
"]",
",",
"'opifer_eav.schema_class'",
"=>",
"$",
"config",
"[",
"'schema_class'",
"]",
",",
"'opifer_eav.valueset_class'",
"=>",
"$",
"config",
"[",
"'valueset_class'",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"config",
"[",
"'entities'",
"]",
"as",
"$",
"label",
"=>",
"$",
"entity",
")",
"{",
"$",
"params",
"[",
"'opifer_eav.entities'",
"]",
"[",
"$",
"label",
"]",
"=",
"$",
"entity",
";",
"}",
"return",
"$",
"params",
";",
"}"
] |
Simplifying parameter syntax
@param array $config
@return array
|
[
"Simplifying",
"parameter",
"syntax"
] |
4236fdc28b7574dac43f420704d0fc3c04905a4c
|
https://github.com/Opifer/EavBundle/blob/4236fdc28b7574dac43f420704d0fc3c04905a4c/DependencyInjection/OpiferEavExtension.php#L35-L51
|
20,576 |
Opifer/EavBundle
|
DependencyInjection/OpiferEavExtension.php
|
OpiferEavExtension.prepend
|
public function prepend(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$parameters = $this->getParameters($config);
foreach ($parameters as $key => $value) {
$container->setParameter($key, $value);
}
$resolvableEntities = [
'Opifer\EavBundle\Model\AttributeInterface' => $config['attribute_class'],
'Opifer\EavBundle\Model\OptionInterface' => $config['option_class'],
'Opifer\EavBundle\Model\SchemaInterface' => $config['schema_class'],
'Opifer\EavBundle\Model\ValueSetInterface' => $config['valueset_class'],
];
if ($config['nestable_class'] != '') {
$resolvableEntities['Opifer\EavBundle\Model\Nestable'] = $config['nestable_class'];
}
if ($config['media_class'] != '') {
$resolvableEntities['Opifer\EavBundle\Model\MediaInterface'] = $config['media_class'];
}
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'doctrine':
$container->prependExtensionConfig($name, [
'orm' => [
'resolve_target_entities' => $resolvableEntities,
],
]);
break;
}
}
}
|
php
|
public function prepend(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$parameters = $this->getParameters($config);
foreach ($parameters as $key => $value) {
$container->setParameter($key, $value);
}
$resolvableEntities = [
'Opifer\EavBundle\Model\AttributeInterface' => $config['attribute_class'],
'Opifer\EavBundle\Model\OptionInterface' => $config['option_class'],
'Opifer\EavBundle\Model\SchemaInterface' => $config['schema_class'],
'Opifer\EavBundle\Model\ValueSetInterface' => $config['valueset_class'],
];
if ($config['nestable_class'] != '') {
$resolvableEntities['Opifer\EavBundle\Model\Nestable'] = $config['nestable_class'];
}
if ($config['media_class'] != '') {
$resolvableEntities['Opifer\EavBundle\Model\MediaInterface'] = $config['media_class'];
}
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'doctrine':
$container->prependExtensionConfig($name, [
'orm' => [
'resolve_target_entities' => $resolvableEntities,
],
]);
break;
}
}
}
|
[
"public",
"function",
"prepend",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configs",
"=",
"$",
"container",
"->",
"getExtensionConfig",
"(",
"$",
"this",
"->",
"getAlias",
"(",
")",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"new",
"Configuration",
"(",
")",
",",
"$",
"configs",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getParameters",
"(",
"$",
"config",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"container",
"->",
"setParameter",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"resolvableEntities",
"=",
"[",
"'Opifer\\EavBundle\\Model\\AttributeInterface'",
"=>",
"$",
"config",
"[",
"'attribute_class'",
"]",
",",
"'Opifer\\EavBundle\\Model\\OptionInterface'",
"=>",
"$",
"config",
"[",
"'option_class'",
"]",
",",
"'Opifer\\EavBundle\\Model\\SchemaInterface'",
"=>",
"$",
"config",
"[",
"'schema_class'",
"]",
",",
"'Opifer\\EavBundle\\Model\\ValueSetInterface'",
"=>",
"$",
"config",
"[",
"'valueset_class'",
"]",
",",
"]",
";",
"if",
"(",
"$",
"config",
"[",
"'nestable_class'",
"]",
"!=",
"''",
")",
"{",
"$",
"resolvableEntities",
"[",
"'Opifer\\EavBundle\\Model\\Nestable'",
"]",
"=",
"$",
"config",
"[",
"'nestable_class'",
"]",
";",
"}",
"if",
"(",
"$",
"config",
"[",
"'media_class'",
"]",
"!=",
"''",
")",
"{",
"$",
"resolvableEntities",
"[",
"'Opifer\\EavBundle\\Model\\MediaInterface'",
"]",
"=",
"$",
"config",
"[",
"'media_class'",
"]",
";",
"}",
"foreach",
"(",
"$",
"container",
"->",
"getExtensions",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"extension",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'doctrine'",
":",
"$",
"container",
"->",
"prependExtensionConfig",
"(",
"$",
"name",
",",
"[",
"'orm'",
"=>",
"[",
"'resolve_target_entities'",
"=>",
"$",
"resolvableEntities",
",",
"]",
",",
"]",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Prepend our config before other bundles, so we can preset
their config with our parameters
@param ContainerBuilder $container
@return void
|
[
"Prepend",
"our",
"config",
"before",
"other",
"bundles",
"so",
"we",
"can",
"preset",
"their",
"config",
"with",
"our",
"parameters"
] |
4236fdc28b7574dac43f420704d0fc3c04905a4c
|
https://github.com/Opifer/EavBundle/blob/4236fdc28b7574dac43f420704d0fc3c04905a4c/DependencyInjection/OpiferEavExtension.php#L61-L97
|
20,577 |
MASNathan/Parser
|
src/Type/Json.php
|
Json.encode
|
public static function encode($data, $prettyPrint = false)
{
if ($prettyPrint) {
// Check if the PHP version is >= 5.4 and has the JSON_PRETTY_PRINT constant
if (version_compare(PHP_VERSION, '5.4.0', '>=') && defined('JSON_PRETTY_PRINT')) {
return json_encode($data, JSON_PRETTY_PRINT);
} else {
$jsonPretty = new JsonPretty();
return $jsonPretty->prettify($data, null, ' ');
}
}
return json_encode($data);
}
|
php
|
public static function encode($data, $prettyPrint = false)
{
if ($prettyPrint) {
// Check if the PHP version is >= 5.4 and has the JSON_PRETTY_PRINT constant
if (version_compare(PHP_VERSION, '5.4.0', '>=') && defined('JSON_PRETTY_PRINT')) {
return json_encode($data, JSON_PRETTY_PRINT);
} else {
$jsonPretty = new JsonPretty();
return $jsonPretty->prettify($data, null, ' ');
}
}
return json_encode($data);
}
|
[
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"prettyPrint",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prettyPrint",
")",
"{",
"// Check if the PHP version is >= 5.4 and has the JSON_PRETTY_PRINT constant",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.4.0'",
",",
"'>='",
")",
"&&",
"defined",
"(",
"'JSON_PRETTY_PRINT'",
")",
")",
"{",
"return",
"json_encode",
"(",
"$",
"data",
",",
"JSON_PRETTY_PRINT",
")",
";",
"}",
"else",
"{",
"$",
"jsonPretty",
"=",
"new",
"JsonPretty",
"(",
")",
";",
"return",
"$",
"jsonPretty",
"->",
"prettify",
"(",
"$",
"data",
",",
"null",
",",
"' '",
")",
";",
"}",
"}",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"}"
] |
Encodes an array to json strutcture
@param array $data Data to encode
@param boolean $prettyPrint True to output the encoded data a little bit more readable for the humans
@return string
|
[
"Encodes",
"an",
"array",
"to",
"json",
"strutcture"
] |
0f55402b99b1e071bdcd6277b9268f783ca25e34
|
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Json.php#L15-L28
|
20,578 |
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/ServiceProvider.php
|
ServiceProvider.provideTemplatingSystem
|
protected function provideTemplatingSystem(Application $app)
{
$templateDir = __DIR__ . '/../../../data/templates';
// when installed using composer the templates are in a different folder
$composerTemplatePath = __DIR__ . '/../../../../templates';
if (file_exists($composerTemplatePath)) {
$templateDir = $composerTemplatePath;
}
// parameters
$app['transformer.template.location'] = $templateDir;
// services
$app['transformer.template.path_resolver'] = $app->share(
function ($container) {
return new PathResolver($container['transformer.template.location']);
}
);
$app['transformer.template.factory'] = $app->share(
function ($container) {
return new Factory(
$container['transformer.template.path_resolver'],
$container['serializer']
);
}
);
$app['transformer.template.collection'] = $app->share(
function ($container) {
return new Template\Collection(
$container['transformer.template.factory'],
$container['transformer.writer.collection']
);
}
);
}
|
php
|
protected function provideTemplatingSystem(Application $app)
{
$templateDir = __DIR__ . '/../../../data/templates';
// when installed using composer the templates are in a different folder
$composerTemplatePath = __DIR__ . '/../../../../templates';
if (file_exists($composerTemplatePath)) {
$templateDir = $composerTemplatePath;
}
// parameters
$app['transformer.template.location'] = $templateDir;
// services
$app['transformer.template.path_resolver'] = $app->share(
function ($container) {
return new PathResolver($container['transformer.template.location']);
}
);
$app['transformer.template.factory'] = $app->share(
function ($container) {
return new Factory(
$container['transformer.template.path_resolver'],
$container['serializer']
);
}
);
$app['transformer.template.collection'] = $app->share(
function ($container) {
return new Template\Collection(
$container['transformer.template.factory'],
$container['transformer.writer.collection']
);
}
);
}
|
[
"protected",
"function",
"provideTemplatingSystem",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"templateDir",
"=",
"__DIR__",
".",
"'/../../../data/templates'",
";",
"// when installed using composer the templates are in a different folder",
"$",
"composerTemplatePath",
"=",
"__DIR__",
".",
"'/../../../../templates'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"composerTemplatePath",
")",
")",
"{",
"$",
"templateDir",
"=",
"$",
"composerTemplatePath",
";",
"}",
"// parameters",
"$",
"app",
"[",
"'transformer.template.location'",
"]",
"=",
"$",
"templateDir",
";",
"// services",
"$",
"app",
"[",
"'transformer.template.path_resolver'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"PathResolver",
"(",
"$",
"container",
"[",
"'transformer.template.location'",
"]",
")",
";",
"}",
")",
";",
"$",
"app",
"[",
"'transformer.template.factory'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"Factory",
"(",
"$",
"container",
"[",
"'transformer.template.path_resolver'",
"]",
",",
"$",
"container",
"[",
"'serializer'",
"]",
")",
";",
"}",
")",
";",
"$",
"app",
"[",
"'transformer.template.collection'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"Template",
"\\",
"Collection",
"(",
"$",
"container",
"[",
"'transformer.template.factory'",
"]",
",",
"$",
"container",
"[",
"'transformer.writer.collection'",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Initializes the templating system in the container.
@param Application $app
@return void
|
[
"Initializes",
"the",
"templating",
"system",
"in",
"the",
"container",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/ServiceProvider.php#L207-L244
|
20,579 |
j-d/draggy
|
src/Draggy/Autocode/Templates/Template.php
|
Template.getIndentationPrefix
|
public function getIndentationPrefix($times = 1)
{
if (!is_integer($times)) {
throw new \InvalidArgumentException('The times parameter has to be an integer');
}
$indentation = '';
for ($i = 0; $i < $times; $i++) {
$indentation .= $this->getTemplate()->getIndentation();
}
return $indentation;
}
|
php
|
public function getIndentationPrefix($times = 1)
{
if (!is_integer($times)) {
throw new \InvalidArgumentException('The times parameter has to be an integer');
}
$indentation = '';
for ($i = 0; $i < $times; $i++) {
$indentation .= $this->getTemplate()->getIndentation();
}
return $indentation;
}
|
[
"public",
"function",
"getIndentationPrefix",
"(",
"$",
"times",
"=",
"1",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"times",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The times parameter has to be an integer'",
")",
";",
"}",
"$",
"indentation",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"times",
";",
"$",
"i",
"++",
")",
"{",
"$",
"indentation",
".=",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"getIndentation",
"(",
")",
";",
"}",
"return",
"$",
"indentation",
";",
"}"
] |
Returns all the indentation that should be put before the current line
@param int $times
@return string
@throws \InvalidArgumentException
|
[
"Returns",
"all",
"the",
"indentation",
"that",
"should",
"be",
"put",
"before",
"the",
"current",
"line"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Template.php#L88-L101
|
20,580 |
j-d/draggy
|
src/Draggy/Autocode/Templates/Template.php
|
Template.convertLinesToCode
|
public function convertLinesToCode(array $lines) {
if (0 === count($lines)) {
return '';
}
if (0 !== strlen($this->getTemplate()->getIndentationPrefix())) {
foreach ($lines as $lineNumber => $line) {
if (null === $line) {
unset($lines[$lineNumber]);
} elseif ('' === trim($line)) {
$lines[$lineNumber] = '';
}
}
}
return implode($this->getTemplate()->getEol(), $lines) . $this->getTemplate()->getEol();
}
|
php
|
public function convertLinesToCode(array $lines) {
if (0 === count($lines)) {
return '';
}
if (0 !== strlen($this->getTemplate()->getIndentationPrefix())) {
foreach ($lines as $lineNumber => $line) {
if (null === $line) {
unset($lines[$lineNumber]);
} elseif ('' === trim($line)) {
$lines[$lineNumber] = '';
}
}
}
return implode($this->getTemplate()->getEol(), $lines) . $this->getTemplate()->getEol();
}
|
[
"public",
"function",
"convertLinesToCode",
"(",
"array",
"$",
"lines",
")",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"lines",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"0",
"!==",
"strlen",
"(",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"getIndentationPrefix",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"lineNumber",
"=>",
"$",
"line",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"line",
")",
"{",
"unset",
"(",
"$",
"lines",
"[",
"$",
"lineNumber",
"]",
")",
";",
"}",
"elseif",
"(",
"''",
"===",
"trim",
"(",
"$",
"line",
")",
")",
"{",
"$",
"lines",
"[",
"$",
"lineNumber",
"]",
"=",
"''",
";",
"}",
"}",
"}",
"return",
"implode",
"(",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"getEol",
"(",
")",
",",
"$",
"lines",
")",
".",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"getEol",
"(",
")",
";",
"}"
] |
Converts an array of lines into code, including the current indentation
@param array $lines
@return string
|
[
"Converts",
"an",
"array",
"of",
"lines",
"into",
"code",
"including",
"the",
"current",
"indentation"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Template.php#L110-L126
|
20,581 |
j-d/draggy
|
src/Draggy/Autocode/Templates/Template.php
|
Template.getBlurbLines
|
public function getBlurbLines()
{
$lines = [];
$lines[] = '';
$lines[] = '/************************************************************************************************';
$lines[] = ' ** THIS IS AN AUTOMATICALLY GENERATED BASE FILE AND SHOULD NOT BE MANUALLY EDITED **';
$lines[] = ' ** All user content should be placed within <user-additions' . ' part="(name)"></user-additions' . '> **';
$lines[] = ' ************************************************************************************************/';
$lines[] = '';
$lines[] = '/*';
$lines[] = ' * This file was automatically generated with \'Autocode\'';
$lines[] = ' * by Jose Diaz-Angulo <[email protected]>';
$lines[] = ' * ';
$lines[] = ' * For the full copyright and license information, please view the LICENSE';
$lines[] = ' * file that was distributed with the package\'s source code.';
$lines[] = ' */';
$lines[] = '';
return $lines;
}
|
php
|
public function getBlurbLines()
{
$lines = [];
$lines[] = '';
$lines[] = '/************************************************************************************************';
$lines[] = ' ** THIS IS AN AUTOMATICALLY GENERATED BASE FILE AND SHOULD NOT BE MANUALLY EDITED **';
$lines[] = ' ** All user content should be placed within <user-additions' . ' part="(name)"></user-additions' . '> **';
$lines[] = ' ************************************************************************************************/';
$lines[] = '';
$lines[] = '/*';
$lines[] = ' * This file was automatically generated with \'Autocode\'';
$lines[] = ' * by Jose Diaz-Angulo <[email protected]>';
$lines[] = ' * ';
$lines[] = ' * For the full copyright and license information, please view the LICENSE';
$lines[] = ' * file that was distributed with the package\'s source code.';
$lines[] = ' */';
$lines[] = '';
return $lines;
}
|
[
"public",
"function",
"getBlurbLines",
"(",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"[",
"]",
"=",
"''",
";",
"$",
"lines",
"[",
"]",
"=",
"'/************************************************************************************************'",
";",
"$",
"lines",
"[",
"]",
"=",
"' ** THIS IS AN AUTOMATICALLY GENERATED BASE FILE AND SHOULD NOT BE MANUALLY EDITED **'",
";",
"$",
"lines",
"[",
"]",
"=",
"' ** All user content should be placed within <user-additions'",
".",
"' part=\"(name)\"></user-additions'",
".",
"'> **'",
";",
"$",
"lines",
"[",
"]",
"=",
"' ************************************************************************************************/'",
";",
"$",
"lines",
"[",
"]",
"=",
"''",
";",
"$",
"lines",
"[",
"]",
"=",
"'/*'",
";",
"$",
"lines",
"[",
"]",
"=",
"' * This file was automatically generated with \\'Autocode\\''",
";",
"$",
"lines",
"[",
"]",
"=",
"' * by Jose Diaz-Angulo <[email protected]>'",
";",
"$",
"lines",
"[",
"]",
"=",
"' * '",
";",
"$",
"lines",
"[",
"]",
"=",
"' * For the full copyright and license information, please view the LICENSE'",
";",
"$",
"lines",
"[",
"]",
"=",
"' * file that was distributed with the package\\'s source code.'",
";",
"$",
"lines",
"[",
"]",
"=",
"' */'",
";",
"$",
"lines",
"[",
"]",
"=",
"''",
";",
"return",
"$",
"lines",
";",
"}"
] |
Get the default Blurb
@return string
|
[
"Get",
"the",
"default",
"Blurb"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Template.php#L133-L153
|
20,582 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.from_path
|
public function from_path(string $path, $type = 'page'): ?string
{
$parent = null;
if ( $root = $this->opt->from_code($type, self::$option_root_id) ){
$parts = explode('/', $path);
$parent = $root;
foreach ( $parts as $i => $p ){
$is_not_last = $i < (\count($parts) - 1);
if ( !empty($p) ){
$prev_parent = $parent;
// Adds a slash for each bit of the path except the last one
$parent = $this->opt->from_code($p.($is_not_last ? '/' : ''), $prev_parent);
// If not found looking for a subpermission
if ( !$parent && $is_not_last ){
$parent = $this->opt->from_code($p, $prev_parent);
}
}
}
}
return $parent ?: null;
}
|
php
|
public function from_path(string $path, $type = 'page'): ?string
{
$parent = null;
if ( $root = $this->opt->from_code($type, self::$option_root_id) ){
$parts = explode('/', $path);
$parent = $root;
foreach ( $parts as $i => $p ){
$is_not_last = $i < (\count($parts) - 1);
if ( !empty($p) ){
$prev_parent = $parent;
// Adds a slash for each bit of the path except the last one
$parent = $this->opt->from_code($p.($is_not_last ? '/' : ''), $prev_parent);
// If not found looking for a subpermission
if ( !$parent && $is_not_last ){
$parent = $this->opt->from_code($p, $prev_parent);
}
}
}
}
return $parent ?: null;
}
|
[
"public",
"function",
"from_path",
"(",
"string",
"$",
"path",
",",
"$",
"type",
"=",
"'page'",
")",
":",
"?",
"string",
"{",
"$",
"parent",
"=",
"null",
";",
"if",
"(",
"$",
"root",
"=",
"$",
"this",
"->",
"opt",
"->",
"from_code",
"(",
"$",
"type",
",",
"self",
"::",
"$",
"option_root_id",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"parent",
"=",
"$",
"root",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"i",
"=>",
"$",
"p",
")",
"{",
"$",
"is_not_last",
"=",
"$",
"i",
"<",
"(",
"\\",
"count",
"(",
"$",
"parts",
")",
"-",
"1",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"p",
")",
")",
"{",
"$",
"prev_parent",
"=",
"$",
"parent",
";",
"// Adds a slash for each bit of the path except the last one",
"$",
"parent",
"=",
"$",
"this",
"->",
"opt",
"->",
"from_code",
"(",
"$",
"p",
".",
"(",
"$",
"is_not_last",
"?",
"'/'",
":",
"''",
")",
",",
"$",
"prev_parent",
")",
";",
"// If not found looking for a subpermission",
"if",
"(",
"!",
"$",
"parent",
"&&",
"$",
"is_not_last",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"opt",
"->",
"from_code",
"(",
"$",
"p",
",",
"$",
"prev_parent",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"parent",
"?",
":",
"null",
";",
"}"
] |
Returns the option's ID corresponds to the given path.
@param string $path
@param string $type
@return null|string
|
[
"Returns",
"the",
"option",
"s",
"ID",
"corresponds",
"to",
"the",
"given",
"path",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L76-L96
|
20,583 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.get_all
|
public function get_all(string $id_option = null, string $type = 'page'): ?array
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->options($id_option ?: $this->get_current());
}
return null;
}
|
php
|
public function get_all(string $id_option = null, string $type = 'page'): ?array
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->options($id_option ?: $this->get_current());
}
return null;
}
|
[
"public",
"function",
"get_all",
"(",
"string",
"$",
"id_option",
"=",
"null",
",",
"string",
"$",
"type",
"=",
"'page'",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"id_option",
"=",
"$",
"this",
"->",
"_get_id_option",
"(",
"$",
"id_option",
",",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pref",
"->",
"options",
"(",
"$",
"id_option",
"?",
":",
"$",
"this",
"->",
"get_current",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the full list of permissions existing in the given option
@param null|string $id_option
@param string $type
@return null|array
|
[
"Returns",
"the",
"full",
"list",
"of",
"permissions",
"existing",
"in",
"the",
"given",
"option"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L153-L159
|
20,584 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.get_full
|
public function get_full($id_option = null, string $type = 'page'): ?array
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->full_options($id_option ?: $this->get_current());
}
return null;
}
|
php
|
public function get_full($id_option = null, string $type = 'page'): ?array
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->full_options($id_option ?: $this->get_current());
}
return null;
}
|
[
"public",
"function",
"get_full",
"(",
"$",
"id_option",
"=",
"null",
",",
"string",
"$",
"type",
"=",
"'page'",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"id_option",
"=",
"$",
"this",
"->",
"_get_id_option",
"(",
"$",
"id_option",
",",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pref",
"->",
"full_options",
"(",
"$",
"id_option",
"?",
":",
"$",
"this",
"->",
"get_current",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the full list of permissions existing in the given option with all the current user's preferences
@param null|string $id_option
@param string $type
@return array|bool|false
|
[
"Returns",
"the",
"full",
"list",
"of",
"permissions",
"existing",
"in",
"the",
"given",
"option",
"with",
"all",
"the",
"current",
"user",
"s",
"preferences"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L168-L174
|
20,585 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.is
|
public function is(string $path, string $type = 'page'): ?string
{
return $this->from_path($path, $type);
}
|
php
|
public function is(string $path, string $type = 'page'): ?string
{
return $this->from_path($path, $type);
}
|
[
"public",
"function",
"is",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"type",
"=",
"'page'",
")",
":",
"?",
"string",
"{",
"return",
"$",
"this",
"->",
"from_path",
"(",
"$",
"path",
",",
"$",
"type",
")",
";",
"}"
] |
Checks if an option corresponds to the given path.
@param string $path
@param string $type
@return null|string
|
[
"Checks",
"if",
"an",
"option",
"corresponds",
"to",
"the",
"given",
"path",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L236-L239
|
20,586 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.customize
|
public function customize(array $arr): array
{
$res = [];
if ( isset($arr[0]) ){
foreach ( $arr as $a ){
if ( isset($a['id']) && $this->has($a['id']) ){
$res[] = $a;
}
}
}
else if ( isset($arr['items']) ){
$res = $arr;
unset($res['items']);
foreach ( $arr['items'] as $a ){
if ( isset($a['id']) && $this->has($a['id']) ){
if ( !isset($res['items']) ){
$res['items'] = [];
}
$res['items'][] = $a;
}
}
}
return $res;
}
|
php
|
public function customize(array $arr): array
{
$res = [];
if ( isset($arr[0]) ){
foreach ( $arr as $a ){
if ( isset($a['id']) && $this->has($a['id']) ){
$res[] = $a;
}
}
}
else if ( isset($arr['items']) ){
$res = $arr;
unset($res['items']);
foreach ( $arr['items'] as $a ){
if ( isset($a['id']) && $this->has($a['id']) ){
if ( !isset($res['items']) ){
$res['items'] = [];
}
$res['items'][] = $a;
}
}
}
return $res;
}
|
[
"public",
"function",
"customize",
"(",
"array",
"$",
"arr",
")",
":",
"array",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"0",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"a",
"[",
"'id'",
"]",
")",
"&&",
"$",
"this",
"->",
"has",
"(",
"$",
"a",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"a",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"res",
"=",
"$",
"arr",
";",
"unset",
"(",
"$",
"res",
"[",
"'items'",
"]",
")",
";",
"foreach",
"(",
"$",
"arr",
"[",
"'items'",
"]",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"a",
"[",
"'id'",
"]",
")",
"&&",
"$",
"this",
"->",
"has",
"(",
"$",
"a",
"[",
"'id'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"res",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"res",
"[",
"'items'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"res",
"[",
"'items'",
"]",
"[",
"]",
"=",
"$",
"a",
";",
"}",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] |
Adapts a given array of options' to user's permissions
@param array $arr
@return array
|
[
"Adapts",
"a",
"given",
"array",
"of",
"options",
"to",
"user",
"s",
"permissions"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L247-L270
|
20,587 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.add
|
public function add(string $id_option, string $type = 'page'): ?int
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->set_by_option($id_option, []);
}
return null;
}
|
php
|
public function add(string $id_option, string $type = 'page'): ?int
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->set_by_option($id_option, []);
}
return null;
}
|
[
"public",
"function",
"add",
"(",
"string",
"$",
"id_option",
",",
"string",
"$",
"type",
"=",
"'page'",
")",
":",
"?",
"int",
"{",
"if",
"(",
"$",
"id_option",
"=",
"$",
"this",
"->",
"_get_id_option",
"(",
"$",
"id_option",
",",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pref",
"->",
"set_by_option",
"(",
"$",
"id_option",
",",
"[",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Grants a new permission to a user or a group
@param null|string $id_option
@param string $type
@return int
|
[
"Grants",
"a",
"new",
"permission",
"to",
"a",
"user",
"or",
"a",
"group"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L278-L284
|
20,588 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.remove
|
public function remove($id_option, string $type = 'page'): ?int
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->delete($id_option);
}
return null;
}
|
php
|
public function remove($id_option, string $type = 'page'): ?int
{
if ( $id_option = $this->_get_id_option($id_option, $type) ){
return $this->pref->delete($id_option);
}
return null;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"id_option",
",",
"string",
"$",
"type",
"=",
"'page'",
")",
":",
"?",
"int",
"{",
"if",
"(",
"$",
"id_option",
"=",
"$",
"this",
"->",
"_get_id_option",
"(",
"$",
"id_option",
",",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pref",
"->",
"delete",
"(",
"$",
"id_option",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Deletes a preference for a path or an ID.
@param null|string $id_option
@param string $type
@return null|int
|
[
"Deletes",
"a",
"preference",
"for",
"a",
"path",
"or",
"an",
"ID",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L293-L299
|
20,589 |
nabab/bbn
|
src/bbn/user/permissions.php
|
permissions.read_option
|
public function read_option(string $id_option = null): ?bool
{
if ( bbn\str::is_uid($id_option) ){
$root = self::get_option_id('options');
$id_to_check = $this->opt->from_code('opt'.$id_option, $root);
return $this->has($id_to_check, 'options');
}
return null;
}
|
php
|
public function read_option(string $id_option = null): ?bool
{
if ( bbn\str::is_uid($id_option) ){
$root = self::get_option_id('options');
$id_to_check = $this->opt->from_code('opt'.$id_option, $root);
return $this->has($id_to_check, 'options');
}
return null;
}
|
[
"public",
"function",
"read_option",
"(",
"string",
"$",
"id_option",
"=",
"null",
")",
":",
"?",
"bool",
"{",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_option",
")",
")",
"{",
"$",
"root",
"=",
"self",
"::",
"get_option_id",
"(",
"'options'",
")",
";",
"$",
"id_to_check",
"=",
"$",
"this",
"->",
"opt",
"->",
"from_code",
"(",
"'opt'",
".",
"$",
"id_option",
",",
"$",
"root",
")",
";",
"return",
"$",
"this",
"->",
"has",
"(",
"$",
"id_to_check",
",",
"'options'",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if the category represented by the given option ID is readable by the current user
@param string|null $id_option
@return bool|null
|
[
"Checks",
"if",
"the",
"category",
"represented",
"by",
"the",
"given",
"option",
"ID",
"is",
"readable",
"by",
"the",
"current",
"user"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/permissions.php#L307-L315
|
20,590 |
Erdiko/core
|
src/View.php
|
View.renderMustache
|
public function renderMustache($filename, $data) {
// This is for mustache compatibility
$data['getView'] = function($name, $data) {
return $this->getView($name, $data);
};
return parent::renderMustache($filename, $data);
}
|
php
|
public function renderMustache($filename, $data) {
// This is for mustache compatibility
$data['getView'] = function($name, $data) {
return $this->getView($name, $data);
};
return parent::renderMustache($filename, $data);
}
|
[
"public",
"function",
"renderMustache",
"(",
"$",
"filename",
",",
"$",
"data",
")",
"{",
"// This is for mustache compatibility",
"$",
"data",
"[",
"'getView'",
"]",
"=",
"function",
"(",
"$",
"name",
",",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"getView",
"(",
"$",
"name",
",",
"$",
"data",
")",
";",
"}",
";",
"return",
"parent",
"::",
"renderMustache",
"(",
"$",
"filename",
",",
"$",
"data",
")",
";",
"}"
] |
Attach getView function to the mustache view
|
[
"Attach",
"getView",
"function",
"to",
"the",
"mustache",
"view"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/View.php#L31-L37
|
20,591 |
PayBreak/foundation
|
src/Decision/Condition/AbstractCondition.php
|
AbstractCondition.availableTypes
|
public static function availableTypes()
{
return [
self::CONDITION_EQUAL,
self::CONDITION_NOT_EQUAL,
self::CONDITION_GREATER_THAN,
self::CONDITION_LESS_THAN,
self::CONDITION_GREATER_THAN_OR_EQUAL_TO,
self::CONDITION_LESS_THAN_OR_EQUAL_TO,
self::CONDITION_IF_EMPTY,
self::CONDITION_IF_NOT_EXISTS,
self::CONDITION_IS_DEFAULT,
];
}
|
php
|
public static function availableTypes()
{
return [
self::CONDITION_EQUAL,
self::CONDITION_NOT_EQUAL,
self::CONDITION_GREATER_THAN,
self::CONDITION_LESS_THAN,
self::CONDITION_GREATER_THAN_OR_EQUAL_TO,
self::CONDITION_LESS_THAN_OR_EQUAL_TO,
self::CONDITION_IF_EMPTY,
self::CONDITION_IF_NOT_EXISTS,
self::CONDITION_IS_DEFAULT,
];
}
|
[
"public",
"static",
"function",
"availableTypes",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"CONDITION_EQUAL",
",",
"self",
"::",
"CONDITION_NOT_EQUAL",
",",
"self",
"::",
"CONDITION_GREATER_THAN",
",",
"self",
"::",
"CONDITION_LESS_THAN",
",",
"self",
"::",
"CONDITION_GREATER_THAN_OR_EQUAL_TO",
",",
"self",
"::",
"CONDITION_LESS_THAN_OR_EQUAL_TO",
",",
"self",
"::",
"CONDITION_IF_EMPTY",
",",
"self",
"::",
"CONDITION_IF_NOT_EXISTS",
",",
"self",
"::",
"CONDITION_IS_DEFAULT",
",",
"]",
";",
"}"
] |
All Available ConditionInterface Types
@return array
|
[
"All",
"Available",
"ConditionInterface",
"Types"
] |
3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4
|
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Decision/Condition/AbstractCondition.php#L166-L179
|
20,592 |
eghojansu/moe
|
src/Silet.php
|
Silet.filter
|
function filter($key=NULL,$func=NULL) {
if (!$key)
return array_keys($this->filter);
if (!$func)
return $this->filter[$key];
$this->filter[$key]=$func;
}
|
php
|
function filter($key=NULL,$func=NULL) {
if (!$key)
return array_keys($this->filter);
if (!$func)
return $this->filter[$key];
$this->filter[$key]=$func;
}
|
[
"function",
"filter",
"(",
"$",
"key",
"=",
"NULL",
",",
"$",
"func",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"key",
")",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"filter",
")",
";",
"if",
"(",
"!",
"$",
"func",
")",
"return",
"$",
"this",
"->",
"filter",
"[",
"$",
"key",
"]",
";",
"$",
"this",
"->",
"filter",
"[",
"$",
"key",
"]",
"=",
"$",
"func",
";",
"}"
] |
register token filter
@param string $key
@param string $func
@return array
|
[
"register",
"token",
"filter"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Silet.php#L132-L138
|
20,593 |
tttptd/laravel-responder
|
src/Traits/MakesApiRequests.php
|
MakesApiRequests.seeSuccessData
|
protected function seeSuccessData($data = null)
{
collect($data)->each(function ($value, $key) {
if (is_array($value)) {
$this->seeSuccessData($value);
} else {
$this->seeJson([$key => $value]);
}
});
return $this;
}
|
php
|
protected function seeSuccessData($data = null)
{
collect($data)->each(function ($value, $key) {
if (is_array($value)) {
$this->seeSuccessData($value);
} else {
$this->seeJson([$key => $value]);
}
});
return $this;
}
|
[
"protected",
"function",
"seeSuccessData",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"collect",
"(",
"$",
"data",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"seeSuccessData",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"seeJson",
"(",
"[",
"$",
"key",
"=>",
"$",
"value",
"]",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assert that the response data contains given values.
@param mixed $data
@return $this
|
[
"Assert",
"that",
"the",
"response",
"data",
"contains",
"given",
"values",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/MakesApiRequests.php#L88-L99
|
20,594 |
tttptd/laravel-responder
|
src/Traits/MakesApiRequests.php
|
MakesApiRequests.getSuccessData
|
protected function getSuccessData($attributes = null)
{
$rawData = $this->decodeResponseJson()['data'];
if (is_null($attributes)) {
return $rawData;
} elseif (is_string($attributes)) {
return array_get($rawData, $attributes);
}
$data = [];
foreach ($attributes as $attribute) {
$data[] = array_get($rawData, $attribute);
}
return $data;
}
|
php
|
protected function getSuccessData($attributes = null)
{
$rawData = $this->decodeResponseJson()['data'];
if (is_null($attributes)) {
return $rawData;
} elseif (is_string($attributes)) {
return array_get($rawData, $attributes);
}
$data = [];
foreach ($attributes as $attribute) {
$data[] = array_get($rawData, $attribute);
}
return $data;
}
|
[
"protected",
"function",
"getSuccessData",
"(",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"rawData",
"=",
"$",
"this",
"->",
"decodeResponseJson",
"(",
")",
"[",
"'data'",
"]",
";",
"if",
"(",
"is_null",
"(",
"$",
"attributes",
")",
")",
"{",
"return",
"$",
"rawData",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"attributes",
")",
")",
"{",
"return",
"array_get",
"(",
"$",
"rawData",
",",
"$",
"attributes",
")",
";",
"}",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"array_get",
"(",
"$",
"rawData",
",",
"$",
"attribute",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Decodes JSON response and returns the data.
@param string|array|null $attributes
@return array
|
[
"Decodes",
"JSON",
"response",
"and",
"returns",
"the",
"data",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/MakesApiRequests.php#L107-L124
|
20,595 |
tttptd/laravel-responder
|
src/Traits/MakesApiRequests.php
|
MakesApiRequests.seeError
|
protected function seeError(string $error, int $status = null)
{
if (! is_null($status)) {
$this->seeStatusCode($status);
}
if ($this->app->config->get('responder.status_code')) {
$this->seeJson([
'status' => $status
]);
}
return $this->seeJson([
'success' => false
])->seeJsonSubset([
'error' => [
'code' => $error
]
]);
}
|
php
|
protected function seeError(string $error, int $status = null)
{
if (! is_null($status)) {
$this->seeStatusCode($status);
}
if ($this->app->config->get('responder.status_code')) {
$this->seeJson([
'status' => $status
]);
}
return $this->seeJson([
'success' => false
])->seeJsonSubset([
'error' => [
'code' => $error
]
]);
}
|
[
"protected",
"function",
"seeError",
"(",
"string",
"$",
"error",
",",
"int",
"$",
"status",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"status",
")",
")",
"{",
"$",
"this",
"->",
"seeStatusCode",
"(",
"$",
"status",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.status_code'",
")",
")",
"{",
"$",
"this",
"->",
"seeJson",
"(",
"[",
"'status'",
"=>",
"$",
"status",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"seeJson",
"(",
"[",
"'success'",
"=>",
"false",
"]",
")",
"->",
"seeJsonSubset",
"(",
"[",
"'error'",
"=>",
"[",
"'code'",
"=>",
"$",
"error",
"]",
"]",
")",
";",
"}"
] |
Assert that the response is a valid error response.
@param string $error
@param int|null $status
@return $this
|
[
"Assert",
"that",
"the",
"response",
"is",
"a",
"valid",
"error",
"response",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/MakesApiRequests.php#L133-L152
|
20,596 |
flowcode/AmulenUserBundle
|
src/Flowcode/UserBundle/Service/UserService.php
|
UserService.generateRandomPassword
|
public function generateRandomPassword()
{
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$pass = array();
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass);
}
|
php
|
public function generateRandomPassword()
{
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$pass = array();
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass);
}
|
[
"public",
"function",
"generateRandomPassword",
"(",
")",
"{",
"$",
"alphabet",
"=",
"\"abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789\"",
";",
"$",
"pass",
"=",
"array",
"(",
")",
";",
"$",
"alphaLength",
"=",
"strlen",
"(",
"$",
"alphabet",
")",
"-",
"1",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"8",
";",
"$",
"i",
"++",
")",
"{",
"$",
"n",
"=",
"rand",
"(",
"0",
",",
"$",
"alphaLength",
")",
";",
"$",
"pass",
"[",
"]",
"=",
"$",
"alphabet",
"[",
"$",
"n",
"]",
";",
"}",
"return",
"implode",
"(",
"$",
"pass",
")",
";",
"}"
] |
Geneate Radmon password.
|
[
"Geneate",
"Radmon",
"password",
"."
] |
00055834d9f094e63dcd8d66e2fedb822fcddee0
|
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L118-L128
|
20,597 |
flowcode/AmulenUserBundle
|
src/Flowcode/UserBundle/Service/UserService.php
|
UserService.isUnique
|
public function isUnique($username, $email, $dni = null, $code = null)
{
$entities = $this->getEm()->getRepository("AmulenUserBundle:User")->findByUniques($username, $email, $dni, $code);
return count($entities) <= 0;
}
|
php
|
public function isUnique($username, $email, $dni = null, $code = null)
{
$entities = $this->getEm()->getRepository("AmulenUserBundle:User")->findByUniques($username, $email, $dni, $code);
return count($entities) <= 0;
}
|
[
"public",
"function",
"isUnique",
"(",
"$",
"username",
",",
"$",
"email",
",",
"$",
"dni",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"getEm",
"(",
")",
"->",
"getRepository",
"(",
"\"AmulenUserBundle:User\"",
")",
"->",
"findByUniques",
"(",
"$",
"username",
",",
"$",
"email",
",",
"$",
"dni",
",",
"$",
"code",
")",
";",
"return",
"count",
"(",
"$",
"entities",
")",
"<=",
"0",
";",
"}"
] |
Check if is unique.
@param [type] $username [description]
@param [type] $email [description]
@param [type] $phone [description]
@param [type] $dni [description]
@param [type] $code [description]
@return boolean [description]
|
[
"Check",
"if",
"is",
"unique",
"."
] |
00055834d9f094e63dcd8d66e2fedb822fcddee0
|
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L152-L156
|
20,598 |
flowcode/AmulenUserBundle
|
src/Flowcode/UserBundle/Service/UserService.php
|
UserService.getAuthToken
|
public function getAuthToken($user, $plainPassword, $firewall, $roles = array())
{
// Here, "public" is the name of the firewall in your security.yml
$token = new UsernamePasswordToken($user, $user->getPlainPassword(), $firewall, $roles);
// For older versions of Symfony, use security.context here
$this->tokenStorage->setToken($token);
return $token;
}
|
php
|
public function getAuthToken($user, $plainPassword, $firewall, $roles = array())
{
// Here, "public" is the name of the firewall in your security.yml
$token = new UsernamePasswordToken($user, $user->getPlainPassword(), $firewall, $roles);
// For older versions of Symfony, use security.context here
$this->tokenStorage->setToken($token);
return $token;
}
|
[
"public",
"function",
"getAuthToken",
"(",
"$",
"user",
",",
"$",
"plainPassword",
",",
"$",
"firewall",
",",
"$",
"roles",
"=",
"array",
"(",
")",
")",
"{",
"// Here, \"public\" is the name of the firewall in your security.yml",
"$",
"token",
"=",
"new",
"UsernamePasswordToken",
"(",
"$",
"user",
",",
"$",
"user",
"->",
"getPlainPassword",
"(",
")",
",",
"$",
"firewall",
",",
"$",
"roles",
")",
";",
"// For older versions of Symfony, use security.context here",
"$",
"this",
"->",
"tokenStorage",
"->",
"setToken",
"(",
"$",
"token",
")",
";",
"return",
"$",
"token",
";",
"}"
] |
Get by Code.
@param [type] $user [user to auth]
@param [type] $user [user's plain password]
@param [type] $firewall [name in security.yml]
@param [type] $roles [user's roles]
@return [bool] token [description]
|
[
"Get",
"by",
"Code",
"."
] |
00055834d9f094e63dcd8d66e2fedb822fcddee0
|
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L177-L186
|
20,599 |
flowcode/AmulenUserBundle
|
src/Flowcode/UserBundle/Service/UserService.php
|
UserService.uploadImage
|
public function uploadImage(User $entity)
{
/* the file property can be empty if the field is not required */
if (null === $entity->getFile()) {
return $entity;
}
$uploadBaseDir = $this->container->getParameter("user_avatar_basedir");
$uploadDir = $this->container->getParameter("user_avatar_dir");
/* set the path property to the filename where you've saved the file */
$filename = $entity->getFile()->getClientOriginalName();
$extension = $entity->getFile()->getClientOriginalExtension();
$imageName = md5($filename . time()) . '.' . $extension;
$entity->setAvatar($uploadDir . $imageName);
$entity->getFile()->move($uploadBaseDir . $uploadDir, $imageName);
$entity->setFile(null);
return $entity;
}
|
php
|
public function uploadImage(User $entity)
{
/* the file property can be empty if the field is not required */
if (null === $entity->getFile()) {
return $entity;
}
$uploadBaseDir = $this->container->getParameter("user_avatar_basedir");
$uploadDir = $this->container->getParameter("user_avatar_dir");
/* set the path property to the filename where you've saved the file */
$filename = $entity->getFile()->getClientOriginalName();
$extension = $entity->getFile()->getClientOriginalExtension();
$imageName = md5($filename . time()) . '.' . $extension;
$entity->setAvatar($uploadDir . $imageName);
$entity->getFile()->move($uploadBaseDir . $uploadDir, $imageName);
$entity->setFile(null);
return $entity;
}
|
[
"public",
"function",
"uploadImage",
"(",
"User",
"$",
"entity",
")",
"{",
"/* the file property can be empty if the field is not required */",
"if",
"(",
"null",
"===",
"$",
"entity",
"->",
"getFile",
"(",
")",
")",
"{",
"return",
"$",
"entity",
";",
"}",
"$",
"uploadBaseDir",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"\"user_avatar_basedir\"",
")",
";",
"$",
"uploadDir",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"\"user_avatar_dir\"",
")",
";",
"/* set the path property to the filename where you've saved the file */",
"$",
"filename",
"=",
"$",
"entity",
"->",
"getFile",
"(",
")",
"->",
"getClientOriginalName",
"(",
")",
";",
"$",
"extension",
"=",
"$",
"entity",
"->",
"getFile",
"(",
")",
"->",
"getClientOriginalExtension",
"(",
")",
";",
"$",
"imageName",
"=",
"md5",
"(",
"$",
"filename",
".",
"time",
"(",
")",
")",
".",
"'.'",
".",
"$",
"extension",
";",
"$",
"entity",
"->",
"setAvatar",
"(",
"$",
"uploadDir",
".",
"$",
"imageName",
")",
";",
"$",
"entity",
"->",
"getFile",
"(",
")",
"->",
"move",
"(",
"$",
"uploadBaseDir",
".",
"$",
"uploadDir",
",",
"$",
"imageName",
")",
";",
"$",
"entity",
"->",
"setFile",
"(",
"null",
")",
";",
"return",
"$",
"entity",
";",
"}"
] |
Upload user image.
@param User $entity
@return User
|
[
"Upload",
"user",
"image",
"."
] |
00055834d9f094e63dcd8d66e2fedb822fcddee0
|
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L206-L229
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.