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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
22,000
|
surebert/surebert-framework
|
src/sb/PDO/Debugger.php
|
Debugger.s2o
|
public function s2o($sql, $params = null, $class_name = '', $prepare_and_store = 1)
{
try {
return parent::s2o($sql, $params, $class_name, $prepare_and_store);
} catch (\Exception $e) {
throw(new \sb\PDO\Exception('CALLED: ' . __METHOD__ . "\nERROR RETURNED: " . print_r($e, 1)));
}
}
|
php
|
public function s2o($sql, $params = null, $class_name = '', $prepare_and_store = 1)
{
try {
return parent::s2o($sql, $params, $class_name, $prepare_and_store);
} catch (\Exception $e) {
throw(new \sb\PDO\Exception('CALLED: ' . __METHOD__ . "\nERROR RETURNED: " . print_r($e, 1)));
}
}
|
[
"public",
"function",
"s2o",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"null",
",",
"$",
"class_name",
"=",
"''",
",",
"$",
"prepare_and_store",
"=",
"1",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"s2o",
"(",
"$",
"sql",
",",
"$",
"params",
",",
"$",
"class_name",
",",
"$",
"prepare_and_store",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"(",
"new",
"\\",
"sb",
"\\",
"PDO",
"\\",
"Exception",
"(",
"'CALLED: '",
".",
"__METHOD__",
".",
"\"\\nERROR RETURNED: \"",
".",
"print_r",
"(",
"$",
"e",
",",
"1",
")",
")",
")",
";",
"}",
"}"
] |
Additionally Logs the errors
|
[
"Additionally",
"Logs",
"the",
"errors"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Debugger.php#L39-L47
|
22,001
|
fkooman/php-lib-http
|
src/fkooman/Http/Response.php
|
Response.setHeader
|
public function setHeader($keyName, $value)
{
$normalizedKeyName = self::normalizeHeaderKeyName($keyName);
$this->headers[$normalizedKeyName] = $value;
}
|
php
|
public function setHeader($keyName, $value)
{
$normalizedKeyName = self::normalizeHeaderKeyName($keyName);
$this->headers[$normalizedKeyName] = $value;
}
|
[
"public",
"function",
"setHeader",
"(",
"$",
"keyName",
",",
"$",
"value",
")",
"{",
"$",
"normalizedKeyName",
"=",
"self",
"::",
"normalizeHeaderKeyName",
"(",
"$",
"keyName",
")",
";",
"$",
"this",
"->",
"headers",
"[",
"$",
"normalizedKeyName",
"]",
"=",
"$",
"value",
";",
"}"
] |
Set a header. If it already exists the value is overwritten with the
new one.
@param string $keyName the name of the header
@param string|int $value the value of the header
|
[
"Set",
"a",
"header",
".",
"If",
"it",
"already",
"exists",
"the",
"value",
"is",
"overwritten",
"with",
"the",
"new",
"one",
"."
] |
94956a480459b7f6b880d61f21ef03e683deb995
|
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Response.php#L124-L128
|
22,002
|
fkooman/php-lib-http
|
src/fkooman/Http/Response.php
|
Response.send
|
public function send()
{
header(
sprintf(
'HTTP/1.1 %s %s',
$this->statusCode,
self::codeToReason($this->statusCode)
)
);
foreach ($this->headers as $k => $v) {
header(
sprintf('%s: %s', $k, $v)
);
}
echo $this->body;
}
|
php
|
public function send()
{
header(
sprintf(
'HTTP/1.1 %s %s',
$this->statusCode,
self::codeToReason($this->statusCode)
)
);
foreach ($this->headers as $k => $v) {
header(
sprintf('%s: %s', $k, $v)
);
}
echo $this->body;
}
|
[
"public",
"function",
"send",
"(",
")",
"{",
"header",
"(",
"sprintf",
"(",
"'HTTP/1.1 %s %s'",
",",
"$",
"this",
"->",
"statusCode",
",",
"self",
"::",
"codeToReason",
"(",
"$",
"this",
"->",
"statusCode",
")",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"header",
"(",
"sprintf",
"(",
"'%s: %s'",
",",
"$",
"k",
",",
"$",
"v",
")",
")",
";",
"}",
"echo",
"$",
"this",
"->",
"body",
";",
"}"
] |
Construct the response and send it out.
|
[
"Construct",
"the",
"response",
"and",
"send",
"it",
"out",
"."
] |
94956a480459b7f6b880d61f21ef03e683deb995
|
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Response.php#L152-L167
|
22,003
|
fkooman/php-lib-http
|
src/fkooman/Http/Response.php
|
Response.toArray
|
public function toArray()
{
$output = [];
$output[] = sprintf(
'HTTP/1.1 %s %s',
$this->statusCode,
self::codeToReason($this->statusCode)
);
foreach ($this->headers as $k => $v) {
$output[] = sprintf('%s: %s', $k, $v);
}
$output[] = '';
$output[] = $this->body;
return $output;
}
|
php
|
public function toArray()
{
$output = [];
$output[] = sprintf(
'HTTP/1.1 %s %s',
$this->statusCode,
self::codeToReason($this->statusCode)
);
foreach ($this->headers as $k => $v) {
$output[] = sprintf('%s: %s', $k, $v);
}
$output[] = '';
$output[] = $this->body;
return $output;
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"output",
"[",
"]",
"=",
"sprintf",
"(",
"'HTTP/1.1 %s %s'",
",",
"$",
"this",
"->",
"statusCode",
",",
"self",
"::",
"codeToReason",
"(",
"$",
"this",
"->",
"statusCode",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"sprintf",
"(",
"'%s: %s'",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"$",
"output",
"[",
"]",
"=",
"''",
";",
"$",
"output",
"[",
"]",
"=",
"$",
"this",
"->",
"body",
";",
"return",
"$",
"output",
";",
"}"
] |
Convert the full response to array for the purpose of unit testing.
|
[
"Convert",
"the",
"full",
"response",
"to",
"array",
"for",
"the",
"purpose",
"of",
"unit",
"testing",
"."
] |
94956a480459b7f6b880d61f21ef03e683deb995
|
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Response.php#L172-L187
|
22,004
|
ekuiter/feature-php
|
FeaturePhp/Renderer.php
|
Renderer.render
|
public function render($textOnly = false) {
if ($textOnly)
return $this->renderText();
$str = $this->getStyle();
$str .= "<table><tr><td valign='top'>";
$str .= $this->_render(false);
$str .= "</td></tr></table>";
return $str;
}
|
php
|
public function render($textOnly = false) {
if ($textOnly)
return $this->renderText();
$str = $this->getStyle();
$str .= "<table><tr><td valign='top'>";
$str .= $this->_render(false);
$str .= "</td></tr></table>";
return $str;
}
|
[
"public",
"function",
"render",
"(",
"$",
"textOnly",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"textOnly",
")",
"return",
"$",
"this",
"->",
"renderText",
"(",
")",
";",
"$",
"str",
"=",
"$",
"this",
"->",
"getStyle",
"(",
")",
";",
"$",
"str",
".=",
"\"<table><tr><td valign='top'>\"",
";",
"$",
"str",
".=",
"$",
"this",
"->",
"_render",
"(",
"false",
")",
";",
"$",
"str",
".=",
"\"</td></tr></table>\"",
";",
"return",
"$",
"str",
";",
"}"
] |
Returns the renderer's web page.
@param bool $textOnly whether to render text or HTML
@return string
|
[
"Returns",
"the",
"renderer",
"s",
"web",
"page",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Renderer.php#L46-L55
|
22,005
|
spiral-modules/listing
|
source/Listing/Filters/ValueFilter.php
|
ValueFilter.normalizeValue
|
private function normalizeValue($value)
{
switch ($this->type) {
case self::TYPE_STRING:
return trim((string)$value);
case self::TYPE_INT:
return intval($value);
case self::TYPE_FLOAT:
return floatval($value);
}
throw new FilterException("Invalid filter value type \"{$this->type}\"");
}
|
php
|
private function normalizeValue($value)
{
switch ($this->type) {
case self::TYPE_STRING:
return trim((string)$value);
case self::TYPE_INT:
return intval($value);
case self::TYPE_FLOAT:
return floatval($value);
}
throw new FilterException("Invalid filter value type \"{$this->type}\"");
}
|
[
"private",
"function",
"normalizeValue",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_STRING",
":",
"return",
"trim",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"case",
"self",
"::",
"TYPE_INT",
":",
"return",
"intval",
"(",
"$",
"value",
")",
";",
"case",
"self",
"::",
"TYPE_FLOAT",
":",
"return",
"floatval",
"(",
"$",
"value",
")",
";",
"}",
"throw",
"new",
"FilterException",
"(",
"\"Invalid filter value type \\\"{$this->type}\\\"\"",
")",
";",
"}"
] |
Normalize input value
@param mixed $value
@return float|int|string
|
[
"Normalize",
"input",
"value"
] |
89abe8939ce91cbf61b51b99e93ce1e57c8af83c
|
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Filters/ValueFilter.php#L116-L128
|
22,006
|
phpcq/branch-alias-validation
|
src/Command/ValidateBranchAlias.php
|
ValidateBranchAlias.getTagFromBranch
|
protected function getTagFromBranch($branch)
{
$git = new GitRepository($this->input->getArgument('git-dir'));
$tag = trim($git->describe()->tags()->always()->execute($branch));
$hash = trim($git->revParse()->short(false)->execute($branch));
return $hash !== $tag ? $tag : null;
}
|
php
|
protected function getTagFromBranch($branch)
{
$git = new GitRepository($this->input->getArgument('git-dir'));
$tag = trim($git->describe()->tags()->always()->execute($branch));
$hash = trim($git->revParse()->short(false)->execute($branch));
return $hash !== $tag ? $tag : null;
}
|
[
"protected",
"function",
"getTagFromBranch",
"(",
"$",
"branch",
")",
"{",
"$",
"git",
"=",
"new",
"GitRepository",
"(",
"$",
"this",
"->",
"input",
"->",
"getArgument",
"(",
"'git-dir'",
")",
")",
";",
"$",
"tag",
"=",
"trim",
"(",
"$",
"git",
"->",
"describe",
"(",
")",
"->",
"tags",
"(",
")",
"->",
"always",
"(",
")",
"->",
"execute",
"(",
"$",
"branch",
")",
")",
";",
"$",
"hash",
"=",
"trim",
"(",
"$",
"git",
"->",
"revParse",
"(",
")",
"->",
"short",
"(",
"false",
")",
"->",
"execute",
"(",
"$",
"branch",
")",
")",
";",
"return",
"$",
"hash",
"!==",
"$",
"tag",
"?",
"$",
"tag",
":",
"null",
";",
"}"
] |
Retrieve the latest tag from a branch.
@param string $branch The branch name to retrieve the tag from.
@return null|string Returns null when no tag has been found, the tag name otherwise.
|
[
"Retrieve",
"the",
"latest",
"tag",
"from",
"a",
"branch",
"."
] |
99ff083af418aad87a6da1331d3924c32137fc76
|
https://github.com/phpcq/branch-alias-validation/blob/99ff083af418aad87a6da1331d3924c32137fc76/src/Command/ValidateBranchAlias.php#L86-L92
|
22,007
|
phpcq/branch-alias-validation
|
src/Command/ValidateBranchAlias.php
|
ValidateBranchAlias.validate
|
public function validate($tag, $alias)
{
$simpleAlias = preg_replace('~(\.x)?-dev~', '', $alias);
$versionLevel = count(explode('.', $simpleAlias));
$reducedTag = preg_replace('~-.*$~', '', $tag);
$reducedTag = implode('.', array_slice(explode('.', $reducedTag), 0, $versionLevel));
return version_compare($reducedTag, $simpleAlias, '<=');
}
|
php
|
public function validate($tag, $alias)
{
$simpleAlias = preg_replace('~(\.x)?-dev~', '', $alias);
$versionLevel = count(explode('.', $simpleAlias));
$reducedTag = preg_replace('~-.*$~', '', $tag);
$reducedTag = implode('.', array_slice(explode('.', $reducedTag), 0, $versionLevel));
return version_compare($reducedTag, $simpleAlias, '<=');
}
|
[
"public",
"function",
"validate",
"(",
"$",
"tag",
",",
"$",
"alias",
")",
"{",
"$",
"simpleAlias",
"=",
"preg_replace",
"(",
"'~(\\.x)?-dev~'",
",",
"''",
",",
"$",
"alias",
")",
";",
"$",
"versionLevel",
"=",
"count",
"(",
"explode",
"(",
"'.'",
",",
"$",
"simpleAlias",
")",
")",
";",
"$",
"reducedTag",
"=",
"preg_replace",
"(",
"'~-.*$~'",
",",
"''",
",",
"$",
"tag",
")",
";",
"$",
"reducedTag",
"=",
"implode",
"(",
"'.'",
",",
"array_slice",
"(",
"explode",
"(",
"'.'",
",",
"$",
"reducedTag",
")",
",",
"0",
",",
"$",
"versionLevel",
")",
")",
";",
"return",
"version_compare",
"(",
"$",
"reducedTag",
",",
"$",
"simpleAlias",
",",
"'<='",
")",
";",
"}"
] |
Validate the given branch.
Returns true on success, the name of the offending tag on failure.
@param string $tag The tag to check.
@param string $alias The alias for the given branch.
@return bool|string
|
[
"Validate",
"the",
"given",
"branch",
"."
] |
99ff083af418aad87a6da1331d3924c32137fc76
|
https://github.com/phpcq/branch-alias-validation/blob/99ff083af418aad87a6da1331d3924c32137fc76/src/Command/ValidateBranchAlias.php#L105-L113
|
22,008
|
tttptd/laravel-responder
|
src/Traits/ConvertsParameters.php
|
ConvertsParameters.getConvertedParameters
|
protected function getConvertedParameters():array
{
$parameters = $this->all();
$parameters = $this->castBooleans($parameters);
$parameters = $this->convertToSnakeCase($parameters);
if (method_exists($this, 'convertParameters')) {
$parameters = $this->convertParameters($parameters);
}
return $parameters;
}
|
php
|
protected function getConvertedParameters():array
{
$parameters = $this->all();
$parameters = $this->castBooleans($parameters);
$parameters = $this->convertToSnakeCase($parameters);
if (method_exists($this, 'convertParameters')) {
$parameters = $this->convertParameters($parameters);
}
return $parameters;
}
|
[
"protected",
"function",
"getConvertedParameters",
"(",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"castBooleans",
"(",
"$",
"parameters",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"convertToSnakeCase",
"(",
"$",
"parameters",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'convertParameters'",
")",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"convertParameters",
"(",
"$",
"parameters",
")",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Cast and convert parameters.
@return array
|
[
"Cast",
"and",
"convert",
"parameters",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/ConvertsParameters.php#L62-L73
|
22,009
|
tttptd/laravel-responder
|
src/Traits/ConvertsParameters.php
|
ConvertsParameters.castBooleans
|
protected function castBooleans($input):array
{
if ($this->castToBooleanIsDisabled()) {
return [];
}
$casted = [];
foreach ($input as $key => $value) {
$casted[$key] = $this->castValueToBoolean($value);
}
return $casted;
}
|
php
|
protected function castBooleans($input):array
{
if ($this->castToBooleanIsDisabled()) {
return [];
}
$casted = [];
foreach ($input as $key => $value) {
$casted[$key] = $this->castValueToBoolean($value);
}
return $casted;
}
|
[
"protected",
"function",
"castBooleans",
"(",
"$",
"input",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"castToBooleanIsDisabled",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"casted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"casted",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"castValueToBoolean",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"casted",
";",
"}"
] |
Cast all string booleans to real boolean values.
@param mixed $input
@return array
|
[
"Cast",
"all",
"string",
"booleans",
"to",
"real",
"boolean",
"values",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/ConvertsParameters.php#L88-L101
|
22,010
|
tttptd/laravel-responder
|
src/Traits/ConvertsParameters.php
|
ConvertsParameters.convertToSnakeCase
|
protected function convertToSnakeCase($input)
{
if ($this->convertToSnakeCaseIsDisabled()) {
return;
}
if (is_null($input)) {
return null;
} elseif (is_array($input)) {
return $this->convertArrayToSnakeCase($input);
}
return snake_case($input);
}
|
php
|
protected function convertToSnakeCase($input)
{
if ($this->convertToSnakeCaseIsDisabled()) {
return;
}
if (is_null($input)) {
return null;
} elseif (is_array($input)) {
return $this->convertArrayToSnakeCase($input);
}
return snake_case($input);
}
|
[
"protected",
"function",
"convertToSnakeCase",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"convertToSnakeCaseIsDisabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"input",
")",
")",
"{",
"return",
"null",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"return",
"$",
"this",
"->",
"convertArrayToSnakeCase",
"(",
"$",
"input",
")",
";",
"}",
"return",
"snake_case",
"(",
"$",
"input",
")",
";",
"}"
] |
Convert a string or array to snake case.
@param mixed $input
@return mixed
|
[
"Convert",
"a",
"string",
"or",
"array",
"to",
"snake",
"case",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/ConvertsParameters.php#L134-L147
|
22,011
|
tttptd/laravel-responder
|
src/Traits/ConvertsParameters.php
|
ConvertsParameters.convertArrayToSnakeCase
|
protected function convertArrayToSnakeCase(array $input):array
{
$converted = [];
foreach ($input as $key => $value) {
$converted[snake_case($key)] = $value;
}
return $converted;
}
|
php
|
protected function convertArrayToSnakeCase(array $input):array
{
$converted = [];
foreach ($input as $key => $value) {
$converted[snake_case($key)] = $value;
}
return $converted;
}
|
[
"protected",
"function",
"convertArrayToSnakeCase",
"(",
"array",
"$",
"input",
")",
":",
"array",
"{",
"$",
"converted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"converted",
"[",
"snake_case",
"(",
"$",
"key",
")",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"converted",
";",
"}"
] |
Convert all keys of an array to snake case.
@param array $input
@return array
|
[
"Convert",
"all",
"keys",
"of",
"an",
"array",
"to",
"snake",
"case",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/ConvertsParameters.php#L165-L174
|
22,012
|
ajgarlag/AjglSessionConcurrency
|
src/Http/Session/Registry/SessionRegistry.php
|
SessionRegistry.refreshLastUsed
|
public function refreshLastUsed($sessionId, $lastUsed = null)
{
if ($sessionInformation = $this->getSessionInformation($sessionId)) {
if ($sessionInformation->getLastUsed() !== $lastUsed) {
$sessionInformation->refreshLastUsed($lastUsed);
$this->saveSessionInformation($sessionInformation);
}
}
}
|
php
|
public function refreshLastUsed($sessionId, $lastUsed = null)
{
if ($sessionInformation = $this->getSessionInformation($sessionId)) {
if ($sessionInformation->getLastUsed() !== $lastUsed) {
$sessionInformation->refreshLastUsed($lastUsed);
$this->saveSessionInformation($sessionInformation);
}
}
}
|
[
"public",
"function",
"refreshLastUsed",
"(",
"$",
"sessionId",
",",
"$",
"lastUsed",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"sessionInformation",
"=",
"$",
"this",
"->",
"getSessionInformation",
"(",
"$",
"sessionId",
")",
")",
"{",
"if",
"(",
"$",
"sessionInformation",
"->",
"getLastUsed",
"(",
")",
"!==",
"$",
"lastUsed",
")",
"{",
"$",
"sessionInformation",
"->",
"refreshLastUsed",
"(",
"$",
"lastUsed",
")",
";",
"$",
"this",
"->",
"saveSessionInformation",
"(",
"$",
"sessionInformation",
")",
";",
"}",
"}",
"}"
] |
Updates the given sessionId so its last request time is equal to the present date and time.
@param string $sessionId the session identifier key.
@param int|null $lastUsed the last request timestamp
|
[
"Updates",
"the",
"given",
"sessionId",
"so",
"its",
"last",
"request",
"time",
"is",
"equal",
"to",
"the",
"present",
"date",
"and",
"time",
"."
] |
daa3b1ff3ad4951947f7192e12b2496555e135fb
|
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/SessionRegistry.php#L64-L72
|
22,013
|
ajgarlag/AjglSessionConcurrency
|
src/Http/Session/Registry/SessionRegistry.php
|
SessionRegistry.expireNow
|
public function expireNow($sessionId)
{
if ($sessionInformation = $this->getSessionInformation($sessionId)) {
$sessionInformation->expireNow();
$this->saveSessionInformation($sessionInformation);
}
}
|
php
|
public function expireNow($sessionId)
{
if ($sessionInformation = $this->getSessionInformation($sessionId)) {
$sessionInformation->expireNow();
$this->saveSessionInformation($sessionInformation);
}
}
|
[
"public",
"function",
"expireNow",
"(",
"$",
"sessionId",
")",
"{",
"if",
"(",
"$",
"sessionInformation",
"=",
"$",
"this",
"->",
"getSessionInformation",
"(",
"$",
"sessionId",
")",
")",
"{",
"$",
"sessionInformation",
"->",
"expireNow",
"(",
")",
";",
"$",
"this",
"->",
"saveSessionInformation",
"(",
"$",
"sessionInformation",
")",
";",
"}",
"}"
] |
Expires the given sessionId.
@param string $sessionId the session identifier key.
|
[
"Expires",
"the",
"given",
"sessionId",
"."
] |
daa3b1ff3ad4951947f7192e12b2496555e135fb
|
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/SessionRegistry.php#L79-L85
|
22,014
|
ajgarlag/AjglSessionConcurrency
|
src/Http/Session/Registry/SessionRegistry.php
|
SessionRegistry.registerNewSession
|
public function registerNewSession($sessionId, $username, $lastUsed = null)
{
$sessionInformation = new SessionInformation($sessionId, $username, $lastUsed ?: time());
$this->saveSessionInformation($sessionInformation);
}
|
php
|
public function registerNewSession($sessionId, $username, $lastUsed = null)
{
$sessionInformation = new SessionInformation($sessionId, $username, $lastUsed ?: time());
$this->saveSessionInformation($sessionInformation);
}
|
[
"public",
"function",
"registerNewSession",
"(",
"$",
"sessionId",
",",
"$",
"username",
",",
"$",
"lastUsed",
"=",
"null",
")",
"{",
"$",
"sessionInformation",
"=",
"new",
"SessionInformation",
"(",
"$",
"sessionId",
",",
"$",
"username",
",",
"$",
"lastUsed",
"?",
":",
"time",
"(",
")",
")",
";",
"$",
"this",
"->",
"saveSessionInformation",
"(",
"$",
"sessionInformation",
")",
";",
"}"
] |
Registers a new session for the given user.
@param string $sessionId the session identifier key.
@param string $username the given user.
@param int $lastUsed
|
[
"Registers",
"a",
"new",
"session",
"for",
"the",
"given",
"user",
"."
] |
daa3b1ff3ad4951947f7192e12b2496555e135fb
|
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/SessionRegistry.php#L94-L99
|
22,015
|
ajgarlag/AjglSessionConcurrency
|
src/Http/Session/Registry/SessionRegistry.php
|
SessionRegistry.collectGarbage
|
public function collectGarbage($maxLifetime = null)
{
$maxLifetime = $maxLifetime ?: ini_get('session.gc_maxlifetime');
$this->sessionRegistryStorage->collectGarbage($maxLifetime);
}
|
php
|
public function collectGarbage($maxLifetime = null)
{
$maxLifetime = $maxLifetime ?: ini_get('session.gc_maxlifetime');
$this->sessionRegistryStorage->collectGarbage($maxLifetime);
}
|
[
"public",
"function",
"collectGarbage",
"(",
"$",
"maxLifetime",
"=",
"null",
")",
"{",
"$",
"maxLifetime",
"=",
"$",
"maxLifetime",
"?",
":",
"ini_get",
"(",
"'session.gc_maxlifetime'",
")",
";",
"$",
"this",
"->",
"sessionRegistryStorage",
"->",
"collectGarbage",
"(",
"$",
"maxLifetime",
")",
";",
"}"
] |
Removes sessions information which last used timestamp is older
than the given lifetime.
@param int $maxLifetime
|
[
"Removes",
"sessions",
"information",
"which",
"last",
"used",
"timestamp",
"is",
"older",
"than",
"the",
"given",
"lifetime",
"."
] |
daa3b1ff3ad4951947f7192e12b2496555e135fb
|
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/Registry/SessionRegistry.php#L117-L121
|
22,016
|
DevGroup-ru/yii2-users-module
|
src/models/RegistrationForm.php
|
RegistrationForm.register
|
public function register()
{
if (!$this->validate()) {
return false;
}
/** @var User $user */
$user = Yii::createObject(ModelMapHelper::User());
$user->setAttributes($this->attributes);
$result = $user->register();
if ($user->hasErrors()) {
foreach ($user->errors as $attribute => $errors) {
foreach ($errors as $error) {
$this->addError($attribute, $error);
}
}
}
return $result;
}
|
php
|
public function register()
{
if (!$this->validate()) {
return false;
}
/** @var User $user */
$user = Yii::createObject(ModelMapHelper::User());
$user->setAttributes($this->attributes);
$result = $user->register();
if ($user->hasErrors()) {
foreach ($user->errors as $attribute => $errors) {
foreach ($errors as $error) {
$this->addError($attribute, $error);
}
}
}
return $result;
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var User $user */",
"$",
"user",
"=",
"Yii",
"::",
"createObject",
"(",
"ModelMapHelper",
"::",
"User",
"(",
")",
")",
";",
"$",
"user",
"->",
"setAttributes",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"$",
"result",
"=",
"$",
"user",
"->",
"register",
"(",
")",
";",
"if",
"(",
"$",
"user",
"->",
"hasErrors",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"user",
"->",
"errors",
"as",
"$",
"attribute",
"=>",
"$",
"errors",
")",
"{",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"$",
"error",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Performs registration of user.
Returns User object on success or false on failure.
@return bool|User
@throws \yii\base\InvalidConfigException
|
[
"Performs",
"registration",
"of",
"user",
".",
"Returns",
"User",
"object",
"on",
"success",
"or",
"false",
"on",
"failure",
"."
] |
ff0103dc55c3462627ccc704c33e70c96053f750
|
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/RegistrationForm.php#L64-L85
|
22,017
|
mekras/atompub
|
src/Element/Workspace.php
|
Workspace.getCollections
|
public function getCollections()
{
return $this->getCachedProperty(
'collections',
function () {
$result = [];
/** @var \DOMNodeList $items */
// No REQUIRED — no exception.
$items = $this->query('app:collection');
foreach ($items as $item) {
$result[] = $this->getExtensions()->parseElement($this, $item);
}
return $result;
}
);
}
|
php
|
public function getCollections()
{
return $this->getCachedProperty(
'collections',
function () {
$result = [];
/** @var \DOMNodeList $items */
// No REQUIRED — no exception.
$items = $this->query('app:collection');
foreach ($items as $item) {
$result[] = $this->getExtensions()->parseElement($this, $item);
}
return $result;
}
);
}
|
[
"public",
"function",
"getCollections",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getCachedProperty",
"(",
"'collections'",
",",
"function",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var \\DOMNodeList $items */",
"// No REQUIRED — no exception.",
"$",
"items",
"=",
"$",
"this",
"->",
"query",
"(",
"'app:collection'",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getExtensions",
"(",
")",
"->",
"parseElement",
"(",
"$",
"this",
",",
"$",
"item",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
")",
";",
"}"
] |
Return collections.
@return Collection[]
@since 1.0
|
[
"Return",
"collections",
"."
] |
cfc9aab97cff7a822b720e1dd84ef16733183dbb
|
https://github.com/mekras/atompub/blob/cfc9aab97cff7a822b720e1dd84ef16733183dbb/src/Element/Workspace.php#L30-L46
|
22,018
|
mekras/atompub
|
src/Element/Workspace.php
|
Workspace.addCollection
|
public function addCollection($title)
{
$collections = $this->getCollections();
/** @var Collection $collection */
$collection = $this->getExtensions()->createElement($this, 'app:collection');
$collection->addTitle($title);
$collections[] = $collection;
$this->setCachedProperty('collections', $collections);
return $collection;
}
|
php
|
public function addCollection($title)
{
$collections = $this->getCollections();
/** @var Collection $collection */
$collection = $this->getExtensions()->createElement($this, 'app:collection');
$collection->addTitle($title);
$collections[] = $collection;
$this->setCachedProperty('collections', $collections);
return $collection;
}
|
[
"public",
"function",
"addCollection",
"(",
"$",
"title",
")",
"{",
"$",
"collections",
"=",
"$",
"this",
"->",
"getCollections",
"(",
")",
";",
"/** @var Collection $collection */",
"$",
"collection",
"=",
"$",
"this",
"->",
"getExtensions",
"(",
")",
"->",
"createElement",
"(",
"$",
"this",
",",
"'app:collection'",
")",
";",
"$",
"collection",
"->",
"addTitle",
"(",
"$",
"title",
")",
";",
"$",
"collections",
"[",
"]",
"=",
"$",
"collection",
";",
"$",
"this",
"->",
"setCachedProperty",
"(",
"'collections'",
",",
"$",
"collections",
")",
";",
"return",
"$",
"collection",
";",
"}"
] |
Add new Collection
@param string $title
@return Collection
@since 1.0
|
[
"Add",
"new",
"Collection"
] |
cfc9aab97cff7a822b720e1dd84ef16733183dbb
|
https://github.com/mekras/atompub/blob/cfc9aab97cff7a822b720e1dd84ef16733183dbb/src/Element/Workspace.php#L57-L69
|
22,019
|
i-lateral/silverstripe-modeladminplus
|
src/GridFieldDateFinder.php
|
GridFieldDateFinder.convertDateFields
|
public function convertDateFields()
{
$grid_field = $this->getGridField();
$config = $grid_field->getConfig();
$db = Config::inst()->get($grid_field->getModelClass(), "db");
$dates = self::config()->date_fields;
$fields = $this->findDateFields();
// First setup columns
foreach ($config->getComponents() as $component) {
$class = get_class($component);
$is_header = ($component instanceof GridFieldSortableHeader);
$is_columns = ClassInfo::classImplements(
$class,
GridField_ColumnProvider::class
);
// If we are working with a set of data columns, look for
// date/datetime columns
if ($is_columns && method_exists($component, "getDisplayFields")) {
$display_fields = $component->getDisplayFields($grid_field);
foreach ($fields as $field) {
$display_fields = $this->changeKeys(
$field["Sort"],
$field["Column"],
$display_fields
);
}
$component->setDisplayFields($display_fields);
}
// If we are working with sortable headers, look for
// date/datetime columns
if ($is_header && count($component->getFieldSorting()) == 0) {
$sort_fields = [];
foreach ($fields as $field) {
$sort_fields[$field["Column"]] = $field["Sort"];
}
$component->setFieldSorting($sort_fields);
}
}
$this->setGridField($grid_field);
return $this;
}
|
php
|
public function convertDateFields()
{
$grid_field = $this->getGridField();
$config = $grid_field->getConfig();
$db = Config::inst()->get($grid_field->getModelClass(), "db");
$dates = self::config()->date_fields;
$fields = $this->findDateFields();
// First setup columns
foreach ($config->getComponents() as $component) {
$class = get_class($component);
$is_header = ($component instanceof GridFieldSortableHeader);
$is_columns = ClassInfo::classImplements(
$class,
GridField_ColumnProvider::class
);
// If we are working with a set of data columns, look for
// date/datetime columns
if ($is_columns && method_exists($component, "getDisplayFields")) {
$display_fields = $component->getDisplayFields($grid_field);
foreach ($fields as $field) {
$display_fields = $this->changeKeys(
$field["Sort"],
$field["Column"],
$display_fields
);
}
$component->setDisplayFields($display_fields);
}
// If we are working with sortable headers, look for
// date/datetime columns
if ($is_header && count($component->getFieldSorting()) == 0) {
$sort_fields = [];
foreach ($fields as $field) {
$sort_fields[$field["Column"]] = $field["Sort"];
}
$component->setFieldSorting($sort_fields);
}
}
$this->setGridField($grid_field);
return $this;
}
|
[
"public",
"function",
"convertDateFields",
"(",
")",
"{",
"$",
"grid_field",
"=",
"$",
"this",
"->",
"getGridField",
"(",
")",
";",
"$",
"config",
"=",
"$",
"grid_field",
"->",
"getConfig",
"(",
")",
";",
"$",
"db",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"grid_field",
"->",
"getModelClass",
"(",
")",
",",
"\"db\"",
")",
";",
"$",
"dates",
"=",
"self",
"::",
"config",
"(",
")",
"->",
"date_fields",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"findDateFields",
"(",
")",
";",
"// First setup columns",
"foreach",
"(",
"$",
"config",
"->",
"getComponents",
"(",
")",
"as",
"$",
"component",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"component",
")",
";",
"$",
"is_header",
"=",
"(",
"$",
"component",
"instanceof",
"GridFieldSortableHeader",
")",
";",
"$",
"is_columns",
"=",
"ClassInfo",
"::",
"classImplements",
"(",
"$",
"class",
",",
"GridField_ColumnProvider",
"::",
"class",
")",
";",
"// If we are working with a set of data columns, look for",
"// date/datetime columns",
"if",
"(",
"$",
"is_columns",
"&&",
"method_exists",
"(",
"$",
"component",
",",
"\"getDisplayFields\"",
")",
")",
"{",
"$",
"display_fields",
"=",
"$",
"component",
"->",
"getDisplayFields",
"(",
"$",
"grid_field",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"display_fields",
"=",
"$",
"this",
"->",
"changeKeys",
"(",
"$",
"field",
"[",
"\"Sort\"",
"]",
",",
"$",
"field",
"[",
"\"Column\"",
"]",
",",
"$",
"display_fields",
")",
";",
"}",
"$",
"component",
"->",
"setDisplayFields",
"(",
"$",
"display_fields",
")",
";",
"}",
"// If we are working with sortable headers, look for",
"// date/datetime columns",
"if",
"(",
"$",
"is_header",
"&&",
"count",
"(",
"$",
"component",
"->",
"getFieldSorting",
"(",
")",
")",
"==",
"0",
")",
"{",
"$",
"sort_fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"sort_fields",
"[",
"$",
"field",
"[",
"\"Column\"",
"]",
"]",
"=",
"$",
"field",
"[",
"\"Sort\"",
"]",
";",
"}",
"$",
"component",
"->",
"setFieldSorting",
"(",
"$",
"sort_fields",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setGridField",
"(",
"$",
"grid_field",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Get any date fields from the passed list and convert to .Nice format.
@param GridField $field GridField want to convert
@return self
|
[
"Get",
"any",
"date",
"fields",
"from",
"the",
"passed",
"list",
"and",
"convert",
"to",
".",
"Nice",
"format",
"."
] |
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
|
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/GridFieldDateFinder.php#L59-L104
|
22,020
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.open
|
public function open($method, $action = '', $attr = array())
{
// check if they wish to send a file
// default to post method and add the enctype needed to send files
$method = strtolower($method);
if ($method === 'file') {
$method = 'post';
$attr['enctype'] = 'multipart/form-data';
}
if (! in_array($method, array('post', 'get'))) {
$method = 'post';
}
$attr['method'] = $method;
$attr['action'] = $action;
return $this->Html->tag('form', $attr);
}
|
php
|
public function open($method, $action = '', $attr = array())
{
// check if they wish to send a file
// default to post method and add the enctype needed to send files
$method = strtolower($method);
if ($method === 'file') {
$method = 'post';
$attr['enctype'] = 'multipart/form-data';
}
if (! in_array($method, array('post', 'get'))) {
$method = 'post';
}
$attr['method'] = $method;
$attr['action'] = $action;
return $this->Html->tag('form', $attr);
}
|
[
"public",
"function",
"open",
"(",
"$",
"method",
",",
"$",
"action",
"=",
"''",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"// check if they wish to send a file",
"// default to post method and add the enctype needed to send files",
"$",
"method",
"=",
"strtolower",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"method",
"===",
"'file'",
")",
"{",
"$",
"method",
"=",
"'post'",
";",
"$",
"attr",
"[",
"'enctype'",
"]",
"=",
"'multipart/form-data'",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"method",
",",
"array",
"(",
"'post'",
",",
"'get'",
")",
")",
")",
"{",
"$",
"method",
"=",
"'post'",
";",
"}",
"$",
"attr",
"[",
"'method'",
"]",
"=",
"$",
"method",
";",
"$",
"attr",
"[",
"'action'",
"]",
"=",
"$",
"action",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'form'",
",",
"$",
"attr",
")",
";",
"}"
] |
open a form
@param string Type of form, get / post / file (adds as post and adds enctype) etc...
@param string Action for the form
@param array Array of extra params
@return string
|
[
"open",
"a",
"form"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L57-L75
|
22,021
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.hidden
|
public function hidden($name, $attr = array())
{
return $this->input(
$name,
false,
array_merge(
$attr,
array('type' => 'hidden', 'wrapper' => false)
)
);
}
|
php
|
public function hidden($name, $attr = array())
{
return $this->input(
$name,
false,
array_merge(
$attr,
array('type' => 'hidden', 'wrapper' => false)
)
);
}
|
[
"public",
"function",
"hidden",
"(",
"$",
"name",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"false",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'wrapper'",
"=>",
"false",
")",
")",
")",
";",
"}"
] |
shortcut for hidden input field
@param string input name (dot notation for multi-dimensional array)
@param array input attributes
@return string
|
[
"shortcut",
"for",
"hidden",
"input",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L106-L116
|
22,022
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.password
|
public function password($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'password')
)
);
}
|
php
|
public function password($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'password')
)
);
}
|
[
"public",
"function",
"password",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"$",
"label",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'password'",
")",
")",
")",
";",
"}"
] |
shortcut for password field
@param string input name (dot notation for multi-dimensional array)
@param string|array Label string or array of label value and attributes
@param array input attributes
@return string
|
[
"shortcut",
"for",
"password",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L126-L136
|
22,023
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.textarea
|
public function textarea($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'textarea')
)
);
}
|
php
|
public function textarea($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'textarea')
)
);
}
|
[
"public",
"function",
"textarea",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"$",
"label",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'textarea'",
")",
")",
")",
";",
"}"
] |
shortcut for textarea field
@param string input name (dot notation for multi-dimensional array)
@param string|array Label string or array of label value and attributes
@param array input attributes
@return string
|
[
"shortcut",
"for",
"textarea",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L146-L156
|
22,024
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.file
|
public function file($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'file')
)
);
}
|
php
|
public function file($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'file')
)
);
}
|
[
"public",
"function",
"file",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"$",
"label",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'file'",
")",
")",
")",
";",
"}"
] |
shortcut for file field
@param string input name (dot notation for multi-dimensional array)
@param string|array Label string or array of label value and attributes
@param array input attributes
@return string
|
[
"shortcut",
"for",
"file",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L166-L176
|
22,025
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.checkbox
|
public function checkbox($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'checkbox')
)
);
}
|
php
|
public function checkbox($name, $label, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array('type' => 'checkbox')
)
);
}
|
[
"public",
"function",
"checkbox",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"$",
"label",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'checkbox'",
")",
")",
")",
";",
"}"
] |
shortcut for checkbox field
@param string input name (dot notation for multi-dimensional array)
@param string|array Label string or array of label value and attributes
@param array input attributes
@return string
|
[
"shortcut",
"for",
"checkbox",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L186-L196
|
22,026
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.submit
|
public function submit($name, $label, $attr = array())
{
return $this->input(
$name,
false,
array_merge(
$attr,
array(
'type' => 'submit',
'value' => $label
)
)
);
}
|
php
|
public function submit($name, $label, $attr = array())
{
return $this->input(
$name,
false,
array_merge(
$attr,
array(
'type' => 'submit',
'value' => $label
)
)
);
}
|
[
"public",
"function",
"submit",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"false",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'submit'",
",",
"'value'",
"=>",
"$",
"label",
")",
")",
")",
";",
"}"
] |
generate a submit input
@param string dot notation form for input - will match with Input handler and prefill if found
@param string label for form, pass false to not show label
@param array array of extra options for the input
@return string form element
|
[
"generate",
"a",
"submit",
"input"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L206-L219
|
22,027
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.button
|
public function button($name, $label, $attr = array())
{
return $this->input(
$name,
false,
array_merge(
$attr,
array(
'type' => 'button',
'value' => $label
)
)
);
}
|
php
|
public function button($name, $label, $attr = array())
{
return $this->input(
$name,
false,
array_merge(
$attr,
array(
'type' => 'button',
'value' => $label
)
)
);
}
|
[
"public",
"function",
"button",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"false",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'button'",
",",
"'value'",
"=>",
"$",
"label",
")",
")",
")",
";",
"}"
] |
generate a button input
@param string dot notation form for input - will match with Input handler and prefill if found
@param string label for form, pass false to not show label
@param array array of extra options for the input
@return string form element
|
[
"generate",
"a",
"button",
"input"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L229-L242
|
22,028
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.radio
|
public function radio($name, $label, $options, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array(
'type' => 'radio',
'options' => $options
)
)
);
}
|
php
|
public function radio($name, $label, $options, $attr = array())
{
return $this->input(
$name,
$label,
array_merge(
$attr,
array(
'type' => 'radio',
'options' => $options
)
)
);
}
|
[
"public",
"function",
"radio",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"options",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"(",
"$",
"name",
",",
"$",
"label",
",",
"array_merge",
"(",
"$",
"attr",
",",
"array",
"(",
"'type'",
"=>",
"'radio'",
",",
"'options'",
"=>",
"$",
"options",
")",
")",
")",
";",
"}"
] |
generate a group of radio buttons
@param string input name (dot notation for multi-dimensional array)
@param string|array Label string or array of label value and attributes
@param array radio Options
@param array input attributes
@return string
|
[
"generate",
"a",
"group",
"of",
"radio",
"buttons"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L277-L290
|
22,029
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.input
|
public function input($name, $label, $attr = array())
{
// generate an id if none exists
if (empty($attr['id'])) {
$attr['id'] = $this->transformNameForID($name);
}
// build the label
if ($label !== false) {
$labelAttr = [];
if (is_array($label)) {
$labelAttr = $label;
$label = (! empty($label['value'])) ? $label['value'] : $name;
unset($labelAttr['value']);
}
$labelAttr['for'] = $attr['id'];
$label = $this->label($label, $labelAttr);
} else {
$label = '';
}
// remove any wrapper attributes
// these will be dealt with later
$wrapper = array();
if (isset($attr['wrapper'])) {
$wrapper = $attr['wrapper'];
unset($attr['wrapper']);
}
// any before / between / after set
// $attr passed by reference
$injects = $this->getInjects($attr);
// generate the actual field
if (empty($attr['type'])) {
$attr['type'] = 'text';
}
$field = $this->generateField(
$name,
$attr
);
// build the contents for the wrapper
$contents = $this->buildField($attr['type'], $label, $field, $injects);
// check if they actually want a wrapper
if (isset($wrapper) && $wrapper === false) {
return $contents;
}
// build up the wrapper info
// should return the tag and attributes array
$wrapperInfo = $this->getWrapper($wrapper, $attr);
// return the final wrapper tag with the contents
return $this->Html->tag(
$wrapperInfo['tag'],
$wrapperInfo['attr'],
$contents,
true
);
}
|
php
|
public function input($name, $label, $attr = array())
{
// generate an id if none exists
if (empty($attr['id'])) {
$attr['id'] = $this->transformNameForID($name);
}
// build the label
if ($label !== false) {
$labelAttr = [];
if (is_array($label)) {
$labelAttr = $label;
$label = (! empty($label['value'])) ? $label['value'] : $name;
unset($labelAttr['value']);
}
$labelAttr['for'] = $attr['id'];
$label = $this->label($label, $labelAttr);
} else {
$label = '';
}
// remove any wrapper attributes
// these will be dealt with later
$wrapper = array();
if (isset($attr['wrapper'])) {
$wrapper = $attr['wrapper'];
unset($attr['wrapper']);
}
// any before / between / after set
// $attr passed by reference
$injects = $this->getInjects($attr);
// generate the actual field
if (empty($attr['type'])) {
$attr['type'] = 'text';
}
$field = $this->generateField(
$name,
$attr
);
// build the contents for the wrapper
$contents = $this->buildField($attr['type'], $label, $field, $injects);
// check if they actually want a wrapper
if (isset($wrapper) && $wrapper === false) {
return $contents;
}
// build up the wrapper info
// should return the tag and attributes array
$wrapperInfo = $this->getWrapper($wrapper, $attr);
// return the final wrapper tag with the contents
return $this->Html->tag(
$wrapperInfo['tag'],
$wrapperInfo['attr'],
$contents,
true
);
}
|
[
"public",
"function",
"input",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"// generate an id if none exists",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"attr",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"transformNameForID",
"(",
"$",
"name",
")",
";",
"}",
"// build the label",
"if",
"(",
"$",
"label",
"!==",
"false",
")",
"{",
"$",
"labelAttr",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"label",
")",
")",
"{",
"$",
"labelAttr",
"=",
"$",
"label",
";",
"$",
"label",
"=",
"(",
"!",
"empty",
"(",
"$",
"label",
"[",
"'value'",
"]",
")",
")",
"?",
"$",
"label",
"[",
"'value'",
"]",
":",
"$",
"name",
";",
"unset",
"(",
"$",
"labelAttr",
"[",
"'value'",
"]",
")",
";",
"}",
"$",
"labelAttr",
"[",
"'for'",
"]",
"=",
"$",
"attr",
"[",
"'id'",
"]",
";",
"$",
"label",
"=",
"$",
"this",
"->",
"label",
"(",
"$",
"label",
",",
"$",
"labelAttr",
")",
";",
"}",
"else",
"{",
"$",
"label",
"=",
"''",
";",
"}",
"// remove any wrapper attributes",
"// these will be dealt with later",
"$",
"wrapper",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'wrapper'",
"]",
")",
")",
"{",
"$",
"wrapper",
"=",
"$",
"attr",
"[",
"'wrapper'",
"]",
";",
"unset",
"(",
"$",
"attr",
"[",
"'wrapper'",
"]",
")",
";",
"}",
"// any before / between / after set",
"// $attr passed by reference",
"$",
"injects",
"=",
"$",
"this",
"->",
"getInjects",
"(",
"$",
"attr",
")",
";",
"// generate the actual field",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"attr",
"[",
"'type'",
"]",
"=",
"'text'",
";",
"}",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"name",
",",
"$",
"attr",
")",
";",
"// build the contents for the wrapper",
"$",
"contents",
"=",
"$",
"this",
"->",
"buildField",
"(",
"$",
"attr",
"[",
"'type'",
"]",
",",
"$",
"label",
",",
"$",
"field",
",",
"$",
"injects",
")",
";",
"// check if they actually want a wrapper",
"if",
"(",
"isset",
"(",
"$",
"wrapper",
")",
"&&",
"$",
"wrapper",
"===",
"false",
")",
"{",
"return",
"$",
"contents",
";",
"}",
"// build up the wrapper info",
"// should return the tag and attributes array",
"$",
"wrapperInfo",
"=",
"$",
"this",
"->",
"getWrapper",
"(",
"$",
"wrapper",
",",
"$",
"attr",
")",
";",
"// return the final wrapper tag with the contents",
"return",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"$",
"wrapperInfo",
"[",
"'tag'",
"]",
",",
"$",
"wrapperInfo",
"[",
"'attr'",
"]",
",",
"$",
"contents",
",",
"true",
")",
";",
"}"
] |
generate a complete input with wrapped div and label
@param string input name (dot notation for multi-dimensional array)
@param string|array Label string or array of label value and attributes
@param array input attributes
@return string
|
[
"generate",
"a",
"complete",
"input",
"with",
"wrapped",
"div",
"and",
"label"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L325-L388
|
22,030
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.generateField
|
public function generateField($name, $attr = array())
{
$tag = 'input';
if (in_array($attr['type'], $this->customGenerate)) {
$tag = $attr['type'];
}
$attr['name'] = $this->transformName($name);
$attr = $this->getData($name, $attr);
if ($tag !== 'input') {
$generate = 'generate' . ucfirst(strtolower($tag)) . 'Field';
return $this->{$generate}($attr);
} else {
return $this->Html->tag('input', $attr);
}
}
|
php
|
public function generateField($name, $attr = array())
{
$tag = 'input';
if (in_array($attr['type'], $this->customGenerate)) {
$tag = $attr['type'];
}
$attr['name'] = $this->transformName($name);
$attr = $this->getData($name, $attr);
if ($tag !== 'input') {
$generate = 'generate' . ucfirst(strtolower($tag)) . 'Field';
return $this->{$generate}($attr);
} else {
return $this->Html->tag('input', $attr);
}
}
|
[
"public",
"function",
"generateField",
"(",
"$",
"name",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"tag",
"=",
"'input'",
";",
"if",
"(",
"in_array",
"(",
"$",
"attr",
"[",
"'type'",
"]",
",",
"$",
"this",
"->",
"customGenerate",
")",
")",
"{",
"$",
"tag",
"=",
"$",
"attr",
"[",
"'type'",
"]",
";",
"}",
"$",
"attr",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"transformName",
"(",
"$",
"name",
")",
";",
"$",
"attr",
"=",
"$",
"this",
"->",
"getData",
"(",
"$",
"name",
",",
"$",
"attr",
")",
";",
"if",
"(",
"$",
"tag",
"!==",
"'input'",
")",
"{",
"$",
"generate",
"=",
"'generate'",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"tag",
")",
")",
".",
"'Field'",
";",
"return",
"$",
"this",
"->",
"{",
"$",
"generate",
"}",
"(",
"$",
"attr",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'input'",
",",
"$",
"attr",
")",
";",
"}",
"}"
] |
generate a field
@param string The type of input field to create
@param array Array of attributes for the tag
@return string
|
[
"generate",
"a",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L429-L446
|
22,031
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.generateRadioField
|
public function generateRadioField($attr)
{
if (empty($attr['name'])) {
return '';
}
$out = '';
$options = array();
if (! empty($attr['options'])) {
$options = $attr['options'];
}
if (isset($attr['checked'])) {
$checkedItem = $attr['checked'];
}
unset($attr['options'], $attr['checked']);
foreach ($options as $value => $label) {
$id = $attr['id'] . '_' . $value;
$optionsAttr = array('id' => $id, 'value' => $value);
if (isset($checkedItem) && $checkedItem == $value) {
$optionsAttr[] = 'checked';
}
$input = $this->Html->tag(
'input',
array_merge(
$attr,
$optionsAttr
)
);
$label = $this->Html->tag(
'label',
array('for' => $id),
$label,
true
);
$out .= $this->Html->tag(
'div',
array(
'class' => 'radio-item'
),
$input . $label,
true
);
}
return $out;
}
|
php
|
public function generateRadioField($attr)
{
if (empty($attr['name'])) {
return '';
}
$out = '';
$options = array();
if (! empty($attr['options'])) {
$options = $attr['options'];
}
if (isset($attr['checked'])) {
$checkedItem = $attr['checked'];
}
unset($attr['options'], $attr['checked']);
foreach ($options as $value => $label) {
$id = $attr['id'] . '_' . $value;
$optionsAttr = array('id' => $id, 'value' => $value);
if (isset($checkedItem) && $checkedItem == $value) {
$optionsAttr[] = 'checked';
}
$input = $this->Html->tag(
'input',
array_merge(
$attr,
$optionsAttr
)
);
$label = $this->Html->tag(
'label',
array('for' => $id),
$label,
true
);
$out .= $this->Html->tag(
'div',
array(
'class' => 'radio-item'
),
$input . $label,
true
);
}
return $out;
}
|
[
"public",
"function",
"generateRadioField",
"(",
"$",
"attr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"'name'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"out",
"=",
"''",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"$",
"attr",
"[",
"'options'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'checked'",
"]",
")",
")",
"{",
"$",
"checkedItem",
"=",
"$",
"attr",
"[",
"'checked'",
"]",
";",
"}",
"unset",
"(",
"$",
"attr",
"[",
"'options'",
"]",
",",
"$",
"attr",
"[",
"'checked'",
"]",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"$",
"id",
"=",
"$",
"attr",
"[",
"'id'",
"]",
".",
"'_'",
".",
"$",
"value",
";",
"$",
"optionsAttr",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'value'",
"=>",
"$",
"value",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"checkedItem",
")",
"&&",
"$",
"checkedItem",
"==",
"$",
"value",
")",
"{",
"$",
"optionsAttr",
"[",
"]",
"=",
"'checked'",
";",
"}",
"$",
"input",
"=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'input'",
",",
"array_merge",
"(",
"$",
"attr",
",",
"$",
"optionsAttr",
")",
")",
";",
"$",
"label",
"=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'label'",
",",
"array",
"(",
"'for'",
"=>",
"$",
"id",
")",
",",
"$",
"label",
",",
"true",
")",
";",
"$",
"out",
".=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'radio-item'",
")",
",",
"$",
"input",
".",
"$",
"label",
",",
"true",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
generate a selection of radio buttons
@param array array of attributes
@return string
|
[
"generate",
"a",
"selection",
"of",
"radio",
"buttons"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L454-L506
|
22,032
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.generateCheckboxField
|
public function generateCheckboxField($attr)
{
if (empty($attr['name'])) {
return '';
}
$out = '';
if ((isset($attr['hiddenCheckbox']) && $attr['hiddenCheckbox']) || ! isset($attr['hiddenCheckbox'])) {
$out .= $this->input(
$attr['name'],
false,
array(
'type' => 'hidden',
'wrapper' => false,
'id' => '_' . $attr['id'],
'value' => 0
)
);
}
unset($attr['hiddenCheckbox']);
if (! isset($attr['value'])) {
$attr['value'] = 1;
}
$out .= $this->Html->tag('input', $attr);
return $out;
}
|
php
|
public function generateCheckboxField($attr)
{
if (empty($attr['name'])) {
return '';
}
$out = '';
if ((isset($attr['hiddenCheckbox']) && $attr['hiddenCheckbox']) || ! isset($attr['hiddenCheckbox'])) {
$out .= $this->input(
$attr['name'],
false,
array(
'type' => 'hidden',
'wrapper' => false,
'id' => '_' . $attr['id'],
'value' => 0
)
);
}
unset($attr['hiddenCheckbox']);
if (! isset($attr['value'])) {
$attr['value'] = 1;
}
$out .= $this->Html->tag('input', $attr);
return $out;
}
|
[
"public",
"function",
"generateCheckboxField",
"(",
"$",
"attr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"'name'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"out",
"=",
"''",
";",
"if",
"(",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'hiddenCheckbox'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'hiddenCheckbox'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"attr",
"[",
"'hiddenCheckbox'",
"]",
")",
")",
"{",
"$",
"out",
".=",
"$",
"this",
"->",
"input",
"(",
"$",
"attr",
"[",
"'name'",
"]",
",",
"false",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'wrapper'",
"=>",
"false",
",",
"'id'",
"=>",
"'_'",
".",
"$",
"attr",
"[",
"'id'",
"]",
",",
"'value'",
"=>",
"0",
")",
")",
";",
"}",
"unset",
"(",
"$",
"attr",
"[",
"'hiddenCheckbox'",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attr",
"[",
"'value'",
"]",
")",
")",
"{",
"$",
"attr",
"[",
"'value'",
"]",
"=",
"1",
";",
"}",
"$",
"out",
".=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'input'",
",",
"$",
"attr",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
generate a checkbox
@param array array of attributes
@return string
|
[
"generate",
"a",
"checkbox"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L514-L542
|
22,033
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.generateButtonField
|
public function generateButtonField($attr)
{
$value = 'Submit';
if (! empty($attr['value'])) {
$value = $attr['value'];
}
unset($attr['value'], $attr['type']);
return $this->Html->tag('button', $attr, $value, true);
}
|
php
|
public function generateButtonField($attr)
{
$value = 'Submit';
if (! empty($attr['value'])) {
$value = $attr['value'];
}
unset($attr['value'], $attr['type']);
return $this->Html->tag('button', $attr, $value, true);
}
|
[
"public",
"function",
"generateButtonField",
"(",
"$",
"attr",
")",
"{",
"$",
"value",
"=",
"'Submit'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'value'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"attr",
"[",
"'value'",
"]",
";",
"}",
"unset",
"(",
"$",
"attr",
"[",
"'value'",
"]",
",",
"$",
"attr",
"[",
"'type'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'button'",
",",
"$",
"attr",
",",
"$",
"value",
",",
"true",
")",
";",
"}"
] |
generate a button
@param array array of attributes
@return string
|
[
"generate",
"a",
"button"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L571-L581
|
22,034
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.generateSelectField
|
public function generateSelectField($attr)
{
if (empty($attr['name'])) {
return '';
}
$options = array();
if (! empty($attr['options'])) {
$options = $attr['options'];
}
$options = $this->generateSelectOptions($options, $attr);
unset($attr['options'], $attr['type'], $attr['selected']);
return $this->Html->tag('select', $attr, $options, true);
}
|
php
|
public function generateSelectField($attr)
{
if (empty($attr['name'])) {
return '';
}
$options = array();
if (! empty($attr['options'])) {
$options = $attr['options'];
}
$options = $this->generateSelectOptions($options, $attr);
unset($attr['options'], $attr['type'], $attr['selected']);
return $this->Html->tag('select', $attr, $options, true);
}
|
[
"public",
"function",
"generateSelectField",
"(",
"$",
"attr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attr",
"[",
"'name'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"options",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"$",
"attr",
"[",
"'options'",
"]",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"generateSelectOptions",
"(",
"$",
"options",
",",
"$",
"attr",
")",
";",
"unset",
"(",
"$",
"attr",
"[",
"'options'",
"]",
",",
"$",
"attr",
"[",
"'type'",
"]",
",",
"$",
"attr",
"[",
"'selected'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'select'",
",",
"$",
"attr",
",",
"$",
"options",
",",
"true",
")",
";",
"}"
] |
generate a select field
@param array array of attributes
@return string
|
[
"generate",
"a",
"select",
"field"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L589-L605
|
22,035
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.generateSelectOptions
|
public function generateSelectOptions($options, $attr)
{
$return = '';
foreach ($options as $key => $value) {
if (is_array($value)) {
$subArray = $this->generateSelectOptions($value, $attr);
$return .= $this->Html->tag(
'optgroup',
array(
'label' => $key
),
$subArray,
true
);
} else {
$optionsAttr = array('value' => $key);
if (isset($attr['selected']) && $attr['selected'] == $key) {
$optionsAttr[] = 'selected';
}
$return .= $this->Html->tag(
'option',
$optionsAttr,
$value,
true
);
}
}
return $return;
}
|
php
|
public function generateSelectOptions($options, $attr)
{
$return = '';
foreach ($options as $key => $value) {
if (is_array($value)) {
$subArray = $this->generateSelectOptions($value, $attr);
$return .= $this->Html->tag(
'optgroup',
array(
'label' => $key
),
$subArray,
true
);
} else {
$optionsAttr = array('value' => $key);
if (isset($attr['selected']) && $attr['selected'] == $key) {
$optionsAttr[] = 'selected';
}
$return .= $this->Html->tag(
'option',
$optionsAttr,
$value,
true
);
}
}
return $return;
}
|
[
"public",
"function",
"generateSelectOptions",
"(",
"$",
"options",
",",
"$",
"attr",
")",
"{",
"$",
"return",
"=",
"''",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"subArray",
"=",
"$",
"this",
"->",
"generateSelectOptions",
"(",
"$",
"value",
",",
"$",
"attr",
")",
";",
"$",
"return",
".=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'optgroup'",
",",
"array",
"(",
"'label'",
"=>",
"$",
"key",
")",
",",
"$",
"subArray",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"optionsAttr",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'selected'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'selected'",
"]",
"==",
"$",
"key",
")",
"{",
"$",
"optionsAttr",
"[",
"]",
"=",
"'selected'",
";",
"}",
"$",
"return",
".=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'option'",
",",
"$",
"optionsAttr",
",",
"$",
"value",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
generate the options for a select box
@param array array of options
@param array array of attributes
@return string
|
[
"generate",
"the",
"options",
"for",
"a",
"select",
"box"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L625-L658
|
22,036
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.transformName
|
public function transformName($name)
{
if (strpos($name, '.') !== false) {
$bits = explode('.', $name, 2);
$bits['1'] = '[' . str_replace('.', '][', $bits['1']) . ']';
return implode('', $bits);
} else {
return $name;
}
}
|
php
|
public function transformName($name)
{
if (strpos($name, '.') !== false) {
$bits = explode('.', $name, 2);
$bits['1'] = '[' . str_replace('.', '][', $bits['1']) . ']';
return implode('', $bits);
} else {
return $name;
}
}
|
[
"public",
"function",
"transformName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"bits",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
",",
"2",
")",
";",
"$",
"bits",
"[",
"'1'",
"]",
"=",
"'['",
".",
"str_replace",
"(",
"'.'",
",",
"']['",
",",
"$",
"bits",
"[",
"'1'",
"]",
")",
".",
"']'",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"bits",
")",
";",
"}",
"else",
"{",
"return",
"$",
"name",
";",
"}",
"}"
] |
transform the dot notation name into proper name
@param string Dot notation input name
@return string transformed name for input
|
[
"transform",
"the",
"dot",
"notation",
"name",
"into",
"proper",
"name"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L666-L675
|
22,037
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.transformNameForID
|
public function transformNameForID($name)
{
$bits = explode('.', $name);
array_walk(
$bits,
function (&$value, $key) {
$value = ucfirst(strtolower($value));
}
);
return implode('', $bits);
}
|
php
|
public function transformNameForID($name)
{
$bits = explode('.', $name);
array_walk(
$bits,
function (&$value, $key) {
$value = ucfirst(strtolower($value));
}
);
return implode('', $bits);
}
|
[
"public",
"function",
"transformNameForID",
"(",
"$",
"name",
")",
"{",
"$",
"bits",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
")",
";",
"array_walk",
"(",
"$",
"bits",
",",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"value",
")",
")",
";",
"}",
")",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"bits",
")",
";",
"}"
] |
transform the dot notation name into a name for input ID
if no ID was passed
@param string Dot notation input name
@return string transformed name for input ID
|
[
"transform",
"the",
"dot",
"notation",
"name",
"into",
"a",
"name",
"for",
"input",
"ID",
"if",
"no",
"ID",
"was",
"passed"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L684-L694
|
22,038
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.getInjects
|
public function getInjects(&$attr)
{
$inject = array(
'before' => '',
'between' => '',
'after' => ''
);
if (! empty($attr['before'])) {
$inject['before'] = $attr['before'];
unset($attr['before']);
}
if (! empty($attr['between'])) {
$inject['between'] = $attr['between'];
unset($attr['between']);
}
if (! empty($attr['after'])) {
$inject['after'] = $attr['after'];
unset($attr['after']);
}
return $inject;
}
|
php
|
public function getInjects(&$attr)
{
$inject = array(
'before' => '',
'between' => '',
'after' => ''
);
if (! empty($attr['before'])) {
$inject['before'] = $attr['before'];
unset($attr['before']);
}
if (! empty($attr['between'])) {
$inject['between'] = $attr['between'];
unset($attr['between']);
}
if (! empty($attr['after'])) {
$inject['after'] = $attr['after'];
unset($attr['after']);
}
return $inject;
}
|
[
"public",
"function",
"getInjects",
"(",
"&",
"$",
"attr",
")",
"{",
"$",
"inject",
"=",
"array",
"(",
"'before'",
"=>",
"''",
",",
"'between'",
"=>",
"''",
",",
"'after'",
"=>",
"''",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"inject",
"[",
"'before'",
"]",
"=",
"$",
"attr",
"[",
"'before'",
"]",
";",
"unset",
"(",
"$",
"attr",
"[",
"'before'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'between'",
"]",
")",
")",
"{",
"$",
"inject",
"[",
"'between'",
"]",
"=",
"$",
"attr",
"[",
"'between'",
"]",
";",
"unset",
"(",
"$",
"attr",
"[",
"'between'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'after'",
"]",
")",
")",
"{",
"$",
"inject",
"[",
"'after'",
"]",
"=",
"$",
"attr",
"[",
"'after'",
"]",
";",
"unset",
"(",
"$",
"attr",
"[",
"'after'",
"]",
")",
";",
"}",
"return",
"$",
"inject",
";",
"}"
] |
get injections from the attributes
allows data to be entered before, between, after
@param array attributes array (Passed by reference)
@return array
|
[
"get",
"injections",
"from",
"the",
"attributes",
"allows",
"data",
"to",
"be",
"entered",
"before",
"between",
"after"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L703-L727
|
22,039
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.getWrapper
|
public function getWrapper($wrapper, $attr)
{
$type = '';
if (! empty($attr['type'])) {
$type = ' ' . $attr['type'];
if ((isset($attr['type']) && $attr['type'] == 'select') && in_array('multiple', $attr)) {
$type .= ' multiselect';
}
}
$defaults = array(
'tag' => 'div',
'class' => 'input' . $type
);
$wrapperAttr = array_merge(
$defaults,
$wrapper
);
// double check for the presence of a tag element
$tag = $wrapperAttr['tag'];
unset($wrapperAttr['tag']);
return array(
'tag' => $tag,
'attr' => $wrapperAttr
);
}
|
php
|
public function getWrapper($wrapper, $attr)
{
$type = '';
if (! empty($attr['type'])) {
$type = ' ' . $attr['type'];
if ((isset($attr['type']) && $attr['type'] == 'select') && in_array('multiple', $attr)) {
$type .= ' multiselect';
}
}
$defaults = array(
'tag' => 'div',
'class' => 'input' . $type
);
$wrapperAttr = array_merge(
$defaults,
$wrapper
);
// double check for the presence of a tag element
$tag = $wrapperAttr['tag'];
unset($wrapperAttr['tag']);
return array(
'tag' => $tag,
'attr' => $wrapperAttr
);
}
|
[
"public",
"function",
"getWrapper",
"(",
"$",
"wrapper",
",",
"$",
"attr",
")",
"{",
"$",
"type",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attr",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"type",
"=",
"' '",
".",
"$",
"attr",
"[",
"'type'",
"]",
";",
"if",
"(",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'type'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'type'",
"]",
"==",
"'select'",
")",
"&&",
"in_array",
"(",
"'multiple'",
",",
"$",
"attr",
")",
")",
"{",
"$",
"type",
".=",
"' multiselect'",
";",
"}",
"}",
"$",
"defaults",
"=",
"array",
"(",
"'tag'",
"=>",
"'div'",
",",
"'class'",
"=>",
"'input'",
".",
"$",
"type",
")",
";",
"$",
"wrapperAttr",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"wrapper",
")",
";",
"// double check for the presence of a tag element",
"$",
"tag",
"=",
"$",
"wrapperAttr",
"[",
"'tag'",
"]",
";",
"unset",
"(",
"$",
"wrapperAttr",
"[",
"'tag'",
"]",
")",
";",
"return",
"array",
"(",
"'tag'",
"=>",
"$",
"tag",
",",
"'attr'",
"=>",
"$",
"wrapperAttr",
")",
";",
"}"
] |
given any user defined wrapper instructions
build the wrapper data
@param array Array of any passed wrapper info
@param array Array of the inputs attributes
@return array two element array of tag / attr
|
[
"given",
"any",
"user",
"defined",
"wrapper",
"instructions",
"build",
"the",
"wrapper",
"data"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L737-L766
|
22,040
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.getData
|
public function getData($name, $attr)
{
if (empty($name)) {
return $attr;
}
$value = $this->Data->getValue($name);
if ($value !== null) {
$isCheckbox = (isset($attr['type']) && $attr['type'] == 'checkbox');
$isRadio = (isset($attr['type']) && $attr['type'] == 'radio');
$isSelect = (isset($attr['type']) && $attr['type'] == 'select');
if ($isCheckbox) {
$attr[] = 'checked';
} elseif ($isRadio) {
$attr['checked'] = $value;
} elseif ($isSelect) {
$attr['selected'] = $value;
} else {
$attr['value'] = $value;
}
}
return $attr;
}
|
php
|
public function getData($name, $attr)
{
if (empty($name)) {
return $attr;
}
$value = $this->Data->getValue($name);
if ($value !== null) {
$isCheckbox = (isset($attr['type']) && $attr['type'] == 'checkbox');
$isRadio = (isset($attr['type']) && $attr['type'] == 'radio');
$isSelect = (isset($attr['type']) && $attr['type'] == 'select');
if ($isCheckbox) {
$attr[] = 'checked';
} elseif ($isRadio) {
$attr['checked'] = $value;
} elseif ($isSelect) {
$attr['selected'] = $value;
} else {
$attr['value'] = $value;
}
}
return $attr;
}
|
[
"public",
"function",
"getData",
"(",
"$",
"name",
",",
"$",
"attr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"attr",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"Data",
"->",
"getValue",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"isCheckbox",
"=",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'type'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'type'",
"]",
"==",
"'checkbox'",
")",
";",
"$",
"isRadio",
"=",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'type'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'type'",
"]",
"==",
"'radio'",
")",
";",
"$",
"isSelect",
"=",
"(",
"isset",
"(",
"$",
"attr",
"[",
"'type'",
"]",
")",
"&&",
"$",
"attr",
"[",
"'type'",
"]",
"==",
"'select'",
")",
";",
"if",
"(",
"$",
"isCheckbox",
")",
"{",
"$",
"attr",
"[",
"]",
"=",
"'checked'",
";",
"}",
"elseif",
"(",
"$",
"isRadio",
")",
"{",
"$",
"attr",
"[",
"'checked'",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"$",
"isSelect",
")",
"{",
"$",
"attr",
"[",
"'selected'",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"attr",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"attr",
";",
"}"
] |
use the Data interface and find any post data
@param string input name (dot notation for multi-dimensional array)
@param array Array of attributes for the tag
@return array Return the attribute array with added post data
|
[
"use",
"the",
"Data",
"interface",
"and",
"find",
"any",
"post",
"data"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L775-L800
|
22,041
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.setData
|
public function setData($Data)
{
if (! is_object($Data) || ! $Data instanceof Data) {
throw new \InvalidArgumentException(
'The Data Interface must be a valid Data Object'
);
}
$this->Data = $Data;
return true;
}
|
php
|
public function setData($Data)
{
if (! is_object($Data) || ! $Data instanceof Data) {
throw new \InvalidArgumentException(
'The Data Interface must be a valid Data Object'
);
}
$this->Data = $Data;
return true;
}
|
[
"public",
"function",
"setData",
"(",
"$",
"Data",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"Data",
")",
"||",
"!",
"$",
"Data",
"instanceof",
"Data",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The Data Interface must be a valid Data Object'",
")",
";",
"}",
"$",
"this",
"->",
"Data",
"=",
"$",
"Data",
";",
"return",
"true",
";",
"}"
] |
check and set the form data interface
@param Object Instance of an Data Interface
@return bool
@throws \InvalidArgumentException
|
[
"check",
"and",
"set",
"the",
"form",
"data",
"interface"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L809-L819
|
22,042
|
mikebarlow/html-helper
|
src/Helpers/Form.php
|
Form.setHtml
|
public function setHtml($Html)
{
if (! is_object($Html) || ! $Html instanceof HtmlObject) {
throw new \InvalidArgumentException(
'The HTML Object must be a valid HTML Object'
);
}
$this->Html = $Html;
return true;
}
|
php
|
public function setHtml($Html)
{
if (! is_object($Html) || ! $Html instanceof HtmlObject) {
throw new \InvalidArgumentException(
'The HTML Object must be a valid HTML Object'
);
}
$this->Html = $Html;
return true;
}
|
[
"public",
"function",
"setHtml",
"(",
"$",
"Html",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"Html",
")",
"||",
"!",
"$",
"Html",
"instanceof",
"HtmlObject",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The HTML Object must be a valid HTML Object'",
")",
";",
"}",
"$",
"this",
"->",
"Html",
"=",
"$",
"Html",
";",
"return",
"true",
";",
"}"
] |
check and set the HTML Object
@param Object Instance of an Html
@return bool
@throws \InvalidArgumentException
|
[
"check",
"and",
"set",
"the",
"HTML",
"Object"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Helpers/Form.php#L838-L848
|
22,043
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Twig/Writer/Twig.php
|
Twig.addExtensionsFromTemplateConfiguration
|
protected function addExtensionsFromTemplateConfiguration(
Transformation $transformation,
ProjectDescriptor $project,
\Twig_Environment $twigEnvironment
) {
$isDebug = $transformation->getParameter('twig-debug')
? $transformation->getParameter('twig-debug')->getValue()
: false;
if ($isDebug == 'true') {
$twigEnvironment->enableDebug();
$twigEnvironment->enableAutoReload();
$twigEnvironment->addExtension(new \Twig_Extension_Debug());
}
/** @var Template\Parameter $extension */
foreach ($transformation->getParametersWithKey('twig-extension') as $extension) {
$extensionValue = $extension->getValue();
if (!class_exists($extensionValue)) {
throw new \InvalidArgumentException('Unknown twig extension: ' . $extensionValue);
}
// to support 'normal' Twig extensions we check the interface to determine what instantiation to do.
$implementsInterface = in_array(
'phpDocumentor\Plugin\Twig\ExtensionInterface',
class_implements($extensionValue)
);
$twigEnvironment->addExtension(
$implementsInterface ? new $extensionValue($project, $transformation) : new $extensionValue()
);
}
}
|
php
|
protected function addExtensionsFromTemplateConfiguration(
Transformation $transformation,
ProjectDescriptor $project,
\Twig_Environment $twigEnvironment
) {
$isDebug = $transformation->getParameter('twig-debug')
? $transformation->getParameter('twig-debug')->getValue()
: false;
if ($isDebug == 'true') {
$twigEnvironment->enableDebug();
$twigEnvironment->enableAutoReload();
$twigEnvironment->addExtension(new \Twig_Extension_Debug());
}
/** @var Template\Parameter $extension */
foreach ($transformation->getParametersWithKey('twig-extension') as $extension) {
$extensionValue = $extension->getValue();
if (!class_exists($extensionValue)) {
throw new \InvalidArgumentException('Unknown twig extension: ' . $extensionValue);
}
// to support 'normal' Twig extensions we check the interface to determine what instantiation to do.
$implementsInterface = in_array(
'phpDocumentor\Plugin\Twig\ExtensionInterface',
class_implements($extensionValue)
);
$twigEnvironment->addExtension(
$implementsInterface ? new $extensionValue($project, $transformation) : new $extensionValue()
);
}
}
|
[
"protected",
"function",
"addExtensionsFromTemplateConfiguration",
"(",
"Transformation",
"$",
"transformation",
",",
"ProjectDescriptor",
"$",
"project",
",",
"\\",
"Twig_Environment",
"$",
"twigEnvironment",
")",
"{",
"$",
"isDebug",
"=",
"$",
"transformation",
"->",
"getParameter",
"(",
"'twig-debug'",
")",
"?",
"$",
"transformation",
"->",
"getParameter",
"(",
"'twig-debug'",
")",
"->",
"getValue",
"(",
")",
":",
"false",
";",
"if",
"(",
"$",
"isDebug",
"==",
"'true'",
")",
"{",
"$",
"twigEnvironment",
"->",
"enableDebug",
"(",
")",
";",
"$",
"twigEnvironment",
"->",
"enableAutoReload",
"(",
")",
";",
"$",
"twigEnvironment",
"->",
"addExtension",
"(",
"new",
"\\",
"Twig_Extension_Debug",
"(",
")",
")",
";",
"}",
"/** @var Template\\Parameter $extension */",
"foreach",
"(",
"$",
"transformation",
"->",
"getParametersWithKey",
"(",
"'twig-extension'",
")",
"as",
"$",
"extension",
")",
"{",
"$",
"extensionValue",
"=",
"$",
"extension",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"extensionValue",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unknown twig extension: '",
".",
"$",
"extensionValue",
")",
";",
"}",
"// to support 'normal' Twig extensions we check the interface to determine what instantiation to do.",
"$",
"implementsInterface",
"=",
"in_array",
"(",
"'phpDocumentor\\Plugin\\Twig\\ExtensionInterface'",
",",
"class_implements",
"(",
"$",
"extensionValue",
")",
")",
";",
"$",
"twigEnvironment",
"->",
"addExtension",
"(",
"$",
"implementsInterface",
"?",
"new",
"$",
"extensionValue",
"(",
"$",
"project",
",",
"$",
"transformation",
")",
":",
"new",
"$",
"extensionValue",
"(",
")",
")",
";",
"}",
"}"
] |
Tries to add any custom extensions that have been defined in the template or the transformation's configuration.
This method will read the `twig-extension` parameter of the transformation (which inherits the template's
parameter set) and try to add those extensions to the environment.
@param Transformation $transformation
@param ProjectDescriptor $project
@param \Twig_Environment $twigEnvironment
@throws \InvalidArgumentException if a twig-extension should be loaded but it could not be found.
@return void
|
[
"Tries",
"to",
"add",
"any",
"custom",
"extensions",
"that",
"have",
"been",
"defined",
"in",
"the",
"template",
"or",
"the",
"transformation",
"s",
"configuration",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L199-L230
|
22,044
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Twig/Writer/Twig.php
|
Twig.getDestinationPath
|
protected function getDestinationPath($node, Transformation $transformation)
{
$writer = $this;
if (!$node) {
throw new \UnexpectedValueException(
'The transformation node in the twig writer is not expected to be false or null'
);
}
if (!$transformation->getArtifact()) {
$rule = $this->routers->match($node);
if (!$rule) {
throw new \InvalidArgumentException(
'No matching routing rule could be found for the given node, please provide an artifact location, '
. 'encountered: ' . ($node === null ? 'NULL' : get_class($node))
);
}
$rule = new ForFileProxy($rule);
$url = $rule->generate($node);
if ($url === false || $url[0] !== DIRECTORY_SEPARATOR) {
return false;
}
$path = $transformation->getTransformer()->getTarget() . str_replace('/', DIRECTORY_SEPARATOR, $url);
} else {
$path = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR . $transformation->getArtifact();
}
$finder = new Pathfinder();
$destination = preg_replace_callback(
'/{{([^}]+)}}/', // explicitly do not use the unicode modifier; this breaks windows
function ($query) use ($node, $writer, $finder) {
// strip any surrounding \ or /
$filepart = trim((string) current($finder->find($node, $query[1])), '\\/');
// make it windows proof
if (extension_loaded('iconv')) {
$filepart = iconv('UTF-8', 'ASCII//TRANSLIT', $filepart);
}
$filepart = strpos($filepart, '/') !== false
? implode('/', array_map('urlencode', explode('/', $filepart)))
: implode('\\', array_map('urlencode', explode('\\', $filepart)));
return $filepart;
},
$path
);
// replace any \ with the directory separator to be compatible with the
// current filesystem and allow the next file_exists to do its work
$destination = str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $destination);
// create directory if it does not exist yet
if (!file_exists(dirname($destination))) {
mkdir(dirname($destination), 0777, true);
}
return $destination;
}
|
php
|
protected function getDestinationPath($node, Transformation $transformation)
{
$writer = $this;
if (!$node) {
throw new \UnexpectedValueException(
'The transformation node in the twig writer is not expected to be false or null'
);
}
if (!$transformation->getArtifact()) {
$rule = $this->routers->match($node);
if (!$rule) {
throw new \InvalidArgumentException(
'No matching routing rule could be found for the given node, please provide an artifact location, '
. 'encountered: ' . ($node === null ? 'NULL' : get_class($node))
);
}
$rule = new ForFileProxy($rule);
$url = $rule->generate($node);
if ($url === false || $url[0] !== DIRECTORY_SEPARATOR) {
return false;
}
$path = $transformation->getTransformer()->getTarget() . str_replace('/', DIRECTORY_SEPARATOR, $url);
} else {
$path = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR . $transformation->getArtifact();
}
$finder = new Pathfinder();
$destination = preg_replace_callback(
'/{{([^}]+)}}/', // explicitly do not use the unicode modifier; this breaks windows
function ($query) use ($node, $writer, $finder) {
// strip any surrounding \ or /
$filepart = trim((string) current($finder->find($node, $query[1])), '\\/');
// make it windows proof
if (extension_loaded('iconv')) {
$filepart = iconv('UTF-8', 'ASCII//TRANSLIT', $filepart);
}
$filepart = strpos($filepart, '/') !== false
? implode('/', array_map('urlencode', explode('/', $filepart)))
: implode('\\', array_map('urlencode', explode('\\', $filepart)));
return $filepart;
},
$path
);
// replace any \ with the directory separator to be compatible with the
// current filesystem and allow the next file_exists to do its work
$destination = str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $destination);
// create directory if it does not exist yet
if (!file_exists(dirname($destination))) {
mkdir(dirname($destination), 0777, true);
}
return $destination;
}
|
[
"protected",
"function",
"getDestinationPath",
"(",
"$",
"node",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"writer",
"=",
"$",
"this",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'The transformation node in the twig writer is not expected to be false or null'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"routers",
"->",
"match",
"(",
"$",
"node",
")",
";",
"if",
"(",
"!",
"$",
"rule",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No matching routing rule could be found for the given node, please provide an artifact location, '",
".",
"'encountered: '",
".",
"(",
"$",
"node",
"===",
"null",
"?",
"'NULL'",
":",
"get_class",
"(",
"$",
"node",
")",
")",
")",
";",
"}",
"$",
"rule",
"=",
"new",
"ForFileProxy",
"(",
"$",
"rule",
")",
";",
"$",
"url",
"=",
"$",
"rule",
"->",
"generate",
"(",
"$",
"node",
")",
";",
"if",
"(",
"$",
"url",
"===",
"false",
"||",
"$",
"url",
"[",
"0",
"]",
"!==",
"DIRECTORY_SEPARATOR",
")",
"{",
"return",
"false",
";",
"}",
"$",
"path",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
".",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
";",
"}",
"$",
"finder",
"=",
"new",
"Pathfinder",
"(",
")",
";",
"$",
"destination",
"=",
"preg_replace_callback",
"(",
"'/{{([^}]+)}}/'",
",",
"// explicitly do not use the unicode modifier; this breaks windows",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"node",
",",
"$",
"writer",
",",
"$",
"finder",
")",
"{",
"// strip any surrounding \\ or /",
"$",
"filepart",
"=",
"trim",
"(",
"(",
"string",
")",
"current",
"(",
"$",
"finder",
"->",
"find",
"(",
"$",
"node",
",",
"$",
"query",
"[",
"1",
"]",
")",
")",
",",
"'\\\\/'",
")",
";",
"// make it windows proof",
"if",
"(",
"extension_loaded",
"(",
"'iconv'",
")",
")",
"{",
"$",
"filepart",
"=",
"iconv",
"(",
"'UTF-8'",
",",
"'ASCII//TRANSLIT'",
",",
"$",
"filepart",
")",
";",
"}",
"$",
"filepart",
"=",
"strpos",
"(",
"$",
"filepart",
",",
"'/'",
")",
"!==",
"false",
"?",
"implode",
"(",
"'/'",
",",
"array_map",
"(",
"'urlencode'",
",",
"explode",
"(",
"'/'",
",",
"$",
"filepart",
")",
")",
")",
":",
"implode",
"(",
"'\\\\'",
",",
"array_map",
"(",
"'urlencode'",
",",
"explode",
"(",
"'\\\\'",
",",
"$",
"filepart",
")",
")",
")",
";",
"return",
"$",
"filepart",
";",
"}",
",",
"$",
"path",
")",
";",
"// replace any \\ with the directory separator to be compatible with the",
"// current filesystem and allow the next file_exists to do its work",
"$",
"destination",
"=",
"str_replace",
"(",
"array",
"(",
"'/'",
",",
"'\\\\'",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"destination",
")",
";",
"// create directory if it does not exist yet",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"destination",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"destination",
")",
",",
"0777",
",",
"true",
")",
";",
"}",
"return",
"$",
"destination",
";",
"}"
] |
Uses the currently selected node and transformation to assemble the destination path for the file.
The Twig writer accepts the use of a Query to be able to generate output for multiple objects using the same
template.
The given node is the result of such a query, or if no query given the selected element, and the transformation
contains the destination file.
Since it is important to be able to generate a unique name per element can the user provide a template variable
in the name of the file.
Such a template variable always resides between double braces and tries to take the node value of a given
query string.
Example:
An artifact stating `classes/{{name}}.html` will try to find the
node 'name' as a child of the given $node and use that value instead.
@param DescriptorAbstract $node
@param Transformation $transformation
@throws \InvalidArgumentException if no artifact is provided and no routing rule matches.
@throws \UnexpectedValueException if the provided node does not contain anything.
@return string|false returns the destination location or false if generation should be aborted.
|
[
"Uses",
"the",
"currently",
"selected",
"node",
"and",
"transformation",
"to",
"assemble",
"the",
"destination",
"path",
"for",
"the",
"file",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Twig/Writer/Twig.php#L259-L319
|
22,045
|
WScore/Validation
|
src/Filter/Sanitizers.php
|
Sanitizers.filter_sanitize
|
public function filter_sanitize($v, $p)
{
$option = Helper::arrGet($this->sanitizes, $p, $p);
$v->setValue(filter_var($v->getValue(), $option));
if ($p === 'int') {
if ((int)$v->getValue() !== (int)(float)$v->getValue()) {
$v->setValue('');
}
}
}
|
php
|
public function filter_sanitize($v, $p)
{
$option = Helper::arrGet($this->sanitizes, $p, $p);
$v->setValue(filter_var($v->getValue(), $option));
if ($p === 'int') {
if ((int)$v->getValue() !== (int)(float)$v->getValue()) {
$v->setValue('');
}
}
}
|
[
"public",
"function",
"filter_sanitize",
"(",
"$",
"v",
",",
"$",
"p",
")",
"{",
"$",
"option",
"=",
"Helper",
"::",
"arrGet",
"(",
"$",
"this",
"->",
"sanitizes",
",",
"$",
"p",
",",
"$",
"p",
")",
";",
"$",
"v",
"->",
"setValue",
"(",
"filter_var",
"(",
"$",
"v",
"->",
"getValue",
"(",
")",
",",
"$",
"option",
")",
")",
";",
"if",
"(",
"$",
"p",
"===",
"'int'",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"v",
"->",
"getValue",
"(",
")",
"!==",
"(",
"int",
")",
"(",
"float",
")",
"$",
"v",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"v",
"->",
"setValue",
"(",
"''",
")",
";",
"}",
"}",
"}"
] |
sanitize the value using filter_var.
@param ValueTO $v
@param $p
|
[
"sanitize",
"the",
"value",
"using",
"filter_var",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Filter/Sanitizers.php#L49-L58
|
22,046
|
WScore/Validation
|
src/Filter/Sanitizers.php
|
Sanitizers.filter_datetime
|
public function filter_datetime($v, $p)
{
if (is_bool($p) && $p) {
$p = 'Y-m-d H:i:s';
}
$dt = \date_create_from_format($p, $v->getValue());
if (!$dt) {
$v->setValue(null);
$v->setError(__METHOD__, $p);
return;
}
$v->setValue($dt->format($p));
}
|
php
|
public function filter_datetime($v, $p)
{
if (is_bool($p) && $p) {
$p = 'Y-m-d H:i:s';
}
$dt = \date_create_from_format($p, $v->getValue());
if (!$dt) {
$v->setValue(null);
$v->setError(__METHOD__, $p);
return;
}
$v->setValue($dt->format($p));
}
|
[
"public",
"function",
"filter_datetime",
"(",
"$",
"v",
",",
"$",
"p",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"p",
")",
"&&",
"$",
"p",
")",
"{",
"$",
"p",
"=",
"'Y-m-d H:i:s'",
";",
"}",
"$",
"dt",
"=",
"\\",
"date_create_from_format",
"(",
"$",
"p",
",",
"$",
"v",
"->",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"dt",
")",
"{",
"$",
"v",
"->",
"setValue",
"(",
"null",
")",
";",
"$",
"v",
"->",
"setError",
"(",
"__METHOD__",
",",
"$",
"p",
")",
";",
"return",
";",
"}",
"$",
"v",
"->",
"setValue",
"(",
"$",
"dt",
"->",
"format",
"(",
"$",
"p",
")",
")",
";",
"}"
] |
check for valid date-time input string.
@param ValueTO $v
@param bool|string $p
|
[
"check",
"for",
"valid",
"date",
"-",
"time",
"input",
"string",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Filter/Sanitizers.php#L66-L78
|
22,047
|
ttreeagency/Taxonomy
|
Classes/Command/TaxonomyCommandController.php
|
TaxonomyCommandController.showMappingCommand
|
public function showMappingCommand(string $node)
{
foreach ($this->contentDimensionCombinator->getAllAllowedCombinations() as $dimensions) {
$context = $this->createContentContext('live', $dimensions);
$siteNode = $context->getNodeByIdentifier($node);
$taxonomyNodes = (new FlowQuery([$siteNode]))->find('[instanceof Ttree.Taxonomy:Document.Taxonomy]')->get();
$settings = [];
/** @var NodeInterface $taxonomyNode */
foreach ($taxonomyNodes as $taxonomyNode) {
$this->outputLine();
$this->outputLine('Show mapping for <b>%s</b> (%s)', [$taxonomyNode->getLabel(), $taxonomyNode->getContextPath()]);
$settings = $this->managedVocabulary->build($taxonomyNode);
foreach (Arrays::getValueByPath($settings, 'analysis.analyzer') as $analyzerName => $analyzerConfiguration) {
$this->outputLine();
$this->outputLine('+ Analyzer <info>%s</info>', [$analyzerName]);
$this->outputLine(' Tokenizer <info>%s</info>', [$analyzerConfiguration['tokenizer']]);
$this->outputLine(' Filter <info>%s</info>', [\implode(', ', $analyzerConfiguration['filter'])]);
}
foreach (Arrays::getValueByPath($settings, 'analysis.filter') as $filterName => $filterConfiguration) {
$this->outputLine();
$this->outputLine('+ Filter <info>%s</info>', [$analyzerName]);
$this->outputLine(' Type <info>%s</info>', [$filterConfiguration['type']]);
if ($filterConfiguration['type'] === 'synonym') {
$this->outputLine(' Synonyms <info>%d</info>', [count($filterConfiguration['synonyms'])]);
}
}
}
}
}
|
php
|
public function showMappingCommand(string $node)
{
foreach ($this->contentDimensionCombinator->getAllAllowedCombinations() as $dimensions) {
$context = $this->createContentContext('live', $dimensions);
$siteNode = $context->getNodeByIdentifier($node);
$taxonomyNodes = (new FlowQuery([$siteNode]))->find('[instanceof Ttree.Taxonomy:Document.Taxonomy]')->get();
$settings = [];
/** @var NodeInterface $taxonomyNode */
foreach ($taxonomyNodes as $taxonomyNode) {
$this->outputLine();
$this->outputLine('Show mapping for <b>%s</b> (%s)', [$taxonomyNode->getLabel(), $taxonomyNode->getContextPath()]);
$settings = $this->managedVocabulary->build($taxonomyNode);
foreach (Arrays::getValueByPath($settings, 'analysis.analyzer') as $analyzerName => $analyzerConfiguration) {
$this->outputLine();
$this->outputLine('+ Analyzer <info>%s</info>', [$analyzerName]);
$this->outputLine(' Tokenizer <info>%s</info>', [$analyzerConfiguration['tokenizer']]);
$this->outputLine(' Filter <info>%s</info>', [\implode(', ', $analyzerConfiguration['filter'])]);
}
foreach (Arrays::getValueByPath($settings, 'analysis.filter') as $filterName => $filterConfiguration) {
$this->outputLine();
$this->outputLine('+ Filter <info>%s</info>', [$analyzerName]);
$this->outputLine(' Type <info>%s</info>', [$filterConfiguration['type']]);
if ($filterConfiguration['type'] === 'synonym') {
$this->outputLine(' Synonyms <info>%d</info>', [count($filterConfiguration['synonyms'])]);
}
}
}
}
}
|
[
"public",
"function",
"showMappingCommand",
"(",
"string",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"contentDimensionCombinator",
"->",
"getAllAllowedCombinations",
"(",
")",
"as",
"$",
"dimensions",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"createContentContext",
"(",
"'live'",
",",
"$",
"dimensions",
")",
";",
"$",
"siteNode",
"=",
"$",
"context",
"->",
"getNodeByIdentifier",
"(",
"$",
"node",
")",
";",
"$",
"taxonomyNodes",
"=",
"(",
"new",
"FlowQuery",
"(",
"[",
"$",
"siteNode",
"]",
")",
")",
"->",
"find",
"(",
"'[instanceof Ttree.Taxonomy:Document.Taxonomy]'",
")",
"->",
"get",
"(",
")",
";",
"$",
"settings",
"=",
"[",
"]",
";",
"/** @var NodeInterface $taxonomyNode */",
"foreach",
"(",
"$",
"taxonomyNodes",
"as",
"$",
"taxonomyNode",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'Show mapping for <b>%s</b> (%s)'",
",",
"[",
"$",
"taxonomyNode",
"->",
"getLabel",
"(",
")",
",",
"$",
"taxonomyNode",
"->",
"getContextPath",
"(",
")",
"]",
")",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"managedVocabulary",
"->",
"build",
"(",
"$",
"taxonomyNode",
")",
";",
"foreach",
"(",
"Arrays",
"::",
"getValueByPath",
"(",
"$",
"settings",
",",
"'analysis.analyzer'",
")",
"as",
"$",
"analyzerName",
"=>",
"$",
"analyzerConfiguration",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'+ Analyzer <info>%s</info>'",
",",
"[",
"$",
"analyzerName",
"]",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"' Tokenizer <info>%s</info>'",
",",
"[",
"$",
"analyzerConfiguration",
"[",
"'tokenizer'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"' Filter <info>%s</info>'",
",",
"[",
"\\",
"implode",
"(",
"', '",
",",
"$",
"analyzerConfiguration",
"[",
"'filter'",
"]",
")",
"]",
")",
";",
"}",
"foreach",
"(",
"Arrays",
"::",
"getValueByPath",
"(",
"$",
"settings",
",",
"'analysis.filter'",
")",
"as",
"$",
"filterName",
"=>",
"$",
"filterConfiguration",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'+ Filter <info>%s</info>'",
",",
"[",
"$",
"analyzerName",
"]",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"' Type <info>%s</info>'",
",",
"[",
"$",
"filterConfiguration",
"[",
"'type'",
"]",
"]",
")",
";",
"if",
"(",
"$",
"filterConfiguration",
"[",
"'type'",
"]",
"===",
"'synonym'",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"' Synonyms <info>%d</info>'",
",",
"[",
"count",
"(",
"$",
"filterConfiguration",
"[",
"'synonyms'",
"]",
")",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Show ElasticSearch filters and analyzers
|
[
"Show",
"ElasticSearch",
"filters",
"and",
"analyzers"
] |
9e94e2863a722bbdb1dcbdc34afbda1e1e10b4c9
|
https://github.com/ttreeagency/Taxonomy/blob/9e94e2863a722bbdb1dcbdc34afbda1e1e10b4c9/Classes/Command/TaxonomyCommandController.php#L37-L65
|
22,048
|
creolab/resources
|
src/Item.php
|
Item.toArray
|
public function toArray()
{
$this->data = $this->transformer->transformBack($this->data);
return $this->data;
}
|
php
|
public function toArray()
{
$this->data = $this->transformer->transformBack($this->data);
return $this->data;
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"transformer",
"->",
"transformBack",
"(",
"$",
"this",
"->",
"data",
")",
";",
"return",
"$",
"this",
"->",
"data",
";",
"}"
] |
Return array representation of item
@return array
|
[
"Return",
"array",
"representation",
"of",
"item"
] |
6e1bdd266aa373f6dafd2408b230f7d2fa05a637
|
https://github.com/creolab/resources/blob/6e1bdd266aa373f6dafd2408b230f7d2fa05a637/src/Item.php#L68-L73
|
22,049
|
ekuiter/feature-php
|
FeaturePhp/Helper/XmlParser.php
|
XmlParser.validate
|
public function validate($schemaFile) {
if (!$this->xmlString)
throw new XmlParserException("attempting to validate before parsing");
if (!extension_loaded("DOM")) {
trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE);
return $this;
}
libxml_use_internal_errors(true);
$document = new \DOMDocument();
$document->loadXML($this->xmlString);
if (!$document->schemaValidate($schemaFile)) {
$msg = "The following XML errors occurred while validating:";
foreach (libxml_get_errors() as $error)
$msg .= "\n" . $error->message;
throw new XmlParserException($msg);
}
return $this;
}
|
php
|
public function validate($schemaFile) {
if (!$this->xmlString)
throw new XmlParserException("attempting to validate before parsing");
if (!extension_loaded("DOM")) {
trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE);
return $this;
}
libxml_use_internal_errors(true);
$document = new \DOMDocument();
$document->loadXML($this->xmlString);
if (!$document->schemaValidate($schemaFile)) {
$msg = "The following XML errors occurred while validating:";
foreach (libxml_get_errors() as $error)
$msg .= "\n" . $error->message;
throw new XmlParserException($msg);
}
return $this;
}
|
[
"public",
"function",
"validate",
"(",
"$",
"schemaFile",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"xmlString",
")",
"throw",
"new",
"XmlParserException",
"(",
"\"attempting to validate before parsing\"",
")",
";",
"if",
"(",
"!",
"extension_loaded",
"(",
"\"DOM\"",
")",
")",
"{",
"trigger_error",
"(",
"\"DOM extension not loaded, will not validate XML\"",
",",
"E_USER_NOTICE",
")",
";",
"return",
"$",
"this",
";",
"}",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"document",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"$",
"document",
"->",
"loadXML",
"(",
"$",
"this",
"->",
"xmlString",
")",
";",
"if",
"(",
"!",
"$",
"document",
"->",
"schemaValidate",
"(",
"$",
"schemaFile",
")",
")",
"{",
"$",
"msg",
"=",
"\"The following XML errors occurred while validating:\"",
";",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"$",
"msg",
".=",
"\"\\n\"",
".",
"$",
"error",
"->",
"message",
";",
"throw",
"new",
"XmlParserException",
"(",
"$",
"msg",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Validates XML using a schema.
@param string $schemaFile
@return XmlParser
|
[
"Validates",
"XML",
"using",
"a",
"schema",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/XmlParser.php#L86-L107
|
22,050
|
ekuiter/feature-php
|
FeaturePhp/Helper/XmlParser.php
|
XmlParser.get
|
public static function get($node, $tagName, $count = 1) {
$node = $node->{$tagName};
if ($node->count() !== $count)
throw new XmlParserException("xml does not have exactly $count $tagName's");
return $node[0];
}
|
php
|
public static function get($node, $tagName, $count = 1) {
$node = $node->{$tagName};
if ($node->count() !== $count)
throw new XmlParserException("xml does not have exactly $count $tagName's");
return $node[0];
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"node",
",",
"$",
"tagName",
",",
"$",
"count",
"=",
"1",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"{",
"$",
"tagName",
"}",
";",
"if",
"(",
"$",
"node",
"->",
"count",
"(",
")",
"!==",
"$",
"count",
")",
"throw",
"new",
"XmlParserException",
"(",
"\"xml does not have exactly $count $tagName's\"",
")",
";",
"return",
"$",
"node",
"[",
"0",
"]",
";",
"}"
] |
Returns a child node for a tag name from an XML node.
@param \SimpleXMLElement $node
@param string $tagName
@param int $count how many child nodes for the tag name are allowed
@return \SimpleXMLElement
|
[
"Returns",
"a",
"child",
"node",
"for",
"a",
"tag",
"name",
"from",
"an",
"XML",
"node",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/XmlParser.php#L116-L121
|
22,051
|
leoshtika/database
|
src/Mysql.php
|
Mysql.connect
|
public static function connect($mysqlConfig)
{
$dbConfig = array(
'dsn' => 'mysql:dbname=' . $mysqlConfig['dbname'] . ';host=' . $mysqlConfig['host'],
'user' => $mysqlConfig['user'],
'pass' => $mysqlConfig['pass'],
'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"),
);
return parent::connect($dbConfig);
}
|
php
|
public static function connect($mysqlConfig)
{
$dbConfig = array(
'dsn' => 'mysql:dbname=' . $mysqlConfig['dbname'] . ';host=' . $mysqlConfig['host'],
'user' => $mysqlConfig['user'],
'pass' => $mysqlConfig['pass'],
'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"),
);
return parent::connect($dbConfig);
}
|
[
"public",
"static",
"function",
"connect",
"(",
"$",
"mysqlConfig",
")",
"{",
"$",
"dbConfig",
"=",
"array",
"(",
"'dsn'",
"=>",
"'mysql:dbname='",
".",
"$",
"mysqlConfig",
"[",
"'dbname'",
"]",
".",
"';host='",
".",
"$",
"mysqlConfig",
"[",
"'host'",
"]",
",",
"'user'",
"=>",
"$",
"mysqlConfig",
"[",
"'user'",
"]",
",",
"'pass'",
"=>",
"$",
"mysqlConfig",
"[",
"'pass'",
"]",
",",
"'options'",
"=>",
"array",
"(",
"PDO",
"::",
"MYSQL_ATTR_INIT_COMMAND",
"=>",
"\"SET NAMES utf8\"",
")",
",",
")",
";",
"return",
"parent",
"::",
"connect",
"(",
"$",
"dbConfig",
")",
";",
"}"
] |
Returns a PDO instance
@param array $mysqlConfig
@return PDO
|
[
"Returns",
"a",
"PDO",
"instance"
] |
a8a82cb6b16eb97caf8b583506c0e08ab944f761
|
https://github.com/leoshtika/database/blob/a8a82cb6b16eb97caf8b583506c0e08ab944f761/src/Mysql.php#L27-L37
|
22,052
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
|
ezcDbSchemaPersistentWriter.writeField
|
private function writeField( $file, $fieldName, $field, $isPrimary )
{
fwrite( $file, "\n" );
if ( $isPrimary )
{
fwrite( $file, "\$def->idProperty = new ezcPersistentObjectIdProperty();\n" );
fwrite( $file, "\$def->idProperty->columnName = '$fieldName';\n" );
fwrite( $file, "\$def->idProperty->propertyName = '$fieldName';\n" );
if ( $field->autoIncrement )
{
fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\n" );
}
else
{
fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\n" );
fwrite( $file, "\$def->idProperty->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;\n" );
}
}
else
{
fwrite( $file, "\$def->properties['$fieldName'] = new ezcPersistentObjectProperty();\n" );
fwrite( $file, "\$def->properties['$fieldName']->columnName = '$fieldName';\n" );
fwrite( $file, "\$def->properties['$fieldName']->propertyName = '$fieldName';\n" );
fwrite( $file, "\$def->properties['$fieldName']->propertyType = {$this->translateType($field->type)};\n" );
}
fwrite( $file, "\n" );
}
|
php
|
private function writeField( $file, $fieldName, $field, $isPrimary )
{
fwrite( $file, "\n" );
if ( $isPrimary )
{
fwrite( $file, "\$def->idProperty = new ezcPersistentObjectIdProperty();\n" );
fwrite( $file, "\$def->idProperty->columnName = '$fieldName';\n" );
fwrite( $file, "\$def->idProperty->propertyName = '$fieldName';\n" );
if ( $field->autoIncrement )
{
fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\n" );
}
else
{
fwrite( $file, "\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\n" );
fwrite( $file, "\$def->idProperty->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;\n" );
}
}
else
{
fwrite( $file, "\$def->properties['$fieldName'] = new ezcPersistentObjectProperty();\n" );
fwrite( $file, "\$def->properties['$fieldName']->columnName = '$fieldName';\n" );
fwrite( $file, "\$def->properties['$fieldName']->propertyName = '$fieldName';\n" );
fwrite( $file, "\$def->properties['$fieldName']->propertyType = {$this->translateType($field->type)};\n" );
}
fwrite( $file, "\n" );
}
|
[
"private",
"function",
"writeField",
"(",
"$",
"file",
",",
"$",
"fieldName",
",",
"$",
"field",
",",
"$",
"isPrimary",
")",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"isPrimary",
")",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->idProperty = new ezcPersistentObjectIdProperty();\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->idProperty->columnName = '$fieldName';\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->idProperty->propertyName = '$fieldName';\\n\"",
")",
";",
"if",
"(",
"$",
"field",
"->",
"autoIncrement",
")",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentSequenceGenerator' );\\n\"",
")",
";",
"}",
"else",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentManualGenerator' );\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->idProperty->propertyType = ezcPersistentObjectProperty::PHP_TYPE_STRING;\\n\"",
")",
";",
"}",
"}",
"else",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->properties['$fieldName'] = new ezcPersistentObjectProperty();\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->properties['$fieldName']->columnName = '$fieldName';\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->properties['$fieldName']->propertyName = '$fieldName';\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->properties['$fieldName']->propertyType = {$this->translateType($field->type)};\\n\"",
")",
";",
"}",
"fwrite",
"(",
"$",
"file",
",",
"\"\\n\"",
")",
";",
"}"
] |
Write a field of the schema to the PersistentObject definition.
This method writes a database field to the PersistentObject definition
file.
@param resource(file) $file The file to write to.
@param string $fieldName The name of the field.
@param ezcDbSchemaField $field The field object.
@param bool $isPrimary Whether the field is the primary key.
|
[
"Write",
"a",
"field",
"of",
"the",
"schema",
"to",
"the",
"PersistentObject",
"definition",
".",
"This",
"method",
"writes",
"a",
"database",
"field",
"to",
"the",
"PersistentObject",
"definition",
"file",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L102-L128
|
22,053
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
|
ezcDbSchemaPersistentWriter.writeTable
|
private function writeTable( $dir, $tableName, ezcDbSchemaTable $table )
{
$file = $this->openFile( $dir, $tableName );
fwrite( $file, "\$def = new ezcPersistentObjectDefinition();\n" );
fwrite( $file, "\$def->table = '$tableName';\n" );
fwrite( $file, "\$def->class = '{$this->prefix}$tableName';\n" );
$primaries = $this->determinePrimaries( $table->indexes );
// fields
foreach ( $table->fields as $fieldName => $field )
{
$this->writeField( $file, $fieldName, $field, isset( $primaries[$fieldName] ) );
}
$this->closeFile( $file );
}
|
php
|
private function writeTable( $dir, $tableName, ezcDbSchemaTable $table )
{
$file = $this->openFile( $dir, $tableName );
fwrite( $file, "\$def = new ezcPersistentObjectDefinition();\n" );
fwrite( $file, "\$def->table = '$tableName';\n" );
fwrite( $file, "\$def->class = '{$this->prefix}$tableName';\n" );
$primaries = $this->determinePrimaries( $table->indexes );
// fields
foreach ( $table->fields as $fieldName => $field )
{
$this->writeField( $file, $fieldName, $field, isset( $primaries[$fieldName] ) );
}
$this->closeFile( $file );
}
|
[
"private",
"function",
"writeTable",
"(",
"$",
"dir",
",",
"$",
"tableName",
",",
"ezcDbSchemaTable",
"$",
"table",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"openFile",
"(",
"$",
"dir",
",",
"$",
"tableName",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def = new ezcPersistentObjectDefinition();\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->table = '$tableName';\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\$def->class = '{$this->prefix}$tableName';\\n\"",
")",
";",
"$",
"primaries",
"=",
"$",
"this",
"->",
"determinePrimaries",
"(",
"$",
"table",
"->",
"indexes",
")",
";",
"// fields ",
"foreach",
"(",
"$",
"table",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"writeField",
"(",
"$",
"file",
",",
"$",
"fieldName",
",",
"$",
"field",
",",
"isset",
"(",
"$",
"primaries",
"[",
"$",
"fieldName",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"closeFile",
"(",
"$",
"file",
")",
";",
"}"
] |
Writes the PersistentObject defintion for a table.
This method writes the PersistentObject definition for a single database
table. It creates a new file in the given directory, named in the format
<table_name>.php, writes the start of the definition to it and calls the
{@link ezcDbschemaPersistentWriter::writeField()} method for each of the
database fields.
The defition files always contain an object instance $def, which is
returned in the end.
@param string $dir The directory to write the defititions to.
@param string $tableName Name of the database table.
@param ezcDbSchemaTable $table The table definition.
|
[
"Writes",
"the",
"PersistentObject",
"defintion",
"for",
"a",
"table",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L181-L197
|
22,054
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
|
ezcDbSchemaPersistentWriter.closeFile
|
private function closeFile( $file )
{
fwrite( $file, "return \$def;\n" );
fwrite( $file, "\n" );
fwrite( $file, "?>\n" );
fclose( $file );
}
|
php
|
private function closeFile( $file )
{
fwrite( $file, "return \$def;\n" );
fwrite( $file, "\n" );
fwrite( $file, "?>\n" );
fclose( $file );
}
|
[
"private",
"function",
"closeFile",
"(",
"$",
"file",
")",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\"return \\$def;\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"\\n\"",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"\"?>\\n\"",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"}"
] |
Close a file where a PersistentObject definition has been written to.
This method closes a file after writing a PersistentObject definition to
it and writes the PHP closing tag to it.
@param resource(file) $file The file resource to close.
@return void
|
[
"Close",
"a",
"file",
"where",
"a",
"PersistentObject",
"definition",
"has",
"been",
"written",
"to",
".",
"This",
"method",
"closes",
"a",
"file",
"after",
"writing",
"a",
"PersistentObject",
"definition",
"to",
"it",
"and",
"writes",
"the",
"PHP",
"closing",
"tag",
"to",
"it",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L240-L246
|
22,055
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php
|
ezcDbSchemaPersistentWriter.determinePrimaries
|
private function determinePrimaries( $indexes )
{
$primaries = array();
foreach ( $indexes as $index )
{
if ( $index->primary )
{
foreach ( $index->indexFields as $field => $definiton )
{
$primaries[$field] = true;
}
}
}
return $primaries;
}
|
php
|
private function determinePrimaries( $indexes )
{
$primaries = array();
foreach ( $indexes as $index )
{
if ( $index->primary )
{
foreach ( $index->indexFields as $field => $definiton )
{
$primaries[$field] = true;
}
}
}
return $primaries;
}
|
[
"private",
"function",
"determinePrimaries",
"(",
"$",
"indexes",
")",
"{",
"$",
"primaries",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
"->",
"primary",
")",
"{",
"foreach",
"(",
"$",
"index",
"->",
"indexFields",
"as",
"$",
"field",
"=>",
"$",
"definiton",
")",
"{",
"$",
"primaries",
"[",
"$",
"field",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"$",
"primaries",
";",
"}"
] |
Extract primary keys from an index definition.
This method extracts the names of all primary keys from the index
defintions of a table.
@param array(string=>ezcDbSchemaIndex) $indexes Indices.
@return array(string=>bool) The primary keys.
|
[
"Extract",
"primary",
"keys",
"from",
"an",
"index",
"definition",
".",
"This",
"method",
"extracts",
"the",
"names",
"of",
"all",
"primary",
"keys",
"from",
"the",
"index",
"defintions",
"of",
"a",
"table",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/persistent/writer.php#L256-L270
|
22,056
|
tttptd/laravel-responder
|
src/Console/MakeTransformer.php
|
MakeTransformer.generateTransformer
|
protected function generateTransformer()
{
$name = (string) $this->argument('name');
$path = $this->laravel->basePath() . '/app/Transformers/' . $name . '.php';
if ($this->files->exists($path)) {
return $this->error($name . ' already exists!');
}
$this->makeDirectory($path);
$stubPath = $this->option('pivot') ? 'resources/stubs/transformer.pivot.stub' : 'resources/stubs/transformer.stub';
$stub = $this->files->get(__DIR__ . '/../../' . $stubPath);
$this->files->put($path, $this->makeTransformer($name, $stub));
$this->info('Transformer created successfully.');
}
|
php
|
protected function generateTransformer()
{
$name = (string) $this->argument('name');
$path = $this->laravel->basePath() . '/app/Transformers/' . $name . '.php';
if ($this->files->exists($path)) {
return $this->error($name . ' already exists!');
}
$this->makeDirectory($path);
$stubPath = $this->option('pivot') ? 'resources/stubs/transformer.pivot.stub' : 'resources/stubs/transformer.stub';
$stub = $this->files->get(__DIR__ . '/../../' . $stubPath);
$this->files->put($path, $this->makeTransformer($name, $stub));
$this->info('Transformer created successfully.');
}
|
[
"protected",
"function",
"generateTransformer",
"(",
")",
"{",
"$",
"name",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"laravel",
"->",
"basePath",
"(",
")",
".",
"'/app/Transformers/'",
".",
"$",
"name",
".",
"'.php'",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"$",
"name",
".",
"' already exists!'",
")",
";",
"}",
"$",
"this",
"->",
"makeDirectory",
"(",
"$",
"path",
")",
";",
"$",
"stubPath",
"=",
"$",
"this",
"->",
"option",
"(",
"'pivot'",
")",
"?",
"'resources/stubs/transformer.pivot.stub'",
":",
"'resources/stubs/transformer.stub'",
";",
"$",
"stub",
"=",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../../'",
".",
"$",
"stubPath",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"makeTransformer",
"(",
"$",
"name",
",",
"$",
"stub",
")",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Transformer created successfully.'",
")",
";",
"}"
] |
Generate the transformer class.
@return void
|
[
"Generate",
"the",
"transformer",
"class",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L68-L85
|
22,057
|
tttptd/laravel-responder
|
src/Console/MakeTransformer.php
|
MakeTransformer.makeTransformer
|
protected function makeTransformer(string $name, string $stub):string
{
$stub = $this->replaceNamespace($stub);
$stub = $this->replaceClass($stub, $name);
$stub = $this->replaceModel($stub, $name);
return $stub;
}
|
php
|
protected function makeTransformer(string $name, string $stub):string
{
$stub = $this->replaceNamespace($stub);
$stub = $this->replaceClass($stub, $name);
$stub = $this->replaceModel($stub, $name);
return $stub;
}
|
[
"protected",
"function",
"makeTransformer",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"stub",
")",
":",
"string",
"{",
"$",
"stub",
"=",
"$",
"this",
"->",
"replaceNamespace",
"(",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"$",
"this",
"->",
"replaceClass",
"(",
"$",
"stub",
",",
"$",
"name",
")",
";",
"$",
"stub",
"=",
"$",
"this",
"->",
"replaceModel",
"(",
"$",
"stub",
",",
"$",
"name",
")",
";",
"return",
"$",
"stub",
";",
"}"
] |
Build the transformer class using the given name and stub.
@param string $name
@param string $stub
@return string
|
[
"Build",
"the",
"transformer",
"class",
"using",
"the",
"given",
"name",
"and",
"stub",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L107-L114
|
22,058
|
tttptd/laravel-responder
|
src/Console/MakeTransformer.php
|
MakeTransformer.getModelNamespace
|
protected function getModelNamespace(string $name):string
{
if ($this->option('model')) {
return $this->option('model');
}
return 'App\\' . str_replace('Transformer', '', $name);
}
|
php
|
protected function getModelNamespace(string $name):string
{
if ($this->option('model')) {
return $this->option('model');
}
return 'App\\' . str_replace('Transformer', '', $name);
}
|
[
"protected",
"function",
"getModelNamespace",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
";",
"}",
"return",
"'App\\\\'",
".",
"str_replace",
"(",
"'Transformer'",
",",
"''",
",",
"$",
"name",
")",
";",
"}"
] |
Get the full class path for the model.
@param string $name
@return string
|
[
"Get",
"the",
"full",
"class",
"path",
"for",
"the",
"model",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Console/MakeTransformer.php#L174-L181
|
22,059
|
NuclearCMS/Hierarchy
|
src/Support/LocaleManager.php
|
LocaleManager.setAppLocale
|
public function setAppLocale($locale = null, $session = true)
{
$locale = $locale ?: $this->session->get('_locale', null);
if ($locale)
{
$this->app->setLocale($locale);
if ($session)
{
$this->session->put('_locale', $locale);
}
$this->setTimeLocale($locale);
}
}
|
php
|
public function setAppLocale($locale = null, $session = true)
{
$locale = $locale ?: $this->session->get('_locale', null);
if ($locale)
{
$this->app->setLocale($locale);
if ($session)
{
$this->session->put('_locale', $locale);
}
$this->setTimeLocale($locale);
}
}
|
[
"public",
"function",
"setAppLocale",
"(",
"$",
"locale",
"=",
"null",
",",
"$",
"session",
"=",
"true",
")",
"{",
"$",
"locale",
"=",
"$",
"locale",
"?",
":",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'_locale'",
",",
"null",
")",
";",
"if",
"(",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"if",
"(",
"$",
"session",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"put",
"(",
"'_locale'",
",",
"$",
"locale",
")",
";",
"}",
"$",
"this",
"->",
"setTimeLocale",
"(",
"$",
"locale",
")",
";",
"}",
"}"
] |
Sets the app locale
@param string $locale
@param bool $session
@return void
|
[
"Sets",
"the",
"app",
"locale"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/LocaleManager.php#L43-L58
|
22,060
|
NuclearCMS/Hierarchy
|
src/Support/LocaleManager.php
|
LocaleManager.setTimeLocale
|
public function setTimeLocale($locale = null)
{
$locale = $locale ?: $this->session->get('_locale', $this->app->getLocale());
setlocale(LC_TIME, $this->config->get('translatable.full_locales.' . $locale, null));
Carbon::setLocale($locale);
}
|
php
|
public function setTimeLocale($locale = null)
{
$locale = $locale ?: $this->session->get('_locale', $this->app->getLocale());
setlocale(LC_TIME, $this->config->get('translatable.full_locales.' . $locale, null));
Carbon::setLocale($locale);
}
|
[
"public",
"function",
"setTimeLocale",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"$",
"locale",
"?",
":",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'_locale'",
",",
"$",
"this",
"->",
"app",
"->",
"getLocale",
"(",
")",
")",
";",
"setlocale",
"(",
"LC_TIME",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'translatable.full_locales.'",
".",
"$",
"locale",
",",
"null",
")",
")",
";",
"Carbon",
"::",
"setLocale",
"(",
"$",
"locale",
")",
";",
"}"
] |
Sets the time locale
@param string $locale
@return void
|
[
"Sets",
"the",
"time",
"locale"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/LocaleManager.php#L66-L73
|
22,061
|
surebert/surebert-framework
|
src/sb/Files/ForceDownload.php
|
ForceDownload.send
|
public static function send($file, $display_file_name = '', $seekat=0)
{
$display_file_name = $display_file_name ? $display_file_name : basename($file);
$display_file_name = str_replace(" ", "_", $display_file_name);
header("HTTP/1.1 200 OK");
header("Status: 200 OK");
header("Pragma: private");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Transfer-Encoding: Binary");
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename="'.$display_file_name.'"');
while (ob_get_level() > 0) {
ob_end_flush();
}
\sb\Files::readChunked($file, $seekat);
}
|
php
|
public static function send($file, $display_file_name = '', $seekat=0)
{
$display_file_name = $display_file_name ? $display_file_name : basename($file);
$display_file_name = str_replace(" ", "_", $display_file_name);
header("HTTP/1.1 200 OK");
header("Status: 200 OK");
header("Pragma: private");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Transfer-Encoding: Binary");
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename="'.$display_file_name.'"');
while (ob_get_level() > 0) {
ob_end_flush();
}
\sb\Files::readChunked($file, $seekat);
}
|
[
"public",
"static",
"function",
"send",
"(",
"$",
"file",
",",
"$",
"display_file_name",
"=",
"''",
",",
"$",
"seekat",
"=",
"0",
")",
"{",
"$",
"display_file_name",
"=",
"$",
"display_file_name",
"?",
"$",
"display_file_name",
":",
"basename",
"(",
"$",
"file",
")",
";",
"$",
"display_file_name",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"$",
"display_file_name",
")",
";",
"header",
"(",
"\"HTTP/1.1 200 OK\"",
")",
";",
"header",
"(",
"\"Status: 200 OK\"",
")",
";",
"header",
"(",
"\"Pragma: private\"",
")",
";",
"header",
"(",
"\"Expires: 0\"",
")",
";",
"header",
"(",
"\"Cache-Control: must-revalidate, post-check=0, pre-check=0\"",
")",
";",
"header",
"(",
"\"Content-Transfer-Encoding: Binary\"",
")",
";",
"header",
"(",
"'Content-Type: application/force-download'",
")",
";",
"header",
"(",
"'Content-disposition: attachment; filename=\"'",
".",
"$",
"display_file_name",
".",
"'\"'",
")",
";",
"while",
"(",
"ob_get_level",
"(",
")",
">",
"0",
")",
"{",
"ob_end_flush",
"(",
")",
";",
"}",
"\\",
"sb",
"\\",
"Files",
"::",
"readChunked",
"(",
"$",
"file",
",",
"$",
"seekat",
")",
";",
"}"
] |
Send headers and begins force-download
@param string $file The path to the file to force download
@param string $display_file_name The filename to give to the
@param int $seekat Where to start in file stream
force download if different than the basename of the file arg
|
[
"Send",
"headers",
"and",
"begins",
"force",
"-",
"download"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Files/ForceDownload.php#L23-L40
|
22,062
|
surebert/surebert-framework
|
src/sb/Files/ForceDownload.php
|
ForceDownload.fileToZip
|
public static function fileToZip($path)
{
if (is_file($path) || is_dir($path)) {
$zip = new \ZipArchive;
$zip_file = ROOT . '/private/cache/zip/' . md5(microtime(true));
if (!is_dir(dirname($zip_file))) {
mkdir(dirname($zip_file), 0775, true);
}
if ($zip->open($zip_file, \ZipArchive::CREATE) === true) {
if (is_dir($path)) {
$iterator = new \DirectoryIterator($path);
foreach ($iterator as $file) {
if ($file->isFile()) {
$bn = $file->getBasename();
$zip->addFile($file->getPath() . '/' . $bn, $bn);
}
}
} else {
$zip->addFile($path, basename($path));
}
if ($zip->close()) {
self::send($zip_file, str_replace("/", "_", basename($path)) . '.zip');
unlink($zip_file);
}
} else {
throw(new \Exception('failed to create zip file'));
}
} else {
throw(new \Exception('No data found!'));
}
}
|
php
|
public static function fileToZip($path)
{
if (is_file($path) || is_dir($path)) {
$zip = new \ZipArchive;
$zip_file = ROOT . '/private/cache/zip/' . md5(microtime(true));
if (!is_dir(dirname($zip_file))) {
mkdir(dirname($zip_file), 0775, true);
}
if ($zip->open($zip_file, \ZipArchive::CREATE) === true) {
if (is_dir($path)) {
$iterator = new \DirectoryIterator($path);
foreach ($iterator as $file) {
if ($file->isFile()) {
$bn = $file->getBasename();
$zip->addFile($file->getPath() . '/' . $bn, $bn);
}
}
} else {
$zip->addFile($path, basename($path));
}
if ($zip->close()) {
self::send($zip_file, str_replace("/", "_", basename($path)) . '.zip');
unlink($zip_file);
}
} else {
throw(new \Exception('failed to create zip file'));
}
} else {
throw(new \Exception('No data found!'));
}
}
|
[
"public",
"static",
"function",
"fileToZip",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
"||",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
";",
"$",
"zip_file",
"=",
"ROOT",
".",
"'/private/cache/zip/'",
".",
"md5",
"(",
"microtime",
"(",
"true",
")",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"zip_file",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"zip_file",
")",
",",
"0775",
",",
"true",
")",
";",
"}",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zip_file",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
")",
"===",
"true",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"$",
"bn",
"=",
"$",
"file",
"->",
"getBasename",
"(",
")",
";",
"$",
"zip",
"->",
"addFile",
"(",
"$",
"file",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"bn",
",",
"$",
"bn",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"zip",
"->",
"addFile",
"(",
"$",
"path",
",",
"basename",
"(",
"$",
"path",
")",
")",
";",
"}",
"if",
"(",
"$",
"zip",
"->",
"close",
"(",
")",
")",
"{",
"self",
"::",
"send",
"(",
"$",
"zip_file",
",",
"str_replace",
"(",
"\"/\"",
",",
"\"_\"",
",",
"basename",
"(",
"$",
"path",
")",
")",
".",
"'.zip'",
")",
";",
"unlink",
"(",
"$",
"zip_file",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"'failed to create zip file'",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"'No data found!'",
")",
")",
";",
"}",
"}"
] |
Converts a file or directory into a zip file for consumption by the browser
@param string $path The path to the file or directory
@return string
|
[
"Converts",
"a",
"file",
"or",
"directory",
"into",
"a",
"zip",
"file",
"for",
"consumption",
"by",
"the",
"browser"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Files/ForceDownload.php#L47-L80
|
22,063
|
david-mk/mail-map
|
src/MailMap/Connection.php
|
Connection.search
|
public function search($search = '', $criteria = SORTDATE, $opt = SE_UID, $dir = 1)
{
if ('' === ($search = trim($search))) {
$search = null;
}
return imap_sort($this->stream, $criteria, $dir, $opt, $search);
}
|
php
|
public function search($search = '', $criteria = SORTDATE, $opt = SE_UID, $dir = 1)
{
if ('' === ($search = trim($search))) {
$search = null;
}
return imap_sort($this->stream, $criteria, $dir, $opt, $search);
}
|
[
"public",
"function",
"search",
"(",
"$",
"search",
"=",
"''",
",",
"$",
"criteria",
"=",
"SORTDATE",
",",
"$",
"opt",
"=",
"SE_UID",
",",
"$",
"dir",
"=",
"1",
")",
"{",
"if",
"(",
"''",
"===",
"(",
"$",
"search",
"=",
"trim",
"(",
"$",
"search",
")",
")",
")",
"{",
"$",
"search",
"=",
"null",
";",
"}",
"return",
"imap_sort",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"criteria",
",",
"$",
"dir",
",",
"$",
"opt",
",",
"$",
"search",
")",
";",
"}"
] |
Search mailbox for emails
@param string $search Search string as specified in http://php.net/manual/en/function.imap-search.php
@param int $criteria Sort flag from http://php.net/manual/en/function.imap-sort.php
@param int $opt Options flags from http://php.net/manual/en/function.imap-sort.php
@param int $dir Reverse option from http://php.net/manual/en/function.imap-sort.php
@return array List of matched uids
|
[
"Search",
"mailbox",
"for",
"emails"
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Connection.php#L45-L52
|
22,064
|
glynnforrest/blockade
|
src/Blockade/Exception/BlockadeException.php
|
BlockadeException.from
|
public static function from(DriverInterface $driver, $message = '', $code = 0, \Exception $previous = null)
{
//make sure that empty arguments don't get passed to exceptions as
//they have default messages and codes.
$self = $message ? ($code ? new static($message, $code, $previous) : new static($message)) : new static();
$self->setDriver($driver);
return $self;
}
|
php
|
public static function from(DriverInterface $driver, $message = '', $code = 0, \Exception $previous = null)
{
//make sure that empty arguments don't get passed to exceptions as
//they have default messages and codes.
$self = $message ? ($code ? new static($message, $code, $previous) : new static($message)) : new static();
$self->setDriver($driver);
return $self;
}
|
[
"public",
"static",
"function",
"from",
"(",
"DriverInterface",
"$",
"driver",
",",
"$",
"message",
"=",
"''",
",",
"$",
"code",
"=",
"0",
",",
"\\",
"Exception",
"$",
"previous",
"=",
"null",
")",
"{",
"//make sure that empty arguments don't get passed to exceptions as",
"//they have default messages and codes.",
"$",
"self",
"=",
"$",
"message",
"?",
"(",
"$",
"code",
"?",
"new",
"static",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"previous",
")",
":",
"new",
"static",
"(",
"$",
"message",
")",
")",
":",
"new",
"static",
"(",
")",
";",
"$",
"self",
"->",
"setDriver",
"(",
"$",
"driver",
")",
";",
"return",
"$",
"self",
";",
"}"
] |
Factory method to set the driver that created this exception.
@param DriverInterface $driver The driver
|
[
"Factory",
"method",
"to",
"set",
"the",
"driver",
"that",
"created",
"this",
"exception",
"."
] |
5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b
|
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Exception/BlockadeException.php#L21-L30
|
22,065
|
songshenzong/log
|
src/DebugBar.php
|
DebugBar.initStackSession
|
protected function initStackSession()
{
$http = $this->getHttpDriver();
if (!$http->isSessionStarted()) {
throw new DebugBarException('Session must be started before using stack data in the songshenzong');
}
if (!$http->hasSessionValue($this->stackSessionNamespace)) {
$http->setSessionValue($this->stackSessionNamespace, []);
}
return $http;
}
|
php
|
protected function initStackSession()
{
$http = $this->getHttpDriver();
if (!$http->isSessionStarted()) {
throw new DebugBarException('Session must be started before using stack data in the songshenzong');
}
if (!$http->hasSessionValue($this->stackSessionNamespace)) {
$http->setSessionValue($this->stackSessionNamespace, []);
}
return $http;
}
|
[
"protected",
"function",
"initStackSession",
"(",
")",
"{",
"$",
"http",
"=",
"$",
"this",
"->",
"getHttpDriver",
"(",
")",
";",
"if",
"(",
"!",
"$",
"http",
"->",
"isSessionStarted",
"(",
")",
")",
"{",
"throw",
"new",
"DebugBarException",
"(",
"'Session must be started before using stack data in the songshenzong'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"http",
"->",
"hasSessionValue",
"(",
"$",
"this",
"->",
"stackSessionNamespace",
")",
")",
"{",
"$",
"http",
"->",
"setSessionValue",
"(",
"$",
"this",
"->",
"stackSessionNamespace",
",",
"[",
"]",
")",
";",
"}",
"return",
"$",
"http",
";",
"}"
] |
Initializes the session for stacked data
@return HttpDriverInterface
@throws DebugBarException
|
[
"Initializes",
"the",
"session",
"for",
"stacked",
"data"
] |
b1e01f7994da47737866eabf82367490eab17c46
|
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DebugBar.php#L252-L264
|
22,066
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/LegacyNamespaceConverter/ServiceProvider.php
|
ServiceProvider.addNamespaceFilter
|
private function addNamespaceFilter(ProjectDescriptorBuilder $builder, Filter $filterManager)
{
$filter = new LegacyNamespaceFilter($builder);
// parse parameters
foreach ($this->plugin->getParameters() as $param) {
if ($param->getKey() == 'NamespacePrefix') {
$filter->setNamespacePrefix($param->getValue());
}
}
$filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\FileDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\ClassDescriptor', $filter);
}
|
php
|
private function addNamespaceFilter(ProjectDescriptorBuilder $builder, Filter $filterManager)
{
$filter = new LegacyNamespaceFilter($builder);
// parse parameters
foreach ($this->plugin->getParameters() as $param) {
if ($param->getKey() == 'NamespacePrefix') {
$filter->setNamespacePrefix($param->getValue());
}
}
$filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\FileDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\ClassDescriptor', $filter);
}
|
[
"private",
"function",
"addNamespaceFilter",
"(",
"ProjectDescriptorBuilder",
"$",
"builder",
",",
"Filter",
"$",
"filterManager",
")",
"{",
"$",
"filter",
"=",
"new",
"LegacyNamespaceFilter",
"(",
"$",
"builder",
")",
";",
"// parse parameters",
"foreach",
"(",
"$",
"this",
"->",
"plugin",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"param",
"->",
"getKey",
"(",
")",
"==",
"'NamespacePrefix'",
")",
"{",
"$",
"filter",
"->",
"setNamespacePrefix",
"(",
"$",
"param",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\ConstantDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\FunctionDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\InterfaceDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\TraitDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\PropertyDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\FileDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\ClassDescriptor'",
",",
"$",
"filter",
")",
";",
"}"
] |
Attaches the filter responsible for the conversion to all structural elements.
@param ProjectDescriptorBuilder $builder
@param Filter $filterManager
@return void
|
[
"Attaches",
"the",
"filter",
"responsible",
"for",
"the",
"conversion",
"to",
"all",
"structural",
"elements",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/LegacyNamespaceConverter/ServiceProvider.php#L67-L85
|
22,067
|
hametuha/wpametu
|
src/WPametu/Http/PostRedirectGet.php
|
PostRedirectGet.writeSession
|
private function writeSession($message, $from = '', $is_error = false){
if( session_id() ){
$key = $is_error ? $this->error_key : $this->message_key;
// Initialize
if( !isset($_SESSION[$key]) || !is_array($_SESSION[$key]) ){
$_SESSION[$key] = [];
}
// Add message
$_SESSION[$key][] = ( empty($from) ? '' : sprintf('<strong>[%s]</strong> ', $from) ).$message;
}
}
|
php
|
private function writeSession($message, $from = '', $is_error = false){
if( session_id() ){
$key = $is_error ? $this->error_key : $this->message_key;
// Initialize
if( !isset($_SESSION[$key]) || !is_array($_SESSION[$key]) ){
$_SESSION[$key] = [];
}
// Add message
$_SESSION[$key][] = ( empty($from) ? '' : sprintf('<strong>[%s]</strong> ', $from) ).$message;
}
}
|
[
"private",
"function",
"writeSession",
"(",
"$",
"message",
",",
"$",
"from",
"=",
"''",
",",
"$",
"is_error",
"=",
"false",
")",
"{",
"if",
"(",
"session_id",
"(",
")",
")",
"{",
"$",
"key",
"=",
"$",
"is_error",
"?",
"$",
"this",
"->",
"error_key",
":",
"$",
"this",
"->",
"message_key",
";",
"// Initialize",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"// Add message",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"(",
"empty",
"(",
"$",
"from",
")",
"?",
"''",
":",
"sprintf",
"(",
"'<strong>[%s]</strong> '",
",",
"$",
"from",
")",
")",
".",
"$",
"message",
";",
"}",
"}"
] |
Write message to session
@param $message
@param string $from
@param bool $is_error
|
[
"Write",
"message",
"to",
"session"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Http/PostRedirectGet.php#L105-L115
|
22,068
|
hametuha/wpametu
|
src/WPametu/Http/PostRedirectGet.php
|
PostRedirectGet.flushMessage
|
public function flushMessage(){
if( session_id() ){
foreach( [ $this->error_key => 'error', $this->message_key => 'updated' ] as $key => $class_name ){
if( isset($_SESSION[$key]) && !empty($_SESSION[$key]) ){
$markup = sprintf('<div class="%s"><p>%s</p></div>', $class_name, implode('<br />', $_SESSION[$key]));
if( is_admin() ){
echo $markup;
}else{
/**
* Post redirect get message's filter
*
* @param string $markup html string
* @param array $messages Messages' array
* @param string $class_name updated or error.
* @return string
*/
echo apply_filters('wpametu_prg_message_class', $markup, $_SESSION[$key], $class_name);
}
// Make session empty.
$_SESSION[$key] = [];
}
}
}
}
|
php
|
public function flushMessage(){
if( session_id() ){
foreach( [ $this->error_key => 'error', $this->message_key => 'updated' ] as $key => $class_name ){
if( isset($_SESSION[$key]) && !empty($_SESSION[$key]) ){
$markup = sprintf('<div class="%s"><p>%s</p></div>', $class_name, implode('<br />', $_SESSION[$key]));
if( is_admin() ){
echo $markup;
}else{
/**
* Post redirect get message's filter
*
* @param string $markup html string
* @param array $messages Messages' array
* @param string $class_name updated or error.
* @return string
*/
echo apply_filters('wpametu_prg_message_class', $markup, $_SESSION[$key], $class_name);
}
// Make session empty.
$_SESSION[$key] = [];
}
}
}
}
|
[
"public",
"function",
"flushMessage",
"(",
")",
"{",
"if",
"(",
"session_id",
"(",
")",
")",
"{",
"foreach",
"(",
"[",
"$",
"this",
"->",
"error_key",
"=>",
"'error'",
",",
"$",
"this",
"->",
"message_key",
"=>",
"'updated'",
"]",
"as",
"$",
"key",
"=>",
"$",
"class_name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"markup",
"=",
"sprintf",
"(",
"'<div class=\"%s\"><p>%s</p></div>'",
",",
"$",
"class_name",
",",
"implode",
"(",
"'<br />'",
",",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
")",
")",
";",
"if",
"(",
"is_admin",
"(",
")",
")",
"{",
"echo",
"$",
"markup",
";",
"}",
"else",
"{",
"/**\n * Post redirect get message's filter\n *\n * @param string $markup html string\n * @param array $messages Messages' array\n * @param string $class_name updated or error.\n * @return string\n */",
"echo",
"apply_filters",
"(",
"'wpametu_prg_message_class'",
",",
"$",
"markup",
",",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
",",
"$",
"class_name",
")",
";",
"}",
"// Make session empty.",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"}",
"}",
"}"
] |
Show message on screen
|
[
"Show",
"message",
"on",
"screen"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Http/PostRedirectGet.php#L120-L143
|
22,069
|
WScore/Validation
|
src/Utils/HelperMultiple.php
|
HelperMultiple.prepare
|
public static function prepare($name, $source, $option)
{
// get options.
if (is_string($option)) {
$option = (array) Helper::arrGet(self::$multiples, $option, array());
}
$lists = self::find_multiple($name, $source, $option);
$found = self::merge_multiple($option, $lists);
return $found;
}
|
php
|
public static function prepare($name, $source, $option)
{
// get options.
if (is_string($option)) {
$option = (array) Helper::arrGet(self::$multiples, $option, array());
}
$lists = self::find_multiple($name, $source, $option);
$found = self::merge_multiple($option, $lists);
return $found;
}
|
[
"public",
"static",
"function",
"prepare",
"(",
"$",
"name",
",",
"$",
"source",
",",
"$",
"option",
")",
"{",
"// get options.",
"if",
"(",
"is_string",
"(",
"$",
"option",
")",
")",
"{",
"$",
"option",
"=",
"(",
"array",
")",
"Helper",
"::",
"arrGet",
"(",
"self",
"::",
"$",
"multiples",
",",
"$",
"option",
",",
"array",
"(",
")",
")",
";",
"}",
"$",
"lists",
"=",
"self",
"::",
"find_multiple",
"(",
"$",
"name",
",",
"$",
"source",
",",
"$",
"option",
")",
";",
"$",
"found",
"=",
"self",
"::",
"merge_multiple",
"(",
"$",
"option",
",",
"$",
"lists",
")",
";",
"return",
"$",
"found",
";",
"}"
] |
prepares for validation by creating a value from multiple value.
@param string $name
@param array $source
@param string|array $option
@return mixed|null|string
|
[
"prepares",
"for",
"validation",
"by",
"creating",
"a",
"value",
"from",
"multiple",
"value",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperMultiple.php#L33-L44
|
22,070
|
WScore/Validation
|
src/Utils/HelperMultiple.php
|
HelperMultiple.find_multiple
|
private static function find_multiple($name, $source, $option)
{
$sep = Helper::arrGet($option, 'separator', '_');
$suffix = explode(',', $option['suffix']);
$lists = [];
foreach ($suffix as $sfx) {
$name_sfx = $name . $sep . $sfx;
if (array_key_exists($name_sfx, $source) && trim($source[$name_sfx])) {
$lists[] = trim($source[$name_sfx]);
}
}
return $lists;
}
|
php
|
private static function find_multiple($name, $source, $option)
{
$sep = Helper::arrGet($option, 'separator', '_');
$suffix = explode(',', $option['suffix']);
$lists = [];
foreach ($suffix as $sfx) {
$name_sfx = $name . $sep . $sfx;
if (array_key_exists($name_sfx, $source) && trim($source[$name_sfx])) {
$lists[] = trim($source[$name_sfx]);
}
}
return $lists;
}
|
[
"private",
"static",
"function",
"find_multiple",
"(",
"$",
"name",
",",
"$",
"source",
",",
"$",
"option",
")",
"{",
"$",
"sep",
"=",
"Helper",
"::",
"arrGet",
"(",
"$",
"option",
",",
"'separator'",
",",
"'_'",
")",
";",
"$",
"suffix",
"=",
"explode",
"(",
"','",
",",
"$",
"option",
"[",
"'suffix'",
"]",
")",
";",
"$",
"lists",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"suffix",
"as",
"$",
"sfx",
")",
"{",
"$",
"name_sfx",
"=",
"$",
"name",
".",
"$",
"sep",
".",
"$",
"sfx",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name_sfx",
",",
"$",
"source",
")",
"&&",
"trim",
"(",
"$",
"source",
"[",
"$",
"name_sfx",
"]",
")",
")",
"{",
"$",
"lists",
"[",
"]",
"=",
"trim",
"(",
"$",
"source",
"[",
"$",
"name_sfx",
"]",
")",
";",
"}",
"}",
"return",
"$",
"lists",
";",
"}"
] |
find multiples values from suffix list.
@param string $name
@param array $source
@param array $option
@return array
|
[
"find",
"multiples",
"values",
"from",
"suffix",
"list",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperMultiple.php#L54-L67
|
22,071
|
WScore/Validation
|
src/Utils/HelperMultiple.php
|
HelperMultiple.merge_multiple
|
private static function merge_multiple($option, $lists)
{
if (empty($lists)) {
return null;
}
// found format using sprintf.
if (isset($option['format'])) {
$param = array_merge(array($option['format']), $lists);
$found = call_user_func_array('sprintf', $param);
} else {
$con = Helper::arrGet($option, 'connector', '-');
$found = implode($con, $lists);
}
return $found;
}
|
php
|
private static function merge_multiple($option, $lists)
{
if (empty($lists)) {
return null;
}
// found format using sprintf.
if (isset($option['format'])) {
$param = array_merge(array($option['format']), $lists);
$found = call_user_func_array('sprintf', $param);
} else {
$con = Helper::arrGet($option, 'connector', '-');
$found = implode($con, $lists);
}
return $found;
}
|
[
"private",
"static",
"function",
"merge_multiple",
"(",
"$",
"option",
",",
"$",
"lists",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"lists",
")",
")",
"{",
"return",
"null",
";",
"}",
"// found format using sprintf.",
"if",
"(",
"isset",
"(",
"$",
"option",
"[",
"'format'",
"]",
")",
")",
"{",
"$",
"param",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"option",
"[",
"'format'",
"]",
")",
",",
"$",
"lists",
")",
";",
"$",
"found",
"=",
"call_user_func_array",
"(",
"'sprintf'",
",",
"$",
"param",
")",
";",
"}",
"else",
"{",
"$",
"con",
"=",
"Helper",
"::",
"arrGet",
"(",
"$",
"option",
",",
"'connector'",
",",
"'-'",
")",
";",
"$",
"found",
"=",
"implode",
"(",
"$",
"con",
",",
"$",
"lists",
")",
";",
"}",
"return",
"$",
"found",
";",
"}"
] |
merge the found list into one value.
@param array $option
@param array $lists
@return mixed|null|string
|
[
"merge",
"the",
"found",
"list",
"into",
"one",
"value",
"."
] |
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
|
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/HelperMultiple.php#L76-L91
|
22,072
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.to_path
|
public function to_path(string $id){
if ( bbn\str::is_uid($id) ){
return $this->options->to_path($id, '', $this->_get_public_root());
}
return false;
}
|
php
|
public function to_path(string $id){
if ( bbn\str::is_uid($id) ){
return $this->options->to_path($id, '', $this->_get_public_root());
}
return false;
}
|
[
"public",
"function",
"to_path",
"(",
"string",
"$",
"id",
")",
"{",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"options",
"->",
"to_path",
"(",
"$",
"id",
",",
"''",
",",
"$",
"this",
"->",
"_get_public_root",
"(",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns the path corresponding to an ID
@param string $id
@return int|boolean
|
[
"Returns",
"the",
"path",
"corresponding",
"to",
"an",
"ID"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L160-L165
|
22,073
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.add_shortcut
|
public function add_shortcut(string $id): ?string
{
if (
($bit = $this->pref->get_bit($id, false)) &&
($id_option = $this->from_path('shortcuts')) &&
($c = $this->pref->get_class_cfg())
){
if ( $id_menu = $this->pref->get_by_option($id_option) ){
$id_menu = $id_menu[$c['arch']['user_options']['id']];
}
else {
$id_menu = $this->pref->add($id_option, [$c['arch']['user_options']['text'] => _('Shortcuts')]);
}
if (
!empty($id_menu) &&
($arch = $c['arch']['user_options_bits'])
){
if (
($bits = $this->pref->get_bits($id_menu, false, false)) &&
( \bbn\x::find($bits, [$arch['id_option'] => $bit[$arch['id_option']]]) !== false)
){
return null;
}
return $this->pref->add_bit($id_menu, [
$arch['id_option'] => $bit[$arch['id_option']],
$arch['text'] => $bit[$arch['text']],
$arch['cfg'] => $bit[$arch['cfg']],
$arch['num'] => $this->pref->next_bit_num($id_menu) ?: 1
]);
}
}
return null;
}
|
php
|
public function add_shortcut(string $id): ?string
{
if (
($bit = $this->pref->get_bit($id, false)) &&
($id_option = $this->from_path('shortcuts')) &&
($c = $this->pref->get_class_cfg())
){
if ( $id_menu = $this->pref->get_by_option($id_option) ){
$id_menu = $id_menu[$c['arch']['user_options']['id']];
}
else {
$id_menu = $this->pref->add($id_option, [$c['arch']['user_options']['text'] => _('Shortcuts')]);
}
if (
!empty($id_menu) &&
($arch = $c['arch']['user_options_bits'])
){
if (
($bits = $this->pref->get_bits($id_menu, false, false)) &&
( \bbn\x::find($bits, [$arch['id_option'] => $bit[$arch['id_option']]]) !== false)
){
return null;
}
return $this->pref->add_bit($id_menu, [
$arch['id_option'] => $bit[$arch['id_option']],
$arch['text'] => $bit[$arch['text']],
$arch['cfg'] => $bit[$arch['cfg']],
$arch['num'] => $this->pref->next_bit_num($id_menu) ?: 1
]);
}
}
return null;
}
|
[
"public",
"function",
"add_shortcut",
"(",
"string",
"$",
"id",
")",
":",
"?",
"string",
"{",
"if",
"(",
"(",
"$",
"bit",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_bit",
"(",
"$",
"id",
",",
"false",
")",
")",
"&&",
"(",
"$",
"id_option",
"=",
"$",
"this",
"->",
"from_path",
"(",
"'shortcuts'",
")",
")",
"&&",
"(",
"$",
"c",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_class_cfg",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"id_menu",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_by_option",
"(",
"$",
"id_option",
")",
")",
"{",
"$",
"id_menu",
"=",
"$",
"id_menu",
"[",
"$",
"c",
"[",
"'arch'",
"]",
"[",
"'user_options'",
"]",
"[",
"'id'",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"id_menu",
"=",
"$",
"this",
"->",
"pref",
"->",
"add",
"(",
"$",
"id_option",
",",
"[",
"$",
"c",
"[",
"'arch'",
"]",
"[",
"'user_options'",
"]",
"[",
"'text'",
"]",
"=>",
"_",
"(",
"'Shortcuts'",
")",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"id_menu",
")",
"&&",
"(",
"$",
"arch",
"=",
"$",
"c",
"[",
"'arch'",
"]",
"[",
"'user_options_bits'",
"]",
")",
")",
"{",
"if",
"(",
"(",
"$",
"bits",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_bits",
"(",
"$",
"id_menu",
",",
"false",
",",
"false",
")",
")",
"&&",
"(",
"\\",
"bbn",
"\\",
"x",
"::",
"find",
"(",
"$",
"bits",
",",
"[",
"$",
"arch",
"[",
"'id_option'",
"]",
"=>",
"$",
"bit",
"[",
"$",
"arch",
"[",
"'id_option'",
"]",
"]",
"]",
")",
"!==",
"false",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"pref",
"->",
"add_bit",
"(",
"$",
"id_menu",
",",
"[",
"$",
"arch",
"[",
"'id_option'",
"]",
"=>",
"$",
"bit",
"[",
"$",
"arch",
"[",
"'id_option'",
"]",
"]",
",",
"$",
"arch",
"[",
"'text'",
"]",
"=>",
"$",
"bit",
"[",
"$",
"arch",
"[",
"'text'",
"]",
"]",
",",
"$",
"arch",
"[",
"'cfg'",
"]",
"=>",
"$",
"bit",
"[",
"$",
"arch",
"[",
"'cfg'",
"]",
"]",
",",
"$",
"arch",
"[",
"'num'",
"]",
"=>",
"$",
"this",
"->",
"pref",
"->",
"next_bit_num",
"(",
"$",
"id_menu",
")",
"?",
":",
"1",
"]",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Adds an user'shortcut from a menu
@param string $id The menu item's ID to link
@return string|null
|
[
"Adds",
"an",
"user",
"shortcut",
"from",
"a",
"menu"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L191-L223
|
22,074
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.remove_shortcut
|
public function remove_shortcut($id): ?int
{
if ( \bbn\str::is_uid($id) ){
return $this->pref->delete_bit($id);
}
return null;
}
|
php
|
public function remove_shortcut($id): ?int
{
if ( \bbn\str::is_uid($id) ){
return $this->pref->delete_bit($id);
}
return null;
}
|
[
"public",
"function",
"remove_shortcut",
"(",
"$",
"id",
")",
":",
"?",
"int",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pref",
"->",
"delete_bit",
"(",
"$",
"id",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Removes an user'shortcut
@param string $id The shortcut's ID
@return null|int
|
[
"Removes",
"an",
"user",
"shortcut"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L231-L237
|
22,075
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.shortcuts
|
public function shortcuts(): ?array
{
if (
($id_option = $this->from_path('shortcuts')) &&
($menu = $this->pref->get_by_option($id_option))
){
$links = $this->pref->get_bits($menu['id']);
$res = [];
foreach ( $links as $link ){
if ( ($url = $this->to_path($link['id_option'])) ){
$res[] = [
'id' => $link['id'],
'id_option' => $link['id_option'],
'url' => $url,
'text' => $link['text'],
'icon' => $link['icon'],
'num' => $link['num']
];
}
}
return $res;
}
return null;
}
|
php
|
public function shortcuts(): ?array
{
if (
($id_option = $this->from_path('shortcuts')) &&
($menu = $this->pref->get_by_option($id_option))
){
$links = $this->pref->get_bits($menu['id']);
$res = [];
foreach ( $links as $link ){
if ( ($url = $this->to_path($link['id_option'])) ){
$res[] = [
'id' => $link['id'],
'id_option' => $link['id_option'],
'url' => $url,
'text' => $link['text'],
'icon' => $link['icon'],
'num' => $link['num']
];
}
}
return $res;
}
return null;
}
|
[
"public",
"function",
"shortcuts",
"(",
")",
":",
"?",
"array",
"{",
"if",
"(",
"(",
"$",
"id_option",
"=",
"$",
"this",
"->",
"from_path",
"(",
"'shortcuts'",
")",
")",
"&&",
"(",
"$",
"menu",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_by_option",
"(",
"$",
"id_option",
")",
")",
")",
"{",
"$",
"links",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_bits",
"(",
"$",
"menu",
"[",
"'id'",
"]",
")",
";",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"links",
"as",
"$",
"link",
")",
"{",
"if",
"(",
"(",
"$",
"url",
"=",
"$",
"this",
"->",
"to_path",
"(",
"$",
"link",
"[",
"'id_option'",
"]",
")",
")",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"link",
"[",
"'id'",
"]",
",",
"'id_option'",
"=>",
"$",
"link",
"[",
"'id_option'",
"]",
",",
"'url'",
"=>",
"$",
"url",
",",
"'text'",
"=>",
"$",
"link",
"[",
"'text'",
"]",
",",
"'icon'",
"=>",
"$",
"link",
"[",
"'icon'",
"]",
",",
"'num'",
"=>",
"$",
"link",
"[",
"'num'",
"]",
"]",
";",
"}",
"}",
"return",
"$",
"res",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the user' shortcuts list
@return null|array
|
[
"Gets",
"the",
"user",
"shortcuts",
"list"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L244-L267
|
22,076
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.remove
|
public function remove(string $id){
if ( \bbn\str::is_uid($id) ){
if ( $id_menu = $this->get_id_menu($id) ){
if ( $this->pref->delete_bit($id) ){
$this->delete_cache($id_menu);
return true;
}
}
else if ( $this->pref->delete($id) ){
$this->options->delete_cache($this->from_path('menus'));
return true;
}
}
return false;
}
|
php
|
public function remove(string $id){
if ( \bbn\str::is_uid($id) ){
if ( $id_menu = $this->get_id_menu($id) ){
if ( $this->pref->delete_bit($id) ){
$this->delete_cache($id_menu);
return true;
}
}
else if ( $this->pref->delete($id) ){
$this->options->delete_cache($this->from_path('menus'));
return true;
}
}
return false;
}
|
[
"public",
"function",
"remove",
"(",
"string",
"$",
"id",
")",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"$",
"id_menu",
"=",
"$",
"this",
"->",
"get_id_menu",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pref",
"->",
"delete_bit",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"delete_cache",
"(",
"$",
"id_menu",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"pref",
"->",
"delete",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"delete_cache",
"(",
"$",
"this",
"->",
"from_path",
"(",
"'menus'",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Removes menu and deletes parent cache
@param $id
@return int|boolean
|
[
"Removes",
"menu",
"and",
"deletes",
"parent",
"cache"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L285-L299
|
22,077
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.add
|
public function add($id_menu, array $cfg = null): ?string
{
$ids = [];
if ( \is_array($id_menu) ){
$cfg = $id_menu;
$id_opt = $this->from_path('menus');
}
if ( !empty($cfg) ){
if ( \bbn\str::is_uid($id_menu) ){
$id = $this->pref->add_bit($id_menu, $cfg);
}
else {
$id = $this->pref->add($id_opt, $cfg);
}
}
if ( !empty($id) ){
if ( \bbn\str::is_uid($id_menu) ){
$this->delete_cache($id_menu);
}
$this->options->delete_cache($id_opt);
return $id;
}
return null;
}
|
php
|
public function add($id_menu, array $cfg = null): ?string
{
$ids = [];
if ( \is_array($id_menu) ){
$cfg = $id_menu;
$id_opt = $this->from_path('menus');
}
if ( !empty($cfg) ){
if ( \bbn\str::is_uid($id_menu) ){
$id = $this->pref->add_bit($id_menu, $cfg);
}
else {
$id = $this->pref->add($id_opt, $cfg);
}
}
if ( !empty($id) ){
if ( \bbn\str::is_uid($id_menu) ){
$this->delete_cache($id_menu);
}
$this->options->delete_cache($id_opt);
return $id;
}
return null;
}
|
[
"public",
"function",
"add",
"(",
"$",
"id_menu",
",",
"array",
"$",
"cfg",
"=",
"null",
")",
":",
"?",
"string",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"id_menu",
")",
")",
"{",
"$",
"cfg",
"=",
"$",
"id_menu",
";",
"$",
"id_opt",
"=",
"$",
"this",
"->",
"from_path",
"(",
"'menus'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
")",
")",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_menu",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"pref",
"->",
"add_bit",
"(",
"$",
"id_menu",
",",
"$",
"cfg",
")",
";",
"}",
"else",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"pref",
"->",
"add",
"(",
"$",
"id_opt",
",",
"$",
"cfg",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_menu",
")",
")",
"{",
"$",
"this",
"->",
"delete_cache",
"(",
"$",
"id_menu",
")",
";",
"}",
"$",
"this",
"->",
"options",
"->",
"delete_cache",
"(",
"$",
"id_opt",
")",
";",
"return",
"$",
"id",
";",
"}",
"return",
"null",
";",
"}"
] |
Add menu and delete the chache.
@param string|array $id_parent
@param array $cfg
@return null|string
@internal param $id
|
[
"Add",
"menu",
"and",
"delete",
"the",
"chache",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L309-L332
|
22,078
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.set
|
public function set(string $id, array $cfg): bool
{
if (
\bbn\str::is_uid($id) &&
($id_menu = $this->get_id_menu($id)) &&
$this->pref->update_bit($id, $cfg)
){
$this->delete_cache($id_menu);
return true;
}
return false;
}
|
php
|
public function set(string $id, array $cfg): bool
{
if (
\bbn\str::is_uid($id) &&
($id_menu = $this->get_id_menu($id)) &&
$this->pref->update_bit($id, $cfg)
){
$this->delete_cache($id_menu);
return true;
}
return false;
}
|
[
"public",
"function",
"set",
"(",
"string",
"$",
"id",
",",
"array",
"$",
"cfg",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
"&&",
"(",
"$",
"id_menu",
"=",
"$",
"this",
"->",
"get_id_menu",
"(",
"$",
"id",
")",
")",
"&&",
"$",
"this",
"->",
"pref",
"->",
"update_bit",
"(",
"$",
"id",
",",
"$",
"cfg",
")",
")",
"{",
"$",
"this",
"->",
"delete_cache",
"(",
"$",
"id_menu",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Updates a menu item and deletes the menu cache
@param string $id
@param array $cfg
@return bool
|
[
"Updates",
"a",
"menu",
"item",
"and",
"deletes",
"the",
"menu",
"cache"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L341-L352
|
22,079
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.set_text
|
public function set_text(string $id, string $text): bool
{
if ( \bbn\str::is_uid($id) && $this->pref->set_text($id, $text) ){
$this->delete_cache($id);
return true;
}
return false;
}
|
php
|
public function set_text(string $id, string $text): bool
{
if ( \bbn\str::is_uid($id) && $this->pref->set_text($id, $text) ){
$this->delete_cache($id);
return true;
}
return false;
}
|
[
"public",
"function",
"set_text",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"text",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
"&&",
"$",
"this",
"->",
"pref",
"->",
"set_text",
"(",
"$",
"id",
",",
"$",
"text",
")",
")",
"{",
"$",
"this",
"->",
"delete_cache",
"(",
"$",
"id",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Sets the menu's text and deletes its chache
@param string $id The menu's ID
@param array $text The new text tp set
@return bool
|
[
"Sets",
"the",
"menu",
"s",
"text",
"and",
"deletes",
"its",
"chache"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L361-L368
|
22,080
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.delete_cache
|
public function delete_cache($id_menu){
$this->options->delete_cache($this->from_path('menus'), true);
return $this->cache_delete($id_menu);
}
|
php
|
public function delete_cache($id_menu){
$this->options->delete_cache($this->from_path('menus'), true);
return $this->cache_delete($id_menu);
}
|
[
"public",
"function",
"delete_cache",
"(",
"$",
"id_menu",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"delete_cache",
"(",
"$",
"this",
"->",
"from_path",
"(",
"'menus'",
")",
",",
"true",
")",
";",
"return",
"$",
"this",
"->",
"cache_delete",
"(",
"$",
"id_menu",
")",
";",
"}"
] |
Clears the menu cache
|
[
"Clears",
"the",
"menu",
"cache"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L373-L376
|
22,081
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.get_default
|
public function get_default(): ?string
{
if (
($id_opt = $this->from_path('default')) &&
($all = $this->pref->get_all($id_opt))
){
$id = false;
foreach ( $all as $a ){
if ( !empty($a['id_user']) ){
$id = $a['id_alias'];
break;
}
else if ( !empty($a['id_group']) ){
$id = $a['id_alias'];
break;
}
else if ( !empty($a['public']) ){
$id = $a['id_alias'];
break;
}
}
return $id;
}
return null;
}
|
php
|
public function get_default(): ?string
{
if (
($id_opt = $this->from_path('default')) &&
($all = $this->pref->get_all($id_opt))
){
$id = false;
foreach ( $all as $a ){
if ( !empty($a['id_user']) ){
$id = $a['id_alias'];
break;
}
else if ( !empty($a['id_group']) ){
$id = $a['id_alias'];
break;
}
else if ( !empty($a['public']) ){
$id = $a['id_alias'];
break;
}
}
return $id;
}
return null;
}
|
[
"public",
"function",
"get_default",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"(",
"$",
"id_opt",
"=",
"$",
"this",
"->",
"from_path",
"(",
"'default'",
")",
")",
"&&",
"(",
"$",
"all",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_all",
"(",
"$",
"id_opt",
")",
")",
")",
"{",
"$",
"id",
"=",
"false",
";",
"foreach",
"(",
"$",
"all",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"a",
"[",
"'id_user'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"a",
"[",
"'id_alias'",
"]",
";",
"break",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"a",
"[",
"'id_group'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"a",
"[",
"'id_alias'",
"]",
";",
"break",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"a",
"[",
"'public'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"a",
"[",
"'id_alias'",
"]",
";",
"break",
";",
"}",
"}",
"return",
"$",
"id",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the user's default menu
@return string
|
[
"Gets",
"the",
"user",
"s",
"default",
"menu"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L383-L407
|
22,082
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.clone
|
public function clone(string $id, string $name): ?string
{
if ( \bbn\str::is_uid($id) && ($id_menu = $this->add(['text' => $name])) ){
if ( ($bits = $this->pref->get_full_bits($id)) && !$this->_clone($id_menu, $bits) ){
return null;
}
return $id_menu;
}
return null;
}
|
php
|
public function clone(string $id, string $name): ?string
{
if ( \bbn\str::is_uid($id) && ($id_menu = $this->add(['text' => $name])) ){
if ( ($bits = $this->pref->get_full_bits($id)) && !$this->_clone($id_menu, $bits) ){
return null;
}
return $id_menu;
}
return null;
}
|
[
"public",
"function",
"clone",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"name",
")",
":",
"?",
"string",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id",
")",
"&&",
"(",
"$",
"id_menu",
"=",
"$",
"this",
"->",
"add",
"(",
"[",
"'text'",
"=>",
"$",
"name",
"]",
")",
")",
")",
"{",
"if",
"(",
"(",
"$",
"bits",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_full_bits",
"(",
"$",
"id",
")",
")",
"&&",
"!",
"$",
"this",
"->",
"_clone",
"(",
"$",
"id_menu",
",",
"$",
"bits",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"id_menu",
";",
"}",
"return",
"null",
";",
"}"
] |
Clones a menu
@param string $id The menu's ID to clone
@param string $name The new menu's name
@return null|string The new ID
|
[
"Clones",
"a",
"menu"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L439-L448
|
22,083
|
nabab/bbn
|
src/bbn/appui/menus.php
|
menus.copy
|
public function copy(string $id_menu, string $id_menu_to, array $cfg): ?string
{
if (
\bbn\str::is_uid($id_menu) &&
\bbn\str::is_uid($id_menu_to) &&
($bits = $this->pref->get_full_bits($id_menu)) &&
($id = $this->add($id_menu_to, $cfg)) &&
$this->_clone($id_menu_to, $bits, $id)
){
return $id;
}
return null;
}
|
php
|
public function copy(string $id_menu, string $id_menu_to, array $cfg): ?string
{
if (
\bbn\str::is_uid($id_menu) &&
\bbn\str::is_uid($id_menu_to) &&
($bits = $this->pref->get_full_bits($id_menu)) &&
($id = $this->add($id_menu_to, $cfg)) &&
$this->_clone($id_menu_to, $bits, $id)
){
return $id;
}
return null;
}
|
[
"public",
"function",
"copy",
"(",
"string",
"$",
"id_menu",
",",
"string",
"$",
"id_menu_to",
",",
"array",
"$",
"cfg",
")",
":",
"?",
"string",
"{",
"if",
"(",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_menu",
")",
"&&",
"\\",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"id_menu_to",
")",
"&&",
"(",
"$",
"bits",
"=",
"$",
"this",
"->",
"pref",
"->",
"get_full_bits",
"(",
"$",
"id_menu",
")",
")",
"&&",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"add",
"(",
"$",
"id_menu_to",
",",
"$",
"cfg",
")",
")",
"&&",
"$",
"this",
"->",
"_clone",
"(",
"$",
"id_menu_to",
",",
"$",
"bits",
",",
"$",
"id",
")",
")",
"{",
"return",
"$",
"id",
";",
"}",
"return",
"null",
";",
"}"
] |
Copies a menu into another one.
@param string $id The menu's ID to copy
@param string $id_menu_to The target menu's ID
@param array $cfg
@return null|string The new ID
|
[
"Copies",
"a",
"menu",
"into",
"another",
"one",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/menus.php#L460-L472
|
22,084
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.insert
|
public function insert($entity)
{
$values = $this->getInsertValues($entity, $this->namingContention);
$keyString = implode(array_keys($values), ', ');
$questionMarkString = count($values) === 0 ? '' : ('?' . str_repeat(', ?', count($values) - 1));
$sql = "INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)";
$sth = $this->pdo->prepare($sql);
$sth->execute(array_values($values));
$id = $this->pdo->lastInsertId();
if ($this->idProperty !== null) {
$this->idProperty->setValue($entity, $id);
}
return $id;
}
|
php
|
public function insert($entity)
{
$values = $this->getInsertValues($entity, $this->namingContention);
$keyString = implode(array_keys($values), ', ');
$questionMarkString = count($values) === 0 ? '' : ('?' . str_repeat(', ?', count($values) - 1));
$sql = "INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)";
$sth = $this->pdo->prepare($sql);
$sth->execute(array_values($values));
$id = $this->pdo->lastInsertId();
if ($this->idProperty !== null) {
$this->idProperty->setValue($entity, $id);
}
return $id;
}
|
[
"public",
"function",
"insert",
"(",
"$",
"entity",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getInsertValues",
"(",
"$",
"entity",
",",
"$",
"this",
"->",
"namingContention",
")",
";",
"$",
"keyString",
"=",
"implode",
"(",
"array_keys",
"(",
"$",
"values",
")",
",",
"', '",
")",
";",
"$",
"questionMarkString",
"=",
"count",
"(",
"$",
"values",
")",
"===",
"0",
"?",
"''",
":",
"(",
"'?'",
".",
"str_repeat",
"(",
"', ?'",
",",
"count",
"(",
"$",
"values",
")",
"-",
"1",
")",
")",
";",
"$",
"sql",
"=",
"\"INSERT INTO $this->tableName ($keyString) VALUES ($questionMarkString)\"",
";",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
"array_values",
"(",
"$",
"values",
")",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"pdo",
"->",
"lastInsertId",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"idProperty",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"idProperty",
"->",
"setValue",
"(",
"$",
"entity",
",",
"$",
"id",
")",
";",
"}",
"return",
"$",
"id",
";",
"}"
] |
Insert an entity into the database.
You can optionally provide a property name. If you do the inserted id will be assigned to that property.
@param $entity
@return integer the id of the row that was inserted
|
[
"Insert",
"an",
"entity",
"into",
"the",
"database",
".",
"You",
"can",
"optionally",
"provide",
"a",
"property",
"name",
".",
"If",
"you",
"do",
"the",
"inserted",
"id",
"will",
"be",
"assigned",
"to",
"that",
"property",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L71-L87
|
22,085
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.update
|
public function update($entity)
{
if ($this->idProperty === null) {
throw new ConfigurationException('No idProperty set');
}
$id = $this->idProperty->getValue($entity);
if ($id === null) {
throw new ConfigurationException('Value of ' . $this->idProperty->getName() . ' is null');
}
$values = $this->getInsertValues($entity, $this->namingContention);
$keyString = implode(array_keys($values), ' = ?,') . ' = ?';
$idColumn = $this->namingContention->propertyToColumnName($this->idProperty);
$onlyValues = array_values($values);
$onlyValues[] = $id;
$sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?";
$sth = $this->pdo->prepare($sql);
$sth->execute($onlyValues);
return $id;
}
|
php
|
public function update($entity)
{
if ($this->idProperty === null) {
throw new ConfigurationException('No idProperty set');
}
$id = $this->idProperty->getValue($entity);
if ($id === null) {
throw new ConfigurationException('Value of ' . $this->idProperty->getName() . ' is null');
}
$values = $this->getInsertValues($entity, $this->namingContention);
$keyString = implode(array_keys($values), ' = ?,') . ' = ?';
$idColumn = $this->namingContention->propertyToColumnName($this->idProperty);
$onlyValues = array_values($values);
$onlyValues[] = $id;
$sql = "UPDATE $this->tableName SET $keyString WHERE $idColumn = ?";
$sth = $this->pdo->prepare($sql);
$sth->execute($onlyValues);
return $id;
}
|
[
"public",
"function",
"update",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"idProperty",
"===",
"null",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"'No idProperty set'",
")",
";",
"}",
"$",
"id",
"=",
"$",
"this",
"->",
"idProperty",
"->",
"getValue",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"'Value of '",
".",
"$",
"this",
"->",
"idProperty",
"->",
"getName",
"(",
")",
".",
"' is null'",
")",
";",
"}",
"$",
"values",
"=",
"$",
"this",
"->",
"getInsertValues",
"(",
"$",
"entity",
",",
"$",
"this",
"->",
"namingContention",
")",
";",
"$",
"keyString",
"=",
"implode",
"(",
"array_keys",
"(",
"$",
"values",
")",
",",
"' = ?,'",
")",
".",
"' = ?'",
";",
"$",
"idColumn",
"=",
"$",
"this",
"->",
"namingContention",
"->",
"propertyToColumnName",
"(",
"$",
"this",
"->",
"idProperty",
")",
";",
"$",
"onlyValues",
"=",
"array_values",
"(",
"$",
"values",
")",
";",
"$",
"onlyValues",
"[",
"]",
"=",
"$",
"id",
";",
"$",
"sql",
"=",
"\"UPDATE $this->tableName SET $keyString WHERE $idColumn = ?\"",
";",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
"$",
"onlyValues",
")",
";",
"return",
"$",
"id",
";",
"}"
] |
Update an existing entity in the database.
@param mixed $entity the entity
@return int the id of the entity
@throws ConfigurationException if no idProperty was set
|
[
"Update",
"an",
"existing",
"entity",
"in",
"the",
"database",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L95-L117
|
22,086
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.save
|
public function save($entity)
{
if ($this->idProperty->getValue($entity) === null) {
return $this->insert($entity);
} else {
return $this->update($entity);
}
}
|
php
|
public function save($entity)
{
if ($this->idProperty->getValue($entity) === null) {
return $this->insert($entity);
} else {
return $this->update($entity);
}
}
|
[
"public",
"function",
"save",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"idProperty",
"->",
"getValue",
"(",
"$",
"entity",
")",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"insert",
"(",
"$",
"entity",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"entity",
")",
";",
"}",
"}"
] |
Insert an entity into the database if it has no id yet. Otherwise update it by id.
@param mixed $entity the entity
@return int the id of the saved document
@throws ConfigurationException if no idProperty was set
|
[
"Insert",
"an",
"entity",
"into",
"the",
"database",
"if",
"it",
"has",
"no",
"id",
"yet",
".",
"Otherwise",
"update",
"it",
"by",
"id",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L125-L133
|
22,087
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.get
|
public function get($id)
{
$idName = ucfirst($this->idProperty->getName());
return $this->__call("getBy$idName", array($id));
}
|
php
|
public function get($id)
{
$idName = ucfirst($this->idProperty->getName());
return $this->__call("getBy$idName", array($id));
}
|
[
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"$",
"idName",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"idProperty",
"->",
"getName",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"__call",
"(",
"\"getBy$idName\"",
",",
"array",
"(",
"$",
"id",
")",
")",
";",
"}"
] |
Get an entity by it's idProperty value.
@param mixed $id the id value
@return mixed the entity
@throws ErrorException
|
[
"Get",
"an",
"entity",
"by",
"it",
"s",
"idProperty",
"value",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L141-L145
|
22,088
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.delete
|
public function delete($id)
{
$idName = ucfirst($this->idProperty->getName());
return $this->__call("deleteBy$idName", array($id));
}
|
php
|
public function delete($id)
{
$idName = ucfirst($this->idProperty->getName());
return $this->__call("deleteBy$idName", array($id));
}
|
[
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"idName",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"idProperty",
"->",
"getName",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"__call",
"(",
"\"deleteBy$idName\"",
",",
"array",
"(",
"$",
"id",
")",
")",
";",
"}"
] |
Delete an entity by it's idProperty value.
@param mixed $id the id value
@return mixed the entity
@throws ErrorException
|
[
"Delete",
"an",
"entity",
"by",
"it",
"s",
"idProperty",
"value",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L153-L157
|
22,089
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.addMethod
|
private function addMethod($method)
{
$tokens = $this->methodParser->parse($method);
$query = $this->queryBuilder->build($tokens, $this->tableName, $this->namingContention, $this->entityClass);
if ($query->getResultMode() <= QueryBuilderResult::RESULT_SELECT_MULTIPLE) {
$this->addSelectionMethod($query, $method);
} else {
$this->addIntResultMethod($query, $method);
}
}
|
php
|
private function addMethod($method)
{
$tokens = $this->methodParser->parse($method);
$query = $this->queryBuilder->build($tokens, $this->tableName, $this->namingContention, $this->entityClass);
if ($query->getResultMode() <= QueryBuilderResult::RESULT_SELECT_MULTIPLE) {
$this->addSelectionMethod($query, $method);
} else {
$this->addIntResultMethod($query, $method);
}
}
|
[
"private",
"function",
"addMethod",
"(",
"$",
"method",
")",
"{",
"$",
"tokens",
"=",
"$",
"this",
"->",
"methodParser",
"->",
"parse",
"(",
"$",
"method",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"queryBuilder",
"->",
"build",
"(",
"$",
"tokens",
",",
"$",
"this",
"->",
"tableName",
",",
"$",
"this",
"->",
"namingContention",
",",
"$",
"this",
"->",
"entityClass",
")",
";",
"if",
"(",
"$",
"query",
"->",
"getResultMode",
"(",
")",
"<=",
"QueryBuilderResult",
"::",
"RESULT_SELECT_MULTIPLE",
")",
"{",
"$",
"this",
"->",
"addSelectionMethod",
"(",
"$",
"query",
",",
"$",
"method",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addIntResultMethod",
"(",
"$",
"query",
",",
"$",
"method",
")",
";",
"}",
"}"
] |
Parse a dsl method and add it to this repository.
@param $method string the method name
@throws DslSyntaxException
|
[
"Parse",
"a",
"dsl",
"method",
"and",
"add",
"it",
"to",
"this",
"repository",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L201-L211
|
22,090
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.addSelectionMethod
|
private function addSelectionMethod(QueryBuilderResult $query, $methodName)
{
$findMethod = function () use ($query, $methodName) {
$sth = $this->pdo->prepare($query->getSql());
/** @noinspection PhpMethodParametersCountMismatchInspection */
$sth->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass->getName());
try {
$sth->execute(func_get_args());
} catch (PDOException $e) {
throw new DslSyntaxException('Failed to run query [' . $methodName . '] with parameters ' . print_r(func_get_args(), true));
}
switch ($query->getResultMode()) {
case QueryBuilderResult::RESULT_SELECT_SINGLE:
return $sth->fetch();
case QueryBuilderResult::RESULT_SELECT_MULTIPLE:
return $sth->fetchAll();
}
throw new DslSyntaxException('Result Mode ' . $query->getResultMode() . ' is not implemented', DATADO_ILLEGAL_RESULT_MODE);
};
$this->methods[$methodName] = \Closure::bind($findMethod, $this, get_class());
}
|
php
|
private function addSelectionMethod(QueryBuilderResult $query, $methodName)
{
$findMethod = function () use ($query, $methodName) {
$sth = $this->pdo->prepare($query->getSql());
/** @noinspection PhpMethodParametersCountMismatchInspection */
$sth->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass->getName());
try {
$sth->execute(func_get_args());
} catch (PDOException $e) {
throw new DslSyntaxException('Failed to run query [' . $methodName . '] with parameters ' . print_r(func_get_args(), true));
}
switch ($query->getResultMode()) {
case QueryBuilderResult::RESULT_SELECT_SINGLE:
return $sth->fetch();
case QueryBuilderResult::RESULT_SELECT_MULTIPLE:
return $sth->fetchAll();
}
throw new DslSyntaxException('Result Mode ' . $query->getResultMode() . ' is not implemented', DATADO_ILLEGAL_RESULT_MODE);
};
$this->methods[$methodName] = \Closure::bind($findMethod, $this, get_class());
}
|
[
"private",
"function",
"addSelectionMethod",
"(",
"QueryBuilderResult",
"$",
"query",
",",
"$",
"methodName",
")",
"{",
"$",
"findMethod",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"query",
",",
"$",
"methodName",
")",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"$",
"query",
"->",
"getSql",
"(",
")",
")",
";",
"/** @noinspection PhpMethodParametersCountMismatchInspection */",
"$",
"sth",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"this",
"->",
"entityClass",
"->",
"getName",
"(",
")",
")",
";",
"try",
"{",
"$",
"sth",
"->",
"execute",
"(",
"func_get_args",
"(",
")",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"new",
"DslSyntaxException",
"(",
"'Failed to run query ['",
".",
"$",
"methodName",
".",
"'] with parameters '",
".",
"print_r",
"(",
"func_get_args",
"(",
")",
",",
"true",
")",
")",
";",
"}",
"switch",
"(",
"$",
"query",
"->",
"getResultMode",
"(",
")",
")",
"{",
"case",
"QueryBuilderResult",
"::",
"RESULT_SELECT_SINGLE",
":",
"return",
"$",
"sth",
"->",
"fetch",
"(",
")",
";",
"case",
"QueryBuilderResult",
"::",
"RESULT_SELECT_MULTIPLE",
":",
"return",
"$",
"sth",
"->",
"fetchAll",
"(",
")",
";",
"}",
"throw",
"new",
"DslSyntaxException",
"(",
"'Result Mode '",
".",
"$",
"query",
"->",
"getResultMode",
"(",
")",
".",
"' is not implemented'",
",",
"DATADO_ILLEGAL_RESULT_MODE",
")",
";",
"}",
";",
"$",
"this",
"->",
"methods",
"[",
"$",
"methodName",
"]",
"=",
"\\",
"Closure",
"::",
"bind",
"(",
"$",
"findMethod",
",",
"$",
"this",
",",
"get_class",
"(",
")",
")",
";",
"}"
] |
Add a method that can either result in an entity or an array of entities.
@param $query QueryBuilderResult a parsed query
@param $methodName string the name of the dsl method
@throws DslSyntaxException if an unsupported result mode was requested
|
[
"Add",
"a",
"method",
"that",
"can",
"either",
"result",
"in",
"an",
"entity",
"or",
"an",
"array",
"of",
"entities",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L219-L244
|
22,091
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.addIntResultMethod
|
private function addIntResultMethod(QueryBuilderResult $query, $methodName)
{
$intResultMethod = function () use ($query) {
$sth = $this->pdo->prepare($query->getSql());
$sth->execute(func_get_args());
return $sth->rowCount();
};
$this->methods[$methodName] = \Closure::bind($intResultMethod, $this, get_class());
}
|
php
|
private function addIntResultMethod(QueryBuilderResult $query, $methodName)
{
$intResultMethod = function () use ($query) {
$sth = $this->pdo->prepare($query->getSql());
$sth->execute(func_get_args());
return $sth->rowCount();
};
$this->methods[$methodName] = \Closure::bind($intResultMethod, $this, get_class());
}
|
[
"private",
"function",
"addIntResultMethod",
"(",
"QueryBuilderResult",
"$",
"query",
",",
"$",
"methodName",
")",
"{",
"$",
"intResultMethod",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"query",
")",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"$",
"query",
"->",
"getSql",
"(",
")",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"sth",
"->",
"rowCount",
"(",
")",
";",
"}",
";",
"$",
"this",
"->",
"methods",
"[",
"$",
"methodName",
"]",
"=",
"\\",
"Closure",
"::",
"bind",
"(",
"$",
"intResultMethod",
",",
"$",
"this",
",",
"get_class",
"(",
")",
")",
";",
"}"
] |
Add a new method that will result in an integer.
@param $query QueryBuilderResult a parsed dsl query
@param $methodName string the name of the method
|
[
"Add",
"a",
"new",
"method",
"that",
"will",
"result",
"in",
"an",
"integer",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L251-L260
|
22,092
|
DataDo/data
|
src/main/php/DataDo/Data/Repository.php
|
Repository.checkDatabase
|
public function checkDatabase($showAllData = true)
{
switch ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql':
$sth = $this->pdo->prepare('SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?');
$sth->execute(array($this->tableName));
$columnNameColumn = 'COLUMN_NAME';
break;
case 'sqlite':
$sth = $this->pdo->prepare("PRAGMA table_info($this->tableName)");
$sth->execute();
$columnNameColumn = 'name';
break;
default:
echo '<p>SQL Driver: ' . $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME) . ' is not supported by the checking tool... sorry</p>' . PHP_EOL;
return;
}
$tableProperties = $sth->fetchAll();
$classProperties = $this->entityClass->getProperties();
$properties = [];
foreach ($tableProperties as $prop) {
$newProp = new stdClass();
$newProp->actualColumnName = $prop[$columnNameColumn];
$properties[$newProp->actualColumnName] = $newProp;
}
foreach ($classProperties as $prop) {
$expectedColumnName = $this->namingContention->propertyToColumnName($prop);
if (array_key_exists($expectedColumnName, $properties)) {
$newProp = $properties[$expectedColumnName];
} else {
$newProp = new stdClass();
$properties[$expectedColumnName] = $newProp;
}
$newProp->propertyName = $prop->getName();
$newProp->expectedColumnName = $expectedColumnName;
}
$issetOr = function (&$value, $default = '') {
return isset($value) ? $value : $default;
};
$pdoAtt = function ($att) {
try {
return $this->pdo->getAttribute($att);
} catch (PDOException $e) {
return 'Not supported by driver';
}
};
$getClass = function (stdClass $prop) use ($issetOr) {
$classes = $issetOr($prop->expectedColumnName) === $issetOr($prop->actualColumnName) ? 'correct' : 'error';
if ($issetOr($prop->propertyName) === $this->idProperty->getName()) {
$classes .= ' primary-key';
}
return $classes;
};
$entitiesError = false;
$entities = [];
if ($showAllData) {
try {
$entities = $this->findAll();
} catch (\Exception $e) {
$entitiesError = $e;
}
}
include 'Check/checkDatabaseTable.php';
}
|
php
|
public function checkDatabase($showAllData = true)
{
switch ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql':
$sth = $this->pdo->prepare('SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?');
$sth->execute(array($this->tableName));
$columnNameColumn = 'COLUMN_NAME';
break;
case 'sqlite':
$sth = $this->pdo->prepare("PRAGMA table_info($this->tableName)");
$sth->execute();
$columnNameColumn = 'name';
break;
default:
echo '<p>SQL Driver: ' . $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME) . ' is not supported by the checking tool... sorry</p>' . PHP_EOL;
return;
}
$tableProperties = $sth->fetchAll();
$classProperties = $this->entityClass->getProperties();
$properties = [];
foreach ($tableProperties as $prop) {
$newProp = new stdClass();
$newProp->actualColumnName = $prop[$columnNameColumn];
$properties[$newProp->actualColumnName] = $newProp;
}
foreach ($classProperties as $prop) {
$expectedColumnName = $this->namingContention->propertyToColumnName($prop);
if (array_key_exists($expectedColumnName, $properties)) {
$newProp = $properties[$expectedColumnName];
} else {
$newProp = new stdClass();
$properties[$expectedColumnName] = $newProp;
}
$newProp->propertyName = $prop->getName();
$newProp->expectedColumnName = $expectedColumnName;
}
$issetOr = function (&$value, $default = '') {
return isset($value) ? $value : $default;
};
$pdoAtt = function ($att) {
try {
return $this->pdo->getAttribute($att);
} catch (PDOException $e) {
return 'Not supported by driver';
}
};
$getClass = function (stdClass $prop) use ($issetOr) {
$classes = $issetOr($prop->expectedColumnName) === $issetOr($prop->actualColumnName) ? 'correct' : 'error';
if ($issetOr($prop->propertyName) === $this->idProperty->getName()) {
$classes .= ' primary-key';
}
return $classes;
};
$entitiesError = false;
$entities = [];
if ($showAllData) {
try {
$entities = $this->findAll();
} catch (\Exception $e) {
$entitiesError = $e;
}
}
include 'Check/checkDatabaseTable.php';
}
|
[
"public",
"function",
"checkDatabase",
"(",
"$",
"showAllData",
"=",
"true",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"pdo",
"->",
"getAttribute",
"(",
"PDO",
"::",
"ATTR_DRIVER_NAME",
")",
")",
"{",
"case",
"'mysql'",
":",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"'SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?'",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
"array",
"(",
"$",
"this",
"->",
"tableName",
")",
")",
";",
"$",
"columnNameColumn",
"=",
"'COLUMN_NAME'",
";",
"break",
";",
"case",
"'sqlite'",
":",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"\"PRAGMA table_info($this->tableName)\"",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
")",
";",
"$",
"columnNameColumn",
"=",
"'name'",
";",
"break",
";",
"default",
":",
"echo",
"'<p>SQL Driver: '",
".",
"$",
"this",
"->",
"pdo",
"->",
"getAttribute",
"(",
"PDO",
"::",
"ATTR_DRIVER_NAME",
")",
".",
"' is not supported by the checking tool... sorry</p>'",
".",
"PHP_EOL",
";",
"return",
";",
"}",
"$",
"tableProperties",
"=",
"$",
"sth",
"->",
"fetchAll",
"(",
")",
";",
"$",
"classProperties",
"=",
"$",
"this",
"->",
"entityClass",
"->",
"getProperties",
"(",
")",
";",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tableProperties",
"as",
"$",
"prop",
")",
"{",
"$",
"newProp",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"newProp",
"->",
"actualColumnName",
"=",
"$",
"prop",
"[",
"$",
"columnNameColumn",
"]",
";",
"$",
"properties",
"[",
"$",
"newProp",
"->",
"actualColumnName",
"]",
"=",
"$",
"newProp",
";",
"}",
"foreach",
"(",
"$",
"classProperties",
"as",
"$",
"prop",
")",
"{",
"$",
"expectedColumnName",
"=",
"$",
"this",
"->",
"namingContention",
"->",
"propertyToColumnName",
"(",
"$",
"prop",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"expectedColumnName",
",",
"$",
"properties",
")",
")",
"{",
"$",
"newProp",
"=",
"$",
"properties",
"[",
"$",
"expectedColumnName",
"]",
";",
"}",
"else",
"{",
"$",
"newProp",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"properties",
"[",
"$",
"expectedColumnName",
"]",
"=",
"$",
"newProp",
";",
"}",
"$",
"newProp",
"->",
"propertyName",
"=",
"$",
"prop",
"->",
"getName",
"(",
")",
";",
"$",
"newProp",
"->",
"expectedColumnName",
"=",
"$",
"expectedColumnName",
";",
"}",
"$",
"issetOr",
"=",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"default",
"=",
"''",
")",
"{",
"return",
"isset",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"$",
"default",
";",
"}",
";",
"$",
"pdoAtt",
"=",
"function",
"(",
"$",
"att",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"pdo",
"->",
"getAttribute",
"(",
"$",
"att",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"return",
"'Not supported by driver'",
";",
"}",
"}",
";",
"$",
"getClass",
"=",
"function",
"(",
"stdClass",
"$",
"prop",
")",
"use",
"(",
"$",
"issetOr",
")",
"{",
"$",
"classes",
"=",
"$",
"issetOr",
"(",
"$",
"prop",
"->",
"expectedColumnName",
")",
"===",
"$",
"issetOr",
"(",
"$",
"prop",
"->",
"actualColumnName",
")",
"?",
"'correct'",
":",
"'error'",
";",
"if",
"(",
"$",
"issetOr",
"(",
"$",
"prop",
"->",
"propertyName",
")",
"===",
"$",
"this",
"->",
"idProperty",
"->",
"getName",
"(",
")",
")",
"{",
"$",
"classes",
".=",
"' primary-key'",
";",
"}",
"return",
"$",
"classes",
";",
"}",
";",
"$",
"entitiesError",
"=",
"false",
";",
"$",
"entities",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"showAllData",
")",
"{",
"try",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"findAll",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"entitiesError",
"=",
"$",
"e",
";",
"}",
"}",
"include",
"'Check/checkDatabaseTable.php'",
";",
"}"
] |
This method will run some analysis on the correctness of your configuration. It will be exported to the screen.
@param boolean $showAllData set this to false if you want to hide the entities row
|
[
"This",
"method",
"will",
"run",
"some",
"analysis",
"on",
"the",
"correctness",
"of",
"your",
"configuration",
".",
"It",
"will",
"be",
"exported",
"to",
"the",
"screen",
"."
] |
555b02a27755032fcd53e165b0674e81a68067c0
|
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Repository.php#L285-L359
|
22,093
|
f3ath/lazypdo
|
src/LazyPDO.php
|
LazyPDO.getPDO
|
protected function getPDO()
{
if (null === $this->pdo) {
$this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options);
}
return $this->pdo;
}
|
php
|
protected function getPDO()
{
if (null === $this->pdo) {
$this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options);
}
return $this->pdo;
}
|
[
"protected",
"function",
"getPDO",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"pdo",
")",
"{",
"$",
"this",
"->",
"pdo",
"=",
"new",
"\\",
"PDO",
"(",
"$",
"this",
"->",
"dsn",
",",
"$",
"this",
"->",
"user",
",",
"$",
"this",
"->",
"password",
",",
"$",
"this",
"->",
"options",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pdo",
";",
"}"
] |
Get PDO object. Cache the result
@return \PDO
|
[
"Get",
"PDO",
"object",
".",
"Cache",
"the",
"result"
] |
0ebdb3bc87d327d68a322d5fca049f4c21865928
|
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/LazyPDO.php#L43-L49
|
22,094
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/ServiceProvider.php
|
ServiceProvider.register
|
public function register(Application $app)
{
$app['parser.example.finder'] = new Example\Finder();
$this->addCache($app);
$this->addAssemblers($app);
$this->addFilters($app);
$this->addValidators($app);
$this->addBuilder($app);
// I would prefer to extend it but due to a circular reference will pimple fatal
$this->attachFiltersToManager($app['descriptor.filter'], $app);
$app['descriptor.analyzer'] = function () {
return new ProjectAnalyzer();
};
}
|
php
|
public function register(Application $app)
{
$app['parser.example.finder'] = new Example\Finder();
$this->addCache($app);
$this->addAssemblers($app);
$this->addFilters($app);
$this->addValidators($app);
$this->addBuilder($app);
// I would prefer to extend it but due to a circular reference will pimple fatal
$this->attachFiltersToManager($app['descriptor.filter'], $app);
$app['descriptor.analyzer'] = function () {
return new ProjectAnalyzer();
};
}
|
[
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'parser.example.finder'",
"]",
"=",
"new",
"Example",
"\\",
"Finder",
"(",
")",
";",
"$",
"this",
"->",
"addCache",
"(",
"$",
"app",
")",
";",
"$",
"this",
"->",
"addAssemblers",
"(",
"$",
"app",
")",
";",
"$",
"this",
"->",
"addFilters",
"(",
"$",
"app",
")",
";",
"$",
"this",
"->",
"addValidators",
"(",
"$",
"app",
")",
";",
"$",
"this",
"->",
"addBuilder",
"(",
"$",
"app",
")",
";",
"// I would prefer to extend it but due to a circular reference will pimple fatal",
"$",
"this",
"->",
"attachFiltersToManager",
"(",
"$",
"app",
"[",
"'descriptor.filter'",
"]",
",",
"$",
"app",
")",
";",
"$",
"app",
"[",
"'descriptor.analyzer'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"new",
"ProjectAnalyzer",
"(",
")",
";",
"}",
";",
"}"
] |
Adds the services needed to build the descriptors.
@param Application $app An Application instance
@return void
|
[
"Adds",
"the",
"services",
"needed",
"to",
"build",
"the",
"descriptors",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L89-L105
|
22,095
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/ServiceProvider.php
|
ServiceProvider.attachFiltersToManager
|
public function attachFiltersToManager(Filter $filterManager, Application $app)
{
$stripOnVisibility = new StripOnVisibility($app['descriptor.builder']);
$filtersOnAllDescriptors = array(
new StripInternal($app['descriptor.builder']),
new StripIgnore($app['descriptor.builder'])
);
foreach ($filtersOnAllDescriptors as $filter) {
$filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $filter);
}
$filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $stripOnVisibility);
$filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $stripOnVisibility);
return $filterManager;
}
|
php
|
public function attachFiltersToManager(Filter $filterManager, Application $app)
{
$stripOnVisibility = new StripOnVisibility($app['descriptor.builder']);
$filtersOnAllDescriptors = array(
new StripInternal($app['descriptor.builder']),
new StripIgnore($app['descriptor.builder'])
);
foreach ($filtersOnAllDescriptors as $filter) {
$filterManager->attach('phpDocumentor\Descriptor\ConstantDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\FunctionDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\InterfaceDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\TraitDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $filter);
$filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $filter);
}
$filterManager->attach('phpDocumentor\Descriptor\PropertyDescriptor', $stripOnVisibility);
$filterManager->attach('phpDocumentor\Descriptor\MethodDescriptor', $stripOnVisibility);
return $filterManager;
}
|
[
"public",
"function",
"attachFiltersToManager",
"(",
"Filter",
"$",
"filterManager",
",",
"Application",
"$",
"app",
")",
"{",
"$",
"stripOnVisibility",
"=",
"new",
"StripOnVisibility",
"(",
"$",
"app",
"[",
"'descriptor.builder'",
"]",
")",
";",
"$",
"filtersOnAllDescriptors",
"=",
"array",
"(",
"new",
"StripInternal",
"(",
"$",
"app",
"[",
"'descriptor.builder'",
"]",
")",
",",
"new",
"StripIgnore",
"(",
"$",
"app",
"[",
"'descriptor.builder'",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"filtersOnAllDescriptors",
"as",
"$",
"filter",
")",
"{",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\ConstantDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\FunctionDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\InterfaceDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\TraitDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\PropertyDescriptor'",
",",
"$",
"filter",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\MethodDescriptor'",
",",
"$",
"filter",
")",
";",
"}",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\PropertyDescriptor'",
",",
"$",
"stripOnVisibility",
")",
";",
"$",
"filterManager",
"->",
"attach",
"(",
"'phpDocumentor\\Descriptor\\MethodDescriptor'",
",",
"$",
"stripOnVisibility",
")",
";",
"return",
"$",
"filterManager",
";",
"}"
] |
Attaches filters to the manager.
@param Filter $filterManager
@param Application $app
@return Filter
|
[
"Attaches",
"filters",
"to",
"the",
"manager",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L191-L212
|
22,096
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/ServiceProvider.php
|
ServiceProvider.addCache
|
protected function addCache(Application $app)
{
$app['descriptor.cache'] = $app->share(
function () {
$cache = new Filesystem();
$cache->setOptions(
array(
'namespace' => 'phpdoc-cache',
'cache_dir' => sys_get_temp_dir(),
)
);
$plugin = new SerializerPlugin();
if (extension_loaded('igbinary')) {
$options = new PluginOptions();
$options->setSerializer('igbinary');
$plugin->setOptions($options);
}
$cache->addPlugin($plugin);
return $cache;
}
);
}
|
php
|
protected function addCache(Application $app)
{
$app['descriptor.cache'] = $app->share(
function () {
$cache = new Filesystem();
$cache->setOptions(
array(
'namespace' => 'phpdoc-cache',
'cache_dir' => sys_get_temp_dir(),
)
);
$plugin = new SerializerPlugin();
if (extension_loaded('igbinary')) {
$options = new PluginOptions();
$options->setSerializer('igbinary');
$plugin->setOptions($options);
}
$cache->addPlugin($plugin);
return $cache;
}
);
}
|
[
"protected",
"function",
"addCache",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'descriptor.cache'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
")",
"{",
"$",
"cache",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"cache",
"->",
"setOptions",
"(",
"array",
"(",
"'namespace'",
"=>",
"'phpdoc-cache'",
",",
"'cache_dir'",
"=>",
"sys_get_temp_dir",
"(",
")",
",",
")",
")",
";",
"$",
"plugin",
"=",
"new",
"SerializerPlugin",
"(",
")",
";",
"if",
"(",
"extension_loaded",
"(",
"'igbinary'",
")",
")",
"{",
"$",
"options",
"=",
"new",
"PluginOptions",
"(",
")",
";",
"$",
"options",
"->",
"setSerializer",
"(",
"'igbinary'",
")",
";",
"$",
"plugin",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"}",
"$",
"cache",
"->",
"addPlugin",
"(",
"$",
"plugin",
")",
";",
"return",
"$",
"cache",
";",
"}",
")",
";",
"}"
] |
Adds the caching mechanism to the dependency injection container with key 'descriptor.cache'.
@param Application $app
@return void
|
[
"Adds",
"the",
"caching",
"mechanism",
"to",
"the",
"dependency",
"injection",
"container",
"with",
"key",
"descriptor",
".",
"cache",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L281-L306
|
22,097
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/ServiceProvider.php
|
ServiceProvider.addBuilder
|
protected function addBuilder(Application $app)
{
if (extension_loaded('igbinary')) {
$app['descriptor.builder.serializer'] = 'IgBinary';
} else {
$app['descriptor.builder.serializer'] = 'PhpSerialize';
}
$app['descriptor.builder'] = $app->share(
function ($container) {
$builder = new ProjectDescriptorBuilder(
$container['descriptor.builder.assembler.factory'],
$container['descriptor.filter'],
$container['validator']
);
$builder->setTranslator($container['translator']);
return $builder;
}
);
}
|
php
|
protected function addBuilder(Application $app)
{
if (extension_loaded('igbinary')) {
$app['descriptor.builder.serializer'] = 'IgBinary';
} else {
$app['descriptor.builder.serializer'] = 'PhpSerialize';
}
$app['descriptor.builder'] = $app->share(
function ($container) {
$builder = new ProjectDescriptorBuilder(
$container['descriptor.builder.assembler.factory'],
$container['descriptor.filter'],
$container['validator']
);
$builder->setTranslator($container['translator']);
return $builder;
}
);
}
|
[
"protected",
"function",
"addBuilder",
"(",
"Application",
"$",
"app",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"'igbinary'",
")",
")",
"{",
"$",
"app",
"[",
"'descriptor.builder.serializer'",
"]",
"=",
"'IgBinary'",
";",
"}",
"else",
"{",
"$",
"app",
"[",
"'descriptor.builder.serializer'",
"]",
"=",
"'PhpSerialize'",
";",
"}",
"$",
"app",
"[",
"'descriptor.builder'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"container",
")",
"{",
"$",
"builder",
"=",
"new",
"ProjectDescriptorBuilder",
"(",
"$",
"container",
"[",
"'descriptor.builder.assembler.factory'",
"]",
",",
"$",
"container",
"[",
"'descriptor.filter'",
"]",
",",
"$",
"container",
"[",
"'validator'",
"]",
")",
";",
"$",
"builder",
"->",
"setTranslator",
"(",
"$",
"container",
"[",
"'translator'",
"]",
")",
";",
"return",
"$",
"builder",
";",
"}",
")",
";",
"}"
] |
Adds the Building mechanism using the key 'descriptor.builder'.
Please note that the type of serializer can be configured using the parameter 'descriptor.builder.serializer'; it
accepts any parameter that Zend\Serializer supports.
@param Application $app
@return void
|
[
"Adds",
"the",
"Building",
"mechanism",
"using",
"the",
"key",
"descriptor",
".",
"builder",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L318-L338
|
22,098
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/ServiceProvider.php
|
ServiceProvider.addAssemblers
|
protected function addAssemblers(Application $app)
{
$app['descriptor.builder.assembler.factory'] = $app->share(
function () {
return new AssemblerFactory();
}
);
$provider = $this;
$app['descriptor.builder.assembler.factory'] = $app->share(
$app->extend(
'descriptor.builder.assembler.factory',
function ($factory) use ($provider, $app) {
return $provider->attachAssemblersToFactory($factory, $app);
}
)
);
}
|
php
|
protected function addAssemblers(Application $app)
{
$app['descriptor.builder.assembler.factory'] = $app->share(
function () {
return new AssemblerFactory();
}
);
$provider = $this;
$app['descriptor.builder.assembler.factory'] = $app->share(
$app->extend(
'descriptor.builder.assembler.factory',
function ($factory) use ($provider, $app) {
return $provider->attachAssemblersToFactory($factory, $app);
}
)
);
}
|
[
"protected",
"function",
"addAssemblers",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'descriptor.builder.assembler.factory'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
")",
"{",
"return",
"new",
"AssemblerFactory",
"(",
")",
";",
"}",
")",
";",
"$",
"provider",
"=",
"$",
"this",
";",
"$",
"app",
"[",
"'descriptor.builder.assembler.factory'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"$",
"app",
"->",
"extend",
"(",
"'descriptor.builder.assembler.factory'",
",",
"function",
"(",
"$",
"factory",
")",
"use",
"(",
"$",
"provider",
",",
"$",
"app",
")",
"{",
"return",
"$",
"provider",
"->",
"attachAssemblersToFactory",
"(",
"$",
"factory",
",",
"$",
"app",
")",
";",
"}",
")",
")",
";",
"}"
] |
Adds the assembler factory and attaches the basic assemblers with key 'descriptor.builder.assembler.factory'.
@param Application $app
@return void
|
[
"Adds",
"the",
"assembler",
"factory",
"and",
"attaches",
"the",
"basic",
"assemblers",
"with",
"key",
"descriptor",
".",
"builder",
".",
"assembler",
".",
"factory",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L347-L364
|
22,099
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/ServiceProvider.php
|
ServiceProvider.addValidators
|
protected function addValidators(Application $app)
{
if (!isset($app['validator'])) {
throw new Exception\MissingDependencyException('The validator manager is missing');
}
$provider = $this;
$app['validator'] = $app->share(
$app->extend(
'validator',
function ($validatorManager) use ($provider) {
return $provider->attachValidators($validatorManager);
}
)
);
}
|
php
|
protected function addValidators(Application $app)
{
if (!isset($app['validator'])) {
throw new Exception\MissingDependencyException('The validator manager is missing');
}
$provider = $this;
$app['validator'] = $app->share(
$app->extend(
'validator',
function ($validatorManager) use ($provider) {
return $provider->attachValidators($validatorManager);
}
)
);
}
|
[
"protected",
"function",
"addValidators",
"(",
"Application",
"$",
"app",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"app",
"[",
"'validator'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"MissingDependencyException",
"(",
"'The validator manager is missing'",
")",
";",
"}",
"$",
"provider",
"=",
"$",
"this",
";",
"$",
"app",
"[",
"'validator'",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"$",
"app",
"->",
"extend",
"(",
"'validator'",
",",
"function",
"(",
"$",
"validatorManager",
")",
"use",
"(",
"$",
"provider",
")",
"{",
"return",
"$",
"provider",
"->",
"attachValidators",
"(",
"$",
"validatorManager",
")",
";",
"}",
")",
")",
";",
"}"
] |
Adds validators for the descriptors to the validator manager.
@param Application $app
@throws Exception\MissingDependencyException if the validator could not be found.
@return void
|
[
"Adds",
"validators",
"for",
"the",
"descriptors",
"to",
"the",
"validator",
"manager",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/ServiceProvider.php#L394-L409
|
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.