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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
237,700
|
phossa2/libs
|
src/Phossa2/Env/Traits/ParseEnvTrait.php
|
ParseEnvTrait.getReference
|
protected function getReference(/*# string */ $name)
{
// default value
$default = $this->defaultValue($name);
// found in environment
if (false !== getenv($name)) {
return getenv($name);
} elseif (null !== $default) {
return $default;
// PHP globals, _SERVER.HTTP_HOST etc.
} elseif ('_' === $name[0]) {
return $this->matchGlobalVars($name);
// not found
} else {
return null;
}
}
|
php
|
protected function getReference(/*# string */ $name)
{
// default value
$default = $this->defaultValue($name);
// found in environment
if (false !== getenv($name)) {
return getenv($name);
} elseif (null !== $default) {
return $default;
// PHP globals, _SERVER.HTTP_HOST etc.
} elseif ('_' === $name[0]) {
return $this->matchGlobalVars($name);
// not found
} else {
return null;
}
}
|
[
"protected",
"function",
"getReference",
"(",
"/*# string */",
"$",
"name",
")",
"{",
"// default value",
"$",
"default",
"=",
"$",
"this",
"->",
"defaultValue",
"(",
"$",
"name",
")",
";",
"// found in environment",
"if",
"(",
"false",
"!==",
"getenv",
"(",
"$",
"name",
")",
")",
"{",
"return",
"getenv",
"(",
"$",
"name",
")",
";",
"}",
"elseif",
"(",
"null",
"!==",
"$",
"default",
")",
"{",
"return",
"$",
"default",
";",
"// PHP globals, _SERVER.HTTP_HOST etc.",
"}",
"elseif",
"(",
"'_'",
"===",
"$",
"name",
"[",
"0",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"matchGlobalVars",
"(",
"$",
"name",
")",
";",
"// not found",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Find the env value base on the name
- support super globals like '${_SERVER.HTTP_HOST}' etc.
- use getenv()
{@inheritDoc}
|
[
"Find",
"the",
"env",
"value",
"base",
"on",
"the",
"name"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Env/Traits/ParseEnvTrait.php#L70-L89
|
237,701
|
phossa2/libs
|
src/Phossa2/Env/Traits/ParseEnvTrait.php
|
ParseEnvTrait.matchGlobalVars
|
protected function matchGlobalVars(/*# string */ $name)/*# : string */
{
if (false !== strpos($name, '.')) {
list($n, $k) = explode('.', $name, 2);
if (isset($GLOBALS[$n]) && isset($GLOBALS[$n][$k])) {
return $GLOBALS[$n][$k];
}
}
return '';
}
|
php
|
protected function matchGlobalVars(/*# string */ $name)/*# : string */
{
if (false !== strpos($name, '.')) {
list($n, $k) = explode('.', $name, 2);
if (isset($GLOBALS[$n]) && isset($GLOBALS[$n][$k])) {
return $GLOBALS[$n][$k];
}
}
return '';
}
|
[
"protected",
"function",
"matchGlobalVars",
"(",
"/*# string */",
"$",
"name",
")",
"/*# : string */",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"name",
",",
"'.'",
")",
")",
"{",
"list",
"(",
"$",
"n",
",",
"$",
"k",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
",",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"n",
"]",
")",
"&&",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"n",
"]",
"[",
"$",
"k",
"]",
")",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"$",
"n",
"]",
"[",
"$",
"k",
"]",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
Match with _SERVER.HTTP_HOST etc.
@param string $name
@return string
@access protected
|
[
"Match",
"with",
"_SERVER",
".",
"HTTP_HOST",
"etc",
"."
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Env/Traits/ParseEnvTrait.php#L127-L136
|
237,702
|
phossa2/libs
|
src/Phossa2/Env/Traits/ParseEnvTrait.php
|
ParseEnvTrait.setEnv
|
protected function setEnv(
/*# string */ $key,
/*# string */ $val,
/*# bool */ $overload
) {
if ($overload || false === getenv($key)) {
// set env
putenv("$key=$val");
// also populate $_ENV
$_ENV[$key] = $val;
}
}
|
php
|
protected function setEnv(
/*# string */ $key,
/*# string */ $val,
/*# bool */ $overload
) {
if ($overload || false === getenv($key)) {
// set env
putenv("$key=$val");
// also populate $_ENV
$_ENV[$key] = $val;
}
}
|
[
"protected",
"function",
"setEnv",
"(",
"/*# string */",
"$",
"key",
",",
"/*# string */",
"$",
"val",
",",
"/*# bool */",
"$",
"overload",
")",
"{",
"if",
"(",
"$",
"overload",
"||",
"false",
"===",
"getenv",
"(",
"$",
"key",
")",
")",
"{",
"// set env",
"putenv",
"(",
"\"$key=$val\"",
")",
";",
"// also populate $_ENV",
"$",
"_ENV",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"}"
] |
Set the env pair
@param string $key
@param string $val
@param bool $overload
@access protected
|
[
"Set",
"the",
"env",
"pair"
] |
921e485c8cc29067f279da2cdd06f47a9bddd115
|
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Env/Traits/ParseEnvTrait.php#L146-L158
|
237,703
|
vinala/kernel
|
src/Setup/Response.php
|
Response.setGlob_step
|
public static function setGlob_step()
{
$project = $_POST['project_name'];
$name = $_POST['dev_name'];
//
if (isset($_POST['ckeck_loggin'])) {
$loggin = true;
} else {
$loggin = false;
}
//
if (isset($_POST['ckeck_maintenance'])) {
$maintenance = 'true';
} else {
$maintenance = 'false';
}
//
if (isset($_POST['ckeck_search'])) {
$robot = true;
} else {
$robot = false;
}
//
if (!Application::$isTest) {
$appCont = App::set($name, $project, true);
$translatorCont = Translator::set('en');
$logginCont = Loggin::set($loggin);
Robots::set($robot);
//
file_put_contents(Application::$root.'config/app.php', $appCont, 0);
file_put_contents(Application::$root.'config/lang.php', $translatorCont, 0);
file_put_contents(Application::$root.'config/loggin.php', $logginCont, 0);
//
echo 'true';
}
}
|
php
|
public static function setGlob_step()
{
$project = $_POST['project_name'];
$name = $_POST['dev_name'];
//
if (isset($_POST['ckeck_loggin'])) {
$loggin = true;
} else {
$loggin = false;
}
//
if (isset($_POST['ckeck_maintenance'])) {
$maintenance = 'true';
} else {
$maintenance = 'false';
}
//
if (isset($_POST['ckeck_search'])) {
$robot = true;
} else {
$robot = false;
}
//
if (!Application::$isTest) {
$appCont = App::set($name, $project, true);
$translatorCont = Translator::set('en');
$logginCont = Loggin::set($loggin);
Robots::set($robot);
//
file_put_contents(Application::$root.'config/app.php', $appCont, 0);
file_put_contents(Application::$root.'config/lang.php', $translatorCont, 0);
file_put_contents(Application::$root.'config/loggin.php', $logginCont, 0);
//
echo 'true';
}
}
|
[
"public",
"static",
"function",
"setGlob_step",
"(",
")",
"{",
"$",
"project",
"=",
"$",
"_POST",
"[",
"'project_name'",
"]",
";",
"$",
"name",
"=",
"$",
"_POST",
"[",
"'dev_name'",
"]",
";",
"//",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'ckeck_loggin'",
"]",
")",
")",
"{",
"$",
"loggin",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"loggin",
"=",
"false",
";",
"}",
"//",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'ckeck_maintenance'",
"]",
")",
")",
"{",
"$",
"maintenance",
"=",
"'true'",
";",
"}",
"else",
"{",
"$",
"maintenance",
"=",
"'false'",
";",
"}",
"//",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'ckeck_search'",
"]",
")",
")",
"{",
"$",
"robot",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"robot",
"=",
"false",
";",
"}",
"//",
"if",
"(",
"!",
"Application",
"::",
"$",
"isTest",
")",
"{",
"$",
"appCont",
"=",
"App",
"::",
"set",
"(",
"$",
"name",
",",
"$",
"project",
",",
"true",
")",
";",
"$",
"translatorCont",
"=",
"Translator",
"::",
"set",
"(",
"'en'",
")",
";",
"$",
"logginCont",
"=",
"Loggin",
"::",
"set",
"(",
"$",
"loggin",
")",
";",
"Robots",
"::",
"set",
"(",
"$",
"robot",
")",
";",
"//",
"file_put_contents",
"(",
"Application",
"::",
"$",
"root",
".",
"'config/app.php'",
",",
"$",
"appCont",
",",
"0",
")",
";",
"file_put_contents",
"(",
"Application",
"::",
"$",
"root",
".",
"'config/lang.php'",
",",
"$",
"translatorCont",
",",
"0",
")",
";",
"file_put_contents",
"(",
"Application",
"::",
"$",
"root",
".",
"'config/loggin.php'",
",",
"$",
"logginCont",
",",
"0",
")",
";",
"//",
"echo",
"'true'",
";",
"}",
"}"
] |
set global setup.
|
[
"set",
"global",
"setup",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Setup/Response.php#L20-L55
|
237,704
|
wasabi-cms/cms
|
src/WasabiCms.php
|
WasabiCms.page
|
public static function page($page = null)
{
if ($page !== null) {
self::$_page = $page;
}
return self::$_page;
}
|
php
|
public static function page($page = null)
{
if ($page !== null) {
self::$_page = $page;
}
return self::$_page;
}
|
[
"public",
"static",
"function",
"page",
"(",
"$",
"page",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"page",
"!==",
"null",
")",
"{",
"self",
"::",
"$",
"_page",
"=",
"$",
"page",
";",
"}",
"return",
"self",
"::",
"$",
"_page",
";",
"}"
] |
Get or set the current page.
@param null|Page $page
@return null|Page
|
[
"Get",
"or",
"set",
"the",
"current",
"page",
"."
] |
2787b6422ea1d719cf49951b3253fd0ac31d22ca
|
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/WasabiCms.php#L47-L53
|
237,705
|
wasabi-cms/cms
|
src/WasabiCms.php
|
WasabiCms.startPage
|
public static function startPage($page = null)
{
if ($page !== null) {
self::$_startPage = $page;
}
return self::$_startPage;
}
|
php
|
public static function startPage($page = null)
{
if ($page !== null) {
self::$_startPage = $page;
}
return self::$_startPage;
}
|
[
"public",
"static",
"function",
"startPage",
"(",
"$",
"page",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"page",
"!==",
"null",
")",
"{",
"self",
"::",
"$",
"_startPage",
"=",
"$",
"page",
";",
"}",
"return",
"self",
"::",
"$",
"_startPage",
";",
"}"
] |
Get or set the start page.
@param null|Page $page
@return null|Page
|
[
"Get",
"or",
"set",
"the",
"start",
"page",
"."
] |
2787b6422ea1d719cf49951b3253fd0ac31d22ca
|
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/WasabiCms.php#L61-L67
|
237,706
|
laraning/flame
|
src/Renderers/Renderer.php
|
Renderer.getHint
|
protected function getHint()
{
// Map a new array with [group => namespace].
$groups = collect(config('flame'))->mapWithKeys(function ($item, $key) {
return [$key => $item['namespace']];
});
//Map a new array only with namespaces.
$namespaces = $groups->values();
//Get the namespace that longest matches the controller namespace.
$matchedNamespace = Str::longestMatch($namespaces->toArray(), $this->controllerNamespace());
// Cannot continue if no namespace was found for the View hint.
if (is_null($matchedNamespace)) {
throw FlameException::namespaceNotFound($this->controllerNamespace());
}
return $groups->flip()[$matchedNamespace];
}
|
php
|
protected function getHint()
{
// Map a new array with [group => namespace].
$groups = collect(config('flame'))->mapWithKeys(function ($item, $key) {
return [$key => $item['namespace']];
});
//Map a new array only with namespaces.
$namespaces = $groups->values();
//Get the namespace that longest matches the controller namespace.
$matchedNamespace = Str::longestMatch($namespaces->toArray(), $this->controllerNamespace());
// Cannot continue if no namespace was found for the View hint.
if (is_null($matchedNamespace)) {
throw FlameException::namespaceNotFound($this->controllerNamespace());
}
return $groups->flip()[$matchedNamespace];
}
|
[
"protected",
"function",
"getHint",
"(",
")",
"{",
"// Map a new array with [group => namespace].",
"$",
"groups",
"=",
"collect",
"(",
"config",
"(",
"'flame'",
")",
")",
"->",
"mapWithKeys",
"(",
"function",
"(",
"$",
"item",
",",
"$",
"key",
")",
"{",
"return",
"[",
"$",
"key",
"=>",
"$",
"item",
"[",
"'namespace'",
"]",
"]",
";",
"}",
")",
";",
"//Map a new array only with namespaces.",
"$",
"namespaces",
"=",
"$",
"groups",
"->",
"values",
"(",
")",
";",
"//Get the namespace that longest matches the controller namespace.",
"$",
"matchedNamespace",
"=",
"Str",
"::",
"longestMatch",
"(",
"$",
"namespaces",
"->",
"toArray",
"(",
")",
",",
"$",
"this",
"->",
"controllerNamespace",
"(",
")",
")",
";",
"// Cannot continue if no namespace was found for the View hint.",
"if",
"(",
"is_null",
"(",
"$",
"matchedNamespace",
")",
")",
"{",
"throw",
"FlameException",
"::",
"namespaceNotFound",
"(",
"$",
"this",
"->",
"controllerNamespace",
"(",
")",
")",
";",
"}",
"return",
"$",
"groups",
"->",
"flip",
"(",
")",
"[",
"$",
"matchedNamespace",
"]",
";",
"}"
] |
Computes the View hint based in the Controller namespace and the
Flame configuration.
@throws Laraning\Flame\Exceptions\FlameException
@return string View hint.
|
[
"Computes",
"the",
"View",
"hint",
"based",
"in",
"the",
"Controller",
"namespace",
"and",
"the",
"Flame",
"configuration",
"."
] |
42bdc99fd3b7c200707bcc407d7d87390b3a7c37
|
https://github.com/laraning/flame/blob/42bdc99fd3b7c200707bcc407d7d87390b3a7c37/src/Renderers/Renderer.php#L33-L52
|
237,707
|
laraning/flame
|
src/Renderers/Renderer.php
|
Renderer.getIntermediatePath
|
protected function getIntermediatePath($hint)
{
$namespace = config("flame.{$hint}.namespace");
$namespaceTail = substr($this->controllerNamespace(), strlen($namespace) + 1);
return collect(explode('\\', $namespaceTail))->splice(0, -2)->implode('.');
}
|
php
|
protected function getIntermediatePath($hint)
{
$namespace = config("flame.{$hint}.namespace");
$namespaceTail = substr($this->controllerNamespace(), strlen($namespace) + 1);
return collect(explode('\\', $namespaceTail))->splice(0, -2)->implode('.');
}
|
[
"protected",
"function",
"getIntermediatePath",
"(",
"$",
"hint",
")",
"{",
"$",
"namespace",
"=",
"config",
"(",
"\"flame.{$hint}.namespace\"",
")",
";",
"$",
"namespaceTail",
"=",
"substr",
"(",
"$",
"this",
"->",
"controllerNamespace",
"(",
")",
",",
"strlen",
"(",
"$",
"namespace",
")",
"+",
"1",
")",
";",
"return",
"collect",
"(",
"explode",
"(",
"'\\\\'",
",",
"$",
"namespaceTail",
")",
")",
"->",
"splice",
"(",
"0",
",",
"-",
"2",
")",
"->",
"implode",
"(",
"'.'",
")",
";",
"}"
] |
Resolves the view intermediate path.
@param string $hint View hint (=the flame group key).
@return string Intermediate path already with '.' separations.
|
[
"Resolves",
"the",
"view",
"intermediate",
"path",
"."
] |
42bdc99fd3b7c200707bcc407d7d87390b3a7c37
|
https://github.com/laraning/flame/blob/42bdc99fd3b7c200707bcc407d7d87390b3a7c37/src/Renderers/Renderer.php#L71-L77
|
237,708
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Cache.php
|
WebDriver_Cache.createScreenshot
|
protected function createScreenshot()
{
$image = imagecreatefromstring($this->webDriver->screenshotAsImage());
if (false === $image) {
throw new WebDriver_Exception("Invalid screenshot data");
}
return $image;
}
|
php
|
protected function createScreenshot()
{
$image = imagecreatefromstring($this->webDriver->screenshotAsImage());
if (false === $image) {
throw new WebDriver_Exception("Invalid screenshot data");
}
return $image;
}
|
[
"protected",
"function",
"createScreenshot",
"(",
")",
"{",
"$",
"image",
"=",
"imagecreatefromstring",
"(",
"$",
"this",
"->",
"webDriver",
"->",
"screenshotAsImage",
"(",
")",
")",
";",
"if",
"(",
"false",
"===",
"$",
"image",
")",
"{",
"throw",
"new",
"WebDriver_Exception",
"(",
"\"Invalid screenshot data\"",
")",
";",
"}",
"return",
"$",
"image",
";",
"}"
] |
Takes screenshot and returns image resource.
@return resource
@throws WebDriver_Exception
|
[
"Takes",
"screenshot",
"and",
"returns",
"image",
"resource",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Cache.php#L134-L141
|
237,709
|
ntentan/logger
|
src/Logger.php
|
Logger.getBackend
|
public static function getBackend()
{
if(!is_object(self::$backend))
{
self::$backend = new \Monolog\Logger(self::$name);
self::$backend->pushHandler(self::getStreamHandler());
self::setLogFormat(self::$logFormat);
}
return self::$backend;
}
|
php
|
public static function getBackend()
{
if(!is_object(self::$backend))
{
self::$backend = new \Monolog\Logger(self::$name);
self::$backend->pushHandler(self::getStreamHandler());
self::setLogFormat(self::$logFormat);
}
return self::$backend;
}
|
[
"public",
"static",
"function",
"getBackend",
"(",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"self",
"::",
"$",
"backend",
")",
")",
"{",
"self",
"::",
"$",
"backend",
"=",
"new",
"\\",
"Monolog",
"\\",
"Logger",
"(",
"self",
"::",
"$",
"name",
")",
";",
"self",
"::",
"$",
"backend",
"->",
"pushHandler",
"(",
"self",
"::",
"getStreamHandler",
"(",
")",
")",
";",
"self",
"::",
"setLogFormat",
"(",
"self",
"::",
"$",
"logFormat",
")",
";",
"}",
"return",
"self",
"::",
"$",
"backend",
";",
"}"
] |
Returns a singleton instance of a monolog logger.
@return \Monolog\Logger
|
[
"Returns",
"a",
"singleton",
"instance",
"of",
"a",
"monolog",
"logger",
"."
] |
798b691daff9acd5738d658e616c49bcf8b4d9b4
|
https://github.com/ntentan/logger/blob/798b691daff9acd5738d658e616c49bcf8b4d9b4/src/Logger.php#L104-L113
|
237,710
|
ntentan/logger
|
src/Logger.php
|
Logger.setLogFormat
|
public static function setLogFormat($format)
{
self::$logFormat = $format;
self::getStreamHandler()->setFormatter(new LineFormatter($format));
}
|
php
|
public static function setLogFormat($format)
{
self::$logFormat = $format;
self::getStreamHandler()->setFormatter(new LineFormatter($format));
}
|
[
"public",
"static",
"function",
"setLogFormat",
"(",
"$",
"format",
")",
"{",
"self",
"::",
"$",
"logFormat",
"=",
"$",
"format",
";",
"self",
"::",
"getStreamHandler",
"(",
")",
"->",
"setFormatter",
"(",
"new",
"LineFormatter",
"(",
"$",
"format",
")",
")",
";",
"}"
] |
Sets up the log format of the log lines written to the log files.
This method actually creates a new monolog LineFormatter and passes the
format argument directly to it. Due to this implementation, the format
it accepts is exactly what monolog uses.
@param string $format
|
[
"Sets",
"up",
"the",
"log",
"format",
"of",
"the",
"log",
"lines",
"written",
"to",
"the",
"log",
"files",
".",
"This",
"method",
"actually",
"creates",
"a",
"new",
"monolog",
"LineFormatter",
"and",
"passes",
"the",
"format",
"argument",
"directly",
"to",
"it",
".",
"Due",
"to",
"this",
"implementation",
"the",
"format",
"it",
"accepts",
"is",
"exactly",
"what",
"monolog",
"uses",
"."
] |
798b691daff9acd5738d658e616c49bcf8b4d9b4
|
https://github.com/ntentan/logger/blob/798b691daff9acd5738d658e616c49bcf8b4d9b4/src/Logger.php#L123-L127
|
237,711
|
ntentan/logger
|
src/Logger.php
|
Logger.getStreamHandler
|
private static function getStreamHandler()
{
if(!is_object(self::$stream))
{
self::$stream = new StreamHandler(self::$logFilePath, self::$minimumLevel);
}
return self::$stream;
}
|
php
|
private static function getStreamHandler()
{
if(!is_object(self::$stream))
{
self::$stream = new StreamHandler(self::$logFilePath, self::$minimumLevel);
}
return self::$stream;
}
|
[
"private",
"static",
"function",
"getStreamHandler",
"(",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"self",
"::",
"$",
"stream",
")",
")",
"{",
"self",
"::",
"$",
"stream",
"=",
"new",
"StreamHandler",
"(",
"self",
"::",
"$",
"logFilePath",
",",
"self",
"::",
"$",
"minimumLevel",
")",
";",
"}",
"return",
"self",
"::",
"$",
"stream",
";",
"}"
] |
Returns a singleton instance of the monolog stream handler.
@return \Monolog\Handler\StreamHandler
|
[
"Returns",
"a",
"singleton",
"instance",
"of",
"the",
"monolog",
"stream",
"handler",
"."
] |
798b691daff9acd5738d658e616c49bcf8b4d9b4
|
https://github.com/ntentan/logger/blob/798b691daff9acd5738d658e616c49bcf8b4d9b4/src/Logger.php#L133-L140
|
237,712
|
ntentan/logger
|
src/Logger.php
|
Logger.init
|
public static function init($path, $name = 'log', $minimumLevel = self::DEBUG)
{
if($path === 'php://output')
{
self::$active = true;
}
else if(is_writable($path))
{
self::$active = true;
}
else
{
self::$active = false;
}
self::$backend = null;
self::$stream = null;
self::$name = $name;
self::$logFilePath = $path;
self::$minimumLevel = $minimumLevel;
}
|
php
|
public static function init($path, $name = 'log', $minimumLevel = self::DEBUG)
{
if($path === 'php://output')
{
self::$active = true;
}
else if(is_writable($path))
{
self::$active = true;
}
else
{
self::$active = false;
}
self::$backend = null;
self::$stream = null;
self::$name = $name;
self::$logFilePath = $path;
self::$minimumLevel = $minimumLevel;
}
|
[
"public",
"static",
"function",
"init",
"(",
"$",
"path",
",",
"$",
"name",
"=",
"'log'",
",",
"$",
"minimumLevel",
"=",
"self",
"::",
"DEBUG",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"'php://output'",
")",
"{",
"self",
"::",
"$",
"active",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"is_writable",
"(",
"$",
"path",
")",
")",
"{",
"self",
"::",
"$",
"active",
"=",
"true",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"active",
"=",
"false",
";",
"}",
"self",
"::",
"$",
"backend",
"=",
"null",
";",
"self",
"::",
"$",
"stream",
"=",
"null",
";",
"self",
"::",
"$",
"name",
"=",
"$",
"name",
";",
"self",
"::",
"$",
"logFilePath",
"=",
"$",
"path",
";",
"self",
"::",
"$",
"minimumLevel",
"=",
"$",
"minimumLevel",
";",
"}"
] |
Initializes the logger.
@param string $path
@param string $name
@param integer $minimumLevel
|
[
"Initializes",
"the",
"logger",
"."
] |
798b691daff9acd5738d658e616c49bcf8b4d9b4
|
https://github.com/ntentan/logger/blob/798b691daff9acd5738d658e616c49bcf8b4d9b4/src/Logger.php#L149-L169
|
237,713
|
ntentan/logger
|
src/Logger.php
|
Logger.log
|
public static function log($level, $message)
{
if(self::$active)
{
self::getBackend()->addRecord($level, $message);
}
}
|
php
|
public static function log($level, $message)
{
if(self::$active)
{
self::getBackend()->addRecord($level, $message);
}
}
|
[
"public",
"static",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"active",
")",
"{",
"self",
"::",
"getBackend",
"(",
")",
"->",
"addRecord",
"(",
"$",
"level",
",",
"$",
"message",
")",
";",
"}",
"}"
] |
Write out the log message to the log file at the specified log level.
@param integer $level
@param string $message
|
[
"Write",
"out",
"the",
"log",
"message",
"to",
"the",
"log",
"file",
"at",
"the",
"specified",
"log",
"level",
"."
] |
798b691daff9acd5738d658e616c49bcf8b4d9b4
|
https://github.com/ntentan/logger/blob/798b691daff9acd5738d658e616c49bcf8b4d9b4/src/Logger.php#L177-L183
|
237,714
|
eghojansu/nutrition
|
src/Utils/Route.php
|
Route.currentPath
|
public function currentPath($params = null, $withParams = true, array $queries = null)
{
$base = Base::instance();
return $this->build(
$base['ALIAS'],
((array) $params) + ($withParams?$base['PARAMS']:[]),
$queries
);
}
|
php
|
public function currentPath($params = null, $withParams = true, array $queries = null)
{
$base = Base::instance();
return $this->build(
$base['ALIAS'],
((array) $params) + ($withParams?$base['PARAMS']:[]),
$queries
);
}
|
[
"public",
"function",
"currentPath",
"(",
"$",
"params",
"=",
"null",
",",
"$",
"withParams",
"=",
"true",
",",
"array",
"$",
"queries",
"=",
"null",
")",
"{",
"$",
"base",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"return",
"$",
"this",
"->",
"build",
"(",
"$",
"base",
"[",
"'ALIAS'",
"]",
",",
"(",
"(",
"array",
")",
"$",
"params",
")",
"+",
"(",
"$",
"withParams",
"?",
"$",
"base",
"[",
"'PARAMS'",
"]",
":",
"[",
"]",
")",
",",
"$",
"queries",
")",
";",
"}"
] |
Get current path
@param mixed $params
@param boolean $withParams
@param array $queries
@return string
|
[
"Get",
"current",
"path"
] |
3941c62aeb6dafda55349a38dd4107d521f8964a
|
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/Route.php#L53-L62
|
237,715
|
agalbourdin/agl-core
|
src/Debug/Debug.php
|
Debug.isHtmlView
|
public static function isHtmlView()
{
if (self::$_isHtmlView === NULL) {
self::$_isHtmlView = false;
$view = Registry::get('view');
if ($view === NULL) {
$template = ViewAbstract::getTemplateConfig();
if (is_array($template)
and isset($template['type'])
and $template['type'] === ViewInterface::TYPE_HTML) {
self::$_isHtmlView = true;
}
} else if ($view instanceof View and $view->getType() == ViewInterface::TYPE_HTML) {
self::$_isHtmlView = true;
}
}
return self::$_isHtmlView;
}
|
php
|
public static function isHtmlView()
{
if (self::$_isHtmlView === NULL) {
self::$_isHtmlView = false;
$view = Registry::get('view');
if ($view === NULL) {
$template = ViewAbstract::getTemplateConfig();
if (is_array($template)
and isset($template['type'])
and $template['type'] === ViewInterface::TYPE_HTML) {
self::$_isHtmlView = true;
}
} else if ($view instanceof View and $view->getType() == ViewInterface::TYPE_HTML) {
self::$_isHtmlView = true;
}
}
return self::$_isHtmlView;
}
|
[
"public",
"static",
"function",
"isHtmlView",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_isHtmlView",
"===",
"NULL",
")",
"{",
"self",
"::",
"$",
"_isHtmlView",
"=",
"false",
";",
"$",
"view",
"=",
"Registry",
"::",
"get",
"(",
"'view'",
")",
";",
"if",
"(",
"$",
"view",
"===",
"NULL",
")",
"{",
"$",
"template",
"=",
"ViewAbstract",
"::",
"getTemplateConfig",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"template",
")",
"and",
"isset",
"(",
"$",
"template",
"[",
"'type'",
"]",
")",
"and",
"$",
"template",
"[",
"'type'",
"]",
"===",
"ViewInterface",
"::",
"TYPE_HTML",
")",
"{",
"self",
"::",
"$",
"_isHtmlView",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"view",
"instanceof",
"View",
"and",
"$",
"view",
"->",
"getType",
"(",
")",
"==",
"ViewInterface",
"::",
"TYPE_HTML",
")",
"{",
"self",
"::",
"$",
"_isHtmlView",
"=",
"true",
";",
"}",
"}",
"return",
"self",
"::",
"$",
"_isHtmlView",
";",
"}"
] |
Check if the view is of HTML type.
@return bool
|
[
"Check",
"if",
"the",
"view",
"is",
"of",
"HTML",
"type",
"."
] |
1db556f9a49488aa9fab6887fefb7141a79ad97d
|
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Debug/Debug.php#L40-L59
|
237,716
|
agalbourdin/agl-core
|
src/Debug/Debug.php
|
Debug.log
|
public static function log($pMessage)
{
if (is_array($pMessage) or is_object($pMessage)) {
$message = json_encode($pMessage);
} else {
$message = (string)$pMessage;
}
$logId = mt_rand();
if (Agl::isInitialized()) {
$message = '[agl_' . $logId . '] [' . date('Y-m-d H:i:s') . '] [' . APP_PATH . '] ' . $message . "\n";
$dir = APP_PATH . Agl::APP_VAR_DIR . sprintf(self::LOG_DIR, date('Y'), date('m'));
if (! is_writable(APP_PATH . Agl::APP_VAR_DIR) or (! is_dir($dir) and ! mkdir($dir, 0777, true)) or ! is_writable($dir)) {
return 0;
}
$file = $dir . sprintf(self::LOG_FILE, date('Y-m-d'));
$logged = FileData::write($file, $message, true);
if (! $logged) {
return 0;
}
} else {
return 0;
}
return $logId;
}
|
php
|
public static function log($pMessage)
{
if (is_array($pMessage) or is_object($pMessage)) {
$message = json_encode($pMessage);
} else {
$message = (string)$pMessage;
}
$logId = mt_rand();
if (Agl::isInitialized()) {
$message = '[agl_' . $logId . '] [' . date('Y-m-d H:i:s') . '] [' . APP_PATH . '] ' . $message . "\n";
$dir = APP_PATH . Agl::APP_VAR_DIR . sprintf(self::LOG_DIR, date('Y'), date('m'));
if (! is_writable(APP_PATH . Agl::APP_VAR_DIR) or (! is_dir($dir) and ! mkdir($dir, 0777, true)) or ! is_writable($dir)) {
return 0;
}
$file = $dir . sprintf(self::LOG_FILE, date('Y-m-d'));
$logged = FileData::write($file, $message, true);
if (! $logged) {
return 0;
}
} else {
return 0;
}
return $logId;
}
|
[
"public",
"static",
"function",
"log",
"(",
"$",
"pMessage",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pMessage",
")",
"or",
"is_object",
"(",
"$",
"pMessage",
")",
")",
"{",
"$",
"message",
"=",
"json_encode",
"(",
"$",
"pMessage",
")",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"(",
"string",
")",
"$",
"pMessage",
";",
"}",
"$",
"logId",
"=",
"mt_rand",
"(",
")",
";",
"if",
"(",
"Agl",
"::",
"isInitialized",
"(",
")",
")",
"{",
"$",
"message",
"=",
"'[agl_'",
".",
"$",
"logId",
".",
"'] ['",
".",
"date",
"(",
"'Y-m-d H:i:s'",
")",
".",
"'] ['",
".",
"APP_PATH",
".",
"'] '",
".",
"$",
"message",
".",
"\"\\n\"",
";",
"$",
"dir",
"=",
"APP_PATH",
".",
"Agl",
"::",
"APP_VAR_DIR",
".",
"sprintf",
"(",
"self",
"::",
"LOG_DIR",
",",
"date",
"(",
"'Y'",
")",
",",
"date",
"(",
"'m'",
")",
")",
";",
"if",
"(",
"!",
"is_writable",
"(",
"APP_PATH",
".",
"Agl",
"::",
"APP_VAR_DIR",
")",
"or",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
"and",
"!",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
")",
"or",
"!",
"is_writable",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"file",
"=",
"$",
"dir",
".",
"sprintf",
"(",
"self",
"::",
"LOG_FILE",
",",
"date",
"(",
"'Y-m-d'",
")",
")",
";",
"$",
"logged",
"=",
"FileData",
"::",
"write",
"(",
"$",
"file",
",",
"$",
"message",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"logged",
")",
"{",
"return",
"0",
";",
"}",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"logId",
";",
"}"
] |
Log a message in the syslog.
@param string $pMessage
@return null|string
|
[
"Log",
"a",
"message",
"in",
"the",
"syslog",
"."
] |
1db556f9a49488aa9fab6887fefb7141a79ad97d
|
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Debug/Debug.php#L77-L106
|
237,717
|
agalbourdin/agl-core
|
src/Debug/Debug.php
|
Debug.getInfos
|
public static function getInfos()
{
$xDebugEnabled = self::isXdebugEnabled();
$debugInfos = array();
$debugInfos['app']['path'] = APP_PATH;
$debugInfos['app']['cache'] = Agl::app()->isCacheEnabled();
if ($xDebugEnabled) {
$debugInfos['time'] = xdebug_time_index();
$debugInfos['memory'] = xdebug_peak_memory_usage();
}
if (Agl::app()->getDb() !== NULL) {
$debugInfos['db']['db_engine'] = Agl::app()->getConfig('main/db/engine');
$debugInfos['db']['queries'] = Agl::app()->getDb()->countQueries();
}
$debugInfos['opcache'] = (ini_get('opcache.enable')) ? true : false;
$debugInfos['apcu'] = (ini_get('apc.enabled')) ? true : false;
$debugInfos['xdebug'] = $xDebugEnabled;
$debugInfos['more_modules'] = Agl::getLoadedModules();
$debugInfos['request'] = Agl::getRequest();
return $debugInfos;
}
|
php
|
public static function getInfos()
{
$xDebugEnabled = self::isXdebugEnabled();
$debugInfos = array();
$debugInfos['app']['path'] = APP_PATH;
$debugInfos['app']['cache'] = Agl::app()->isCacheEnabled();
if ($xDebugEnabled) {
$debugInfos['time'] = xdebug_time_index();
$debugInfos['memory'] = xdebug_peak_memory_usage();
}
if (Agl::app()->getDb() !== NULL) {
$debugInfos['db']['db_engine'] = Agl::app()->getConfig('main/db/engine');
$debugInfos['db']['queries'] = Agl::app()->getDb()->countQueries();
}
$debugInfos['opcache'] = (ini_get('opcache.enable')) ? true : false;
$debugInfos['apcu'] = (ini_get('apc.enabled')) ? true : false;
$debugInfos['xdebug'] = $xDebugEnabled;
$debugInfos['more_modules'] = Agl::getLoadedModules();
$debugInfos['request'] = Agl::getRequest();
return $debugInfos;
}
|
[
"public",
"static",
"function",
"getInfos",
"(",
")",
"{",
"$",
"xDebugEnabled",
"=",
"self",
"::",
"isXdebugEnabled",
"(",
")",
";",
"$",
"debugInfos",
"=",
"array",
"(",
")",
";",
"$",
"debugInfos",
"[",
"'app'",
"]",
"[",
"'path'",
"]",
"=",
"APP_PATH",
";",
"$",
"debugInfos",
"[",
"'app'",
"]",
"[",
"'cache'",
"]",
"=",
"Agl",
"::",
"app",
"(",
")",
"->",
"isCacheEnabled",
"(",
")",
";",
"if",
"(",
"$",
"xDebugEnabled",
")",
"{",
"$",
"debugInfos",
"[",
"'time'",
"]",
"=",
"xdebug_time_index",
"(",
")",
";",
"$",
"debugInfos",
"[",
"'memory'",
"]",
"=",
"xdebug_peak_memory_usage",
"(",
")",
";",
"}",
"if",
"(",
"Agl",
"::",
"app",
"(",
")",
"->",
"getDb",
"(",
")",
"!==",
"NULL",
")",
"{",
"$",
"debugInfos",
"[",
"'db'",
"]",
"[",
"'db_engine'",
"]",
"=",
"Agl",
"::",
"app",
"(",
")",
"->",
"getConfig",
"(",
"'main/db/engine'",
")",
";",
"$",
"debugInfos",
"[",
"'db'",
"]",
"[",
"'queries'",
"]",
"=",
"Agl",
"::",
"app",
"(",
")",
"->",
"getDb",
"(",
")",
"->",
"countQueries",
"(",
")",
";",
"}",
"$",
"debugInfos",
"[",
"'opcache'",
"]",
"=",
"(",
"ini_get",
"(",
"'opcache.enable'",
")",
")",
"?",
"true",
":",
"false",
";",
"$",
"debugInfos",
"[",
"'apcu'",
"]",
"=",
"(",
"ini_get",
"(",
"'apc.enabled'",
")",
")",
"?",
"true",
":",
"false",
";",
"$",
"debugInfos",
"[",
"'xdebug'",
"]",
"=",
"$",
"xDebugEnabled",
";",
"$",
"debugInfos",
"[",
"'more_modules'",
"]",
"=",
"Agl",
"::",
"getLoadedModules",
"(",
")",
";",
"$",
"debugInfos",
"[",
"'request'",
"]",
"=",
"Agl",
"::",
"getRequest",
"(",
")",
";",
"return",
"$",
"debugInfos",
";",
"}"
] |
Return some debug informations about the running script.
@return array
|
[
"Return",
"some",
"debug",
"informations",
"about",
"the",
"running",
"script",
"."
] |
1db556f9a49488aa9fab6887fefb7141a79ad97d
|
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Debug/Debug.php#L113-L138
|
237,718
|
common-libs/user
|
src/permission.php
|
permission.check
|
public static function check() {
if (R::count("permission") < 1) {
$role = R::dispense("permission");
$role->name = "guest";
R::store($role);
}
}
|
php
|
public static function check() {
if (R::count("permission") < 1) {
$role = R::dispense("permission");
$role->name = "guest";
R::store($role);
}
}
|
[
"public",
"static",
"function",
"check",
"(",
")",
"{",
"if",
"(",
"R",
"::",
"count",
"(",
"\"permission\"",
")",
"<",
"1",
")",
"{",
"$",
"role",
"=",
"R",
"::",
"dispense",
"(",
"\"permission\"",
")",
";",
"$",
"role",
"->",
"name",
"=",
"\"guest\"",
";",
"R",
"::",
"store",
"(",
"$",
"role",
")",
";",
"}",
"}"
] |
checks if table is created
|
[
"checks",
"if",
"table",
"is",
"created"
] |
820fce6748a59e8d692bf613b4694f903d9db6c1
|
https://github.com/common-libs/user/blob/820fce6748a59e8d692bf613b4694f903d9db6c1/src/permission.php#L56-L62
|
237,719
|
Dhii/expression-renderer-abstract
|
src/RenderExpressionTrait.php
|
RenderExpressionTrait._render
|
protected function _render($context = null)
{
if ($context === null) {
throw $this->_createInvalidArgumentException(
$this->__('Cannot render with a null context'),
null,
null,
$context
);
}
try {
$expr = $this->_containerGet($context, ExprCtx::K_EXPRESSION);
$result = $this->_renderExpression($expr, $context);
return $result;
} catch (NotFoundExceptionInterface $notFoundException) {
throw $this->_createInvalidArgumentException(
$this->__('Context does not contain an expression'),
null,
$notFoundException,
$context
);
}
}
|
php
|
protected function _render($context = null)
{
if ($context === null) {
throw $this->_createInvalidArgumentException(
$this->__('Cannot render with a null context'),
null,
null,
$context
);
}
try {
$expr = $this->_containerGet($context, ExprCtx::K_EXPRESSION);
$result = $this->_renderExpression($expr, $context);
return $result;
} catch (NotFoundExceptionInterface $notFoundException) {
throw $this->_createInvalidArgumentException(
$this->__('Context does not contain an expression'),
null,
$notFoundException,
$context
);
}
}
|
[
"protected",
"function",
"_render",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"context",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Cannot render with a null context'",
")",
",",
"null",
",",
"null",
",",
"$",
"context",
")",
";",
"}",
"try",
"{",
"$",
"expr",
"=",
"$",
"this",
"->",
"_containerGet",
"(",
"$",
"context",
",",
"ExprCtx",
"::",
"K_EXPRESSION",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"_renderExpression",
"(",
"$",
"expr",
",",
"$",
"context",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"NotFoundExceptionInterface",
"$",
"notFoundException",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Context does not contain an expression'",
")",
",",
"null",
",",
"$",
"notFoundException",
",",
"$",
"context",
")",
";",
"}",
"}"
] |
Renders the given context as an expression.
@since [*next-version*]
@param array|ArrayAccess|stdClass|ContainerInterface|null $context The render context. Must have at least a
TermInterface instance that corresponds
to the key {@see ExprCtx::K_EXPRESSION}.
@throws ContainerExceptionInterface If the context container encountered an error.
@throws NotFoundExceptionInterface If the expression was not found in the context container.
@return string|Stringable The rendered result.
|
[
"Renders",
"the",
"given",
"context",
"as",
"an",
"expression",
"."
] |
8c315e1d034b4198a89e0157f045e4a0d6cc8de8
|
https://github.com/Dhii/expression-renderer-abstract/blob/8c315e1d034b4198a89e0157f045e4a0d6cc8de8/src/RenderExpressionTrait.php#L40-L64
|
237,720
|
tkhatibi/php-field
|
src/Select.php
|
Select.options2html
|
public static function options2html(array $options = [], $selectedValue = null){
// buffer prepared html codes
$buffer = [];
// loop options
foreach ($options as $key => $value) {
// make optgroup
if(is_array($value)){
// turn optgroup options to html
$optgroupOptions = static::options2html($value, $selectedValue);
// append prepared group to buffer
$buffer[] = "<optgroup label='$key'>$optgroupOptions</options>";
} else {
// make option
// print selected='' if option value and selected value are equivalent
$selected = static::selected($selectedValue, $value);
// append prepared option to buffer
$buffer[] = "<option value='$value' $selected>$key</option>";
}
}
// make html
$html = implode('', $buffer);
// return result
return $html;
}
|
php
|
public static function options2html(array $options = [], $selectedValue = null){
// buffer prepared html codes
$buffer = [];
// loop options
foreach ($options as $key => $value) {
// make optgroup
if(is_array($value)){
// turn optgroup options to html
$optgroupOptions = static::options2html($value, $selectedValue);
// append prepared group to buffer
$buffer[] = "<optgroup label='$key'>$optgroupOptions</options>";
} else {
// make option
// print selected='' if option value and selected value are equivalent
$selected = static::selected($selectedValue, $value);
// append prepared option to buffer
$buffer[] = "<option value='$value' $selected>$key</option>";
}
}
// make html
$html = implode('', $buffer);
// return result
return $html;
}
|
[
"public",
"static",
"function",
"options2html",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"selectedValue",
"=",
"null",
")",
"{",
"// buffer prepared html codes\r",
"$",
"buffer",
"=",
"[",
"]",
";",
"// loop options\r",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// make optgroup\r",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"// turn optgroup options to html\r",
"$",
"optgroupOptions",
"=",
"static",
"::",
"options2html",
"(",
"$",
"value",
",",
"$",
"selectedValue",
")",
";",
"// append prepared group to buffer\r",
"$",
"buffer",
"[",
"]",
"=",
"\"<optgroup label='$key'>$optgroupOptions</options>\"",
";",
"}",
"else",
"{",
"// make option\r",
"// print selected='' if option value and selected value are equivalent\r",
"$",
"selected",
"=",
"static",
"::",
"selected",
"(",
"$",
"selectedValue",
",",
"$",
"value",
")",
";",
"// append prepared option to buffer\r",
"$",
"buffer",
"[",
"]",
"=",
"\"<option value='$value' $selected>$key</option>\"",
";",
"}",
"}",
"// make html\r",
"$",
"html",
"=",
"implode",
"(",
"''",
",",
"$",
"buffer",
")",
";",
"// return result\r",
"return",
"$",
"html",
";",
"}"
] |
generate html code by options array
@param array $options list of options
@param integer|string $selectedValue for add selected='' to option attribute
@return string generated html
|
[
"generate",
"html",
"code",
"by",
"options",
"array"
] |
629657a7f96353ab6caf11ca9319a17ede719b76
|
https://github.com/tkhatibi/php-field/blob/629657a7f96353ab6caf11ca9319a17ede719b76/src/Select.php#L47-L70
|
237,721
|
zugoripls/laravel-framework
|
src/Illuminate/Foundation/Console/RouteCacheCommand.php
|
RouteCacheCommand.getFreshApplicationRoutes
|
protected function getFreshApplicationRoutes()
{
$app = require $this->laravel->basePath().'/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
return $app['router']->getRoutes();
}
|
php
|
protected function getFreshApplicationRoutes()
{
$app = require $this->laravel->basePath().'/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
return $app['router']->getRoutes();
}
|
[
"protected",
"function",
"getFreshApplicationRoutes",
"(",
")",
"{",
"$",
"app",
"=",
"require",
"$",
"this",
"->",
"laravel",
"->",
"basePath",
"(",
")",
".",
"'/bootstrap/app.php'",
";",
"$",
"app",
"->",
"make",
"(",
"'Illuminate\\Contracts\\Console\\Kernel'",
")",
"->",
"bootstrap",
"(",
")",
";",
"return",
"$",
"app",
"[",
"'router'",
"]",
"->",
"getRoutes",
"(",
")",
";",
"}"
] |
Boot a fresh copy of the application and get the routes.
@return \Illuminate\Routing\RouteCollection
|
[
"Boot",
"a",
"fresh",
"copy",
"of",
"the",
"application",
"and",
"get",
"the",
"routes",
"."
] |
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
|
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Foundation/Console/RouteCacheCommand.php#L76-L83
|
237,722
|
erikkubica/netlime-theme-navigation
|
ThemeNavigation.php
|
ThemeNavigation.registerNavigation
|
protected function registerNavigation()
{
do_action("before_theme_register_navigation");
foreach ($this->getConfig("navigation") as $name => $description):
register_nav_menu($name, $description);
endforeach;
do_action("after_theme_register_navigation");
}
|
php
|
protected function registerNavigation()
{
do_action("before_theme_register_navigation");
foreach ($this->getConfig("navigation") as $name => $description):
register_nav_menu($name, $description);
endforeach;
do_action("after_theme_register_navigation");
}
|
[
"protected",
"function",
"registerNavigation",
"(",
")",
"{",
"do_action",
"(",
"\"before_theme_register_navigation\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"\"navigation\"",
")",
"as",
"$",
"name",
"=>",
"$",
"description",
")",
":",
"register_nav_menu",
"(",
"$",
"name",
",",
"$",
"description",
")",
";",
"endforeach",
";",
"do_action",
"(",
"\"after_theme_register_navigation\"",
")",
";",
"}"
] |
Register navigation menus
|
[
"Register",
"navigation",
"menus"
] |
a17e0f60a44a625037a63a975ef3c887a9a2d5a6
|
https://github.com/erikkubica/netlime-theme-navigation/blob/a17e0f60a44a625037a63a975ef3c887a9a2d5a6/ThemeNavigation.php#L19-L28
|
237,723
|
coolms/jquery
|
src/Plugin/JQueryPluginManager.php
|
JQueryPluginManager.getRenderer
|
public function getRenderer()
{
$locator = $this->getServiceLocator();
if (null === $this->renderer && $locator->has(Renderer\RendererInterface::class)) {
$this->setRenderer($locator->get(Renderer\RendererInterface::class));
}
return $this->renderer;
}
|
php
|
public function getRenderer()
{
$locator = $this->getServiceLocator();
if (null === $this->renderer && $locator->has(Renderer\RendererInterface::class)) {
$this->setRenderer($locator->get(Renderer\RendererInterface::class));
}
return $this->renderer;
}
|
[
"public",
"function",
"getRenderer",
"(",
")",
"{",
"$",
"locator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"renderer",
"&&",
"$",
"locator",
"->",
"has",
"(",
"Renderer",
"\\",
"RendererInterface",
"::",
"class",
")",
")",
"{",
"$",
"this",
"->",
"setRenderer",
"(",
"$",
"locator",
"->",
"get",
"(",
"Renderer",
"\\",
"RendererInterface",
"::",
"class",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"renderer",
";",
"}"
] |
Retrieve renderer instance
@return null|Renderer\RendererInterface
|
[
"Retrieve",
"renderer",
"instance"
] |
e7a8b0890d1888b44a03dd6affe55a300cca9c73
|
https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Plugin/JQueryPluginManager.php#L79-L87
|
237,724
|
coolms/jquery
|
src/Plugin/JQueryPluginManager.php
|
JQueryPluginManager.injectRenderer
|
public function injectRenderer($helper)
{
$renderer = $this->getRenderer();
if (null === $renderer) {
return;
}
$helper->setView($renderer);
}
|
php
|
public function injectRenderer($helper)
{
$renderer = $this->getRenderer();
if (null === $renderer) {
return;
}
$helper->setView($renderer);
}
|
[
"public",
"function",
"injectRenderer",
"(",
"$",
"helper",
")",
"{",
"$",
"renderer",
"=",
"$",
"this",
"->",
"getRenderer",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"renderer",
")",
"{",
"return",
";",
"}",
"$",
"helper",
"->",
"setView",
"(",
"$",
"renderer",
")",
";",
"}"
] |
Inject a helper instance with the registered renderer
@param Helper\HelperInterface $helper
@return void
|
[
"Inject",
"a",
"helper",
"instance",
"with",
"the",
"registered",
"renderer"
] |
e7a8b0890d1888b44a03dd6affe55a300cca9c73
|
https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Plugin/JQueryPluginManager.php#L95-L103
|
237,725
|
coolms/jquery
|
src/Plugin/JQueryPluginManager.php
|
JQueryPluginManager.injectTranslator
|
public function injectTranslator($helper)
{
if (!$helper instanceof TranslatorAwareInterface) {
return;
}
$locator = $this->getServiceLocator();
if (!$locator) {
return;
}
if ($locator->has('MvcTranslator')) {
$helper->setTranslator($locator->get('MvcTranslator'));
return;
}
if ($locator->has(TranslatorInterface::class)) {
$helper->setTranslator($locator->get(TranslatorInterface::class));
return;
}
if ($locator->has('Translator')) {
$helper->setTranslator($locator->get('Translator'));
return;
}
}
|
php
|
public function injectTranslator($helper)
{
if (!$helper instanceof TranslatorAwareInterface) {
return;
}
$locator = $this->getServiceLocator();
if (!$locator) {
return;
}
if ($locator->has('MvcTranslator')) {
$helper->setTranslator($locator->get('MvcTranslator'));
return;
}
if ($locator->has(TranslatorInterface::class)) {
$helper->setTranslator($locator->get(TranslatorInterface::class));
return;
}
if ($locator->has('Translator')) {
$helper->setTranslator($locator->get('Translator'));
return;
}
}
|
[
"public",
"function",
"injectTranslator",
"(",
"$",
"helper",
")",
"{",
"if",
"(",
"!",
"$",
"helper",
"instanceof",
"TranslatorAwareInterface",
")",
"{",
"return",
";",
"}",
"$",
"locator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"if",
"(",
"!",
"$",
"locator",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"locator",
"->",
"has",
"(",
"'MvcTranslator'",
")",
")",
"{",
"$",
"helper",
"->",
"setTranslator",
"(",
"$",
"locator",
"->",
"get",
"(",
"'MvcTranslator'",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"locator",
"->",
"has",
"(",
"TranslatorInterface",
"::",
"class",
")",
")",
"{",
"$",
"helper",
"->",
"setTranslator",
"(",
"$",
"locator",
"->",
"get",
"(",
"TranslatorInterface",
"::",
"class",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"locator",
"->",
"has",
"(",
"'Translator'",
")",
")",
"{",
"$",
"helper",
"->",
"setTranslator",
"(",
"$",
"locator",
"->",
"get",
"(",
"'Translator'",
")",
")",
";",
"return",
";",
"}",
"}"
] |
Inject a helper instance with the registered translator
@param Helper\HelperInterface $helper
@return void
|
[
"Inject",
"a",
"helper",
"instance",
"with",
"the",
"registered",
"translator"
] |
e7a8b0890d1888b44a03dd6affe55a300cca9c73
|
https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Plugin/JQueryPluginManager.php#L111-L137
|
237,726
|
easy-system/es-http
|
src/Uploading/DirectoryStrategy.php
|
DirectoryStrategy.setDirPermissions
|
public function setDirPermissions($permissions)
{
if (! is_int($permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid directory permissins provided; must be an '
. 'integer, "%s" received.',
is_object($permissions) ? get_class($permissions)
: gettype($permissions)
));
}
if (! (0b100000000 & $permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid permissions "%s" for directories. '
. 'Directories will not available for reading.',
decoct($permissions)
));
}
if (! (0b010000000 & $permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid permissions "%s" for directories. '
. 'Directories will not available for writing.',
decoct($permissions)
));
}
if (! (0b001000000 & $permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid permissions "%s" for directories. '
. 'The content of directories will not available.',
decoct($permissions)
));
}
$this->dirPermissions = $permissions;
}
|
php
|
public function setDirPermissions($permissions)
{
if (! is_int($permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid directory permissins provided; must be an '
. 'integer, "%s" received.',
is_object($permissions) ? get_class($permissions)
: gettype($permissions)
));
}
if (! (0b100000000 & $permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid permissions "%s" for directories. '
. 'Directories will not available for reading.',
decoct($permissions)
));
}
if (! (0b010000000 & $permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid permissions "%s" for directories. '
. 'Directories will not available for writing.',
decoct($permissions)
));
}
if (! (0b001000000 & $permissions)) {
throw new InvalidArgumentException(sprintf(
'Invalid permissions "%s" for directories. '
. 'The content of directories will not available.',
decoct($permissions)
));
}
$this->dirPermissions = $permissions;
}
|
[
"public",
"function",
"setDirPermissions",
"(",
"$",
"permissions",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"permissions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid directory permissins provided; must be an '",
".",
"'integer, \"%s\" received.'",
",",
"is_object",
"(",
"$",
"permissions",
")",
"?",
"get_class",
"(",
"$",
"permissions",
")",
":",
"gettype",
"(",
"$",
"permissions",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"0b100000000",
"&",
"$",
"permissions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid permissions \"%s\" for directories. '",
".",
"'Directories will not available for reading.'",
",",
"decoct",
"(",
"$",
"permissions",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"0b010000000",
"&",
"$",
"permissions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid permissions \"%s\" for directories. '",
".",
"'Directories will not available for writing.'",
",",
"decoct",
"(",
"$",
"permissions",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"0b001000000",
"&",
"$",
"permissions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid permissions \"%s\" for directories. '",
".",
"'The content of directories will not available.'",
",",
"decoct",
"(",
"$",
"permissions",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"dirPermissions",
"=",
"$",
"permissions",
";",
"}"
] |
Sets the permissions of new directories.
If the upload options contains the "dir_permissions" key, this method
will be called automatically.
@param int $permissions The permissions of new directories
@throws \InvalidArgumentException
- If specified permissions are non integer
- If specified permissions are not readable
- If specified permissions are not writable
- If specified permissions makes the content unreadable
|
[
"Sets",
"the",
"permissions",
"of",
"new",
"directories",
"."
] |
dd5852e94901e147a7546a8715133408ece767a1
|
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/DirectoryStrategy.php#L107-L139
|
237,727
|
jfusion/org.jfusion.curl
|
src/HtmlFormParser.php
|
HtmlFormParser._getName
|
function _getName($string)
{
if (preg_match('/name=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
//preg_match('/name=["\']?([\w\s]*)["\']?[\s>]/i', $string, $match)) { -- did not work as expected
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return trim($val_match, '"');
}
return false;
}
|
php
|
function _getName($string)
{
if (preg_match('/name=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
//preg_match('/name=["\']?([\w\s]*)["\']?[\s>]/i', $string, $match)) { -- did not work as expected
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return trim($val_match, '"');
}
return false;
}
|
[
"function",
"_getName",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/name=(\"([^\"]*)\"|\\'([^\\']*)\\'|[^>\\s]*)([^>]*)?>/is'",
",",
"$",
"string",
",",
"$",
"match",
")",
")",
"{",
"//preg_match('/name=[\"\\']?([\\w\\s]*)[\"\\']?[\\s>]/i', $string, $match)) { -- did not work as expected",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"val_match",
",",
"'\"\\''",
")",
";",
"unset",
"(",
"$",
"string",
")",
";",
"return",
"trim",
"(",
"$",
"val_match",
",",
"'\"'",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
gets the name
@param string $string string
@return string something
|
[
"gets",
"the",
"name"
] |
9f45f85b46b2db26e050a1929233af20c54259cc
|
https://github.com/jfusion/org.jfusion.curl/blob/9f45f85b46b2db26e050a1929233af20c54259cc/src/HtmlFormParser.php#L292-L302
|
237,728
|
jfusion/org.jfusion.curl
|
src/HtmlFormParser.php
|
HtmlFormParser._getValue
|
function _getValue($string)
{
if (preg_match('/value=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return $val_match;
}
return false;
}
|
php
|
function _getValue($string)
{
if (preg_match('/value=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return $val_match;
}
return false;
}
|
[
"function",
"_getValue",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/value=(\"([^\"]*)\"|\\'([^\\']*)\\'|[^>\\s]*)([^>]*)?>/is'",
",",
"$",
"string",
",",
"$",
"match",
")",
")",
"{",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"val_match",
",",
"'\"\\''",
")",
";",
"unset",
"(",
"$",
"string",
")",
";",
"return",
"$",
"val_match",
";",
"}",
"return",
"false",
";",
"}"
] |
gets the value
@param string $string string
@return string something
|
[
"gets",
"the",
"value"
] |
9f45f85b46b2db26e050a1929233af20c54259cc
|
https://github.com/jfusion/org.jfusion.curl/blob/9f45f85b46b2db26e050a1929233af20c54259cc/src/HtmlFormParser.php#L311-L320
|
237,729
|
jfusion/org.jfusion.curl
|
src/HtmlFormParser.php
|
HtmlFormParser._getId
|
function _getId($string)
{
if (preg_match('/id=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
//preg_match('/name=["\']?([\w\s]*)["\']?[\s>]/i', $string, $match)) { -- did not work as expected
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return $val_match;
}
return false;
}
|
php
|
function _getId($string)
{
if (preg_match('/id=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
//preg_match('/name=["\']?([\w\s]*)["\']?[\s>]/i', $string, $match)) { -- did not work as expected
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return $val_match;
}
return false;
}
|
[
"function",
"_getId",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/id=(\"([^\"]*)\"|\\'([^\\']*)\\'|[^>\\s]*)([^>]*)?>/is'",
",",
"$",
"string",
",",
"$",
"match",
")",
")",
"{",
"//preg_match('/name=[\"\\']?([\\w\\s]*)[\"\\']?[\\s>]/i', $string, $match)) { -- did not work as expected",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"val_match",
",",
"'\"\\''",
")",
";",
"unset",
"(",
"$",
"string",
")",
";",
"return",
"$",
"val_match",
";",
"}",
"return",
"false",
";",
"}"
] |
gets the id
@param string $string string
@return string something
|
[
"gets",
"the",
"id"
] |
9f45f85b46b2db26e050a1929233af20c54259cc
|
https://github.com/jfusion/org.jfusion.curl/blob/9f45f85b46b2db26e050a1929233af20c54259cc/src/HtmlFormParser.php#L329-L339
|
237,730
|
jfusion/org.jfusion.curl
|
src/HtmlFormParser.php
|
HtmlFormParser._getClass
|
function _getClass($string)
{
if (preg_match('/class=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return $val_match;
}
return false;
}
|
php
|
function _getClass($string)
{
if (preg_match('/class=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) {
$val_match = trim($match[1]);
$val_match = trim($val_match, '"\'');
unset($string);
return $val_match;
}
return false;
}
|
[
"function",
"_getClass",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/class=(\"([^\"]*)\"|\\'([^\\']*)\\'|[^>\\s]*)([^>]*)?>/is'",
",",
"$",
"string",
",",
"$",
"match",
")",
")",
"{",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"val_match",
"=",
"trim",
"(",
"$",
"val_match",
",",
"'\"\\''",
")",
";",
"unset",
"(",
"$",
"string",
")",
";",
"return",
"$",
"val_match",
";",
"}",
"return",
"false",
";",
"}"
] |
gets the class
@param string $string string
@return string something
|
[
"gets",
"the",
"class"
] |
9f45f85b46b2db26e050a1929233af20c54259cc
|
https://github.com/jfusion/org.jfusion.curl/blob/9f45f85b46b2db26e050a1929233af20c54259cc/src/HtmlFormParser.php#L348-L357
|
237,731
|
praxigento/mobi_mod_wallet
|
Plugin/Magento/Quote/Model/QuoteRepository.php
|
QuoteRepository.beforeDelete
|
public function beforeDelete(
$subject,
\Magento\Quote\Api\Data\CartInterface $quote
) {
$quoteId = $quote->getId();
$this->daoPartialQuote->deleteById($quoteId);
return [$quote];
}
|
php
|
public function beforeDelete(
$subject,
\Magento\Quote\Api\Data\CartInterface $quote
) {
$quoteId = $quote->getId();
$this->daoPartialQuote->deleteById($quoteId);
return [$quote];
}
|
[
"public",
"function",
"beforeDelete",
"(",
"$",
"subject",
",",
"\\",
"Magento",
"\\",
"Quote",
"\\",
"Api",
"\\",
"Data",
"\\",
"CartInterface",
"$",
"quote",
")",
"{",
"$",
"quoteId",
"=",
"$",
"quote",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"daoPartialQuote",
"->",
"deleteById",
"(",
"$",
"quoteId",
")",
";",
"return",
"[",
"$",
"quote",
"]",
";",
"}"
] |
Delete partial payment registry data before quote deletion.
@param $subject
@param \Magento\Quote\Api\Data\CartInterface $quote
@return array
@SuppressWarnings(PHPMD.UnusedFormalParameter)
|
[
"Delete",
"partial",
"payment",
"registry",
"data",
"before",
"quote",
"deletion",
"."
] |
8f4789645f2e3c95b1323984aa67215b1647fa39
|
https://github.com/praxigento/mobi_mod_wallet/blob/8f4789645f2e3c95b1323984aa67215b1647fa39/Plugin/Magento/Quote/Model/QuoteRepository.php#L31-L38
|
237,732
|
alanly/picnik
|
src/Picnik/Requests/AbstractRequest.php
|
AbstractRequest.setParameter
|
public function setParameter($key, $value)
{
if (is_bool($value)) $value = ($value ? 'true' : 'false');
$this->parameters[$key] = $value;
}
|
php
|
public function setParameter($key, $value)
{
if (is_bool($value)) $value = ($value ? 'true' : 'false');
$this->parameters[$key] = $value;
}
|
[
"public",
"function",
"setParameter",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"$",
"value",
"=",
"(",
"$",
"value",
"?",
"'true'",
":",
"'false'",
")",
";",
"$",
"this",
"->",
"parameters",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Set a parameter to be used for the request.
@param string $key
@param mixed $value
|
[
"Set",
"a",
"parameter",
"to",
"be",
"used",
"for",
"the",
"request",
"."
] |
17cf7afa43141f217b68ef181401f18b12ae2def
|
https://github.com/alanly/picnik/blob/17cf7afa43141f217b68ef181401f18b12ae2def/src/Picnik/Requests/AbstractRequest.php#L52-L57
|
237,733
|
alanly/picnik
|
src/Picnik/Requests/AbstractRequest.php
|
AbstractRequest.get
|
public function get()
{
// Include the API key into the request parameters.
$this->appendApiKeyToRequestParameters();
// Create the query target.
$target = $this->generateRequestTarget();
// Execute the request and return the parsed response.
return $this->performGetRequest($target, $this->parameters);
}
|
php
|
public function get()
{
// Include the API key into the request parameters.
$this->appendApiKeyToRequestParameters();
// Create the query target.
$target = $this->generateRequestTarget();
// Execute the request and return the parsed response.
return $this->performGetRequest($target, $this->parameters);
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"// Include the API key into the request parameters.",
"$",
"this",
"->",
"appendApiKeyToRequestParameters",
"(",
")",
";",
"// Create the query target.",
"$",
"target",
"=",
"$",
"this",
"->",
"generateRequestTarget",
"(",
")",
";",
"// Execute the request and return the parsed response.",
"return",
"$",
"this",
"->",
"performGetRequest",
"(",
"$",
"target",
",",
"$",
"this",
"->",
"parameters",
")",
";",
"}"
] |
Execute the request and return the parsed response.
@return mixed
|
[
"Execute",
"the",
"request",
"and",
"return",
"the",
"parsed",
"response",
"."
] |
17cf7afa43141f217b68ef181401f18b12ae2def
|
https://github.com/alanly/picnik/blob/17cf7afa43141f217b68ef181401f18b12ae2def/src/Picnik/Requests/AbstractRequest.php#L72-L82
|
237,734
|
alanly/picnik
|
src/Picnik/Requests/AbstractRequest.php
|
AbstractRequest.performGetRequest
|
protected function performGetRequest($target, $parameters)
{
$response = $this->doGetRequest($target, $parameters);
$result = $this->parseResponse($response);
return $result;
}
|
php
|
protected function performGetRequest($target, $parameters)
{
$response = $this->doGetRequest($target, $parameters);
$result = $this->parseResponse($response);
return $result;
}
|
[
"protected",
"function",
"performGetRequest",
"(",
"$",
"target",
",",
"$",
"parameters",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"doGetRequest",
"(",
"$",
"target",
",",
"$",
"parameters",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Orchestrates the GET request and response parsing.
@param string $target the target URL for the request
@param array $parameters the parameters for the request
@return mixed the parsed response
|
[
"Orchestrates",
"the",
"GET",
"request",
"and",
"response",
"parsing",
"."
] |
17cf7afa43141f217b68ef181401f18b12ae2def
|
https://github.com/alanly/picnik/blob/17cf7afa43141f217b68ef181401f18b12ae2def/src/Picnik/Requests/AbstractRequest.php#L90-L95
|
237,735
|
alanly/picnik
|
src/Picnik/Requests/AbstractRequest.php
|
AbstractRequest.doGetRequest
|
private function doGetRequest($target, $parameters)
{
// Execute the GET request to the given target, along with the given parameters.
$guzzle = $this->client->getGuzzle();
$response = $guzzle->get($target, ['query' => $parameters]);
return $response;
}
|
php
|
private function doGetRequest($target, $parameters)
{
// Execute the GET request to the given target, along with the given parameters.
$guzzle = $this->client->getGuzzle();
$response = $guzzle->get($target, ['query' => $parameters]);
return $response;
}
|
[
"private",
"function",
"doGetRequest",
"(",
"$",
"target",
",",
"$",
"parameters",
")",
"{",
"// Execute the GET request to the given target, along with the given parameters.",
"$",
"guzzle",
"=",
"$",
"this",
"->",
"client",
"->",
"getGuzzle",
"(",
")",
";",
"$",
"response",
"=",
"$",
"guzzle",
"->",
"get",
"(",
"$",
"target",
",",
"[",
"'query'",
"=>",
"$",
"parameters",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Executes the GET request over the given target with the given GET parameters.
@param string $target the target URL for the request
@param array $parameters the parameters for the request
@return ResponseInterface
|
[
"Executes",
"the",
"GET",
"request",
"over",
"the",
"given",
"target",
"with",
"the",
"given",
"GET",
"parameters",
"."
] |
17cf7afa43141f217b68ef181401f18b12ae2def
|
https://github.com/alanly/picnik/blob/17cf7afa43141f217b68ef181401f18b12ae2def/src/Picnik/Requests/AbstractRequest.php#L116-L122
|
237,736
|
alanly/picnik
|
src/Picnik/Requests/AbstractRequest.php
|
AbstractRequest.appendApiKeyToRequestParameters
|
private function appendApiKeyToRequestParameters()
{
if (! $this->client->getApiKey())
throw new AuthorizationException('Missing API key.');
$this->setParameter(
Client::API_KEY_PARAM_NAME,
$this->client->getApiKey()
);
}
|
php
|
private function appendApiKeyToRequestParameters()
{
if (! $this->client->getApiKey())
throw new AuthorizationException('Missing API key.');
$this->setParameter(
Client::API_KEY_PARAM_NAME,
$this->client->getApiKey()
);
}
|
[
"private",
"function",
"appendApiKeyToRequestParameters",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"client",
"->",
"getApiKey",
"(",
")",
")",
"throw",
"new",
"AuthorizationException",
"(",
"'Missing API key.'",
")",
";",
"$",
"this",
"->",
"setParameter",
"(",
"Client",
"::",
"API_KEY_PARAM_NAME",
",",
"$",
"this",
"->",
"client",
"->",
"getApiKey",
"(",
")",
")",
";",
"}"
] |
Gets the API key from the Client instance and adds it to the request
parameters. An `AuthorizationException` is thrown when the API key is
missing from the Client.
@throws AuthorizationException If API key is missing.
|
[
"Gets",
"the",
"API",
"key",
"from",
"the",
"Client",
"instance",
"and",
"adds",
"it",
"to",
"the",
"request",
"parameters",
".",
"An",
"AuthorizationException",
"is",
"thrown",
"when",
"the",
"API",
"key",
"is",
"missing",
"from",
"the",
"Client",
"."
] |
17cf7afa43141f217b68ef181401f18b12ae2def
|
https://github.com/alanly/picnik/blob/17cf7afa43141f217b68ef181401f18b12ae2def/src/Picnik/Requests/AbstractRequest.php#L130-L139
|
237,737
|
AnonymPHP/Anonym-Library
|
src/Anonym/Mail/Mail.php
|
Mail.driver
|
public function driver($driver = '', array $configs = [])
{
$driverList = $this->defaultDriverList;
if (isset($driverList[$driver])) {
$driver = $driverList[$driver];
$driver = new $driver($configs);
if ($driver instanceof DriverInterface) {
return $driver;
} else {
throw new DriverException(sprintf('your %s driver has not Driver Interface', get_class($driver)));
}
} else {
throw new DriverNotInstalledException(sprintf('your %s driver is not installed', $driver));
}
}
|
php
|
public function driver($driver = '', array $configs = [])
{
$driverList = $this->defaultDriverList;
if (isset($driverList[$driver])) {
$driver = $driverList[$driver];
$driver = new $driver($configs);
if ($driver instanceof DriverInterface) {
return $driver;
} else {
throw new DriverException(sprintf('your %s driver has not Driver Interface', get_class($driver)));
}
} else {
throw new DriverNotInstalledException(sprintf('your %s driver is not installed', $driver));
}
}
|
[
"public",
"function",
"driver",
"(",
"$",
"driver",
"=",
"''",
",",
"array",
"$",
"configs",
"=",
"[",
"]",
")",
"{",
"$",
"driverList",
"=",
"$",
"this",
"->",
"defaultDriverList",
";",
"if",
"(",
"isset",
"(",
"$",
"driverList",
"[",
"$",
"driver",
"]",
")",
")",
"{",
"$",
"driver",
"=",
"$",
"driverList",
"[",
"$",
"driver",
"]",
";",
"$",
"driver",
"=",
"new",
"$",
"driver",
"(",
"$",
"configs",
")",
";",
"if",
"(",
"$",
"driver",
"instanceof",
"DriverInterface",
")",
"{",
"return",
"$",
"driver",
";",
"}",
"else",
"{",
"throw",
"new",
"DriverException",
"(",
"sprintf",
"(",
"'your %s driver has not Driver Interface'",
",",
"get_class",
"(",
"$",
"driver",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"DriverNotInstalledException",
"(",
"sprintf",
"(",
"'your %s driver is not installed'",
",",
"$",
"driver",
")",
")",
";",
"}",
"}"
] |
select a driver
@param string $driver the name of driver
@param array $configs the configs for driver
@throws DriverException
@throws DriverNotInstalledException
@return DriverInterface if driver name isset in driver list, return the driver instance, else return false
|
[
"select",
"a",
"driver"
] |
c967ad804f84e8fb204593a0959cda2fed5ae075
|
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Mail/Mail.php#L57-L73
|
237,738
|
AnonymPHP/Anonym-Library
|
src/Anonym/Mail/Mail.php
|
Mail.send
|
public function send($name = '', callable $callback)
{
$configs = Config::get($name);
$driver = $this->driver(isset($configs['driver']) ? $configs['driver']: 'swift', $configs);
return $callback($driver);
}
|
php
|
public function send($name = '', callable $callback)
{
$configs = Config::get($name);
$driver = $this->driver(isset($configs['driver']) ? $configs['driver']: 'swift', $configs);
return $callback($driver);
}
|
[
"public",
"function",
"send",
"(",
"$",
"name",
"=",
"''",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"configs",
"=",
"Config",
"::",
"get",
"(",
"$",
"name",
")",
";",
"$",
"driver",
"=",
"$",
"this",
"->",
"driver",
"(",
"isset",
"(",
"$",
"configs",
"[",
"'driver'",
"]",
")",
"?",
"$",
"configs",
"[",
"'driver'",
"]",
":",
"'swift'",
",",
"$",
"configs",
")",
";",
"return",
"$",
"callback",
"(",
"$",
"driver",
")",
";",
"}"
] |
send the mail with config name and closure callback
@param string $name
@param callable $callback
@return mixed
@throws DriverException
@throws DriverNotInstalledException
|
[
"send",
"the",
"mail",
"with",
"config",
"name",
"and",
"closure",
"callback"
] |
c967ad804f84e8fb204593a0959cda2fed5ae075
|
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Mail/Mail.php#L114-L120
|
237,739
|
codebobbly/dvoconnector
|
Classes/Utility/TemplateLayout.php
|
TemplateLayout.getAvailableTemplateLayouts
|
public function getAvailableTemplateLayouts($pageUid)
{
$templateLayouts = [];
// Check if the layouts are extended by ext_tables
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts'])
&& is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts'])
) {
$templateLayouts = $GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts'];
}
// Add TsConfig values
foreach ($this->getTemplateLayoutsFromTsConfig($pageUid) as $templateKey => $title) {
if (GeneralUtility::isFirstPartOfStr($title, '--div--')) {
$optGroupParts = GeneralUtility::trimExplode(',', $title, true, 2);
$title = $optGroupParts[1];
$templateKey = $optGroupParts[0];
}
$templateLayouts[] = [$title, $templateKey];
}
return $templateLayouts;
}
|
php
|
public function getAvailableTemplateLayouts($pageUid)
{
$templateLayouts = [];
// Check if the layouts are extended by ext_tables
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts'])
&& is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts'])
) {
$templateLayouts = $GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts'];
}
// Add TsConfig values
foreach ($this->getTemplateLayoutsFromTsConfig($pageUid) as $templateKey => $title) {
if (GeneralUtility::isFirstPartOfStr($title, '--div--')) {
$optGroupParts = GeneralUtility::trimExplode(',', $title, true, 2);
$title = $optGroupParts[1];
$templateKey = $optGroupParts[0];
}
$templateLayouts[] = [$title, $templateKey];
}
return $templateLayouts;
}
|
[
"public",
"function",
"getAvailableTemplateLayouts",
"(",
"$",
"pageUid",
")",
"{",
"$",
"templateLayouts",
"=",
"[",
"]",
";",
"// Check if the layouts are extended by ext_tables",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'EXT'",
"]",
"[",
"'dvoconnector'",
"]",
"[",
"'templateLayouts'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'EXT'",
"]",
"[",
"'dvoconnector'",
"]",
"[",
"'templateLayouts'",
"]",
")",
")",
"{",
"$",
"templateLayouts",
"=",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'EXT'",
"]",
"[",
"'dvoconnector'",
"]",
"[",
"'templateLayouts'",
"]",
";",
"}",
"// Add TsConfig values",
"foreach",
"(",
"$",
"this",
"->",
"getTemplateLayoutsFromTsConfig",
"(",
"$",
"pageUid",
")",
"as",
"$",
"templateKey",
"=>",
"$",
"title",
")",
"{",
"if",
"(",
"GeneralUtility",
"::",
"isFirstPartOfStr",
"(",
"$",
"title",
",",
"'--div--'",
")",
")",
"{",
"$",
"optGroupParts",
"=",
"GeneralUtility",
"::",
"trimExplode",
"(",
"','",
",",
"$",
"title",
",",
"true",
",",
"2",
")",
";",
"$",
"title",
"=",
"$",
"optGroupParts",
"[",
"1",
"]",
";",
"$",
"templateKey",
"=",
"$",
"optGroupParts",
"[",
"0",
"]",
";",
"}",
"$",
"templateLayouts",
"[",
"]",
"=",
"[",
"$",
"title",
",",
"$",
"templateKey",
"]",
";",
"}",
"return",
"$",
"templateLayouts",
";",
"}"
] |
Get available template layouts for a certain page
@param int $pageUid
@return array
|
[
"Get",
"available",
"template",
"layouts",
"for",
"a",
"certain",
"page"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Utility/TemplateLayout.php#L21-L43
|
237,740
|
codebobbly/dvoconnector
|
Classes/Utility/TemplateLayout.php
|
TemplateLayout.getTemplateLayoutsFromTsConfig
|
protected function getTemplateLayoutsFromTsConfig($pageUid)
{
$templateLayouts = [];
$pagesTsConfig = BackendUtility::getPagesTSconfig($pageUid);
if (isset($pagesTsConfig['tx_dvoconnector.']['templateLayouts.']) && is_array($pagesTsConfig['tx_dvoconnector.']['templateLayouts.'])) {
$templateLayouts = $pagesTsConfig['tx_dvoconnector.']['templateLayouts.'];
}
return $templateLayouts;
}
|
php
|
protected function getTemplateLayoutsFromTsConfig($pageUid)
{
$templateLayouts = [];
$pagesTsConfig = BackendUtility::getPagesTSconfig($pageUid);
if (isset($pagesTsConfig['tx_dvoconnector.']['templateLayouts.']) && is_array($pagesTsConfig['tx_dvoconnector.']['templateLayouts.'])) {
$templateLayouts = $pagesTsConfig['tx_dvoconnector.']['templateLayouts.'];
}
return $templateLayouts;
}
|
[
"protected",
"function",
"getTemplateLayoutsFromTsConfig",
"(",
"$",
"pageUid",
")",
"{",
"$",
"templateLayouts",
"=",
"[",
"]",
";",
"$",
"pagesTsConfig",
"=",
"BackendUtility",
"::",
"getPagesTSconfig",
"(",
"$",
"pageUid",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"pagesTsConfig",
"[",
"'tx_dvoconnector.'",
"]",
"[",
"'templateLayouts.'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"pagesTsConfig",
"[",
"'tx_dvoconnector.'",
"]",
"[",
"'templateLayouts.'",
"]",
")",
")",
"{",
"$",
"templateLayouts",
"=",
"$",
"pagesTsConfig",
"[",
"'tx_dvoconnector.'",
"]",
"[",
"'templateLayouts.'",
"]",
";",
"}",
"return",
"$",
"templateLayouts",
";",
"}"
] |
Get template layouts defined in TsConfig
@param $pageUid
@return array
|
[
"Get",
"template",
"layouts",
"defined",
"in",
"TsConfig"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Utility/TemplateLayout.php#L51-L59
|
237,741
|
sebardo/ecommerce
|
EcommerceBundle/Entity/Repository/ProductRepository.php
|
ProductRepository.findSameCategoryProduct
|
public function findSameCategoryProduct($product, $direction)
{
$qb = $this->getQueryBuilder()
->select('p')
->andWhere('p.category = :category')
->setMaxResults(1)
->setParameter('category', $product->getCategory());
if ('next' == $direction) {
$qb->andWhere('p.id > :id')
->orderBy('p.id', 'asc');
} else {
$qb->andWhere('p.id < :id')
->orderBy('p.id', 'desc');
}
$qb->setParameter('id', $product->getId());
if (0 == count($qb->getQuery()->getResult())) {
return null;
}
return $qb->getQuery()
->getSingleResult();
}
|
php
|
public function findSameCategoryProduct($product, $direction)
{
$qb = $this->getQueryBuilder()
->select('p')
->andWhere('p.category = :category')
->setMaxResults(1)
->setParameter('category', $product->getCategory());
if ('next' == $direction) {
$qb->andWhere('p.id > :id')
->orderBy('p.id', 'asc');
} else {
$qb->andWhere('p.id < :id')
->orderBy('p.id', 'desc');
}
$qb->setParameter('id', $product->getId());
if (0 == count($qb->getQuery()->getResult())) {
return null;
}
return $qb->getQuery()
->getSingleResult();
}
|
[
"public",
"function",
"findSameCategoryProduct",
"(",
"$",
"product",
",",
"$",
"direction",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'p'",
")",
"->",
"andWhere",
"(",
"'p.category = :category'",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"setParameter",
"(",
"'category'",
",",
"$",
"product",
"->",
"getCategory",
"(",
")",
")",
";",
"if",
"(",
"'next'",
"==",
"$",
"direction",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'p.id > :id'",
")",
"->",
"orderBy",
"(",
"'p.id'",
",",
"'asc'",
")",
";",
"}",
"else",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'p.id < :id'",
")",
"->",
"orderBy",
"(",
"'p.id'",
",",
"'desc'",
")",
";",
"}",
"$",
"qb",
"->",
"setParameter",
"(",
"'id'",
",",
"$",
"product",
"->",
"getId",
"(",
")",
")",
";",
"if",
"(",
"0",
"==",
"count",
"(",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getSingleResult",
"(",
")",
";",
"}"
] |
Find a product from the same category
@param Product $product
@param string $direction
@return Product|null
|
[
"Find",
"a",
"product",
"from",
"the",
"same",
"category"
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/ProductRepository.php#L317-L341
|
237,742
|
sebardo/ecommerce
|
EcommerceBundle/Entity/Repository/ProductRepository.php
|
ProductRepository.findNews
|
public function findNews($family, $limit = null)
{
$qb = $this->getQueryBuilder()
->orderBy('p.highlighted', 'desc')
->addOrderBy('p.createdAt', 'desc');
// filter by family
if (!is_null($family)) {
$qb->innerJoin('p.category', 'c')
->innerJoin('c.parentCategory', 'pc')
->andWhere('pc.family = :family')
->setParameter('family', $family);
}
if (!is_null($limit)) {
$qb->setMaxResults($limit);
}
return $qb->getQuery()
->getResult();
}
|
php
|
public function findNews($family, $limit = null)
{
$qb = $this->getQueryBuilder()
->orderBy('p.highlighted', 'desc')
->addOrderBy('p.createdAt', 'desc');
// filter by family
if (!is_null($family)) {
$qb->innerJoin('p.category', 'c')
->innerJoin('c.parentCategory', 'pc')
->andWhere('pc.family = :family')
->setParameter('family', $family);
}
if (!is_null($limit)) {
$qb->setMaxResults($limit);
}
return $qb->getQuery()
->getResult();
}
|
[
"public",
"function",
"findNews",
"(",
"$",
"family",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"orderBy",
"(",
"'p.highlighted'",
",",
"'desc'",
")",
"->",
"addOrderBy",
"(",
"'p.createdAt'",
",",
"'desc'",
")",
";",
"// filter by family",
"if",
"(",
"!",
"is_null",
"(",
"$",
"family",
")",
")",
"{",
"$",
"qb",
"->",
"innerJoin",
"(",
"'p.category'",
",",
"'c'",
")",
"->",
"innerJoin",
"(",
"'c.parentCategory'",
",",
"'pc'",
")",
"->",
"andWhere",
"(",
"'pc.family = :family'",
")",
"->",
"setParameter",
"(",
"'family'",
",",
"$",
"family",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"limit",
")",
")",
"{",
"$",
"qb",
"->",
"setMaxResults",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Find new products
@param Family|null $family
@param int|null $limit
@return ArrayCollection
|
[
"Find",
"new",
"products"
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/ProductRepository.php#L351-L371
|
237,743
|
sebardo/ecommerce
|
EcommerceBundle/Entity/Repository/ProductRepository.php
|
ProductRepository.findAttributeValues
|
public function findAttributeValues($product)
{
// select
$qb = $this->getQueryBuilder()
->select('a.name attributeName, av.name, i.path imagePath');
// join
$qb->join('p.attributeValues', 'av')
->join('av.attribute', 'a')
->leftJoin('av.image', 'i');
// where
$qb->andWhere('p = :product')
->setParameter('product', $product);
// order by
$qb->orderBy('a.order', 'asc');
return $qb->getQuery()
->getResult();
}
|
php
|
public function findAttributeValues($product)
{
// select
$qb = $this->getQueryBuilder()
->select('a.name attributeName, av.name, i.path imagePath');
// join
$qb->join('p.attributeValues', 'av')
->join('av.attribute', 'a')
->leftJoin('av.image', 'i');
// where
$qb->andWhere('p = :product')
->setParameter('product', $product);
// order by
$qb->orderBy('a.order', 'asc');
return $qb->getQuery()
->getResult();
}
|
[
"public",
"function",
"findAttributeValues",
"(",
"$",
"product",
")",
"{",
"// select",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'a.name attributeName, av.name, i.path imagePath'",
")",
";",
"// join",
"$",
"qb",
"->",
"join",
"(",
"'p.attributeValues'",
",",
"'av'",
")",
"->",
"join",
"(",
"'av.attribute'",
",",
"'a'",
")",
"->",
"leftJoin",
"(",
"'av.image'",
",",
"'i'",
")",
";",
"// where",
"$",
"qb",
"->",
"andWhere",
"(",
"'p = :product'",
")",
"->",
"setParameter",
"(",
"'product'",
",",
"$",
"product",
")",
";",
"// order by",
"$",
"qb",
"->",
"orderBy",
"(",
"'a.order'",
",",
"'asc'",
")",
";",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Find sorted attribute values
@param Product $product
@return ArrayCollection
|
[
"Find",
"sorted",
"attribute",
"values"
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/ProductRepository.php#L553-L573
|
237,744
|
sebardo/ecommerce
|
EcommerceBundle/Entity/Repository/ProductRepository.php
|
ProductRepository.getQueryProductsAssembly
|
public function getQueryProductsAssembly()
{
$category_id = $this->getEntityManager()->getRepository('EcommerceBundle:Category')->AssemblyCategory();
return $this->createQueryBuilder('p')
->where('p.category = :category_id')
->setParameter('category_id', $category_id);
}
|
php
|
public function getQueryProductsAssembly()
{
$category_id = $this->getEntityManager()->getRepository('EcommerceBundle:Category')->AssemblyCategory();
return $this->createQueryBuilder('p')
->where('p.category = :category_id')
->setParameter('category_id', $category_id);
}
|
[
"public",
"function",
"getQueryProductsAssembly",
"(",
")",
"{",
"$",
"category_id",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"getRepository",
"(",
"'EcommerceBundle:Category'",
")",
"->",
"AssemblyCategory",
"(",
")",
";",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'p'",
")",
"->",
"where",
"(",
"'p.category = :category_id'",
")",
"->",
"setParameter",
"(",
"'category_id'",
",",
"$",
"category_id",
")",
";",
"}"
] |
Return products of the assembly category
@return \Doctrine\ORM\QueryBuilder
|
[
"Return",
"products",
"of",
"the",
"assembly",
"category"
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/ProductRepository.php#L628-L634
|
237,745
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.start
|
private function start($message, $hook = true) {
if (!isset($this->status))
$this->status = new \SplStack;
if($hook)
$this->applyHooks ('Pre', $message);
$this->status->push([
microtime(true),
$message,
]);
if ($this->verbose >= 1)
echo PHP_EOL, str_repeat("\t", $this->status->count() - 1), $message, '... ';
return $this;
}
|
php
|
private function start($message, $hook = true) {
if (!isset($this->status))
$this->status = new \SplStack;
if($hook)
$this->applyHooks ('Pre', $message);
$this->status->push([
microtime(true),
$message,
]);
if ($this->verbose >= 1)
echo PHP_EOL, str_repeat("\t", $this->status->count() - 1), $message, '... ';
return $this;
}
|
[
"private",
"function",
"start",
"(",
"$",
"message",
",",
"$",
"hook",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"status",
")",
")",
"$",
"this",
"->",
"status",
"=",
"new",
"\\",
"SplStack",
";",
"if",
"(",
"$",
"hook",
")",
"$",
"this",
"->",
"applyHooks",
"(",
"'Pre'",
",",
"$",
"message",
")",
";",
"$",
"this",
"->",
"status",
"->",
"push",
"(",
"[",
"microtime",
"(",
"true",
")",
",",
"$",
"message",
",",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"verbose",
">=",
"1",
")",
"echo",
"PHP_EOL",
",",
"str_repeat",
"(",
"\"\\t\"",
",",
"$",
"this",
"->",
"status",
"->",
"count",
"(",
")",
"-",
"1",
")",
",",
"$",
"message",
",",
"'... '",
";",
"return",
"$",
"this",
";",
"}"
] |
Report current action being taken
@param string $message
|
[
"Report",
"current",
"action",
"being",
"taken"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L315-L332
|
237,746
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.rglob
|
protected final static function rglob($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir)
$files = array_merge(self::rglob($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags), $files);
return $files;
}
|
php
|
protected final static function rglob($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir)
$files = array_merge(self::rglob($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags), $files);
return $files;
}
|
[
"protected",
"final",
"static",
"function",
"rglob",
"(",
"$",
"pattern",
",",
"$",
"flags",
"=",
"0",
")",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"pattern",
",",
"$",
"flags",
")",
";",
"foreach",
"(",
"glob",
"(",
"dirname",
"(",
"$",
"pattern",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'*'",
",",
"GLOB_ONLYDIR",
"|",
"GLOB_NOSORT",
")",
"as",
"$",
"dir",
")",
"$",
"files",
"=",
"array_merge",
"(",
"self",
"::",
"rglob",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"basename",
"(",
"$",
"pattern",
")",
",",
"$",
"flags",
")",
",",
"$",
"files",
")",
";",
"return",
"$",
"files",
";",
"}"
] |
Recursively gets files in path
@param string $pattern
@param byte $flags
@return array
|
[
"Recursively",
"gets",
"files",
"in",
"path"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L383-L388
|
237,747
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.readyDir
|
protected final static function readyDir($dir) {
if(is_file($dir))
return false;
if (!is_dir(dirname($dir)))
return mkdir(dirname($dir), 0777, true);
return true;
}
|
php
|
protected final static function readyDir($dir) {
if(is_file($dir))
return false;
if (!is_dir(dirname($dir)))
return mkdir(dirname($dir), 0777, true);
return true;
}
|
[
"protected",
"final",
"static",
"function",
"readyDir",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"dir",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"dir",
")",
")",
")",
"return",
"mkdir",
"(",
"dirname",
"(",
"$",
"dir",
")",
",",
"0777",
",",
"true",
")",
";",
"return",
"true",
";",
"}"
] |
Makes all directories leading up to given file or folder
@param string $dir path
@return boolean successful
|
[
"Makes",
"all",
"directories",
"leading",
"up",
"to",
"given",
"file",
"or",
"folder"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L406-L414
|
237,748
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.wipeDir
|
protected final static function wipeDir($dir, $rmdir = false) {
if (file_exists($dir)) {
$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file)
if ($file->isDir())
self::wipeDir($file->getRealPath(), true); //rmdir($file->getRealPath());
else
unlink($file->getRealPath());
if ($rmdir)
rmdir($dir);
}
}
|
php
|
protected final static function wipeDir($dir, $rmdir = false) {
if (file_exists($dir)) {
$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file)
if ($file->isDir())
self::wipeDir($file->getRealPath(), true); //rmdir($file->getRealPath());
else
unlink($file->getRealPath());
if ($rmdir)
rmdir($dir);
}
}
|
[
"protected",
"final",
"static",
"function",
"wipeDir",
"(",
"$",
"dir",
",",
"$",
"rmdir",
"=",
"false",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"it",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"dir",
",",
"\\",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
";",
"$",
"files",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"it",
",",
"\\",
"RecursiveIteratorIterator",
"::",
"CHILD_FIRST",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"self",
"::",
"wipeDir",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"true",
")",
";",
"//rmdir($file->getRealPath());",
"else",
"unlink",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"if",
"(",
"$",
"rmdir",
")",
"rmdir",
"(",
"$",
"dir",
")",
";",
"}",
"}"
] |
Remove everything in a directory
@param string $dir directiory to wipe
@param boolean $rmdir remove directory also?
|
[
"Remove",
"everything",
"in",
"a",
"directory"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L422-L437
|
237,749
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.commandExists
|
private static function commandExists($command) {
$whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'which';
$process = proc_open("$whereIsCommand $command", [
0 => array("pipe", "r"), //STDIN
1 => array("pipe", "w"), //STDOUT
2 => array("pipe", "w"), //STDERR
], $pipes);
if ($process !== false) {
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $stdout != '';
}
return false;
}
|
php
|
private static function commandExists($command) {
$whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'which';
$process = proc_open("$whereIsCommand $command", [
0 => array("pipe", "r"), //STDIN
1 => array("pipe", "w"), //STDOUT
2 => array("pipe", "w"), //STDERR
], $pipes);
if ($process !== false) {
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $stdout != '';
}
return false;
}
|
[
"private",
"static",
"function",
"commandExists",
"(",
"$",
"command",
")",
"{",
"$",
"whereIsCommand",
"=",
"(",
"PHP_OS",
"==",
"'WINNT'",
")",
"?",
"'where'",
":",
"'which'",
";",
"$",
"process",
"=",
"proc_open",
"(",
"\"$whereIsCommand $command\"",
",",
"[",
"0",
"=>",
"array",
"(",
"\"pipe\"",
",",
"\"r\"",
")",
",",
"//STDIN",
"1",
"=>",
"array",
"(",
"\"pipe\"",
",",
"\"w\"",
")",
",",
"//STDOUT",
"2",
"=>",
"array",
"(",
"\"pipe\"",
",",
"\"w\"",
")",
",",
"//STDERR",
"]",
",",
"$",
"pipes",
")",
";",
"if",
"(",
"$",
"process",
"!==",
"false",
")",
"{",
"$",
"stdout",
"=",
"stream_get_contents",
"(",
"$",
"pipes",
"[",
"1",
"]",
")",
";",
"$",
"stderr",
"=",
"stream_get_contents",
"(",
"$",
"pipes",
"[",
"2",
"]",
")",
";",
"fclose",
"(",
"$",
"pipes",
"[",
"1",
"]",
")",
";",
"fclose",
"(",
"$",
"pipes",
"[",
"2",
"]",
")",
";",
"proc_close",
"(",
"$",
"process",
")",
";",
"return",
"$",
"stdout",
"!=",
"''",
";",
"}",
"return",
"false",
";",
"}"
] |
Determines if a command exists on the current environment
@link http://stackoverflow.com/a/18540185
@param string $command The command to check
@return bool True if the command has been found ; otherwise, false.
|
[
"Determines",
"if",
"a",
"command",
"exists",
"on",
"the",
"current",
"environment"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L458-L477
|
237,750
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.checkBinaries
|
public static function checkBinaries(\Composer\Script\Event $event) {
foreach (self::$binaries as $cmd) {
if (!self::commandExists($cmd))
throw new \Exception('Binary "' . $cmd . '" not found in PATH');
// $event->getIO()->write($cmd . ' found.');
}
}
|
php
|
public static function checkBinaries(\Composer\Script\Event $event) {
foreach (self::$binaries as $cmd) {
if (!self::commandExists($cmd))
throw new \Exception('Binary "' . $cmd . '" not found in PATH');
// $event->getIO()->write($cmd . ' found.');
}
}
|
[
"public",
"static",
"function",
"checkBinaries",
"(",
"\\",
"Composer",
"\\",
"Script",
"\\",
"Event",
"$",
"event",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"binaries",
"as",
"$",
"cmd",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"commandExists",
"(",
"$",
"cmd",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Binary \"'",
".",
"$",
"cmd",
".",
"'\" not found in PATH'",
")",
";",
"// $event->getIO()->write($cmd . ' found.');",
"}",
"}"
] |
Makes sure all binaries are on system
@param \Composer\Script\Event $event
@throws Exception
|
[
"Makes",
"sure",
"all",
"binaries",
"are",
"on",
"system"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L485-L492
|
237,751
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.makeTpl
|
private function makeTpl() {
$this->localTpl = rtrim($this->localTpl, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$this->wipe[] = $output = self::path(sys_get_temp_dir()) . 'twigjs' . time() . DIRECTORY_SEPARATOR;
self::readyDir($output);
$data = array();
foreach (self::rglob($this->localTpl . '*.twig') as $file) {
$id = substr($file, strlen($this->localTpl));
$data[ $id ] = file_get_contents($file);
}
file_put_contents($output . 'tpl.js', 'var templates = '. json_encode($data) .';');
$this->addLocalStatic('js', $output);
//$this->addCopy($this->localTpl);
return $this;
}
|
php
|
private function makeTpl() {
$this->localTpl = rtrim($this->localTpl, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$this->wipe[] = $output = self::path(sys_get_temp_dir()) . 'twigjs' . time() . DIRECTORY_SEPARATOR;
self::readyDir($output);
$data = array();
foreach (self::rglob($this->localTpl . '*.twig') as $file) {
$id = substr($file, strlen($this->localTpl));
$data[ $id ] = file_get_contents($file);
}
file_put_contents($output . 'tpl.js', 'var templates = '. json_encode($data) .';');
$this->addLocalStatic('js', $output);
//$this->addCopy($this->localTpl);
return $this;
}
|
[
"private",
"function",
"makeTpl",
"(",
")",
"{",
"$",
"this",
"->",
"localTpl",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"localTpl",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"$",
"this",
"->",
"wipe",
"[",
"]",
"=",
"$",
"output",
"=",
"self",
"::",
"path",
"(",
"sys_get_temp_dir",
"(",
")",
")",
".",
"'twigjs'",
".",
"time",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"self",
"::",
"readyDir",
"(",
"$",
"output",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"rglob",
"(",
"$",
"this",
"->",
"localTpl",
".",
"'*.twig'",
")",
"as",
"$",
"file",
")",
"{",
"$",
"id",
"=",
"substr",
"(",
"$",
"file",
",",
"strlen",
"(",
"$",
"this",
"->",
"localTpl",
")",
")",
";",
"$",
"data",
"[",
"$",
"id",
"]",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"output",
".",
"'tpl.js'",
",",
"'var templates = '",
".",
"json_encode",
"(",
"$",
"data",
")",
".",
"';'",
")",
";",
"$",
"this",
"->",
"addLocalStatic",
"(",
"'js'",
",",
"$",
"output",
")",
";",
"//$this->addCopy($this->localTpl);",
"return",
"$",
"this",
";",
"}"
] |
Make Twig Templates in Javascript
Makes JS files in current directory then moves them to static JS
|
[
"Make",
"Twig",
"Templates",
"in",
"Javascript"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L503-L521
|
237,752
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.makeDoc
|
private function makeDoc() {
//wipe destination directory manually
$neon = file_get_contents($this->localDoc);
$data = \Nette\Neon\Neon::decode($neon);
$dest = $data['destination'];
// wipe before and after
self::wipeDir($dest, true);
$this->wipe[] = $dest;
return $this->runLocal([self::BIN . 'apigen.bat',
'generate',
'--config', $this->localDoc,
]);
}
|
php
|
private function makeDoc() {
//wipe destination directory manually
$neon = file_get_contents($this->localDoc);
$data = \Nette\Neon\Neon::decode($neon);
$dest = $data['destination'];
// wipe before and after
self::wipeDir($dest, true);
$this->wipe[] = $dest;
return $this->runLocal([self::BIN . 'apigen.bat',
'generate',
'--config', $this->localDoc,
]);
}
|
[
"private",
"function",
"makeDoc",
"(",
")",
"{",
"//wipe destination directory manually",
"$",
"neon",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"localDoc",
")",
";",
"$",
"data",
"=",
"\\",
"Nette",
"\\",
"Neon",
"\\",
"Neon",
"::",
"decode",
"(",
"$",
"neon",
")",
";",
"$",
"dest",
"=",
"$",
"data",
"[",
"'destination'",
"]",
";",
"// wipe before and after",
"self",
"::",
"wipeDir",
"(",
"$",
"dest",
",",
"true",
")",
";",
"$",
"this",
"->",
"wipe",
"[",
"]",
"=",
"$",
"dest",
";",
"return",
"$",
"this",
"->",
"runLocal",
"(",
"[",
"self",
"::",
"BIN",
".",
"'apigen.bat'",
",",
"'generate'",
",",
"'--config'",
",",
"$",
"this",
"->",
"localDoc",
",",
"]",
")",
";",
"}"
] |
Make Documentation for site
|
[
"Make",
"Documentation",
"for",
"site"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L527-L543
|
237,753
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.sass
|
private function sass() {
// get all sass dirs
foreach ($this->localStatic[ __FUNCTION__ ] as $dir) {
$this->start('Converting SASS to CSS in ' . $dir);
foreach (glob($dir . DIRECTORY_SEPARATOR . '*.{scss,sass}', GLOB_BRACE) as $file) {
//skip if partial
$output = basename($file);
if (substr($output, 0, 1) === '_')
continue;
$this->start('Working on ' . $output);
$scss = (substr($file, -5) === '.scss');
// Add Constants variables
if(isset($GLOBALS["constants"])) {
$old = $file;
// sass which will actuall be compiled [hidden]
$file .= md5(time()) . '.sex';
$f = fopen($file, 'w');
exec('attrib +H ' . escapeshellarg($file));
// get the URL Constants
$const = array();
foreach ($GLOBALS["constants"] as $name => $val)
$const[] = '$const-' . str_replace('\\', '-', strtolower($name)) . ': \'' . $val . '\' !default;';
// add URL vars to temp sass file
fwrite($f, implode(PHP_EOL, $const));
fwrite($f, file_get_contents($old));
fclose($f);
}
// the correct path for output
echo $output = $this->tmp[ __FUNCTION__ ] . $output;
$output = substr($output, 0, -4) . 'css';
// make sure path is ready
self::readyDir($output);
// run sass
$this->runLocal(['sass',
($scss ? '--scss' : null),
'--trace',
'--unix-newlines',
'--style',
($this->compress ? 'compressed --sourcemap=none' : 'expanded -l'),
$file,
$output,
]);
$this->finish();
}
foreach (glob($dir . DIRECTORY_SEPARATOR . '*.sex') as $file)
unlink($file);
$this->finish();
}
return $this;
}
|
php
|
private function sass() {
// get all sass dirs
foreach ($this->localStatic[ __FUNCTION__ ] as $dir) {
$this->start('Converting SASS to CSS in ' . $dir);
foreach (glob($dir . DIRECTORY_SEPARATOR . '*.{scss,sass}', GLOB_BRACE) as $file) {
//skip if partial
$output = basename($file);
if (substr($output, 0, 1) === '_')
continue;
$this->start('Working on ' . $output);
$scss = (substr($file, -5) === '.scss');
// Add Constants variables
if(isset($GLOBALS["constants"])) {
$old = $file;
// sass which will actuall be compiled [hidden]
$file .= md5(time()) . '.sex';
$f = fopen($file, 'w');
exec('attrib +H ' . escapeshellarg($file));
// get the URL Constants
$const = array();
foreach ($GLOBALS["constants"] as $name => $val)
$const[] = '$const-' . str_replace('\\', '-', strtolower($name)) . ': \'' . $val . '\' !default;';
// add URL vars to temp sass file
fwrite($f, implode(PHP_EOL, $const));
fwrite($f, file_get_contents($old));
fclose($f);
}
// the correct path for output
echo $output = $this->tmp[ __FUNCTION__ ] . $output;
$output = substr($output, 0, -4) . 'css';
// make sure path is ready
self::readyDir($output);
// run sass
$this->runLocal(['sass',
($scss ? '--scss' : null),
'--trace',
'--unix-newlines',
'--style',
($this->compress ? 'compressed --sourcemap=none' : 'expanded -l'),
$file,
$output,
]);
$this->finish();
}
foreach (glob($dir . DIRECTORY_SEPARATOR . '*.sex') as $file)
unlink($file);
$this->finish();
}
return $this;
}
|
[
"private",
"function",
"sass",
"(",
")",
"{",
"// get all sass dirs",
"foreach",
"(",
"$",
"this",
"->",
"localStatic",
"[",
"__FUNCTION__",
"]",
"as",
"$",
"dir",
")",
"{",
"$",
"this",
"->",
"start",
"(",
"'Converting SASS to CSS in '",
".",
"$",
"dir",
")",
";",
"foreach",
"(",
"glob",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'*.{scss,sass}'",
",",
"GLOB_BRACE",
")",
"as",
"$",
"file",
")",
"{",
"//skip if partial",
"$",
"output",
"=",
"basename",
"(",
"$",
"file",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"1",
")",
"===",
"'_'",
")",
"continue",
";",
"$",
"this",
"->",
"start",
"(",
"'Working on '",
".",
"$",
"output",
")",
";",
"$",
"scss",
"=",
"(",
"substr",
"(",
"$",
"file",
",",
"-",
"5",
")",
"===",
"'.scss'",
")",
";",
"// Add Constants variables ",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"\"constants\"",
"]",
")",
")",
"{",
"$",
"old",
"=",
"$",
"file",
";",
"// sass which will actuall be compiled [hidden]",
"$",
"file",
".=",
"md5",
"(",
"time",
"(",
")",
")",
".",
"'.sex'",
";",
"$",
"f",
"=",
"fopen",
"(",
"$",
"file",
",",
"'w'",
")",
";",
"exec",
"(",
"'attrib +H '",
".",
"escapeshellarg",
"(",
"$",
"file",
")",
")",
";",
"// get the URL Constants",
"$",
"const",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"\"constants\"",
"]",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"$",
"const",
"[",
"]",
"=",
"'$const-'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'-'",
",",
"strtolower",
"(",
"$",
"name",
")",
")",
".",
"': \\''",
".",
"$",
"val",
".",
"'\\' !default;'",
";",
"// add URL vars to temp sass file",
"fwrite",
"(",
"$",
"f",
",",
"implode",
"(",
"PHP_EOL",
",",
"$",
"const",
")",
")",
";",
"fwrite",
"(",
"$",
"f",
",",
"file_get_contents",
"(",
"$",
"old",
")",
")",
";",
"fclose",
"(",
"$",
"f",
")",
";",
"}",
"// the correct path for output",
"echo",
"$",
"output",
"=",
"$",
"this",
"->",
"tmp",
"[",
"__FUNCTION__",
"]",
".",
"$",
"output",
";",
"$",
"output",
"=",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"-",
"4",
")",
".",
"'css'",
";",
"// make sure path is ready",
"self",
"::",
"readyDir",
"(",
"$",
"output",
")",
";",
"// run sass",
"$",
"this",
"->",
"runLocal",
"(",
"[",
"'sass'",
",",
"(",
"$",
"scss",
"?",
"'--scss'",
":",
"null",
")",
",",
"'--trace'",
",",
"'--unix-newlines'",
",",
"'--style'",
",",
"(",
"$",
"this",
"->",
"compress",
"?",
"'compressed --sourcemap=none'",
":",
"'expanded -l'",
")",
",",
"$",
"file",
",",
"$",
"output",
",",
"]",
")",
";",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"}",
"foreach",
"(",
"glob",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"'*.sex'",
")",
"as",
"$",
"file",
")",
"unlink",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Combines SASS to a file foreach folder
|
[
"Combines",
"SASS",
"to",
"a",
"file",
"foreach",
"folder"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L552-L617
|
237,754
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.js
|
private function js() {
foreach ($this->localStatic[ __FUNCTION__ ] as $jswip) {
// r.js optimization
if($this->compress) {
$rjsBuild = $jswip .DIRECTORY_SEPARATOR. self::RJS_BUILD;
if(is_file($rjsBuild)) {
$this ->start('Optimizing '. self::RJS_BUILD .' with r.js')
->runLocal(['r.js.cmd',
'-o', $rjsBuild,
])->finish();
// temp destination directory
$jswip .= DIRECTORY_SEPARATOR . 'dist';
$this->wipe[] = $jswip;
}
}
// make file for each sub folder
foreach (glob($jswip . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR) as $v) {
if ($this->compress) {
$output = $this->tmp[ __FUNCTION__ ] . basename($v) . '.js';
self::readyDir($output);
$this->start('Minifing ' . basename($v) . ' with closure');
$this->runLocal([self::BIN . 'closure.bat',
'--language_in', 'ECMASCRIPT5',
'--js_output_file', $output,
$v . DIRECTORY_SEPARATOR . '**',
]);
$this->finish();
} else {
$this->start('Merging ' . basename($v) . '\'s JS files');
$full = $this->tmp[ __FUNCTION__ ] . basename($v) . '.js';
//remove compiled file
if (is_file($full))
unlink($full);
// append to new js file
self::readyDir($full);
$f = fopen($full, 'a'); //match with $g!
// get js files
$g = self::rglob($v . DIRECTORY_SEPARATOR . '*.js');
// add js files
foreach ($g as $vv) {
//$this->start('Adding in '. basename($vv) .' to '. basename($v));
// start buffer
ob_start();
// nice title
echo "\n\n\n/*** ", basename($vv), " ***/\n\n";
// output file
require $vv;
// save the executed css file
$file = ob_get_clean();
// add to file
fwrite($f, $file);
//$this->finish();
}
fclose($f);
$this->finish();
}
}
}
return $this;
}
|
php
|
private function js() {
foreach ($this->localStatic[ __FUNCTION__ ] as $jswip) {
// r.js optimization
if($this->compress) {
$rjsBuild = $jswip .DIRECTORY_SEPARATOR. self::RJS_BUILD;
if(is_file($rjsBuild)) {
$this ->start('Optimizing '. self::RJS_BUILD .' with r.js')
->runLocal(['r.js.cmd',
'-o', $rjsBuild,
])->finish();
// temp destination directory
$jswip .= DIRECTORY_SEPARATOR . 'dist';
$this->wipe[] = $jswip;
}
}
// make file for each sub folder
foreach (glob($jswip . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR) as $v) {
if ($this->compress) {
$output = $this->tmp[ __FUNCTION__ ] . basename($v) . '.js';
self::readyDir($output);
$this->start('Minifing ' . basename($v) . ' with closure');
$this->runLocal([self::BIN . 'closure.bat',
'--language_in', 'ECMASCRIPT5',
'--js_output_file', $output,
$v . DIRECTORY_SEPARATOR . '**',
]);
$this->finish();
} else {
$this->start('Merging ' . basename($v) . '\'s JS files');
$full = $this->tmp[ __FUNCTION__ ] . basename($v) . '.js';
//remove compiled file
if (is_file($full))
unlink($full);
// append to new js file
self::readyDir($full);
$f = fopen($full, 'a'); //match with $g!
// get js files
$g = self::rglob($v . DIRECTORY_SEPARATOR . '*.js');
// add js files
foreach ($g as $vv) {
//$this->start('Adding in '. basename($vv) .' to '. basename($v));
// start buffer
ob_start();
// nice title
echo "\n\n\n/*** ", basename($vv), " ***/\n\n";
// output file
require $vv;
// save the executed css file
$file = ob_get_clean();
// add to file
fwrite($f, $file);
//$this->finish();
}
fclose($f);
$this->finish();
}
}
}
return $this;
}
|
[
"private",
"function",
"js",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"localStatic",
"[",
"__FUNCTION__",
"]",
"as",
"$",
"jswip",
")",
"{",
"// r.js optimization",
"if",
"(",
"$",
"this",
"->",
"compress",
")",
"{",
"$",
"rjsBuild",
"=",
"$",
"jswip",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"RJS_BUILD",
";",
"if",
"(",
"is_file",
"(",
"$",
"rjsBuild",
")",
")",
"{",
"$",
"this",
"->",
"start",
"(",
"'Optimizing '",
".",
"self",
"::",
"RJS_BUILD",
".",
"' with r.js'",
")",
"->",
"runLocal",
"(",
"[",
"'r.js.cmd'",
",",
"'-o'",
",",
"$",
"rjsBuild",
",",
"]",
")",
"->",
"finish",
"(",
")",
";",
"// temp destination directory",
"$",
"jswip",
".=",
"DIRECTORY_SEPARATOR",
".",
"'dist'",
";",
"$",
"this",
"->",
"wipe",
"[",
"]",
"=",
"$",
"jswip",
";",
"}",
"}",
"// make file for each sub folder",
"foreach",
"(",
"glob",
"(",
"$",
"jswip",
".",
"DIRECTORY_SEPARATOR",
".",
"'*'",
",",
"GLOB_ONLYDIR",
")",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"compress",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"tmp",
"[",
"__FUNCTION__",
"]",
".",
"basename",
"(",
"$",
"v",
")",
".",
"'.js'",
";",
"self",
"::",
"readyDir",
"(",
"$",
"output",
")",
";",
"$",
"this",
"->",
"start",
"(",
"'Minifing '",
".",
"basename",
"(",
"$",
"v",
")",
".",
"' with closure'",
")",
";",
"$",
"this",
"->",
"runLocal",
"(",
"[",
"self",
"::",
"BIN",
".",
"'closure.bat'",
",",
"'--language_in'",
",",
"'ECMASCRIPT5'",
",",
"'--js_output_file'",
",",
"$",
"output",
",",
"$",
"v",
".",
"DIRECTORY_SEPARATOR",
".",
"'**'",
",",
"]",
")",
";",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"start",
"(",
"'Merging '",
".",
"basename",
"(",
"$",
"v",
")",
".",
"'\\'s JS files'",
")",
";",
"$",
"full",
"=",
"$",
"this",
"->",
"tmp",
"[",
"__FUNCTION__",
"]",
".",
"basename",
"(",
"$",
"v",
")",
".",
"'.js'",
";",
"//remove compiled file",
"if",
"(",
"is_file",
"(",
"$",
"full",
")",
")",
"unlink",
"(",
"$",
"full",
")",
";",
"// append to new js file",
"self",
"::",
"readyDir",
"(",
"$",
"full",
")",
";",
"$",
"f",
"=",
"fopen",
"(",
"$",
"full",
",",
"'a'",
")",
";",
"//match with $g!",
"// get js files",
"$",
"g",
"=",
"self",
"::",
"rglob",
"(",
"$",
"v",
".",
"DIRECTORY_SEPARATOR",
".",
"'*.js'",
")",
";",
"// add js files",
"foreach",
"(",
"$",
"g",
"as",
"$",
"vv",
")",
"{",
"//$this->start('Adding in '. basename($vv) .' to '. basename($v));",
"// start buffer",
"ob_start",
"(",
")",
";",
"// nice title",
"echo",
"\"\\n\\n\\n/*** \"",
",",
"basename",
"(",
"$",
"vv",
")",
",",
"\" ***/\\n\\n\"",
";",
"// output file",
"require",
"$",
"vv",
";",
"// save the executed css file",
"$",
"file",
"=",
"ob_get_clean",
"(",
")",
";",
"// add to file",
"fwrite",
"(",
"$",
"f",
",",
"$",
"file",
")",
";",
"//$this->finish();",
"}",
"fclose",
"(",
"$",
"f",
")",
";",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Merges all files
|
[
"Merges",
"all",
"files"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L623-L699
|
237,755
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.img
|
protected function img() {
foreach ($this->localStatic[ __FUNCTION__ ] as $imgDir) {
//if(is_file($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db'))
// unlink($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db');
/*
$this->start('Optimizing '. $imgDir)
->runLocal([
self::IMGMIN,
'-o', 7,
$imgDir,// . DIRECTORY_SEPARATOR. '*',
$this->localStatic . 'img'
])->finish();
*/
foreach (self::rglob($imgDir . DIRECTORY_SEPARATOR . '*.{jpg,jpeg,png,gif,svg,bmp}', GLOB_BRACE) as $image) {
$output = $this->tmp[ __FUNCTION__ ] . substr($image, strlen($imgDir) + 1);
self::readyDir($output);
if ($this->compress)
$this->start('Optimizing ' . $image)
->runLocal(['imagemin',
//'-o', 7,
$image,
'>',
$output
])->finish();
else
copy($image, $output); // symlink
}
}
return $this;
}
|
php
|
protected function img() {
foreach ($this->localStatic[ __FUNCTION__ ] as $imgDir) {
//if(is_file($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db'))
// unlink($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db');
/*
$this->start('Optimizing '. $imgDir)
->runLocal([
self::IMGMIN,
'-o', 7,
$imgDir,// . DIRECTORY_SEPARATOR. '*',
$this->localStatic . 'img'
])->finish();
*/
foreach (self::rglob($imgDir . DIRECTORY_SEPARATOR . '*.{jpg,jpeg,png,gif,svg,bmp}', GLOB_BRACE) as $image) {
$output = $this->tmp[ __FUNCTION__ ] . substr($image, strlen($imgDir) + 1);
self::readyDir($output);
if ($this->compress)
$this->start('Optimizing ' . $image)
->runLocal(['imagemin',
//'-o', 7,
$image,
'>',
$output
])->finish();
else
copy($image, $output); // symlink
}
}
return $this;
}
|
[
"protected",
"function",
"img",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"localStatic",
"[",
"__FUNCTION__",
"]",
"as",
"$",
"imgDir",
")",
"{",
"//if(is_file($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db'))",
"//\tunlink($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db');",
"/*\n\t\t\t $this->start('Optimizing '. $imgDir)\n\t\t\t ->runLocal([\n\t\t\t self::IMGMIN,\n\t\t\t '-o', 7,\n\t\t\t $imgDir,// . DIRECTORY_SEPARATOR. '*',\n\t\t\t $this->localStatic . 'img'\n\t\t\t ])->finish();\n\t\t\t */",
"foreach",
"(",
"self",
"::",
"rglob",
"(",
"$",
"imgDir",
".",
"DIRECTORY_SEPARATOR",
".",
"'*.{jpg,jpeg,png,gif,svg,bmp}'",
",",
"GLOB_BRACE",
")",
"as",
"$",
"image",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"tmp",
"[",
"__FUNCTION__",
"]",
".",
"substr",
"(",
"$",
"image",
",",
"strlen",
"(",
"$",
"imgDir",
")",
"+",
"1",
")",
";",
"self",
"::",
"readyDir",
"(",
"$",
"output",
")",
";",
"if",
"(",
"$",
"this",
"->",
"compress",
")",
"$",
"this",
"->",
"start",
"(",
"'Optimizing '",
".",
"$",
"image",
")",
"->",
"runLocal",
"(",
"[",
"'imagemin'",
",",
"//'-o', 7,",
"$",
"image",
",",
"'>'",
",",
"$",
"output",
"]",
")",
"->",
"finish",
"(",
")",
";",
"else",
"copy",
"(",
"$",
"image",
",",
"$",
"output",
")",
";",
"// symlink",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Move images to upload dir
Optimize them if needed
|
[
"Move",
"images",
"to",
"upload",
"dir",
"Optimize",
"them",
"if",
"needed"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L706-L738
|
237,756
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.runRemote
|
private function runRemote($command) {
// make commands a list
if (!is_array($command))
$command = array($command);
$command = strval(implode(';', $command));
return $this->runLocal(['plink',
'-ssh', // interacting method
'-i', static::safeDir($this->ppk), // Private key file to access server
$this->host, // username and hostname to connect to
'"' . $command . '"', // Commands to run
]);
}
|
php
|
private function runRemote($command) {
// make commands a list
if (!is_array($command))
$command = array($command);
$command = strval(implode(';', $command));
return $this->runLocal(['plink',
'-ssh', // interacting method
'-i', static::safeDir($this->ppk), // Private key file to access server
$this->host, // username and hostname to connect to
'"' . $command . '"', // Commands to run
]);
}
|
[
"private",
"function",
"runRemote",
"(",
"$",
"command",
")",
"{",
"// make commands a list",
"if",
"(",
"!",
"is_array",
"(",
"$",
"command",
")",
")",
"$",
"command",
"=",
"array",
"(",
"$",
"command",
")",
";",
"$",
"command",
"=",
"strval",
"(",
"implode",
"(",
"';'",
",",
"$",
"command",
")",
")",
";",
"return",
"$",
"this",
"->",
"runLocal",
"(",
"[",
"'plink'",
",",
"'-ssh'",
",",
"// interacting method",
"'-i'",
",",
"static",
"::",
"safeDir",
"(",
"$",
"this",
"->",
"ppk",
")",
",",
"// Private key file to access server",
"$",
"this",
"->",
"host",
",",
"// username and hostname to connect to",
"'\"'",
".",
"$",
"command",
".",
"'\"'",
",",
"// Commands to run",
"]",
")",
";",
"}"
] |
Run some commands on the remote server
@param string|array $command commands to run
@return \Compiler this
|
[
"Run",
"some",
"commands",
"on",
"the",
"remote",
"server"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L749-L762
|
237,757
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.runLocal
|
private function runLocal($command) {
// make commands a list
if (!is_array($command))
$command = array($command);
$command = strval(implode(' ', $command));
// run
if ($this->verbose >= 3) {
echo "\n$ $command\n";
passthru($command);
} else
exec($command);
return $this;
}
|
php
|
private function runLocal($command) {
// make commands a list
if (!is_array($command))
$command = array($command);
$command = strval(implode(' ', $command));
// run
if ($this->verbose >= 3) {
echo "\n$ $command\n";
passthru($command);
} else
exec($command);
return $this;
}
|
[
"private",
"function",
"runLocal",
"(",
"$",
"command",
")",
"{",
"// make commands a list",
"if",
"(",
"!",
"is_array",
"(",
"$",
"command",
")",
")",
"$",
"command",
"=",
"array",
"(",
"$",
"command",
")",
";",
"$",
"command",
"=",
"strval",
"(",
"implode",
"(",
"' '",
",",
"$",
"command",
")",
")",
";",
"// run",
"if",
"(",
"$",
"this",
"->",
"verbose",
">=",
"3",
")",
"{",
"echo",
"\"\\n$ $command\\n\"",
";",
"passthru",
"(",
"$",
"command",
")",
";",
"}",
"else",
"exec",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Run some commands on this computer
@param array $command commands to run
@return \Compiler $this
|
[
"Run",
"some",
"commands",
"on",
"this",
"computer"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L770-L785
|
237,758
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.uploadStatic
|
protected function uploadStatic() {
// copy to all destination folders
foreach($this->remoteStatic as $type => $destDir) {
// copy from all static
if(isset($this->s3)) {
foreach(self::rglob($this->tmp[ $type ] . '*') as $file) {
$info = new \SplFileInfo($file);
if($info->isDir() || !$info->isReadable())
continue;
$this->start('Putting '. $info->getBasename() .' on '. $destDir);
// get mime
$mime = 'text/plain'; // 'application/octet-stream';
if(isset(static::$mimes[ $info->getExtension() ]))
$mime = static::$mimes[ $info->getExtension() ];
// headers
$headers = [
'Content-Type' => $mime,
'Cache-Control' => 'max-age=315360000',
'Expires' => 'Thu, 31 Dec 2037 23:55:55 GMT', //gmdate(DateTime::RFC1123, strtotime('+5 years'))
'Vary' => 'Accept-Encoding',
];
$data = file_get_contents($file);
// gzip
if(substr($mime, 0, 5) === 'text/'
|| $mime === 'application/javascript'
|| $mime === 'application/x-javascript'
|| $mime === 'application/json') {
$data = gzencode($data, 9);
$headers['Content-Encoding'] = 'gzip';
}
// data length
$headers['Content-Length'] = mb_strlen($data, '8bit');
// push it
$this->s3->putObject(
$data,
$destDir,
$info->getBasename(),
\S3::ACL_PUBLIC_READ,
array(),
$headers
);
$this->finish();
}
} else {
$this ->start('Local object '. $type .' -> '. $destDir)
// ->runRemote('rm -r '. $destDir .'; mkdir -p '. $destDir)
->runLocal(['pscp',
'-p', // preserve attributes
'-r', // copy recursively
'-q', // silent
//'-sftp', // for use of SFTP protocal
'-batch', // non interactive
'-C', // enable compression
'-i', static::safeDir($this->ppk), // Private key file to access server
static::safeDir($this->tmp[ $type ]), // Directory to upload
$this->host .':'. $destDir, // host:path on server to save data
])->finish();
}
}
return $this;
}
|
php
|
protected function uploadStatic() {
// copy to all destination folders
foreach($this->remoteStatic as $type => $destDir) {
// copy from all static
if(isset($this->s3)) {
foreach(self::rglob($this->tmp[ $type ] . '*') as $file) {
$info = new \SplFileInfo($file);
if($info->isDir() || !$info->isReadable())
continue;
$this->start('Putting '. $info->getBasename() .' on '. $destDir);
// get mime
$mime = 'text/plain'; // 'application/octet-stream';
if(isset(static::$mimes[ $info->getExtension() ]))
$mime = static::$mimes[ $info->getExtension() ];
// headers
$headers = [
'Content-Type' => $mime,
'Cache-Control' => 'max-age=315360000',
'Expires' => 'Thu, 31 Dec 2037 23:55:55 GMT', //gmdate(DateTime::RFC1123, strtotime('+5 years'))
'Vary' => 'Accept-Encoding',
];
$data = file_get_contents($file);
// gzip
if(substr($mime, 0, 5) === 'text/'
|| $mime === 'application/javascript'
|| $mime === 'application/x-javascript'
|| $mime === 'application/json') {
$data = gzencode($data, 9);
$headers['Content-Encoding'] = 'gzip';
}
// data length
$headers['Content-Length'] = mb_strlen($data, '8bit');
// push it
$this->s3->putObject(
$data,
$destDir,
$info->getBasename(),
\S3::ACL_PUBLIC_READ,
array(),
$headers
);
$this->finish();
}
} else {
$this ->start('Local object '. $type .' -> '. $destDir)
// ->runRemote('rm -r '. $destDir .'; mkdir -p '. $destDir)
->runLocal(['pscp',
'-p', // preserve attributes
'-r', // copy recursively
'-q', // silent
//'-sftp', // for use of SFTP protocal
'-batch', // non interactive
'-C', // enable compression
'-i', static::safeDir($this->ppk), // Private key file to access server
static::safeDir($this->tmp[ $type ]), // Directory to upload
$this->host .':'. $destDir, // host:path on server to save data
])->finish();
}
}
return $this;
}
|
[
"protected",
"function",
"uploadStatic",
"(",
")",
"{",
"// copy to all destination folders",
"foreach",
"(",
"$",
"this",
"->",
"remoteStatic",
"as",
"$",
"type",
"=>",
"$",
"destDir",
")",
"{",
"// copy from all static",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"s3",
")",
")",
"{",
"foreach",
"(",
"self",
"::",
"rglob",
"(",
"$",
"this",
"->",
"tmp",
"[",
"$",
"type",
"]",
".",
"'*'",
")",
"as",
"$",
"file",
")",
"{",
"$",
"info",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"info",
"->",
"isDir",
"(",
")",
"||",
"!",
"$",
"info",
"->",
"isReadable",
"(",
")",
")",
"continue",
";",
"$",
"this",
"->",
"start",
"(",
"'Putting '",
".",
"$",
"info",
"->",
"getBasename",
"(",
")",
".",
"' on '",
".",
"$",
"destDir",
")",
";",
"// get mime",
"$",
"mime",
"=",
"'text/plain'",
";",
"// 'application/octet-stream';",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"mimes",
"[",
"$",
"info",
"->",
"getExtension",
"(",
")",
"]",
")",
")",
"$",
"mime",
"=",
"static",
"::",
"$",
"mimes",
"[",
"$",
"info",
"->",
"getExtension",
"(",
")",
"]",
";",
"// headers",
"$",
"headers",
"=",
"[",
"'Content-Type'",
"=>",
"$",
"mime",
",",
"'Cache-Control'",
"=>",
"'max-age=315360000'",
",",
"'Expires'",
"=>",
"'Thu, 31 Dec 2037 23:55:55 GMT'",
",",
"//gmdate(DateTime::RFC1123, strtotime('+5 years'))",
"'Vary'",
"=>",
"'Accept-Encoding'",
",",
"]",
";",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"// gzip",
"if",
"(",
"substr",
"(",
"$",
"mime",
",",
"0",
",",
"5",
")",
"===",
"'text/'",
"||",
"$",
"mime",
"===",
"'application/javascript'",
"||",
"$",
"mime",
"===",
"'application/x-javascript'",
"||",
"$",
"mime",
"===",
"'application/json'",
")",
"{",
"$",
"data",
"=",
"gzencode",
"(",
"$",
"data",
",",
"9",
")",
";",
"$",
"headers",
"[",
"'Content-Encoding'",
"]",
"=",
"'gzip'",
";",
"}",
"// data length",
"$",
"headers",
"[",
"'Content-Length'",
"]",
"=",
"mb_strlen",
"(",
"$",
"data",
",",
"'8bit'",
")",
";",
"// push it",
"$",
"this",
"->",
"s3",
"->",
"putObject",
"(",
"$",
"data",
",",
"$",
"destDir",
",",
"$",
"info",
"->",
"getBasename",
"(",
")",
",",
"\\",
"S3",
"::",
"ACL_PUBLIC_READ",
",",
"array",
"(",
")",
",",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"start",
"(",
"'Local object '",
".",
"$",
"type",
".",
"' -> '",
".",
"$",
"destDir",
")",
"//\t\t\t\t\t\t->runRemote('rm -r '. $destDir .'; mkdir -p '. $destDir)",
"->",
"runLocal",
"(",
"[",
"'pscp'",
",",
"'-p'",
",",
"// preserve attributes",
"'-r'",
",",
"// copy recursively",
"'-q'",
",",
"// silent",
"//'-sftp',\t\t\t\t\t\t\t\t// for use of SFTP protocal",
"'-batch'",
",",
"// non interactive",
"'-C'",
",",
"// enable compression",
"'-i'",
",",
"static",
"::",
"safeDir",
"(",
"$",
"this",
"->",
"ppk",
")",
",",
"// Private key file to access server",
"static",
"::",
"safeDir",
"(",
"$",
"this",
"->",
"tmp",
"[",
"$",
"type",
"]",
")",
",",
"// Directory to upload",
"$",
"this",
"->",
"host",
".",
"':'",
".",
"$",
"destDir",
",",
"// host:path on server to save data",
"]",
")",
"->",
"finish",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Uploads to S3 or remote server
|
[
"Uploads",
"to",
"S3",
"or",
"remote",
"server"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L791-L861
|
237,759
|
mothepro/MoCompiler
|
src/Compiler.php
|
Compiler.setS3
|
public function setS3($key = null, $secret = null) {
$this->s3 = new \S3($key, $secret);
$this->setCompress(true);
}
|
php
|
public function setS3($key = null, $secret = null) {
$this->s3 = new \S3($key, $secret);
$this->setCompress(true);
}
|
[
"public",
"function",
"setS3",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"secret",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"s3",
"=",
"new",
"\\",
"S3",
"(",
"$",
"key",
",",
"$",
"secret",
")",
";",
"$",
"this",
"->",
"setCompress",
"(",
"true",
")",
";",
"}"
] |
Uploads the static files S3
@param string $key Amazon S3 Key
@param string $secret Amazon S3 Secret
|
[
"Uploads",
"the",
"static",
"files",
"S3"
] |
bedc26fe9f11fbd87bc062175deba95051c7b9b0
|
https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Compiler.php#L992-L995
|
237,760
|
droid-php/droid-fs
|
src/Model/Fstab/FstabLine.php
|
FstabLine.setFieldValue
|
public function setFieldValue($fieldName, $value)
{
if (isset($this->originalValues[$fieldName])
&& $this->originalValues[$fieldName] === $value
) {
# the given value is the same as the original value;
# ignore any given value
unset($this->givenValues[$fieldName]);
} elseif (isset($this->originalValues[$fieldName])
&& $this->originalValues[$fieldName] !== $value
&& isset($this->defaults[$fieldName])
&& $this->defaults[$fieldName] === $value
) {
# the given value is the same as a default value, but different from
# the original value; change it
$this->givenValues[$fieldName] = $value;
} elseif (isset($this->defaults[$fieldName])
&& $this->defaults[$fieldName] === $value
) {
# the given value is the same as the default value;
# ignore any given value
unset($this->givenValues[$fieldName]);
} else {
$this->givenValues[$fieldName] = $value;
}
return $this;
}
|
php
|
public function setFieldValue($fieldName, $value)
{
if (isset($this->originalValues[$fieldName])
&& $this->originalValues[$fieldName] === $value
) {
# the given value is the same as the original value;
# ignore any given value
unset($this->givenValues[$fieldName]);
} elseif (isset($this->originalValues[$fieldName])
&& $this->originalValues[$fieldName] !== $value
&& isset($this->defaults[$fieldName])
&& $this->defaults[$fieldName] === $value
) {
# the given value is the same as a default value, but different from
# the original value; change it
$this->givenValues[$fieldName] = $value;
} elseif (isset($this->defaults[$fieldName])
&& $this->defaults[$fieldName] === $value
) {
# the given value is the same as the default value;
# ignore any given value
unset($this->givenValues[$fieldName]);
} else {
$this->givenValues[$fieldName] = $value;
}
return $this;
}
|
[
"public",
"function",
"setFieldValue",
"(",
"$",
"fieldName",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"originalValues",
"[",
"$",
"fieldName",
"]",
")",
"&&",
"$",
"this",
"->",
"originalValues",
"[",
"$",
"fieldName",
"]",
"===",
"$",
"value",
")",
"{",
"# the given value is the same as the original value;",
"# ignore any given value",
"unset",
"(",
"$",
"this",
"->",
"givenValues",
"[",
"$",
"fieldName",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"originalValues",
"[",
"$",
"fieldName",
"]",
")",
"&&",
"$",
"this",
"->",
"originalValues",
"[",
"$",
"fieldName",
"]",
"!==",
"$",
"value",
"&&",
"isset",
"(",
"$",
"this",
"->",
"defaults",
"[",
"$",
"fieldName",
"]",
")",
"&&",
"$",
"this",
"->",
"defaults",
"[",
"$",
"fieldName",
"]",
"===",
"$",
"value",
")",
"{",
"# the given value is the same as a default value, but different from",
"# the original value; change it",
"$",
"this",
"->",
"givenValues",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"defaults",
"[",
"$",
"fieldName",
"]",
")",
"&&",
"$",
"this",
"->",
"defaults",
"[",
"$",
"fieldName",
"]",
"===",
"$",
"value",
")",
"{",
"# the given value is the same as the default value;",
"# ignore any given value",
"unset",
"(",
"$",
"this",
"->",
"givenValues",
"[",
"$",
"fieldName",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"givenValues",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the value of a named field.
This implementation allows for fields which have an implied value when
not given an explicit value. Thus,
@see \Droid\Lib\Plugin\Model\File\AbstractLine::setFieldValue()
|
[
"Set",
"the",
"value",
"of",
"a",
"named",
"field",
"."
] |
5b8dcf589e601fb3fc3fe7190641ed3774932f3b
|
https://github.com/droid-php/droid-fs/blob/5b8dcf589e601fb3fc3fe7190641ed3774932f3b/src/Model/Fstab/FstabLine.php#L97-L123
|
237,761
|
vinala/kernel
|
src/Processes/Alias.php
|
Alias.set
|
public static function set($enabled, $params)
{
$docs = self::documentations();
$content = $docs['enabled'].self::enbaledFormat($enabled);
$content .= $docs['kernel'].self::arrayFormat($params['kernel'], 'kernel');
$content .= $docs['exceptions'].self::arrayFormat($params['exceptions'], 'exceptions');
$content .= $docs['controllers'].self::arrayFormat($params['controllers'], 'controllers');
$content .= $docs['models'].self::arrayFormat($params['models'], 'models');
$content .= $docs['mailables'].self::arrayFormat($params['mailables'], 'mailables');
if (array_has($params, 'querying')) {
$content .= $docs['querying'].self::arrayFormat($params['querying'], 'querying');
}
$content = self::fileFormat($content);
return self::setFile($content);
}
|
php
|
public static function set($enabled, $params)
{
$docs = self::documentations();
$content = $docs['enabled'].self::enbaledFormat($enabled);
$content .= $docs['kernel'].self::arrayFormat($params['kernel'], 'kernel');
$content .= $docs['exceptions'].self::arrayFormat($params['exceptions'], 'exceptions');
$content .= $docs['controllers'].self::arrayFormat($params['controllers'], 'controllers');
$content .= $docs['models'].self::arrayFormat($params['models'], 'models');
$content .= $docs['mailables'].self::arrayFormat($params['mailables'], 'mailables');
if (array_has($params, 'querying')) {
$content .= $docs['querying'].self::arrayFormat($params['querying'], 'querying');
}
$content = self::fileFormat($content);
return self::setFile($content);
}
|
[
"public",
"static",
"function",
"set",
"(",
"$",
"enabled",
",",
"$",
"params",
")",
"{",
"$",
"docs",
"=",
"self",
"::",
"documentations",
"(",
")",
";",
"$",
"content",
"=",
"$",
"docs",
"[",
"'enabled'",
"]",
".",
"self",
"::",
"enbaledFormat",
"(",
"$",
"enabled",
")",
";",
"$",
"content",
".=",
"$",
"docs",
"[",
"'kernel'",
"]",
".",
"self",
"::",
"arrayFormat",
"(",
"$",
"params",
"[",
"'kernel'",
"]",
",",
"'kernel'",
")",
";",
"$",
"content",
".=",
"$",
"docs",
"[",
"'exceptions'",
"]",
".",
"self",
"::",
"arrayFormat",
"(",
"$",
"params",
"[",
"'exceptions'",
"]",
",",
"'exceptions'",
")",
";",
"$",
"content",
".=",
"$",
"docs",
"[",
"'controllers'",
"]",
".",
"self",
"::",
"arrayFormat",
"(",
"$",
"params",
"[",
"'controllers'",
"]",
",",
"'controllers'",
")",
";",
"$",
"content",
".=",
"$",
"docs",
"[",
"'models'",
"]",
".",
"self",
"::",
"arrayFormat",
"(",
"$",
"params",
"[",
"'models'",
"]",
",",
"'models'",
")",
";",
"$",
"content",
".=",
"$",
"docs",
"[",
"'mailables'",
"]",
".",
"self",
"::",
"arrayFormat",
"(",
"$",
"params",
"[",
"'mailables'",
"]",
",",
"'mailables'",
")",
";",
"if",
"(",
"array_has",
"(",
"$",
"params",
",",
"'querying'",
")",
")",
"{",
"$",
"content",
".=",
"$",
"docs",
"[",
"'querying'",
"]",
".",
"self",
"::",
"arrayFormat",
"(",
"$",
"params",
"[",
"'querying'",
"]",
",",
"'querying'",
")",
";",
"}",
"$",
"content",
"=",
"self",
"::",
"fileFormat",
"(",
"$",
"content",
")",
";",
"return",
"self",
"::",
"setFile",
"(",
"$",
"content",
")",
";",
"}"
] |
Set the config params.
@param bool $enabled
@param array $params
@return bool
|
[
"Set",
"the",
"config",
"params",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Alias.php#L56-L72
|
237,762
|
vinala/kernel
|
src/Processes/Alias.php
|
Alias.setFile
|
protected static function setFile($content)
{
$root = Process::root;
if (file_exists(Process::root.'config/alias.php')) {
$file = fopen(Process::root.'config/alias.php', 'w');
fwrite($file, $content);
fclose($file);
//
return true;
}
return false;
}
|
php
|
protected static function setFile($content)
{
$root = Process::root;
if (file_exists(Process::root.'config/alias.php')) {
$file = fopen(Process::root.'config/alias.php', 'w');
fwrite($file, $content);
fclose($file);
//
return true;
}
return false;
}
|
[
"protected",
"static",
"function",
"setFile",
"(",
"$",
"content",
")",
"{",
"$",
"root",
"=",
"Process",
"::",
"root",
";",
"if",
"(",
"file_exists",
"(",
"Process",
"::",
"root",
".",
"'config/alias.php'",
")",
")",
"{",
"$",
"file",
"=",
"fopen",
"(",
"Process",
"::",
"root",
".",
"'config/alias.php'",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"$",
"content",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"//",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Set the file.
@param string $content
@return bool
|
[
"Set",
"the",
"file",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Alias.php#L81-L94
|
237,763
|
vinala/kernel
|
src/Processes/Alias.php
|
Alias.arrayFormat
|
protected static function arrayFormat(array $data, $name)
{
$format = "\t'$name' => [\n";
if (count($data) > 0) {
foreach ($data as $key => $value) {
$format .= "\t\t'$key' => $value::class , \n";
}
} else {
$format .= "\t\t//\n";
}
$format .= "\t],\n\n";
return $format;
}
|
php
|
protected static function arrayFormat(array $data, $name)
{
$format = "\t'$name' => [\n";
if (count($data) > 0) {
foreach ($data as $key => $value) {
$format .= "\t\t'$key' => $value::class , \n";
}
} else {
$format .= "\t\t//\n";
}
$format .= "\t],\n\n";
return $format;
}
|
[
"protected",
"static",
"function",
"arrayFormat",
"(",
"array",
"$",
"data",
",",
"$",
"name",
")",
"{",
"$",
"format",
"=",
"\"\\t'$name' => [\\n\"",
";",
"if",
"(",
"count",
"(",
"$",
"data",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"format",
".=",
"\"\\t\\t'$key' => $value::class , \\n\"",
";",
"}",
"}",
"else",
"{",
"$",
"format",
".=",
"\"\\t\\t//\\n\"",
";",
"}",
"$",
"format",
".=",
"\"\\t],\\n\\n\"",
";",
"return",
"$",
"format",
";",
"}"
] |
Format args array.
@param array $data
@param string $name
@return string
|
[
"Format",
"args",
"array",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Alias.php#L116-L131
|
237,764
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.create
|
public static function create(
int $year,
int $month,
int $day,
int $hour,
int $minute,
int $second,
?string $timezone = null
): DateTime {
$timezone = $timezone ?: date_default_timezone_get();
assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));
return new static(
Date::create($year, $month, $day),
Time::create($hour, $minute, $second),
Timezone::create($timezone)
);
}
|
php
|
public static function create(
int $year,
int $month,
int $day,
int $hour,
int $minute,
int $second,
?string $timezone = null
): DateTime {
$timezone = $timezone ?: date_default_timezone_get();
assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));
return new static(
Date::create($year, $month, $day),
Time::create($hour, $minute, $second),
Timezone::create($timezone)
);
}
|
[
"public",
"static",
"function",
"create",
"(",
"int",
"$",
"year",
",",
"int",
"$",
"month",
",",
"int",
"$",
"day",
",",
"int",
"$",
"hour",
",",
"int",
"$",
"minute",
",",
"int",
"$",
"second",
",",
"?",
"string",
"$",
"timezone",
"=",
"null",
")",
":",
"DateTime",
"{",
"$",
"timezone",
"=",
"$",
"timezone",
"?",
":",
"date_default_timezone_get",
"(",
")",
";",
"assert",
"(",
"Validate",
"::",
"isTimezone",
"(",
"$",
"timezone",
")",
",",
"sprintf",
"(",
"'Invalid timezone: %s'",
",",
"$",
"timezone",
")",
")",
";",
"return",
"new",
"static",
"(",
"Date",
"::",
"create",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
",",
"Time",
"::",
"create",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
")",
",",
"Timezone",
"::",
"create",
"(",
"$",
"timezone",
")",
")",
";",
"}"
] |
Creates instance from date and time values
@param int $year The year
@param int $month The month
@param int $day The day
@param int $hour The hour
@param int $minute The minute
@param int $second The second
@param string|null $timezone The timezone string or null for default
@return DateTime
@throws DomainException When the date/time is not valid
|
[
"Creates",
"instance",
"from",
"date",
"and",
"time",
"values"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L87-L104
|
237,765
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.now
|
public static function now(?string $timezone = null): DateTime
{
$timezone = $timezone ?: date_default_timezone_get();
assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));
$dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone));
$year = (int) $dateTime->format('Y');
$month = (int) $dateTime->format('n');
$day = (int) $dateTime->format('j');
$hour = (int) $dateTime->format('G');
$minute = (int) $dateTime->format('i');
$second = (int) $dateTime->format('s');
return new static(
Date::create($year, $month, $day),
Time::create($hour, $minute, $second),
Timezone::create($timezone)
);
}
|
php
|
public static function now(?string $timezone = null): DateTime
{
$timezone = $timezone ?: date_default_timezone_get();
assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));
$dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone));
$year = (int) $dateTime->format('Y');
$month = (int) $dateTime->format('n');
$day = (int) $dateTime->format('j');
$hour = (int) $dateTime->format('G');
$minute = (int) $dateTime->format('i');
$second = (int) $dateTime->format('s');
return new static(
Date::create($year, $month, $day),
Time::create($hour, $minute, $second),
Timezone::create($timezone)
);
}
|
[
"public",
"static",
"function",
"now",
"(",
"?",
"string",
"$",
"timezone",
"=",
"null",
")",
":",
"DateTime",
"{",
"$",
"timezone",
"=",
"$",
"timezone",
"?",
":",
"date_default_timezone_get",
"(",
")",
";",
"assert",
"(",
"Validate",
"::",
"isTimezone",
"(",
"$",
"timezone",
")",
",",
"sprintf",
"(",
"'Invalid timezone: %s'",
",",
"$",
"timezone",
")",
")",
";",
"$",
"dateTime",
"=",
"new",
"DateTimeImmutable",
"(",
"'now'",
",",
"new",
"DateTimeZone",
"(",
"$",
"timezone",
")",
")",
";",
"$",
"year",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'Y'",
")",
";",
"$",
"month",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'n'",
")",
";",
"$",
"day",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'j'",
")",
";",
"$",
"hour",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'G'",
")",
";",
"$",
"minute",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'i'",
")",
";",
"$",
"second",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'s'",
")",
";",
"return",
"new",
"static",
"(",
"Date",
"::",
"create",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
",",
"Time",
"::",
"create",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
")",
",",
"Timezone",
"::",
"create",
"(",
"$",
"timezone",
")",
")",
";",
"}"
] |
Creates instance for the current date and time
@param string|null $timezone The timezone string or null for default
@return DateTime
|
[
"Creates",
"instance",
"for",
"the",
"current",
"date",
"and",
"time"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L113-L131
|
237,766
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.withYear
|
public function withYear(int $year): DateTime
{
return new static(
Date::create($year, $this->month(), $this->day()),
$this->time(),
$this->timezone()
);
}
|
php
|
public function withYear(int $year): DateTime
{
return new static(
Date::create($year, $this->month(), $this->day()),
$this->time(),
$this->timezone()
);
}
|
[
"public",
"function",
"withYear",
"(",
"int",
"$",
"year",
")",
":",
"DateTime",
"{",
"return",
"new",
"static",
"(",
"Date",
"::",
"create",
"(",
"$",
"year",
",",
"$",
"this",
"->",
"month",
"(",
")",
",",
"$",
"this",
"->",
"day",
"(",
")",
")",
",",
"$",
"this",
"->",
"time",
"(",
")",
",",
"$",
"this",
"->",
"timezone",
"(",
")",
")",
";",
"}"
] |
Creates instance with a given year
@param int $year The year
@return DateTime
@throws DomainException When the date/time is not valid
|
[
"Creates",
"instance",
"with",
"a",
"given",
"year"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L243-L250
|
237,767
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.withHour
|
public function withHour(int $hour): DateTime
{
return new static(
$this->date(),
Time::create($hour, $this->minute(), $this->second()),
$this->timezone()
);
}
|
php
|
public function withHour(int $hour): DateTime
{
return new static(
$this->date(),
Time::create($hour, $this->minute(), $this->second()),
$this->timezone()
);
}
|
[
"public",
"function",
"withHour",
"(",
"int",
"$",
"hour",
")",
":",
"DateTime",
"{",
"return",
"new",
"static",
"(",
"$",
"this",
"->",
"date",
"(",
")",
",",
"Time",
"::",
"create",
"(",
"$",
"hour",
",",
"$",
"this",
"->",
"minute",
"(",
")",
",",
"$",
"this",
"->",
"second",
"(",
")",
")",
",",
"$",
"this",
"->",
"timezone",
"(",
")",
")",
";",
"}"
] |
Creates instance with a given hour
@param int $hour The hour
@return DateTime
@throws DomainException When the date/time is not valid
|
[
"Creates",
"instance",
"with",
"a",
"given",
"hour"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L309-L316
|
237,768
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.withTimezone
|
public function withTimezone($timezone): DateTime
{
return new static(
$this->date(),
$this->time(),
Timezone::create($timezone)
);
}
|
php
|
public function withTimezone($timezone): DateTime
{
return new static(
$this->date(),
$this->time(),
Timezone::create($timezone)
);
}
|
[
"public",
"function",
"withTimezone",
"(",
"$",
"timezone",
")",
":",
"DateTime",
"{",
"return",
"new",
"static",
"(",
"$",
"this",
"->",
"date",
"(",
")",
",",
"$",
"this",
"->",
"time",
"(",
")",
",",
"Timezone",
"::",
"create",
"(",
"$",
"timezone",
")",
")",
";",
"}"
] |
Creates instance with a given timezone
Note: This method does not convert the date/time values
@param mixed $timezone The timezone value
@return DateTime
@throws DomainException When the timezone is not valid
|
[
"Creates",
"instance",
"with",
"a",
"given",
"timezone"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L365-L372
|
237,769
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.localeFormat
|
public function localeFormat(string $format): string
{
// http://php.net/manual/en/function.strftime.php#refsect1-function.strftime-examples
// Example #3 Cross platform compatible example using the %e modifier
// @codeCoverageIgnoreStart
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
}
// @codeCoverageIgnoreEnd
return strftime($format, $this->timestamp());
}
|
php
|
public function localeFormat(string $format): string
{
// http://php.net/manual/en/function.strftime.php#refsect1-function.strftime-examples
// Example #3 Cross platform compatible example using the %e modifier
// @codeCoverageIgnoreStart
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
}
// @codeCoverageIgnoreEnd
return strftime($format, $this->timestamp());
}
|
[
"public",
"function",
"localeFormat",
"(",
"string",
"$",
"format",
")",
":",
"string",
"{",
"// http://php.net/manual/en/function.strftime.php#refsect1-function.strftime-examples",
"// Example #3 Cross platform compatible example using the %e modifier",
"// @codeCoverageIgnoreStart",
"if",
"(",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
"==",
"'WIN'",
")",
"{",
"$",
"format",
"=",
"preg_replace",
"(",
"'#(?<!%)((?:%%)*)%e#'",
",",
"'\\1%#d'",
",",
"$",
"format",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"return",
"strftime",
"(",
"$",
"format",
",",
"$",
"this",
"->",
"timestamp",
"(",
")",
")",
";",
"}"
] |
Retrieves localized formatted string representation
Returns string formatted according to PHP strftime() function. Set the
current locale using the setlocale() function.
@link http://php.net/strftime PHP strftime function
@link http://php.net/setlocale PHP setlocale function
@param string $format The format string
@return string
|
[
"Retrieves",
"localized",
"formatted",
"string",
"representation"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L419-L430
|
237,770
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.modify
|
public function modify(string $modify): DateTime
{
$dateTime = $this->dateTime()->modify($modify);
return static::fromNative($dateTime);
}
|
php
|
public function modify(string $modify): DateTime
{
$dateTime = $this->dateTime()->modify($modify);
return static::fromNative($dateTime);
}
|
[
"public",
"function",
"modify",
"(",
"string",
"$",
"modify",
")",
":",
"DateTime",
"{",
"$",
"dateTime",
"=",
"$",
"this",
"->",
"dateTime",
"(",
")",
"->",
"modify",
"(",
"$",
"modify",
")",
";",
"return",
"static",
"::",
"fromNative",
"(",
"$",
"dateTime",
")",
";",
"}"
] |
Creates an instance with a modified timestamp
Alters the timestamp of the DateTime by incrementing or decrementing in
a format accepted by strtotime().
@param string $modify A date/time string
@return DateTime
|
[
"Creates",
"an",
"instance",
"with",
"a",
"modified",
"timestamp"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L693-L698
|
237,771
|
novuso/common
|
src/Domain/Value/DateTime/DateTime.php
|
DateTime.createNative
|
private static function createNative(
int $year,
int $month,
int $day,
int $hour,
int $minute,
int $second,
string $timezone
): DateTimeImmutable {
$time = sprintf('%04d-%02d-%02dT%02d:%02d:%02d', $year, $month, $day, $hour, $minute, $second);
return DateTimeImmutable::createFromFormat(self::STRING_FORMAT, $time, new DateTimeZone($timezone));
}
|
php
|
private static function createNative(
int $year,
int $month,
int $day,
int $hour,
int $minute,
int $second,
string $timezone
): DateTimeImmutable {
$time = sprintf('%04d-%02d-%02dT%02d:%02d:%02d', $year, $month, $day, $hour, $minute, $second);
return DateTimeImmutable::createFromFormat(self::STRING_FORMAT, $time, new DateTimeZone($timezone));
}
|
[
"private",
"static",
"function",
"createNative",
"(",
"int",
"$",
"year",
",",
"int",
"$",
"month",
",",
"int",
"$",
"day",
",",
"int",
"$",
"hour",
",",
"int",
"$",
"minute",
",",
"int",
"$",
"second",
",",
"string",
"$",
"timezone",
")",
":",
"DateTimeImmutable",
"{",
"$",
"time",
"=",
"sprintf",
"(",
"'%04d-%02d-%02dT%02d:%02d:%02d'",
",",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
",",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
")",
";",
"return",
"DateTimeImmutable",
"::",
"createFromFormat",
"(",
"self",
"::",
"STRING_FORMAT",
",",
"$",
"time",
",",
"new",
"DateTimeZone",
"(",
"$",
"timezone",
")",
")",
";",
"}"
] |
Creates a native DateTime from date and time values
@param int $year The year
@param int $month The month
@param int $day The day
@param int $hour The hour
@param int $minute The minute
@param int $second The second
@param string $timezone The timezone
@return DateTimeImmutable
|
[
"Creates",
"a",
"native",
"DateTime",
"from",
"date",
"and",
"time",
"values"
] |
7d0e5a4f4c79c9622e068efc8b7c70815c460863
|
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/DateTime.php#L793-L805
|
237,772
|
metastore-libraries/lib-kernel
|
src/Translit.php
|
Translit.get
|
public static function get( $string, $rule = 'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();' ) {
$trans = self::createTranslit( $rule );
$string = preg_replace( '/[-\s]+/', '-', $trans->transliterate( $string ) );
$out = trim( $string, '-' );
return $out;
}
|
php
|
public static function get( $string, $rule = 'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();' ) {
$trans = self::createTranslit( $rule );
$string = preg_replace( '/[-\s]+/', '-', $trans->transliterate( $string ) );
$out = trim( $string, '-' );
return $out;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"string",
",",
"$",
"rule",
"=",
"'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();'",
")",
"{",
"$",
"trans",
"=",
"self",
"::",
"createTranslit",
"(",
"$",
"rule",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/[-\\s]+/'",
",",
"'-'",
",",
"$",
"trans",
"->",
"transliterate",
"(",
"$",
"string",
")",
")",
";",
"$",
"out",
"=",
"trim",
"(",
"$",
"string",
",",
"'-'",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
Transliterate a string.
@param $string
@param string $rule
@return string
|
[
"Transliterate",
"a",
"string",
"."
] |
6fec041a3ad66d0761170a6a8c28c6cd85e2642c
|
https://github.com/metastore-libraries/lib-kernel/blob/6fec041a3ad66d0761170a6a8c28c6cd85e2642c/src/Translit.php#L30-L36
|
237,773
|
tekkla/core-html
|
Core/Html/Controls/DataSelect.php
|
DataSelect.build
|
public function build()
{
foreach ($this->datasource as $index => $val) {
$option = $this->createOption();
// inner will always be used
$option->setInner($val);
$option->setValue($this->index_is_value ? $index : $val);
// in dependence of the data type is value to be selected $val or $inner
if (!empty($this->selected)) {
// A list of selected?
if (is_array($this->selected)) {
if (array_search(($this->index_is_value ? $index : $val), $this->selected)) {
$option->isSelected(1);
}
} // Or a value to look for?
else {
if ($this->selected == ($this->index_is_value ? $index : $val)) {
$option->isSelected(1);
}
}
}
}
return parent::build();
}
|
php
|
public function build()
{
foreach ($this->datasource as $index => $val) {
$option = $this->createOption();
// inner will always be used
$option->setInner($val);
$option->setValue($this->index_is_value ? $index : $val);
// in dependence of the data type is value to be selected $val or $inner
if (!empty($this->selected)) {
// A list of selected?
if (is_array($this->selected)) {
if (array_search(($this->index_is_value ? $index : $val), $this->selected)) {
$option->isSelected(1);
}
} // Or a value to look for?
else {
if ($this->selected == ($this->index_is_value ? $index : $val)) {
$option->isSelected(1);
}
}
}
}
return parent::build();
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"datasource",
"as",
"$",
"index",
"=>",
"$",
"val",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"createOption",
"(",
")",
";",
"// inner will always be used",
"$",
"option",
"->",
"setInner",
"(",
"$",
"val",
")",
";",
"$",
"option",
"->",
"setValue",
"(",
"$",
"this",
"->",
"index_is_value",
"?",
"$",
"index",
":",
"$",
"val",
")",
";",
"// in dependence of the data type is value to be selected $val or $inner",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"selected",
")",
")",
"{",
"// A list of selected?",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"selected",
")",
")",
"{",
"if",
"(",
"array_search",
"(",
"(",
"$",
"this",
"->",
"index_is_value",
"?",
"$",
"index",
":",
"$",
"val",
")",
",",
"$",
"this",
"->",
"selected",
")",
")",
"{",
"$",
"option",
"->",
"isSelected",
"(",
"1",
")",
";",
"}",
"}",
"// Or a value to look for?",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"selected",
"==",
"(",
"$",
"this",
"->",
"index_is_value",
"?",
"$",
"index",
":",
"$",
"val",
")",
")",
"{",
"$",
"option",
"->",
"isSelected",
"(",
"1",
")",
";",
"}",
"}",
"}",
"}",
"return",
"parent",
"::",
"build",
"(",
")",
";",
"}"
] |
Builds and returns html code
@see \Core\Html\Form\Select::build()
|
[
"Builds",
"and",
"returns",
"html",
"code"
] |
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
|
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Controls/DataSelect.php#L90-L117
|
237,774
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Sheet/Structure.php
|
Structure.setRules
|
public function setRules( $rules )
{
$this->rules = array();
foreach ( $rules as $rule )
{
$this->addRule( $rule );
}
return $this;
}
|
php
|
public function setRules( $rules )
{
$this->rules = array();
foreach ( $rules as $rule )
{
$this->addRule( $rule );
}
return $this;
}
|
[
"public",
"function",
"setRules",
"(",
"$",
"rules",
")",
"{",
"$",
"this",
"->",
"rules",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
")",
"{",
"$",
"this",
"->",
"addRule",
"(",
"$",
"rule",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set all rules
@param \Customize\Model\Rule\Structure[] $rules
@return \Customize\Model\Sheet\Structure
|
[
"Set",
"all",
"rules"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Sheet/Structure.php#L98-L108
|
237,775
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Sheet/Structure.php
|
Structure.addRule
|
public function addRule( $rule )
{
if ( ! ( $rule instanceof RuleStructure ) )
{
$rule = new RuleStructure( $rule );
}
$this->rules[] = $rule;
return $this;
}
|
php
|
public function addRule( $rule )
{
if ( ! ( $rule instanceof RuleStructure ) )
{
$rule = new RuleStructure( $rule );
}
$this->rules[] = $rule;
return $this;
}
|
[
"public",
"function",
"addRule",
"(",
"$",
"rule",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"rule",
"instanceof",
"RuleStructure",
")",
")",
"{",
"$",
"rule",
"=",
"new",
"RuleStructure",
"(",
"$",
"rule",
")",
";",
"}",
"$",
"this",
"->",
"rules",
"[",
"]",
"=",
"$",
"rule",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a rule
@param array|\Customize\Model\Rule\Structure $rule
@return \Customize\Model\Sheet\Structure
|
[
"Add",
"a",
"rule"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Sheet/Structure.php#L116-L125
|
237,776
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Sheet/Structure.php
|
Structure.resetContents
|
public function resetContents()
{
$this->setImports( array() )
->setRules( array() );
if ( $this->hasExtraContent() )
{
$this->setExtraContent( null );
}
return $this;
}
|
php
|
public function resetContents()
{
$this->setImports( array() )
->setRules( array() );
if ( $this->hasExtraContent() )
{
$this->setExtraContent( null );
}
return $this;
}
|
[
"public",
"function",
"resetContents",
"(",
")",
"{",
"$",
"this",
"->",
"setImports",
"(",
"array",
"(",
")",
")",
"->",
"setRules",
"(",
"array",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasExtraContent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setExtraContent",
"(",
"null",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Reset all contents
@return Structure
|
[
"Reset",
"all",
"contents"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Sheet/Structure.php#L210-L221
|
237,777
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Sheet/Structure.php
|
Structure.render
|
public function render( $file = null, $eol = null )
{
static $escape = array( '"' => '\\"' );
$renderer = AbstractRenderer::factory( $file, $eol );
$eol = $renderer->getEol();
$renderer->writeLine(
'@charset "' . strtr( static::RENDER_CHARSET, $escape ) . '";'
);
if ( ! $this->comment && $this->extra && $this->extra->updated )
{
$this->comment = $this->extra
->updated
->format( DateTime::ISO8601 );
}
if ( $this->comment )
{
$commentLines = array_map(
function ( $line ) {
return ' * ' . $line;
},
preg_split( '/\s*[\n\r]+\s*/', $this->comment )
);
array_unshift( $commentLines, $eol . '/**' );
array_push( $commentLines, ' */' );
foreach ( $commentLines as $comment )
{
$renderer->writeLine( $comment );
}
}
foreach ( $this->imports as $import )
{
$renderer->writeLine(
'@import url("' . strtr( $import, $escape ) . '");' . $eol
);
}
$media = '';
foreach ( $this->rules as $rule )
{
$newMedia = (string) $rule->media;
if ( $media != $newMedia )
{
if ( $media )
{
$renderer->writeLine( '}' . $eol );
}
$media = $newMedia;
$renderer->writeLine( '@media ' . $media . $eol . '{' . $eol );
}
$rawPropertyNames = $rule->getRawPropertyNames();
if ( ! empty( $rawPropertyNames ) )
{
$renderer->writeLine(
( $media ? "\t" : '' ) .
$rule->selector . $eol .
( $media ? "\t" : '' ) . '{'
);
foreach ( $rawPropertyNames as $propery )
{
$renderer->writeLine(
( $media ? "\t" : '' ) .
"\t" . $propery . ': ' .
$rule->getRawPropertyValue( $propery ) .
$rule->getRawPropertyPostfix( $propery ) . ';'
);
}
$renderer->writeLine( ( $media ? "\t" : '' ) . '}' . $eol );
}
}
if ( $media )
{
$renderer->writeLine( '}' );
}
if ( $this->hasExtraContent() )
{
$renderer->writeLine( $eol . $this->getExtraContent() );
}
return $renderer;
}
|
php
|
public function render( $file = null, $eol = null )
{
static $escape = array( '"' => '\\"' );
$renderer = AbstractRenderer::factory( $file, $eol );
$eol = $renderer->getEol();
$renderer->writeLine(
'@charset "' . strtr( static::RENDER_CHARSET, $escape ) . '";'
);
if ( ! $this->comment && $this->extra && $this->extra->updated )
{
$this->comment = $this->extra
->updated
->format( DateTime::ISO8601 );
}
if ( $this->comment )
{
$commentLines = array_map(
function ( $line ) {
return ' * ' . $line;
},
preg_split( '/\s*[\n\r]+\s*/', $this->comment )
);
array_unshift( $commentLines, $eol . '/**' );
array_push( $commentLines, ' */' );
foreach ( $commentLines as $comment )
{
$renderer->writeLine( $comment );
}
}
foreach ( $this->imports as $import )
{
$renderer->writeLine(
'@import url("' . strtr( $import, $escape ) . '");' . $eol
);
}
$media = '';
foreach ( $this->rules as $rule )
{
$newMedia = (string) $rule->media;
if ( $media != $newMedia )
{
if ( $media )
{
$renderer->writeLine( '}' . $eol );
}
$media = $newMedia;
$renderer->writeLine( '@media ' . $media . $eol . '{' . $eol );
}
$rawPropertyNames = $rule->getRawPropertyNames();
if ( ! empty( $rawPropertyNames ) )
{
$renderer->writeLine(
( $media ? "\t" : '' ) .
$rule->selector . $eol .
( $media ? "\t" : '' ) . '{'
);
foreach ( $rawPropertyNames as $propery )
{
$renderer->writeLine(
( $media ? "\t" : '' ) .
"\t" . $propery . ': ' .
$rule->getRawPropertyValue( $propery ) .
$rule->getRawPropertyPostfix( $propery ) . ';'
);
}
$renderer->writeLine( ( $media ? "\t" : '' ) . '}' . $eol );
}
}
if ( $media )
{
$renderer->writeLine( '}' );
}
if ( $this->hasExtraContent() )
{
$renderer->writeLine( $eol . $this->getExtraContent() );
}
return $renderer;
}
|
[
"public",
"function",
"render",
"(",
"$",
"file",
"=",
"null",
",",
"$",
"eol",
"=",
"null",
")",
"{",
"static",
"$",
"escape",
"=",
"array",
"(",
"'\"'",
"=>",
"'\\\\\"'",
")",
";",
"$",
"renderer",
"=",
"AbstractRenderer",
"::",
"factory",
"(",
"$",
"file",
",",
"$",
"eol",
")",
";",
"$",
"eol",
"=",
"$",
"renderer",
"->",
"getEol",
"(",
")",
";",
"$",
"renderer",
"->",
"writeLine",
"(",
"'@charset \"'",
".",
"strtr",
"(",
"static",
"::",
"RENDER_CHARSET",
",",
"$",
"escape",
")",
".",
"'\";'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"comment",
"&&",
"$",
"this",
"->",
"extra",
"&&",
"$",
"this",
"->",
"extra",
"->",
"updated",
")",
"{",
"$",
"this",
"->",
"comment",
"=",
"$",
"this",
"->",
"extra",
"->",
"updated",
"->",
"format",
"(",
"DateTime",
"::",
"ISO8601",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"comment",
")",
"{",
"$",
"commentLines",
"=",
"array_map",
"(",
"function",
"(",
"$",
"line",
")",
"{",
"return",
"' * '",
".",
"$",
"line",
";",
"}",
",",
"preg_split",
"(",
"'/\\s*[\\n\\r]+\\s*/'",
",",
"$",
"this",
"->",
"comment",
")",
")",
";",
"array_unshift",
"(",
"$",
"commentLines",
",",
"$",
"eol",
".",
"'/**'",
")",
";",
"array_push",
"(",
"$",
"commentLines",
",",
"' */'",
")",
";",
"foreach",
"(",
"$",
"commentLines",
"as",
"$",
"comment",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"$",
"comment",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"imports",
"as",
"$",
"import",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"'@import url(\"'",
".",
"strtr",
"(",
"$",
"import",
",",
"$",
"escape",
")",
".",
"'\");'",
".",
"$",
"eol",
")",
";",
"}",
"$",
"media",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"$",
"newMedia",
"=",
"(",
"string",
")",
"$",
"rule",
"->",
"media",
";",
"if",
"(",
"$",
"media",
"!=",
"$",
"newMedia",
")",
"{",
"if",
"(",
"$",
"media",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"'}'",
".",
"$",
"eol",
")",
";",
"}",
"$",
"media",
"=",
"$",
"newMedia",
";",
"$",
"renderer",
"->",
"writeLine",
"(",
"'@media '",
".",
"$",
"media",
".",
"$",
"eol",
".",
"'{'",
".",
"$",
"eol",
")",
";",
"}",
"$",
"rawPropertyNames",
"=",
"$",
"rule",
"->",
"getRawPropertyNames",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rawPropertyNames",
")",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"(",
"$",
"media",
"?",
"\"\\t\"",
":",
"''",
")",
".",
"$",
"rule",
"->",
"selector",
".",
"$",
"eol",
".",
"(",
"$",
"media",
"?",
"\"\\t\"",
":",
"''",
")",
".",
"'{'",
")",
";",
"foreach",
"(",
"$",
"rawPropertyNames",
"as",
"$",
"propery",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"(",
"$",
"media",
"?",
"\"\\t\"",
":",
"''",
")",
".",
"\"\\t\"",
".",
"$",
"propery",
".",
"': '",
".",
"$",
"rule",
"->",
"getRawPropertyValue",
"(",
"$",
"propery",
")",
".",
"$",
"rule",
"->",
"getRawPropertyPostfix",
"(",
"$",
"propery",
")",
".",
"';'",
")",
";",
"}",
"$",
"renderer",
"->",
"writeLine",
"(",
"(",
"$",
"media",
"?",
"\"\\t\"",
":",
"''",
")",
".",
"'}'",
".",
"$",
"eol",
")",
";",
"}",
"}",
"if",
"(",
"$",
"media",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"'}'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasExtraContent",
"(",
")",
")",
"{",
"$",
"renderer",
"->",
"writeLine",
"(",
"$",
"eol",
".",
"$",
"this",
"->",
"getExtraContent",
"(",
")",
")",
";",
"}",
"return",
"$",
"renderer",
";",
"}"
] |
Render rules to a css-file
@param RendererInterface|resource|string|null $file
@param string|null $eol
@return RendererInterface
|
[
"Render",
"rules",
"to",
"a",
"css",
"-",
"file"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Sheet/Structure.php#L230-L323
|
237,778
|
zepi/turbo-base
|
Zepi/Web/AccessControl/src/Table/UserTable.php
|
UserTable.getColumns
|
public function getColumns()
{
$translationManager = $this->framework->getInstance('\\Zepi\\Core\\Language\\Manager\\TranslationManager');
return array(
new Column('name', $translationManager->translate('Username', '\\Zepi\\Web\\AccessControl'), 50, true, true, Column::DATA_TYPE_HTML, 'icon-column'),
new Column('uuid', $translationManager->translate('UUID', '\\Zepi\\Web\\AccessControl'), 50, true, true, Column::DATA_TYPE_STRING),
new Column('actions', '', Column::WIDTH_AUTO, false, false, Column::DATA_TYPE_HTML, 'auto-width button-column')
);
}
|
php
|
public function getColumns()
{
$translationManager = $this->framework->getInstance('\\Zepi\\Core\\Language\\Manager\\TranslationManager');
return array(
new Column('name', $translationManager->translate('Username', '\\Zepi\\Web\\AccessControl'), 50, true, true, Column::DATA_TYPE_HTML, 'icon-column'),
new Column('uuid', $translationManager->translate('UUID', '\\Zepi\\Web\\AccessControl'), 50, true, true, Column::DATA_TYPE_STRING),
new Column('actions', '', Column::WIDTH_AUTO, false, false, Column::DATA_TYPE_HTML, 'auto-width button-column')
);
}
|
[
"public",
"function",
"getColumns",
"(",
")",
"{",
"$",
"translationManager",
"=",
"$",
"this",
"->",
"framework",
"->",
"getInstance",
"(",
"'\\\\Zepi\\\\Core\\\\Language\\\\Manager\\\\TranslationManager'",
")",
";",
"return",
"array",
"(",
"new",
"Column",
"(",
"'name'",
",",
"$",
"translationManager",
"->",
"translate",
"(",
"'Username'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
",",
"50",
",",
"true",
",",
"true",
",",
"Column",
"::",
"DATA_TYPE_HTML",
",",
"'icon-column'",
")",
",",
"new",
"Column",
"(",
"'uuid'",
",",
"$",
"translationManager",
"->",
"translate",
"(",
"'UUID'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
",",
"50",
",",
"true",
",",
"true",
",",
"Column",
"::",
"DATA_TYPE_STRING",
")",
",",
"new",
"Column",
"(",
"'actions'",
",",
"''",
",",
"Column",
"::",
"WIDTH_AUTO",
",",
"false",
",",
"false",
",",
"Column",
"::",
"DATA_TYPE_HTML",
",",
"'auto-width button-column'",
")",
")",
";",
"}"
] |
Returns an array with all columns
@access public
@return array
|
[
"Returns",
"an",
"array",
"with",
"all",
"columns"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Table/UserTable.php#L89-L98
|
237,779
|
oxy-coach/yii2-seo-behavior
|
SeoBehavior.php
|
SeoBehavior.checkSeoAttributes
|
private function checkSeoAttributes()
{
$model = $this->owner;
$transliterationFunction = $this->transliterationFunction;
// if slug field is empty, filling one with generated slug
if ($this->slugAttribute && $model->{$this->slugAttribute} == null) {
$model->{$this->slugAttribute} = $transliterationFunction($model->{$this->nameAttribute});
}
// if some seo field is empty, filling it with name field data
foreach ($this->seoAttributes as $seoAttribute) {
if ($model->{$seoAttribute} == null){
$model->{$seoAttribute} = $model->{$this->nameAttribute};
}
}
}
|
php
|
private function checkSeoAttributes()
{
$model = $this->owner;
$transliterationFunction = $this->transliterationFunction;
// if slug field is empty, filling one with generated slug
if ($this->slugAttribute && $model->{$this->slugAttribute} == null) {
$model->{$this->slugAttribute} = $transliterationFunction($model->{$this->nameAttribute});
}
// if some seo field is empty, filling it with name field data
foreach ($this->seoAttributes as $seoAttribute) {
if ($model->{$seoAttribute} == null){
$model->{$seoAttribute} = $model->{$this->nameAttribute};
}
}
}
|
[
"private",
"function",
"checkSeoAttributes",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"transliterationFunction",
"=",
"$",
"this",
"->",
"transliterationFunction",
";",
"// if slug field is empty, filling one with generated slug",
"if",
"(",
"$",
"this",
"->",
"slugAttribute",
"&&",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"slugAttribute",
"}",
"==",
"null",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"slugAttribute",
"}",
"=",
"$",
"transliterationFunction",
"(",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"nameAttribute",
"}",
")",
";",
"}",
"// if some seo field is empty, filling it with name field data",
"foreach",
"(",
"$",
"this",
"->",
"seoAttributes",
"as",
"$",
"seoAttribute",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"{",
"$",
"seoAttribute",
"}",
"==",
"null",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"seoAttribute",
"}",
"=",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"nameAttribute",
"}",
";",
"}",
"}",
"}"
] |
Slug and seo attributes generating
|
[
"Slug",
"and",
"seo",
"attributes",
"generating"
] |
edfbc6acb4f86ce9dcfedc1895ff35a4cce8e993
|
https://github.com/oxy-coach/yii2-seo-behavior/blob/edfbc6acb4f86ce9dcfedc1895ff35a4cce8e993/SeoBehavior.php#L47-L63
|
237,780
|
TarikHuber/api-lib
|
src/Controllers/BaseController.php
|
BaseController.create
|
public function create($request, $response, $args) {
$params=$this->getCreateParams($request);
if($this->createWithClientID){
$params['client_id']=$request->getAttribute('client_id');
}
$validation= $this->validator->validateParams($params,$this->getValidation(0));
if($validation->failed()){
return $this->error_helper->validationFailed($response,$validation->getErrors());
}
if(!$created_id = $this->Model->insertGetId($params)){
return $this->error_helper->createFailed($response,'');
}
$data['error']=false;
$data[$this->name_s]=$this->Model->find($created_id);
$response=$response->withAddedHeader('insert_id',$created_id);
return $response->withJson($data);
}
|
php
|
public function create($request, $response, $args) {
$params=$this->getCreateParams($request);
if($this->createWithClientID){
$params['client_id']=$request->getAttribute('client_id');
}
$validation= $this->validator->validateParams($params,$this->getValidation(0));
if($validation->failed()){
return $this->error_helper->validationFailed($response,$validation->getErrors());
}
if(!$created_id = $this->Model->insertGetId($params)){
return $this->error_helper->createFailed($response,'');
}
$data['error']=false;
$data[$this->name_s]=$this->Model->find($created_id);
$response=$response->withAddedHeader('insert_id',$created_id);
return $response->withJson($data);
}
|
[
"public",
"function",
"create",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"args",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getCreateParams",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"this",
"->",
"createWithClientID",
")",
"{",
"$",
"params",
"[",
"'client_id'",
"]",
"=",
"$",
"request",
"->",
"getAttribute",
"(",
"'client_id'",
")",
";",
"}",
"$",
"validation",
"=",
"$",
"this",
"->",
"validator",
"->",
"validateParams",
"(",
"$",
"params",
",",
"$",
"this",
"->",
"getValidation",
"(",
"0",
")",
")",
";",
"if",
"(",
"$",
"validation",
"->",
"failed",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error_helper",
"->",
"validationFailed",
"(",
"$",
"response",
",",
"$",
"validation",
"->",
"getErrors",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"created_id",
"=",
"$",
"this",
"->",
"Model",
"->",
"insertGetId",
"(",
"$",
"params",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error_helper",
"->",
"createFailed",
"(",
"$",
"response",
",",
"''",
")",
";",
"}",
"$",
"data",
"[",
"'error'",
"]",
"=",
"false",
";",
"$",
"data",
"[",
"$",
"this",
"->",
"name_s",
"]",
"=",
"$",
"this",
"->",
"Model",
"->",
"find",
"(",
"$",
"created_id",
")",
";",
"$",
"response",
"=",
"$",
"response",
"->",
"withAddedHeader",
"(",
"'insert_id'",
",",
"$",
"created_id",
")",
";",
"return",
"$",
"response",
"->",
"withJson",
"(",
"$",
"data",
")",
";",
"}"
] |
Creates a new element in the model according to the request
@method create
@param [Object] $request [Slim request object]
@param [Object] $response [Slim response object]
@param [Array] $args [Arguments array]
@return [Object] [Slim response object]
|
[
"Creates",
"a",
"new",
"element",
"in",
"the",
"model",
"according",
"to",
"the",
"request"
] |
3ca7d4289220c5ba330784d83a82e25bad58e032
|
https://github.com/TarikHuber/api-lib/blob/3ca7d4289220c5ba330784d83a82e25bad58e032/src/Controllers/BaseController.php#L104-L127
|
237,781
|
ekyna/UserBundle
|
EventListener/AuthenticationListener.php
|
AuthenticationListener.onAuthenticationSuccess
|
public function onAuthenticationSuccess(AuthenticationEvent $event)
{
if (!$this->config['admin_login']) {
return;
}
$token = $event->getAuthenticationToken();
$userIsAdmin = $this->accessDecisionManager->decide($token, ['ROLE_ADMIN']);
// Only for Admins and fully authenticated
if (!($userIsAdmin && $token instanceof UsernamePasswordToken)) {
return;
}
/** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
$user = $token->getUser();
$this->mailer->sendSuccessfulLoginEmailMessage($user);
}
|
php
|
public function onAuthenticationSuccess(AuthenticationEvent $event)
{
if (!$this->config['admin_login']) {
return;
}
$token = $event->getAuthenticationToken();
$userIsAdmin = $this->accessDecisionManager->decide($token, ['ROLE_ADMIN']);
// Only for Admins and fully authenticated
if (!($userIsAdmin && $token instanceof UsernamePasswordToken)) {
return;
}
/** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
$user = $token->getUser();
$this->mailer->sendSuccessfulLoginEmailMessage($user);
}
|
[
"public",
"function",
"onAuthenticationSuccess",
"(",
"AuthenticationEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'admin_login'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"token",
"=",
"$",
"event",
"->",
"getAuthenticationToken",
"(",
")",
";",
"$",
"userIsAdmin",
"=",
"$",
"this",
"->",
"accessDecisionManager",
"->",
"decide",
"(",
"$",
"token",
",",
"[",
"'ROLE_ADMIN'",
"]",
")",
";",
"// Only for Admins and fully authenticated",
"if",
"(",
"!",
"(",
"$",
"userIsAdmin",
"&&",
"$",
"token",
"instanceof",
"UsernamePasswordToken",
")",
")",
"{",
"return",
";",
"}",
"/** @var \\Ekyna\\Bundle\\UserBundle\\Model\\UserInterface $user */",
"$",
"user",
"=",
"$",
"token",
"->",
"getUser",
"(",
")",
";",
"$",
"this",
"->",
"mailer",
"->",
"sendSuccessfulLoginEmailMessage",
"(",
"$",
"user",
")",
";",
"}"
] |
Handle login success event.
@param AuthenticationEvent $event
|
[
"Handle",
"login",
"success",
"event",
"."
] |
e38d56aee978148a312a923b9e70bdaad1a381bf
|
https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/EventListener/AuthenticationListener.php#L77-L95
|
237,782
|
atelierspierrot/library
|
src/Library/Session/FlashSession.php
|
FlashSession.read
|
public function read()
{
parent::read();
if (isset($_SESSION[static::SESSION_NAME])) {
$sess_table = $this->_uncrypt($_SESSION[static::SESSION_NAME]);
if (isset($sess_table[static::SESSION_FLASHESNAME])) {
$this->old_flashes = $sess_table[static::SESSION_FLASHESNAME];
}
}
$this->addSessionTable(static::SESSION_FLASHESNAME, $this->old_flashes);
return $this;
}
|
php
|
public function read()
{
parent::read();
if (isset($_SESSION[static::SESSION_NAME])) {
$sess_table = $this->_uncrypt($_SESSION[static::SESSION_NAME]);
if (isset($sess_table[static::SESSION_FLASHESNAME])) {
$this->old_flashes = $sess_table[static::SESSION_FLASHESNAME];
}
}
$this->addSessionTable(static::SESSION_FLASHESNAME, $this->old_flashes);
return $this;
}
|
[
"public",
"function",
"read",
"(",
")",
"{",
"parent",
"::",
"read",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"static",
"::",
"SESSION_NAME",
"]",
")",
")",
"{",
"$",
"sess_table",
"=",
"$",
"this",
"->",
"_uncrypt",
"(",
"$",
"_SESSION",
"[",
"static",
"::",
"SESSION_NAME",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"sess_table",
"[",
"static",
"::",
"SESSION_FLASHESNAME",
"]",
")",
")",
"{",
"$",
"this",
"->",
"old_flashes",
"=",
"$",
"sess_table",
"[",
"static",
"::",
"SESSION_FLASHESNAME",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"addSessionTable",
"(",
"static",
"::",
"SESSION_FLASHESNAME",
",",
"$",
"this",
"->",
"old_flashes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Start the current session if so
@return self
|
[
"Start",
"the",
"current",
"session",
"if",
"so"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L67-L78
|
237,783
|
atelierspierrot/library
|
src/Library/Session/FlashSession.php
|
FlashSession.getFlash
|
public function getFlash($index)
{
if ( ! $this->isOpened()) {
$this->start();
}
$_oldf = null;
if (!empty($index) && isset($this->old_flashes[$index])) {
$_oldf = $this->old_flashes[$index];
unset($this->old_flashes[$index]);
return $_oldf;
}
return null;
}
|
php
|
public function getFlash($index)
{
if ( ! $this->isOpened()) {
$this->start();
}
$_oldf = null;
if (!empty($index) && isset($this->old_flashes[$index])) {
$_oldf = $this->old_flashes[$index];
unset($this->old_flashes[$index]);
return $_oldf;
}
return null;
}
|
[
"public",
"function",
"getFlash",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isOpened",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"$",
"_oldf",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"index",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"old_flashes",
"[",
"$",
"index",
"]",
")",
")",
"{",
"$",
"_oldf",
"=",
"$",
"this",
"->",
"old_flashes",
"[",
"$",
"index",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"old_flashes",
"[",
"$",
"index",
"]",
")",
";",
"return",
"$",
"_oldf",
";",
"}",
"return",
"null",
";",
"}"
] |
Get a current session flash parameter
@param string $index
@return mixed
|
[
"Get",
"a",
"current",
"session",
"flash",
"parameter"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L112-L124
|
237,784
|
atelierspierrot/library
|
src/Library/Session/FlashSession.php
|
FlashSession.setFlash
|
public function setFlash($value, $index = null)
{
if ( ! $this->isOpened()) {
$this->start();
}
if (!empty($index)) {
$this->flashes[$index] = $value;
} else {
$this->flashes[] = $value;
}
return $this;
}
|
php
|
public function setFlash($value, $index = null)
{
if ( ! $this->isOpened()) {
$this->start();
}
if (!empty($index)) {
$this->flashes[$index] = $value;
} else {
$this->flashes[] = $value;
}
return $this;
}
|
[
"public",
"function",
"setFlash",
"(",
"$",
"value",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isOpened",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"index",
")",
")",
"{",
"$",
"this",
"->",
"flashes",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"flashes",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set a current session flash parameter
@param mixed $value
@param string $index
@return self
|
[
"Set",
"a",
"current",
"session",
"flash",
"parameter"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L133-L144
|
237,785
|
atelierspierrot/library
|
src/Library/Session/FlashSession.php
|
FlashSession.allFlashes
|
public function allFlashes()
{
if ( ! $this->isOpened()) {
$this->start();
}
if (!empty($this->old_flashes)) {
$_oldf = $this->old_flashes;
$this->old_flashes = array();
return $_oldf;
}
return null;
}
|
php
|
public function allFlashes()
{
if ( ! $this->isOpened()) {
$this->start();
}
if (!empty($this->old_flashes)) {
$_oldf = $this->old_flashes;
$this->old_flashes = array();
return $_oldf;
}
return null;
}
|
[
"public",
"function",
"allFlashes",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isOpened",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"old_flashes",
")",
")",
"{",
"$",
"_oldf",
"=",
"$",
"this",
"->",
"old_flashes",
";",
"$",
"this",
"->",
"old_flashes",
"=",
"array",
"(",
")",
";",
"return",
"$",
"_oldf",
";",
"}",
"return",
"null",
";",
"}"
] |
Get current session flash parameters stack
@return array
|
[
"Get",
"current",
"session",
"flash",
"parameters",
"stack"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L151-L162
|
237,786
|
atelierspierrot/library
|
src/Library/Session/FlashSession.php
|
FlashSession.clearFlashes
|
public function clearFlashes()
{
if ( ! $this->isOpened()) {
$this->start();
}
$this->flashes = array();
$this->old_flashes = array();
return $this;
}
|
php
|
public function clearFlashes()
{
if ( ! $this->isOpened()) {
$this->start();
}
$this->flashes = array();
$this->old_flashes = array();
return $this;
}
|
[
"public",
"function",
"clearFlashes",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isOpened",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"$",
"this",
"->",
"flashes",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"old_flashes",
"=",
"array",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Delete current session flash parameters
@return self
|
[
"Delete",
"current",
"session",
"flash",
"parameters"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L169-L177
|
237,787
|
SymBB/symbb
|
src/Symbb/Core/SystemBundle/Api/StatisticApi.php
|
StatisticApi.addVisitor
|
public function addVisitor(UserInterface $user, Request $request)
{
$days = 30;
$ip = $request->getClientIp();
$data = $this->getVisitors();
$date = new \DateTime();
$currTimestamp = $date->getTimestamp();
// entries should be only hourly
$date->setTime($date->format('H'), 0, 0);
$todayTimestamp = $date->getTimestamp();
if (!isset($data[$todayTimestamp])) {
$data[$todayTimestamp] = array();
}
$type = $user->getSymbbType();
$currVisitor = array(
'id' => $user->getId(),
'type' => $type,
'ip' => $ip,
'lastVisiting' => $currTimestamp
);
$overwriteKey = null;
// remove entries who are to old
$maxOldDate = new \DateTime();
$maxOldDate->setTime(0, 0, 0);
$maxOldDate->modify('-' . $days . 'days');
foreach ($data as $timestamp => $tmp) {
if (!is_numeric($timestamp) || $timestamp < $maxOldDate->getTimestamp()) {
unset($data[$timestamp]);
}
}
foreach ($data[$todayTimestamp] as $key => $visitor) {
if (
// case 1: guest -> check ip
(
$currVisitor['type'] == 'guest' &&
$visitor['type'] == $currVisitor['type'] &&
$visitor['ip'] == $currVisitor['ip']
) ||
// case 2: user -> check id ( can login with different ips )
(
$currVisitor['type'] == 'user' &&
$visitor['type'] == $currVisitor['type'] &&
$visitor['id'] == $currVisitor['id']
)
) {
$overwriteKey = $key;
break;
}
}
// if we have found the same visitor in the data
// then we will overwrite it
// if not we will add the vistor
if ($overwriteKey !== null) {
$data[$todayTimestamp][$overwriteKey] = $currVisitor;
} else {
$data[$todayTimestamp][] = $currVisitor;
}
// sort
ksort($data, SORT_NUMERIC);
// reverse so that the newest are the first
$data = array_reverse($data, true);
$this->memcache->set(self::MEMCACHE_VISITOR_KEY, $data, (86400 * $days)); // 30 days valid
}
|
php
|
public function addVisitor(UserInterface $user, Request $request)
{
$days = 30;
$ip = $request->getClientIp();
$data = $this->getVisitors();
$date = new \DateTime();
$currTimestamp = $date->getTimestamp();
// entries should be only hourly
$date->setTime($date->format('H'), 0, 0);
$todayTimestamp = $date->getTimestamp();
if (!isset($data[$todayTimestamp])) {
$data[$todayTimestamp] = array();
}
$type = $user->getSymbbType();
$currVisitor = array(
'id' => $user->getId(),
'type' => $type,
'ip' => $ip,
'lastVisiting' => $currTimestamp
);
$overwriteKey = null;
// remove entries who are to old
$maxOldDate = new \DateTime();
$maxOldDate->setTime(0, 0, 0);
$maxOldDate->modify('-' . $days . 'days');
foreach ($data as $timestamp => $tmp) {
if (!is_numeric($timestamp) || $timestamp < $maxOldDate->getTimestamp()) {
unset($data[$timestamp]);
}
}
foreach ($data[$todayTimestamp] as $key => $visitor) {
if (
// case 1: guest -> check ip
(
$currVisitor['type'] == 'guest' &&
$visitor['type'] == $currVisitor['type'] &&
$visitor['ip'] == $currVisitor['ip']
) ||
// case 2: user -> check id ( can login with different ips )
(
$currVisitor['type'] == 'user' &&
$visitor['type'] == $currVisitor['type'] &&
$visitor['id'] == $currVisitor['id']
)
) {
$overwriteKey = $key;
break;
}
}
// if we have found the same visitor in the data
// then we will overwrite it
// if not we will add the vistor
if ($overwriteKey !== null) {
$data[$todayTimestamp][$overwriteKey] = $currVisitor;
} else {
$data[$todayTimestamp][] = $currVisitor;
}
// sort
ksort($data, SORT_NUMERIC);
// reverse so that the newest are the first
$data = array_reverse($data, true);
$this->memcache->set(self::MEMCACHE_VISITOR_KEY, $data, (86400 * $days)); // 30 days valid
}
|
[
"public",
"function",
"addVisitor",
"(",
"UserInterface",
"$",
"user",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"days",
"=",
"30",
";",
"$",
"ip",
"=",
"$",
"request",
"->",
"getClientIp",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getVisitors",
"(",
")",
";",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"currTimestamp",
"=",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
";",
"// entries should be only hourly",
"$",
"date",
"->",
"setTime",
"(",
"$",
"date",
"->",
"format",
"(",
"'H'",
")",
",",
"0",
",",
"0",
")",
";",
"$",
"todayTimestamp",
"=",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"todayTimestamp",
"]",
")",
")",
"{",
"$",
"data",
"[",
"$",
"todayTimestamp",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"type",
"=",
"$",
"user",
"->",
"getSymbbType",
"(",
")",
";",
"$",
"currVisitor",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"user",
"->",
"getId",
"(",
")",
",",
"'type'",
"=>",
"$",
"type",
",",
"'ip'",
"=>",
"$",
"ip",
",",
"'lastVisiting'",
"=>",
"$",
"currTimestamp",
")",
";",
"$",
"overwriteKey",
"=",
"null",
";",
"// remove entries who are to old",
"$",
"maxOldDate",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"maxOldDate",
"->",
"setTime",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"$",
"maxOldDate",
"->",
"modify",
"(",
"'-'",
".",
"$",
"days",
".",
"'days'",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"timestamp",
"=>",
"$",
"tmp",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"timestamp",
")",
"||",
"$",
"timestamp",
"<",
"$",
"maxOldDate",
"->",
"getTimestamp",
"(",
")",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"$",
"timestamp",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"data",
"[",
"$",
"todayTimestamp",
"]",
"as",
"$",
"key",
"=>",
"$",
"visitor",
")",
"{",
"if",
"(",
"// case 1: guest -> check ip",
"(",
"$",
"currVisitor",
"[",
"'type'",
"]",
"==",
"'guest'",
"&&",
"$",
"visitor",
"[",
"'type'",
"]",
"==",
"$",
"currVisitor",
"[",
"'type'",
"]",
"&&",
"$",
"visitor",
"[",
"'ip'",
"]",
"==",
"$",
"currVisitor",
"[",
"'ip'",
"]",
")",
"||",
"// case 2: user -> check id ( can login with different ips )",
"(",
"$",
"currVisitor",
"[",
"'type'",
"]",
"==",
"'user'",
"&&",
"$",
"visitor",
"[",
"'type'",
"]",
"==",
"$",
"currVisitor",
"[",
"'type'",
"]",
"&&",
"$",
"visitor",
"[",
"'id'",
"]",
"==",
"$",
"currVisitor",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"overwriteKey",
"=",
"$",
"key",
";",
"break",
";",
"}",
"}",
"// if we have found the same visitor in the data",
"// then we will overwrite it",
"// if not we will add the vistor",
"if",
"(",
"$",
"overwriteKey",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"$",
"todayTimestamp",
"]",
"[",
"$",
"overwriteKey",
"]",
"=",
"$",
"currVisitor",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"todayTimestamp",
"]",
"[",
"]",
"=",
"$",
"currVisitor",
";",
"}",
"// sort",
"ksort",
"(",
"$",
"data",
",",
"SORT_NUMERIC",
")",
";",
"// reverse so that the newest are the first",
"$",
"data",
"=",
"array_reverse",
"(",
"$",
"data",
",",
"true",
")",
";",
"$",
"this",
"->",
"memcache",
"->",
"set",
"(",
"self",
"::",
"MEMCACHE_VISITOR_KEY",
",",
"$",
"data",
",",
"(",
"86400",
"*",
"$",
"days",
")",
")",
";",
"// 30 days valid",
"}"
] |
this method will add a visitor to the statistic
currently its only a memcache storage because this information
is not important if someone will track his visitors fully he should use a analytics tool
@param UserInterface $user
@param Request $request
|
[
"this",
"method",
"will",
"add",
"a",
"visitor",
"to",
"the",
"statistic",
"currently",
"its",
"only",
"a",
"memcache",
"storage",
"because",
"this",
"information",
"is",
"not",
"important",
"if",
"someone",
"will",
"track",
"his",
"visitors",
"fully",
"he",
"should",
"use",
"a",
"analytics",
"tool"
] |
be25357502e6a51016fa0b128a46c2dc87fa8fb2
|
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/StatisticApi.php#L79-L152
|
237,788
|
nubs/sensible
|
src/Strategy/CommandLocatorStrategy.php
|
CommandLocatorStrategy.get
|
public function get()
{
foreach ($this->_commands as $command) {
$location = $this->_commandLocator->locate(basename($command));
if ($location !== null) {
return $location;
}
}
return null;
}
|
php
|
public function get()
{
foreach ($this->_commands as $command) {
$location = $this->_commandLocator->locate(basename($command));
if ($location !== null) {
return $location;
}
}
return null;
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_commands",
"as",
"$",
"command",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"_commandLocator",
"->",
"locate",
"(",
"basename",
"(",
"$",
"command",
")",
")",
";",
"if",
"(",
"$",
"location",
"!==",
"null",
")",
"{",
"return",
"$",
"location",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the path to the first command found in the list.
@return string|null The located command, or null if none could be found.
|
[
"Returns",
"the",
"path",
"to",
"the",
"first",
"command",
"found",
"in",
"the",
"list",
"."
] |
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
|
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Strategy/CommandLocatorStrategy.php#L34-L44
|
237,789
|
dejan7/HTTPQuest
|
src/Decoders/FormDataDecoder.php
|
FormDataDecoder.readUntil
|
protected function readUntil($search)
{
while (($position = strpos($this->buffer, $search)) === false) {
if (feof($this->fp)) {
fclose($this->fp);
throw new DecodeException(
"Invalid multipart data encountered; " .
"end of content was reached before expected"
);
}
$this->buffer .= fread($this->fp, $this->bytesPerRead);
}
return $position;
}
|
php
|
protected function readUntil($search)
{
while (($position = strpos($this->buffer, $search)) === false) {
if (feof($this->fp)) {
fclose($this->fp);
throw new DecodeException(
"Invalid multipart data encountered; " .
"end of content was reached before expected"
);
}
$this->buffer .= fread($this->fp, $this->bytesPerRead);
}
return $position;
}
|
[
"protected",
"function",
"readUntil",
"(",
"$",
"search",
")",
"{",
"while",
"(",
"(",
"$",
"position",
"=",
"strpos",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"search",
")",
")",
"===",
"false",
")",
"{",
"if",
"(",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"throw",
"new",
"DecodeException",
"(",
"\"Invalid multipart data encountered; \"",
".",
"\"end of content was reached before expected\"",
")",
";",
"}",
"$",
"this",
"->",
"buffer",
".=",
"fread",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"this",
"->",
"bytesPerRead",
")",
";",
"}",
"return",
"$",
"position",
";",
"}"
] |
Read the input stream into the buffer until a string is encountered
@param string $search The string to read until
@return int The position of the string in the buffer
@throws DecodeException
|
[
"Read",
"the",
"input",
"stream",
"into",
"the",
"buffer",
"until",
"a",
"string",
"is",
"encountered"
] |
c0e1e2b08db6da2917020090aad767fe31552be3
|
https://github.com/dejan7/HTTPQuest/blob/c0e1e2b08db6da2917020090aad767fe31552be3/src/Decoders/FormDataDecoder.php#L246-L259
|
237,790
|
dejan7/HTTPQuest
|
src/Decoders/FormDataDecoder.php
|
FormDataDecoder.addValue
|
protected function addValue(&$fieldsArray, $name, $value)
{
$arrayCheck = substr($name, -2);
if ($arrayCheck == '[]') {
$nameSubstr = substr($name, 0, -2);
if (!isset($fieldsArray[$nameSubstr]))
$fieldsArray[$nameSubstr] = [];
$fieldsArray[$nameSubstr][] = $value;
} else {
$fieldsArray[$name] = $value;
}
}
|
php
|
protected function addValue(&$fieldsArray, $name, $value)
{
$arrayCheck = substr($name, -2);
if ($arrayCheck == '[]') {
$nameSubstr = substr($name, 0, -2);
if (!isset($fieldsArray[$nameSubstr]))
$fieldsArray[$nameSubstr] = [];
$fieldsArray[$nameSubstr][] = $value;
} else {
$fieldsArray[$name] = $value;
}
}
|
[
"protected",
"function",
"addValue",
"(",
"&",
"$",
"fieldsArray",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"arrayCheck",
"=",
"substr",
"(",
"$",
"name",
",",
"-",
"2",
")",
";",
"if",
"(",
"$",
"arrayCheck",
"==",
"'[]'",
")",
"{",
"$",
"nameSubstr",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"-",
"2",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"fieldsArray",
"[",
"$",
"nameSubstr",
"]",
")",
")",
"$",
"fieldsArray",
"[",
"$",
"nameSubstr",
"]",
"=",
"[",
"]",
";",
"$",
"fieldsArray",
"[",
"$",
"nameSubstr",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"fieldsArray",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Inserts the value into the passed array.
Used to parse input array from HTTP request body, if needed
@param array $fieldsArray
@param string $name name of the field
@param string $value value of the field
|
[
"Inserts",
"the",
"value",
"into",
"the",
"passed",
"array",
".",
"Used",
"to",
"parse",
"input",
"array",
"from",
"HTTP",
"request",
"body",
"if",
"needed"
] |
c0e1e2b08db6da2917020090aad767fe31552be3
|
https://github.com/dejan7/HTTPQuest/blob/c0e1e2b08db6da2917020090aad767fe31552be3/src/Decoders/FormDataDecoder.php#L288-L301
|
237,791
|
logikostech/common
|
src/UserOptionTrait.php
|
UserOptionTrait.getUserOption
|
public function getUserOption($option, $defaultValue=null) {
return isset($this->_options[$option])
? $this->_options[$option]
: $defaultValue;
}
|
php
|
public function getUserOption($option, $defaultValue=null) {
return isset($this->_options[$option])
? $this->_options[$option]
: $defaultValue;
}
|
[
"public",
"function",
"getUserOption",
"(",
"$",
"option",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_options",
"[",
"$",
"option",
"]",
")",
"?",
"$",
"this",
"->",
"_options",
"[",
"$",
"option",
"]",
":",
"$",
"defaultValue",
";",
"}"
] |
Returns the value of an option if present
@param string option
@param mixed defaultValue
@return mixed
|
[
"Returns",
"the",
"value",
"of",
"an",
"option",
"if",
"present"
] |
3329e934e28702b95a9a232f196d87c92e1a9401
|
https://github.com/logikostech/common/blob/3329e934e28702b95a9a232f196d87c92e1a9401/src/UserOptionTrait.php#L46-L50
|
237,792
|
logikostech/common
|
src/UserOptionTrait.php
|
UserOptionTrait._setDefaultUserOptions
|
protected function _setDefaultUserOptions(array $options) {
foreach ($options as $option=>$value) {
if (!$this->getUserOption($option))
$this->setUserOption($option,$value);
}
return $this;
}
|
php
|
protected function _setDefaultUserOptions(array $options) {
foreach ($options as $option=>$value) {
if (!$this->getUserOption($option))
$this->setUserOption($option,$value);
}
return $this;
}
|
[
"protected",
"function",
"_setDefaultUserOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getUserOption",
"(",
"$",
"option",
")",
")",
"$",
"this",
"->",
"setUserOption",
"(",
"$",
"option",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Used to set defaults, will not overwrite existing values
@param array $options
|
[
"Used",
"to",
"set",
"defaults",
"will",
"not",
"overwrite",
"existing",
"values"
] |
3329e934e28702b95a9a232f196d87c92e1a9401
|
https://github.com/logikostech/common/blob/3329e934e28702b95a9a232f196d87c92e1a9401/src/UserOptionTrait.php#L85-L91
|
237,793
|
fintech-fab/money-transfer-emulator-sdk
|
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
|
Gateway.city
|
public function city()
{
$requestParams = $this->initRequestParams('city');
$this->request('city', $requestParams);
return empty($this->error);
}
|
php
|
public function city()
{
$requestParams = $this->initRequestParams('city');
$this->request('city', $requestParams);
return empty($this->error);
}
|
[
"public",
"function",
"city",
"(",
")",
"{",
"$",
"requestParams",
"=",
"$",
"this",
"->",
"initRequestParams",
"(",
"'city'",
")",
";",
"$",
"this",
"->",
"request",
"(",
"'city'",
",",
"$",
"requestParams",
")",
";",
"return",
"empty",
"(",
"$",
"this",
"->",
"error",
")",
";",
"}"
] |
Get City list from gateway
@return boolean
|
[
"Get",
"City",
"list",
"from",
"gateway"
] |
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
|
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L79-L85
|
237,794
|
fintech-fab/money-transfer-emulator-sdk
|
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
|
Gateway.fee
|
public function fee($cityId, $orderAmount)
{
$params = compact('cityId', 'orderAmount');
$requestParams = $this->initRequestParams('fee', $params);
$this->request('fee', $requestParams);
return empty($this->error);
}
|
php
|
public function fee($cityId, $orderAmount)
{
$params = compact('cityId', 'orderAmount');
$requestParams = $this->initRequestParams('fee', $params);
$this->request('fee', $requestParams);
return empty($this->error);
}
|
[
"public",
"function",
"fee",
"(",
"$",
"cityId",
",",
"$",
"orderAmount",
")",
"{",
"$",
"params",
"=",
"compact",
"(",
"'cityId'",
",",
"'orderAmount'",
")",
";",
"$",
"requestParams",
"=",
"$",
"this",
"->",
"initRequestParams",
"(",
"'fee'",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"request",
"(",
"'fee'",
",",
"$",
"requestParams",
")",
";",
"return",
"empty",
"(",
"$",
"this",
"->",
"error",
")",
";",
"}"
] |
Get fee result by city and amount
@param integer $cityId
@param float $orderAmount
@return boolean
|
[
"Get",
"fee",
"result",
"by",
"city",
"and",
"amount"
] |
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
|
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L119-L126
|
237,795
|
fintech-fab/money-transfer-emulator-sdk
|
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
|
Gateway.getFeeValue
|
public function getFeeValue($cityId, $orderAmount)
{
$result = $this->fee($cityId, $orderAmount);
if (!$result) {
dd($this->getResultRaw());
return null;
}
return $this->getResultFeeValue();
}
|
php
|
public function getFeeValue($cityId, $orderAmount)
{
$result = $this->fee($cityId, $orderAmount);
if (!$result) {
dd($this->getResultRaw());
return null;
}
return $this->getResultFeeValue();
}
|
[
"public",
"function",
"getFeeValue",
"(",
"$",
"cityId",
",",
"$",
"orderAmount",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"fee",
"(",
"$",
"cityId",
",",
"$",
"orderAmount",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"dd",
"(",
"$",
"this",
"->",
"getResultRaw",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"getResultFeeValue",
"(",
")",
";",
"}"
] |
Get fee value by city and amount
@param integer $cityId
@param float $orderAmount
@return boolean
|
[
"Get",
"fee",
"value",
"by",
"city",
"and",
"amount"
] |
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
|
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L136-L148
|
237,796
|
fintech-fab/money-transfer-emulator-sdk
|
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
|
Gateway.status
|
public function status($orderCode, $toNumber)
{
$params = compact('orderCode', 'toNumber');
$requestParams = $this->initRequestParams('status', $params);
$this->request('status', $requestParams);
return empty($this->error);
}
|
php
|
public function status($orderCode, $toNumber)
{
$params = compact('orderCode', 'toNumber');
$requestParams = $this->initRequestParams('status', $params);
$this->request('status', $requestParams);
return empty($this->error);
}
|
[
"public",
"function",
"status",
"(",
"$",
"orderCode",
",",
"$",
"toNumber",
")",
"{",
"$",
"params",
"=",
"compact",
"(",
"'orderCode'",
",",
"'toNumber'",
")",
";",
"$",
"requestParams",
"=",
"$",
"this",
"->",
"initRequestParams",
"(",
"'status'",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"request",
"(",
"'status'",
",",
"$",
"requestParams",
")",
";",
"return",
"empty",
"(",
"$",
"this",
"->",
"error",
")",
";",
"}"
] |
Get payment status
@param string $orderCode
@param string $toNumber
@return boolean
|
[
"Get",
"payment",
"status"
] |
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
|
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L195-L202
|
237,797
|
fintech-fab/money-transfer-emulator-sdk
|
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
|
Gateway.request
|
private function request($type, $requestParams)
{
$this->cleanup();
$curl = new Curl();
$curl->setCheckCertificates($this->configParams['strongSSL']);
$curl->post($this->configParams['gatewayUrl'], array(
'type' => $type,
'input' => $requestParams,
));
$this->parseErrors($curl);
if (!$this->error || $this->error['type'] == self::C_ERROR_PROCESSING) {
$this->response = json_decode($curl->result);
}
}
|
php
|
private function request($type, $requestParams)
{
$this->cleanup();
$curl = new Curl();
$curl->setCheckCertificates($this->configParams['strongSSL']);
$curl->post($this->configParams['gatewayUrl'], array(
'type' => $type,
'input' => $requestParams,
));
$this->parseErrors($curl);
if (!$this->error || $this->error['type'] == self::C_ERROR_PROCESSING) {
$this->response = json_decode($curl->result);
}
}
|
[
"private",
"function",
"request",
"(",
"$",
"type",
",",
"$",
"requestParams",
")",
"{",
"$",
"this",
"->",
"cleanup",
"(",
")",
";",
"$",
"curl",
"=",
"new",
"Curl",
"(",
")",
";",
"$",
"curl",
"->",
"setCheckCertificates",
"(",
"$",
"this",
"->",
"configParams",
"[",
"'strongSSL'",
"]",
")",
";",
"$",
"curl",
"->",
"post",
"(",
"$",
"this",
"->",
"configParams",
"[",
"'gatewayUrl'",
"]",
",",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'input'",
"=>",
"$",
"requestParams",
",",
")",
")",
";",
"$",
"this",
"->",
"parseErrors",
"(",
"$",
"curl",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"error",
"||",
"$",
"this",
"->",
"error",
"[",
"'type'",
"]",
"==",
"self",
"::",
"C_ERROR_PROCESSING",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"json_decode",
"(",
"$",
"curl",
"->",
"result",
")",
";",
"}",
"}"
] |
Executing http request
@param string $type
@param array $requestParams
|
[
"Executing",
"http",
"request"
] |
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
|
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L464-L481
|
237,798
|
fintech-fab/money-transfer-emulator-sdk
|
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
|
Gateway.parseErrors
|
private function parseErrors(Curl $curl)
{
$this->rawResponse = $curl->result;
if ($curl->error) {
$this->error = array(
'type' => self::C_ERROR_HTTP,
'message' => 'Curl error: ' . $curl->error,
);
return;
}
if ($curl->code != '200') {
$this->error = array(
'type' => self::C_ERROR_HTTP,
'message' => 'Response code: ' . $curl->code,
);
return;
}
if (empty($curl->result)) {
$this->error = array(
'type' => self::C_ERROR_GATEWAY,
'message' => 'Empty Response',
);
return;
}
$response = @json_decode($curl->result);
if (!$response || empty($response->type)) {
$this->error = array(
'type' => self::C_ERROR_GATEWAY,
'message' => 'Response is not json or Unrecognized response format',
);
return;
}
if ($response->type == 'error') {
$this->error = array(
'type' => self::C_ERROR_PROCESSING,
'message' => $response->message,
);
return;
}
}
|
php
|
private function parseErrors(Curl $curl)
{
$this->rawResponse = $curl->result;
if ($curl->error) {
$this->error = array(
'type' => self::C_ERROR_HTTP,
'message' => 'Curl error: ' . $curl->error,
);
return;
}
if ($curl->code != '200') {
$this->error = array(
'type' => self::C_ERROR_HTTP,
'message' => 'Response code: ' . $curl->code,
);
return;
}
if (empty($curl->result)) {
$this->error = array(
'type' => self::C_ERROR_GATEWAY,
'message' => 'Empty Response',
);
return;
}
$response = @json_decode($curl->result);
if (!$response || empty($response->type)) {
$this->error = array(
'type' => self::C_ERROR_GATEWAY,
'message' => 'Response is not json or Unrecognized response format',
);
return;
}
if ($response->type == 'error') {
$this->error = array(
'type' => self::C_ERROR_PROCESSING,
'message' => $response->message,
);
return;
}
}
|
[
"private",
"function",
"parseErrors",
"(",
"Curl",
"$",
"curl",
")",
"{",
"$",
"this",
"->",
"rawResponse",
"=",
"$",
"curl",
"->",
"result",
";",
"if",
"(",
"$",
"curl",
"->",
"error",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"C_ERROR_HTTP",
",",
"'message'",
"=>",
"'Curl error: '",
".",
"$",
"curl",
"->",
"error",
",",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"curl",
"->",
"code",
"!=",
"'200'",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"C_ERROR_HTTP",
",",
"'message'",
"=>",
"'Response code: '",
".",
"$",
"curl",
"->",
"code",
",",
")",
";",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"curl",
"->",
"result",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"C_ERROR_GATEWAY",
",",
"'message'",
"=>",
"'Empty Response'",
",",
")",
";",
"return",
";",
"}",
"$",
"response",
"=",
"@",
"json_decode",
"(",
"$",
"curl",
"->",
"result",
")",
";",
"if",
"(",
"!",
"$",
"response",
"||",
"empty",
"(",
"$",
"response",
"->",
"type",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"C_ERROR_GATEWAY",
",",
"'message'",
"=>",
"'Response is not json or Unrecognized response format'",
",",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"type",
"==",
"'error'",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"'type'",
"=>",
"self",
"::",
"C_ERROR_PROCESSING",
",",
"'message'",
"=>",
"$",
"response",
"->",
"message",
",",
")",
";",
"return",
";",
"}",
"}"
] |
Parse error type
@param Curl $curl
|
[
"Parse",
"error",
"type"
] |
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
|
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L488-L539
|
237,799
|
kernel-php/xml2object
|
Xml2Object.php
|
Xml2Object.simpleArrayToObject
|
public static function simpleArrayToObject($array, $object = null) {
foreach ($array as $key => $value) {
$object->$key = $value;
}
return $object;
}
|
php
|
public static function simpleArrayToObject($array, $object = null) {
foreach ($array as $key => $value) {
$object->$key = $value;
}
return $object;
}
|
[
"public",
"static",
"function",
"simpleArrayToObject",
"(",
"$",
"array",
",",
"$",
"object",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"object",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
utilisation simple array with numeric keys to object
|
[
"utilisation",
"simple",
"array",
"with",
"numeric",
"keys",
"to",
"object"
] |
12275be3e4d8ed2df5b43aecfabbf6c8fc5809fd
|
https://github.com/kernel-php/xml2object/blob/12275be3e4d8ed2df5b43aecfabbf6c8fc5809fd/Xml2Object.php#L56-L61
|
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.