id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
20,200 |
legalthings/permission-matcher
|
src/PermissionMatcher.php
|
PermissionMatcher.getStringQueryParameters
|
protected function getStringQueryParameters($string)
{
$query = parse_url($string, PHP_URL_QUERY);
$params = [];
if ($query) parse_str($query, $params);
return $params;
}
|
php
|
protected function getStringQueryParameters($string)
{
$query = parse_url($string, PHP_URL_QUERY);
$params = [];
if ($query) parse_str($query, $params);
return $params;
}
|
[
"protected",
"function",
"getStringQueryParameters",
"(",
"$",
"string",
")",
"{",
"$",
"query",
"=",
"parse_url",
"(",
"$",
"string",
",",
"PHP_URL_QUERY",
")",
";",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"query",
")",
"parse_str",
"(",
"$",
"query",
",",
"$",
"params",
")",
";",
"return",
"$",
"params",
";",
"}"
] |
Get the query parameters used in a string
@param string $string
@return array
|
[
"Get",
"the",
"query",
"parameters",
"used",
"in",
"a",
"string"
] |
fbfa925e92406fe9dac83b387be47931e6de0f81
|
https://github.com/legalthings/permission-matcher/blob/fbfa925e92406fe9dac83b387be47931e6de0f81/src/PermissionMatcher.php#L165-L173
|
20,201 |
legalthings/permission-matcher
|
src/PermissionMatcher.php
|
PermissionMatcher.flatten
|
protected function flatten($input)
{
$list = [];
foreach ($input as $item) {
$list = array_merge($list, (array)$item);
}
return array_unique($list);
}
|
php
|
protected function flatten($input)
{
$list = [];
foreach ($input as $item) {
$list = array_merge($list, (array)$item);
}
return array_unique($list);
}
|
[
"protected",
"function",
"flatten",
"(",
"$",
"input",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"item",
")",
"{",
"$",
"list",
"=",
"array_merge",
"(",
"$",
"list",
",",
"(",
"array",
")",
"$",
"item",
")",
";",
"}",
"return",
"array_unique",
"(",
"$",
"list",
")",
";",
"}"
] |
Turn a 2 dimensional privilege array into a list of privileges
@param array $input
@return array
|
[
"Turn",
"a",
"2",
"dimensional",
"privilege",
"array",
"into",
"a",
"list",
"of",
"privileges"
] |
fbfa925e92406fe9dac83b387be47931e6de0f81
|
https://github.com/legalthings/permission-matcher/blob/fbfa925e92406fe9dac83b387be47931e6de0f81/src/PermissionMatcher.php#L182-L191
|
20,202 |
legalthings/permission-matcher
|
src/PermissionMatcher.php
|
PermissionMatcher.addAuthzGroupsToPrivileges
|
protected function addAuthzGroupsToPrivileges(array $privileges, $authzGroupsPrivileges, array $authzGroups)
{
$authzGroupsPrivileges = !is_string($authzGroupsPrivileges) ? $authzGroupsPrivileges : [$authzGroupsPrivileges];
foreach($authzGroupsPrivileges as $privilege) {
$current = !empty($privileges[$privilege]) ? $privileges[$privilege] : [];
$privileges[$privilege] = array_unique(array_merge($current, $authzGroups));
}
return $privileges;
}
|
php
|
protected function addAuthzGroupsToPrivileges(array $privileges, $authzGroupsPrivileges, array $authzGroups)
{
$authzGroupsPrivileges = !is_string($authzGroupsPrivileges) ? $authzGroupsPrivileges : [$authzGroupsPrivileges];
foreach($authzGroupsPrivileges as $privilege) {
$current = !empty($privileges[$privilege]) ? $privileges[$privilege] : [];
$privileges[$privilege] = array_unique(array_merge($current, $authzGroups));
}
return $privileges;
}
|
[
"protected",
"function",
"addAuthzGroupsToPrivileges",
"(",
"array",
"$",
"privileges",
",",
"$",
"authzGroupsPrivileges",
",",
"array",
"$",
"authzGroups",
")",
"{",
"$",
"authzGroupsPrivileges",
"=",
"!",
"is_string",
"(",
"$",
"authzGroupsPrivileges",
")",
"?",
"$",
"authzGroupsPrivileges",
":",
"[",
"$",
"authzGroupsPrivileges",
"]",
";",
"foreach",
"(",
"$",
"authzGroupsPrivileges",
"as",
"$",
"privilege",
")",
"{",
"$",
"current",
"=",
"!",
"empty",
"(",
"$",
"privileges",
"[",
"$",
"privilege",
"]",
")",
"?",
"$",
"privileges",
"[",
"$",
"privilege",
"]",
":",
"[",
"]",
";",
"$",
"privileges",
"[",
"$",
"privilege",
"]",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"current",
",",
"$",
"authzGroups",
")",
")",
";",
"}",
"return",
"$",
"privileges",
";",
"}"
] |
Populate an array of privileges with their corresponding authz groups
@param array $privileges The resulting array
@param string|array $authzGroupsPrivileges The privileges that the authzgroup has
@param array $authzGroups
@return array $privileges
|
[
"Populate",
"an",
"array",
"of",
"privileges",
"with",
"their",
"corresponding",
"authz",
"groups"
] |
fbfa925e92406fe9dac83b387be47931e6de0f81
|
https://github.com/legalthings/permission-matcher/blob/fbfa925e92406fe9dac83b387be47931e6de0f81/src/PermissionMatcher.php#L201-L211
|
20,203 |
lukasz-adamski/teamspeak3-framework
|
src/TeamSpeak3/Helper/Str.php
|
Str.fromHex
|
public static function fromHex($hex)
{
$string = "";
if(strlen($hex)%2 == 1)
{
throw new Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
}
foreach(str_split($hex, 2) as $chunk)
{
$string .= chr(hexdec($chunk));
}
return new self($string);
}
|
php
|
public static function fromHex($hex)
{
$string = "";
if(strlen($hex)%2 == 1)
{
throw new Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
}
foreach(str_split($hex, 2) as $chunk)
{
$string .= chr(hexdec($chunk));
}
return new self($string);
}
|
[
"public",
"static",
"function",
"fromHex",
"(",
"$",
"hex",
")",
"{",
"$",
"string",
"=",
"\"\"",
";",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"%",
"2",
"==",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"given parameter '\"",
".",
"$",
"hex",
".",
"\"' is not a valid hexadecimal number\"",
")",
";",
"}",
"foreach",
"(",
"str_split",
"(",
"$",
"hex",
",",
"2",
")",
"as",
"$",
"chunk",
")",
"{",
"$",
"string",
".=",
"chr",
"(",
"hexdec",
"(",
"$",
"chunk",
")",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"string",
")",
";",
"}"
] |
Returns the Str based on a given hex value.
@param string $hex
@throws Exception
@return Str
|
[
"Returns",
"the",
"Str",
"based",
"on",
"a",
"given",
"hex",
"value",
"."
] |
39a56eca608da6b56b6aa386a7b5b31dc576c41a
|
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Str.php#L529-L544
|
20,204 |
skmetaly/laravel-twitch-restful-api
|
src/API/BaseApi.php
|
BaseApi.createRequest
|
protected function createRequest($type, $url, $token)
{
return $this->client->createRequest($type, $url, $this->getDefaultHeaders($token));
}
|
php
|
protected function createRequest($type, $url, $token)
{
return $this->client->createRequest($type, $url, $this->getDefaultHeaders($token));
}
|
[
"protected",
"function",
"createRequest",
"(",
"$",
"type",
",",
"$",
"url",
",",
"$",
"token",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"createRequest",
"(",
"$",
"type",
",",
"$",
"url",
",",
"$",
"this",
"->",
"getDefaultHeaders",
"(",
"$",
"token",
")",
")",
";",
"}"
] |
Creates an authorized request
@param $type
@param $url
@param $token
@return \GuzzleHttp\Message\Request|\GuzzleHttp\Message\RequestInterface
|
[
"Creates",
"an",
"authorized",
"request"
] |
70c83e441deb411ade2e343ad5cb0339c90dc6c2
|
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/BaseApi.php#L82-L85
|
20,205 |
NuclearCMS/Hierarchy
|
src/Builders/BuilderService.php
|
BuilderService.buildTable
|
public function buildTable($name, $id)
{
$this->modelBuilder->build($name);
$this->formBuilder->build($name);
$migration = $this->migrationBuilder->buildSourceTableMigration($name);
$this->migrateUp($migration);
}
|
php
|
public function buildTable($name, $id)
{
$this->modelBuilder->build($name);
$this->formBuilder->build($name);
$migration = $this->migrationBuilder->buildSourceTableMigration($name);
$this->migrateUp($migration);
}
|
[
"public",
"function",
"buildTable",
"(",
"$",
"name",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"modelBuilder",
"->",
"build",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"formBuilder",
"->",
"build",
"(",
"$",
"name",
")",
";",
"$",
"migration",
"=",
"$",
"this",
"->",
"migrationBuilder",
"->",
"buildSourceTableMigration",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"migrateUp",
"(",
"$",
"migration",
")",
";",
"}"
] |
Builds a source table and associated entities
@param string $name
@param int $id
|
[
"Builds",
"a",
"source",
"table",
"and",
"associated",
"entities"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/BuilderService.php#L50-L57
|
20,206 |
NuclearCMS/Hierarchy
|
src/Builders/BuilderService.php
|
BuilderService.buildField
|
public function buildField($name, $type, $indexed, $tableName, NodeTypeContract $nodeType)
{
$this->modelBuilder->build($tableName, $nodeType->getFields());
$this->buildForm($nodeType);
$migration = $this->migrationBuilder->buildFieldMigrationForTable($name, $type, $indexed, $tableName);
$this->migrateUp($migration);
}
|
php
|
public function buildField($name, $type, $indexed, $tableName, NodeTypeContract $nodeType)
{
$this->modelBuilder->build($tableName, $nodeType->getFields());
$this->buildForm($nodeType);
$migration = $this->migrationBuilder->buildFieldMigrationForTable($name, $type, $indexed, $tableName);
$this->migrateUp($migration);
}
|
[
"public",
"function",
"buildField",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"indexed",
",",
"$",
"tableName",
",",
"NodeTypeContract",
"$",
"nodeType",
")",
"{",
"$",
"this",
"->",
"modelBuilder",
"->",
"build",
"(",
"$",
"tableName",
",",
"$",
"nodeType",
"->",
"getFields",
"(",
")",
")",
";",
"$",
"this",
"->",
"buildForm",
"(",
"$",
"nodeType",
")",
";",
"$",
"migration",
"=",
"$",
"this",
"->",
"migrationBuilder",
"->",
"buildFieldMigrationForTable",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"indexed",
",",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"migrateUp",
"(",
"$",
"migration",
")",
";",
"}"
] |
Builds a field on a source table and associated entities
@param string $name
@param string $type
@param bool $indexed
@param string $tableName
@param NodeTypeContract $nodeType
|
[
"Builds",
"a",
"field",
"on",
"a",
"source",
"table",
"and",
"associated",
"entities"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/BuilderService.php#L68-L75
|
20,207 |
NuclearCMS/Hierarchy
|
src/Builders/BuilderService.php
|
BuilderService.destroyTable
|
public function destroyTable($name, array $fields, $id)
{
$this->modelBuilder->destroy($name);
$this->formBuilder->destroy($name);
$migration = $this->migrationBuilder
->getMigrationClassPathByKey($name);
$this->migrateDown($migration);
$this->migrationBuilder->destroySourceTableMigration($name, $fields);
}
|
php
|
public function destroyTable($name, array $fields, $id)
{
$this->modelBuilder->destroy($name);
$this->formBuilder->destroy($name);
$migration = $this->migrationBuilder
->getMigrationClassPathByKey($name);
$this->migrateDown($migration);
$this->migrationBuilder->destroySourceTableMigration($name, $fields);
}
|
[
"public",
"function",
"destroyTable",
"(",
"$",
"name",
",",
"array",
"$",
"fields",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"modelBuilder",
"->",
"destroy",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"formBuilder",
"->",
"destroy",
"(",
"$",
"name",
")",
";",
"$",
"migration",
"=",
"$",
"this",
"->",
"migrationBuilder",
"->",
"getMigrationClassPathByKey",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"migrateDown",
"(",
"$",
"migration",
")",
";",
"$",
"this",
"->",
"migrationBuilder",
"->",
"destroySourceTableMigration",
"(",
"$",
"name",
",",
"$",
"fields",
")",
";",
"}"
] |
Destroys a source table and all associated entities
@param string $name
@param array $fields
@param int $id
|
[
"Destroys",
"a",
"source",
"table",
"and",
"all",
"associated",
"entities"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/BuilderService.php#L94-L105
|
20,208 |
NuclearCMS/Hierarchy
|
src/Builders/BuilderService.php
|
BuilderService.destroyField
|
public function destroyField($name, $tableName, NodeTypeContract $nodeType)
{
$this->modelBuilder->build($tableName, $nodeType->getFields());
$this->formBuilder->build($tableName, $nodeType->getFields());
$migration = $this->migrationBuilder
->getMigrationClassPathByKey($tableName, $name);
$this->migrateDown($migration);
$this->migrationBuilder->destroyFieldMigrationForTable($name, $tableName);
}
|
php
|
public function destroyField($name, $tableName, NodeTypeContract $nodeType)
{
$this->modelBuilder->build($tableName, $nodeType->getFields());
$this->formBuilder->build($tableName, $nodeType->getFields());
$migration = $this->migrationBuilder
->getMigrationClassPathByKey($tableName, $name);
$this->migrateDown($migration);
$this->migrationBuilder->destroyFieldMigrationForTable($name, $tableName);
}
|
[
"public",
"function",
"destroyField",
"(",
"$",
"name",
",",
"$",
"tableName",
",",
"NodeTypeContract",
"$",
"nodeType",
")",
"{",
"$",
"this",
"->",
"modelBuilder",
"->",
"build",
"(",
"$",
"tableName",
",",
"$",
"nodeType",
"->",
"getFields",
"(",
")",
")",
";",
"$",
"this",
"->",
"formBuilder",
"->",
"build",
"(",
"$",
"tableName",
",",
"$",
"nodeType",
"->",
"getFields",
"(",
")",
")",
";",
"$",
"migration",
"=",
"$",
"this",
"->",
"migrationBuilder",
"->",
"getMigrationClassPathByKey",
"(",
"$",
"tableName",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"migrateDown",
"(",
"$",
"migration",
")",
";",
"$",
"this",
"->",
"migrationBuilder",
"->",
"destroyFieldMigrationForTable",
"(",
"$",
"name",
",",
"$",
"tableName",
")",
";",
"}"
] |
Destroys a field on a source table and all associated entities
@param string $name
@param string $tableName
@param NodeTypeContract $nodeType
|
[
"Destroys",
"a",
"field",
"on",
"a",
"source",
"table",
"and",
"all",
"associated",
"entities"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/BuilderService.php#L114-L125
|
20,209 |
jasny/controller
|
src/Controller/RouteAction.php
|
RouteAction.getFunctionArgs
|
protected function getFunctionArgs(\stdClass $route, \ReflectionFunctionAbstract $refl)
{
$args = [];
$params = $refl->getParameters();
foreach ($params as $param) {
$key = $param->name;
if (property_exists($route, $key)) {
$value = $route->$key;
} else {
if (!$param->isOptional()) {
$fn = $refl instanceof \ReflectionMethod ? $refl->class . '::' . $refl->name : $refl->name;
throw new \RuntimeException("Missing argument '$key' for {$fn}()");
}
$value = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
}
$args[$key] = $value;
}
return $args;
}
|
php
|
protected function getFunctionArgs(\stdClass $route, \ReflectionFunctionAbstract $refl)
{
$args = [];
$params = $refl->getParameters();
foreach ($params as $param) {
$key = $param->name;
if (property_exists($route, $key)) {
$value = $route->$key;
} else {
if (!$param->isOptional()) {
$fn = $refl instanceof \ReflectionMethod ? $refl->class . '::' . $refl->name : $refl->name;
throw new \RuntimeException("Missing argument '$key' for {$fn}()");
}
$value = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
}
$args[$key] = $value;
}
return $args;
}
|
[
"protected",
"function",
"getFunctionArgs",
"(",
"\\",
"stdClass",
"$",
"route",
",",
"\\",
"ReflectionFunctionAbstract",
"$",
"refl",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"$",
"params",
"=",
"$",
"refl",
"->",
"getParameters",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"key",
"=",
"$",
"param",
"->",
"name",
";",
"if",
"(",
"property_exists",
"(",
"$",
"route",
",",
"$",
"key",
")",
")",
"{",
"$",
"value",
"=",
"$",
"route",
"->",
"$",
"key",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"param",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"fn",
"=",
"$",
"refl",
"instanceof",
"\\",
"ReflectionMethod",
"?",
"$",
"refl",
"->",
"class",
".",
"'::'",
".",
"$",
"refl",
"->",
"name",
":",
"$",
"refl",
"->",
"name",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Missing argument '$key' for {$fn}()\"",
")",
";",
"}",
"$",
"value",
"=",
"$",
"param",
"->",
"isDefaultValueAvailable",
"(",
")",
"?",
"$",
"param",
"->",
"getDefaultValue",
"(",
")",
":",
"null",
";",
"}",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"args",
";",
"}"
] |
Get the arguments for a function from a route using reflection
@param \stdClass $route
@param \ReflectionFunctionAbstract $refl
@return array
|
[
"Get",
"the",
"arguments",
"for",
"a",
"function",
"from",
"a",
"route",
"using",
"reflection"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/RouteAction.php#L161-L184
|
20,210 |
42mate/towel
|
src/Towel/Model/User.php
|
User.validateLogin
|
public function validateLogin($email, $password)
{
$password = md5($password);
$result = $this->fetchOne(
"SELECT * FROM {$this->table} WHERE email = ? AND password = ?",
array($email, $password)
);
if (!empty($result)) {
return true;
}
return false;
}
|
php
|
public function validateLogin($email, $password)
{
$password = md5($password);
$result = $this->fetchOne(
"SELECT * FROM {$this->table} WHERE email = ? AND password = ?",
array($email, $password)
);
if (!empty($result)) {
return true;
}
return false;
}
|
[
"public",
"function",
"validateLogin",
"(",
"$",
"email",
",",
"$",
"password",
")",
"{",
"$",
"password",
"=",
"md5",
"(",
"$",
"password",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"fetchOne",
"(",
"\"SELECT * FROM {$this->table} WHERE email = ? AND password = ?\"",
",",
"array",
"(",
"$",
"email",
",",
"$",
"password",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Validates username and password against the DB.
If success sets the user info in the object and return true.
If fails returns false.
@param String $email
@param String $password
@return Boolean
|
[
"Validates",
"username",
"and",
"password",
"against",
"the",
"DB",
".",
"If",
"success",
"sets",
"the",
"user",
"info",
"in",
"the",
"object",
"and",
"return",
"true",
".",
"If",
"fails",
"returns",
"false",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/User.php#L19-L33
|
20,211 |
42mate/towel
|
src/Towel/Model/User.php
|
User.regeneratePassword
|
public function regeneratePassword()
{
$clean_password = generatePassword(6, 4);
$password = md5($clean_password);
$this->db()->executeUpdate(
"UPDATE {$this->table} SET password = ? WHERE ID = ?",
array($password, $this->getId())
);
return $clean_password;
}
|
php
|
public function regeneratePassword()
{
$clean_password = generatePassword(6, 4);
$password = md5($clean_password);
$this->db()->executeUpdate(
"UPDATE {$this->table} SET password = ? WHERE ID = ?",
array($password, $this->getId())
);
return $clean_password;
}
|
[
"public",
"function",
"regeneratePassword",
"(",
")",
"{",
"$",
"clean_password",
"=",
"generatePassword",
"(",
"6",
",",
"4",
")",
";",
"$",
"password",
"=",
"md5",
"(",
"$",
"clean_password",
")",
";",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"executeUpdate",
"(",
"\"UPDATE {$this->table} SET password = ? WHERE ID = ?\"",
",",
"array",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
")",
";",
"return",
"$",
"clean_password",
";",
"}"
] |
Regenerates and sets the new password for a User.
@return String password : The new Password.
|
[
"Regenerates",
"and",
"sets",
"the",
"new",
"password",
"for",
"a",
"User",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/User.php#L70-L80
|
20,212 |
thecodingmachine/security.userservice
|
src/Mouf/Security/UserService/UserService.php
|
UserService.isLogged
|
public function isLogged()
{
$this->byPassIsLogged = true;
try {
// Is a session mechanism available?
if (!session_id()) {
if ($this->sessionManager) {
$this->sessionManager->start();
} else {
throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start().");
}
}
if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) {
return true;
} else {
foreach ($this->authProviders as $provider) {
/* @var $provider AuthenticationProviderInterface */
if ($provider->isLogged($this)) {
return true;
}
}
}
} catch (\Exception $e) {
$this->byPassIsLogged = false;
throw $e;
}
$this->byPassIsLogged = false;
return false;
}
|
php
|
public function isLogged()
{
$this->byPassIsLogged = true;
try {
// Is a session mechanism available?
if (!session_id()) {
if ($this->sessionManager) {
$this->sessionManager->start();
} else {
throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start().");
}
}
if (isset($_SESSION[$this->sessionPrefix.'MoufUserId'])) {
return true;
} else {
foreach ($this->authProviders as $provider) {
/* @var $provider AuthenticationProviderInterface */
if ($provider->isLogged($this)) {
return true;
}
}
}
} catch (\Exception $e) {
$this->byPassIsLogged = false;
throw $e;
}
$this->byPassIsLogged = false;
return false;
}
|
[
"public",
"function",
"isLogged",
"(",
")",
"{",
"$",
"this",
"->",
"byPassIsLogged",
"=",
"true",
";",
"try",
"{",
"// Is a session mechanism available?",
"if",
"(",
"!",
"session_id",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionManager",
")",
"{",
"$",
"this",
"->",
"sessionManager",
"->",
"start",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MoufException",
"(",
"\"The session must be initialized before checking if the user is logged. Please use session_start().\"",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserId'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"authProviders",
"as",
"$",
"provider",
")",
"{",
"/* @var $provider AuthenticationProviderInterface */",
"if",
"(",
"$",
"provider",
"->",
"isLogged",
"(",
"$",
"this",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"byPassIsLogged",
"=",
"false",
";",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"byPassIsLogged",
"=",
"false",
";",
"return",
"false",
";",
"}"
] |
Returns "true" if the user is logged, "false" otherwise.
@return boolean
|
[
"Returns",
"true",
"if",
"the",
"user",
"is",
"logged",
"false",
"otherwise",
"."
] |
39de12c32f324ab113441a69cd73cdb4b4673225
|
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L222-L251
|
20,213 |
thecodingmachine/security.userservice
|
src/Mouf/Security/UserService/UserService.php
|
UserService.logoff
|
public function logoff()
{
// Is a session mechanism available?
if (!session_id()) {
if ($this->sessionManager) {
$this->sessionManager->start();
} else {
throw new MoufException("The session must be initialized before trying to login. Please use session_start().");
}
}
if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) {
$login = $_SESSION[$this->sessionPrefix.'MoufUserLogin'];
if (is_array($this->authenticationListeners)) {
foreach ($this->authenticationListeners as $listener) {
$listener->beforeLogOut($this);
}
}
if ($this->log instanceof LoggerInterface) {
$this->log->debug("User '{login}' logs out.", array('login' => $login));
} else {
$this->log->trace("User '".$login."' logs out.");
}
unset($_SESSION[$this->sessionPrefix.'MoufUserId']);
unset($_SESSION[$this->sessionPrefix.'MoufUserLogin']);
}
}
|
php
|
public function logoff()
{
// Is a session mechanism available?
if (!session_id()) {
if ($this->sessionManager) {
$this->sessionManager->start();
} else {
throw new MoufException("The session must be initialized before trying to login. Please use session_start().");
}
}
if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) {
$login = $_SESSION[$this->sessionPrefix.'MoufUserLogin'];
if (is_array($this->authenticationListeners)) {
foreach ($this->authenticationListeners as $listener) {
$listener->beforeLogOut($this);
}
}
if ($this->log instanceof LoggerInterface) {
$this->log->debug("User '{login}' logs out.", array('login' => $login));
} else {
$this->log->trace("User '".$login."' logs out.");
}
unset($_SESSION[$this->sessionPrefix.'MoufUserId']);
unset($_SESSION[$this->sessionPrefix.'MoufUserLogin']);
}
}
|
[
"public",
"function",
"logoff",
"(",
")",
"{",
"// Is a session mechanism available?",
"if",
"(",
"!",
"session_id",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionManager",
")",
"{",
"$",
"this",
"->",
"sessionManager",
"->",
"start",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MoufException",
"(",
"\"The session must be initialized before trying to login. Please use session_start().\"",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserLogin'",
"]",
")",
")",
"{",
"$",
"login",
"=",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserLogin'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"authenticationListeners",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"authenticationListeners",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
"->",
"beforeLogOut",
"(",
"$",
"this",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"log",
"instanceof",
"LoggerInterface",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"\"User '{login}' logs out.\"",
",",
"array",
"(",
"'login'",
"=>",
"$",
"login",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"->",
"trace",
"(",
"\"User '\"",
".",
"$",
"login",
".",
"\"' logs out.\"",
")",
";",
"}",
"unset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserId'",
"]",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserLogin'",
"]",
")",
";",
"}",
"}"
] |
Logs the user off.
|
[
"Logs",
"the",
"user",
"off",
"."
] |
39de12c32f324ab113441a69cd73cdb4b4673225
|
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L270-L296
|
20,214 |
thecodingmachine/security.userservice
|
src/Mouf/Security/UserService/UserService.php
|
UserService.getUserLogin
|
public function getUserLogin()
{
// Is a session mechanism available?
if (!session_id()) {
if ($this->sessionManager) {
$this->sessionManager->start();
} else {
throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start().");
}
}
if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) {
return $_SESSION[$this->sessionPrefix.'MoufUserLogin'];
} else {
foreach ($this->authProviders as $provider) {
/* @var $provider AuthenticationProviderInterface */
$login = $provider->getUserLogin($this);
if ($login) {
return $login;
}
}
}
return null;
}
|
php
|
public function getUserLogin()
{
// Is a session mechanism available?
if (!session_id()) {
if ($this->sessionManager) {
$this->sessionManager->start();
} else {
throw new MoufException("The session must be initialized before checking if the user is logged. Please use session_start().");
}
}
if (isset($_SESSION[$this->sessionPrefix.'MoufUserLogin'])) {
return $_SESSION[$this->sessionPrefix.'MoufUserLogin'];
} else {
foreach ($this->authProviders as $provider) {
/* @var $provider AuthenticationProviderInterface */
$login = $provider->getUserLogin($this);
if ($login) {
return $login;
}
}
}
return null;
}
|
[
"public",
"function",
"getUserLogin",
"(",
")",
"{",
"// Is a session mechanism available?",
"if",
"(",
"!",
"session_id",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionManager",
")",
"{",
"$",
"this",
"->",
"sessionManager",
"->",
"start",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MoufException",
"(",
"\"The session must be initialized before checking if the user is logged. Please use session_start().\"",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserLogin'",
"]",
")",
")",
"{",
"return",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"sessionPrefix",
".",
"'MoufUserLogin'",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"authProviders",
"as",
"$",
"provider",
")",
"{",
"/* @var $provider AuthenticationProviderInterface */",
"$",
"login",
"=",
"$",
"provider",
"->",
"getUserLogin",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"login",
")",
"{",
"return",
"$",
"login",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the current user login.
@return string
|
[
"Returns",
"the",
"current",
"user",
"login",
"."
] |
39de12c32f324ab113441a69cd73cdb4b4673225
|
https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/UserService.php#L333-L356
|
20,215 |
antaresproject/notifications
|
src/Http/Filter/DateRangeNotificationLogsFilter.php
|
DateRangeNotificationLogsFilter.apply
|
public function apply($builder)
{
if (!empty($values = $this->getValues())) {
$range = json_decode($values, true);
if (!isset($range['start']) or ! isset($range['end'])) {
return $builder;
}
$start = $range['start'] . ' 00:00:00';
$end = $range['end'] . ' 23:59:59';
$builder->whereBetween('tbl_notifications_stack.created_at', [$start, $end]);
}
}
|
php
|
public function apply($builder)
{
if (!empty($values = $this->getValues())) {
$range = json_decode($values, true);
if (!isset($range['start']) or ! isset($range['end'])) {
return $builder;
}
$start = $range['start'] . ' 00:00:00';
$end = $range['end'] . ' 23:59:59';
$builder->whereBetween('tbl_notifications_stack.created_at', [$start, $end]);
}
}
|
[
"public",
"function",
"apply",
"(",
"$",
"builder",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
")",
")",
"{",
"$",
"range",
"=",
"json_decode",
"(",
"$",
"values",
",",
"true",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"range",
"[",
"'start'",
"]",
")",
"or",
"!",
"isset",
"(",
"$",
"range",
"[",
"'end'",
"]",
")",
")",
"{",
"return",
"$",
"builder",
";",
"}",
"$",
"start",
"=",
"$",
"range",
"[",
"'start'",
"]",
".",
"' 00:00:00'",
";",
"$",
"end",
"=",
"$",
"range",
"[",
"'end'",
"]",
".",
"' 23:59:59'",
";",
"$",
"builder",
"->",
"whereBetween",
"(",
"'tbl_notifications_stack.created_at'",
",",
"[",
"$",
"start",
",",
"$",
"end",
"]",
")",
";",
"}",
"}"
] |
Filters data by parameters from memory
@param mixed $builder
|
[
"Filters",
"data",
"by",
"parameters",
"from",
"memory"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Filter/DateRangeNotificationLogsFilter.php#L57-L68
|
20,216 |
gedex/php-janrain-api
|
lib/Janrain/Api/Engage/Sharing.php
|
Sharing.broadcast
|
public function broadcast(array $params)
{
if (!isset($params['identifier']) && !isset($params['device_token'])) {
throw new MissingArgumentException('identifier or device_token');
}
if (!isset($params['message'])) {
throw new MissingArgumentException('message');
}
return $this->post('sharing/broadcast', $params);
}
|
php
|
public function broadcast(array $params)
{
if (!isset($params['identifier']) && !isset($params['device_token'])) {
throw new MissingArgumentException('identifier or device_token');
}
if (!isset($params['message'])) {
throw new MissingArgumentException('message');
}
return $this->post('sharing/broadcast', $params);
}
|
[
"public",
"function",
"broadcast",
"(",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'identifier'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"params",
"[",
"'device_token'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'identifier or device_token'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'message'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'message'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'sharing/broadcast'",
",",
"$",
"params",
")",
";",
"}"
] |
Shares activity information directly with a provider. The information
provided in the parameters is passed to a provider to publish on their
network.
The `broadcast` call shares with one provider at a time, determined by the
`identifier` or `device_token` that you use.
@param array $params
@link http://developers.janrain.com/documentation/api-methods/engage/sharing-widget/broadcast/
|
[
"Shares",
"activity",
"information",
"directly",
"with",
"a",
"provider",
".",
"The",
"information",
"provided",
"in",
"the",
"parameters",
"is",
"passed",
"to",
"a",
"provider",
"to",
"publish",
"on",
"their",
"network",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Sharing.php#L23-L34
|
20,217 |
gedex/php-janrain-api
|
lib/Janrain/Api/Engage/Sharing.php
|
Sharing.direct
|
public function direct(array $params)
{
if (!isset($params['identifier']) && !isset($params['device_token'])) {
throw new MissingArgumentException('identifier or device_token');
}
if (!isset($params['recipients'])) {
throw new MissingArgumentException('recipients');
} else if (!is_array($params['recipients'])) {
throw new InvalidArgumentException('Invalid Argument: recipients must be passed as array');
} else {
$params['recipients'] = json_encode(array_values($params['recipients']));
}
if (!isset($params['message'])) {
throw new MissingArgumentException('message');
}
return $this->post('sharing/direct', $params);
}
|
php
|
public function direct(array $params)
{
if (!isset($params['identifier']) && !isset($params['device_token'])) {
throw new MissingArgumentException('identifier or device_token');
}
if (!isset($params['recipients'])) {
throw new MissingArgumentException('recipients');
} else if (!is_array($params['recipients'])) {
throw new InvalidArgumentException('Invalid Argument: recipients must be passed as array');
} else {
$params['recipients'] = json_encode(array_values($params['recipients']));
}
if (!isset($params['message'])) {
throw new MissingArgumentException('message');
}
return $this->post('sharing/direct', $params);
}
|
[
"public",
"function",
"direct",
"(",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'identifier'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"params",
"[",
"'device_token'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'identifier or device_token'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'recipients'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'recipients'",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
"[",
"'recipients'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid Argument: recipients must be passed as array'",
")",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"'recipients'",
"]",
"=",
"json_encode",
"(",
"array_values",
"(",
"$",
"params",
"[",
"'recipients'",
"]",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'message'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'message'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'sharing/direct'",
",",
"$",
"params",
")",
";",
"}"
] |
Shares activity information directly with the specified recipents on a
provider's network, instead of publishing it to everyone on the network.
The `direct` call shares with one provider at a time, determined by the
`identifier` or `device_token` you enter.
@param array $params
@link http://developers.janrain.com/documentation/api-methods/engage/sharing-widget/direct/
|
[
"Shares",
"activity",
"information",
"directly",
"with",
"the",
"specified",
"recipents",
"on",
"a",
"provider",
"s",
"network",
"instead",
"of",
"publishing",
"it",
"to",
"everyone",
"on",
"the",
"network",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Sharing.php#L47-L66
|
20,218 |
gedex/php-janrain-api
|
lib/Janrain/Api/Engage/Sharing.php
|
Sharing.getShareProviders
|
public function getShareProviders($format = 'json', $callback = '')
{
$params = compact('format');
if (!empty($callback)) {
$params['callback'] = $callback;
}
return $this->post('get_share_providers', $params);
}
|
php
|
public function getShareProviders($format = 'json', $callback = '')
{
$params = compact('format');
if (!empty($callback)) {
$params['callback'] = $callback;
}
return $this->post('get_share_providers', $params);
}
|
[
"public",
"function",
"getShareProviders",
"(",
"$",
"format",
"=",
"'json'",
",",
"$",
"callback",
"=",
"''",
")",
"{",
"$",
"params",
"=",
"compact",
"(",
"'format'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"params",
"[",
"'callback'",
"]",
"=",
"$",
"callback",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'get_share_providers'",
",",
"$",
"params",
")",
";",
"}"
] |
Returns a list of email and sharing providers configured for the widget.
This call has no required parameters; it identifies the proper application
by the realm prefacing the URL path.
@param string $format Either 'json' or 'xml'
@param string $callback Specifies the return of a JSONP-formatted response
@link http://developers.janrain.com/documentation/api-methods/engage/sharing-widget/get_share_providers/
|
[
"Returns",
"a",
"list",
"of",
"email",
"and",
"sharing",
"providers",
"configured",
"for",
"the",
"widget",
".",
"This",
"call",
"has",
"no",
"required",
"parameters",
";",
"it",
"identifies",
"the",
"proper",
"application",
"by",
"the",
"realm",
"prefacing",
"the",
"URL",
"path",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Sharing.php#L92-L100
|
20,219 |
mekras/Types
|
src/DateTime/Traits/DateComingChecks.php
|
DateComingChecks.isDateWillComeIn
|
public function isDateWillComeIn($interval)
{
if (!($interval instanceof \DateInterval)) {
$interval = new \DateInterval((string) $interval);
}
$now = new \DateTime('now');
return 0 === $this->diff($now->add($interval))->invert;
}
|
php
|
public function isDateWillComeIn($interval)
{
if (!($interval instanceof \DateInterval)) {
$interval = new \DateInterval((string) $interval);
}
$now = new \DateTime('now');
return 0 === $this->diff($now->add($interval))->invert;
}
|
[
"public",
"function",
"isDateWillComeIn",
"(",
"$",
"interval",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"interval",
"instanceof",
"\\",
"DateInterval",
")",
")",
"{",
"$",
"interval",
"=",
"new",
"\\",
"DateInterval",
"(",
"(",
"string",
")",
"$",
"interval",
")",
";",
"}",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"return",
"0",
"===",
"$",
"this",
"->",
"diff",
"(",
"$",
"now",
"->",
"add",
"(",
"$",
"interval",
")",
")",
"->",
"invert",
";",
"}"
] |
Return TRUE if this date will come in a given interval
@param \DateInterval|string $interval DateInterval or string interval specification
@return bool
@link http://php.net/DateInterval
@since 1.1
|
[
"Return",
"TRUE",
"if",
"this",
"date",
"will",
"come",
"in",
"a",
"given",
"interval"
] |
a168809097d41f3dacec658b6ecd2fd0f10b30e1
|
https://github.com/mekras/Types/blob/a168809097d41f3dacec658b6ecd2fd0f10b30e1/src/DateTime/Traits/DateComingChecks.php#L43-L50
|
20,220 |
ronaldborla/chikka
|
src/Borla/Chikka/Chikka.php
|
Chikka.replyTo
|
public function replyTo(Message $message, $messageOrContent, $cost = 0, $messageId = null, $adjustCost = true) {
// Return
return $this->reply($message->id, $message->mobile, $messageOrContent, $cost, $messageId, $adjustCost);
}
|
php
|
public function replyTo(Message $message, $messageOrContent, $cost = 0, $messageId = null, $adjustCost = true) {
// Return
return $this->reply($message->id, $message->mobile, $messageOrContent, $cost, $messageId, $adjustCost);
}
|
[
"public",
"function",
"replyTo",
"(",
"Message",
"$",
"message",
",",
"$",
"messageOrContent",
",",
"$",
"cost",
"=",
"0",
",",
"$",
"messageId",
"=",
"null",
",",
"$",
"adjustCost",
"=",
"true",
")",
"{",
"// Return",
"return",
"$",
"this",
"->",
"reply",
"(",
"$",
"message",
"->",
"id",
",",
"$",
"message",
"->",
"mobile",
",",
"$",
"messageOrContent",
",",
"$",
"cost",
",",
"$",
"messageId",
",",
"$",
"adjustCost",
")",
";",
"}"
] |
Reply to a message
|
[
"Reply",
"to",
"a",
"message"
] |
446987706f81d5a0efbc8bd6b7d3b259d0527719
|
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Chikka.php#L89-L92
|
20,221 |
snapwp/snap-blade
|
src/Snap_Blade.php
|
Snap_Blade.run
|
public function run($view, $data = array())
{
return parent::run(
$view,
\array_merge(View::get_additional_data($view, $data), $data)
);
}
|
php
|
public function run($view, $data = array())
{
return parent::run(
$view,
\array_merge(View::get_additional_data($view, $data), $data)
);
}
|
[
"public",
"function",
"run",
"(",
"$",
"view",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"return",
"parent",
"::",
"run",
"(",
"$",
"view",
",",
"\\",
"array_merge",
"(",
"View",
"::",
"get_additional_data",
"(",
"$",
"view",
",",
"$",
"data",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Run the blade engine. Is only called when rendering a view.
@since 1.0.0
@param string $view The template name to render.
@param array $data The data to pass to BladeOne.
@return string
@throws \Exception
|
[
"Run",
"the",
"blade",
"engine",
".",
"Is",
"only",
"called",
"when",
"rendering",
"a",
"view",
"."
] |
41e004e93440f6b58638b64dc8d20cca4a0546fa
|
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Snap_Blade.php#L68-L74
|
20,222 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Customer/Customer.php
|
Customer.setPhone
|
public function setPhone(\Gpupo\CommonSchema\ORM\Entity\People\Phone $phone = null)
{
$this->phone = $phone;
return $this;
}
|
php
|
public function setPhone(\Gpupo\CommonSchema\ORM\Entity\People\Phone $phone = null)
{
$this->phone = $phone;
return $this;
}
|
[
"public",
"function",
"setPhone",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"People",
"\\",
"Phone",
"$",
"phone",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"phone",
"=",
"$",
"phone",
";",
"return",
"$",
"this",
";",
"}"
] |
Set phone.
@param null|\Gpupo\CommonSchema\ORM\Entity\People\Phone $phone
@return Customer
|
[
"Set",
"phone",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L287-L292
|
20,223 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Customer/Customer.php
|
Customer.setAlternativePhone
|
public function setAlternativePhone(\Gpupo\CommonSchema\ORM\Entity\People\AlternativePhone $alternativePhone = null)
{
$this->alternative_phone = $alternativePhone;
return $this;
}
|
php
|
public function setAlternativePhone(\Gpupo\CommonSchema\ORM\Entity\People\AlternativePhone $alternativePhone = null)
{
$this->alternative_phone = $alternativePhone;
return $this;
}
|
[
"public",
"function",
"setAlternativePhone",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"People",
"\\",
"AlternativePhone",
"$",
"alternativePhone",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"alternative_phone",
"=",
"$",
"alternativePhone",
";",
"return",
"$",
"this",
";",
"}"
] |
Set alternativePhone.
@param null|\Gpupo\CommonSchema\ORM\Entity\People\AlternativePhone $alternativePhone
@return Customer
|
[
"Set",
"alternativePhone",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L311-L316
|
20,224 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Customer/Customer.php
|
Customer.setAddressBilling
|
public function setAddressBilling(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressBilling $addressBilling = null)
{
$this->address_billing = $addressBilling;
return $this;
}
|
php
|
public function setAddressBilling(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressBilling $addressBilling = null)
{
$this->address_billing = $addressBilling;
return $this;
}
|
[
"public",
"function",
"setAddressBilling",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Customer",
"\\",
"AddressBilling",
"$",
"addressBilling",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"address_billing",
"=",
"$",
"addressBilling",
";",
"return",
"$",
"this",
";",
"}"
] |
Set addressBilling.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressBilling $addressBilling
@return Customer
|
[
"Set",
"addressBilling",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L359-L364
|
20,225 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Customer/Customer.php
|
Customer.setAddressDelivery
|
public function setAddressDelivery(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressDelivery $addressDelivery = null)
{
$this->address_delivery = $addressDelivery;
return $this;
}
|
php
|
public function setAddressDelivery(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressDelivery $addressDelivery = null)
{
$this->address_delivery = $addressDelivery;
return $this;
}
|
[
"public",
"function",
"setAddressDelivery",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Customer",
"\\",
"AddressDelivery",
"$",
"addressDelivery",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"address_delivery",
"=",
"$",
"addressDelivery",
";",
"return",
"$",
"this",
";",
"}"
] |
Set addressDelivery.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Customer\AddressDelivery $addressDelivery
@return Customer
|
[
"Set",
"addressDelivery",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Customer/Customer.php#L383-L388
|
20,226 |
wenbinye/PhalconX
|
src/Db/Column.php
|
Column.copy
|
public static function copy(BaseColumn $column)
{
$definition = self::filterArray(get_object_vars($column));
return new self($definition['name'], $definition);
}
|
php
|
public static function copy(BaseColumn $column)
{
$definition = self::filterArray(get_object_vars($column));
return new self($definition['name'], $definition);
}
|
[
"public",
"static",
"function",
"copy",
"(",
"BaseColumn",
"$",
"column",
")",
"{",
"$",
"definition",
"=",
"self",
"::",
"filterArray",
"(",
"get_object_vars",
"(",
"$",
"column",
")",
")",
";",
"return",
"new",
"self",
"(",
"$",
"definition",
"[",
"'name'",
"]",
",",
"$",
"definition",
")",
";",
"}"
] |
Copy to new column
|
[
"Copy",
"to",
"new",
"column"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Column.php#L24-L28
|
20,227 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php
|
ezcDbHandler.quoteIdentifier
|
public function quoteIdentifier( $identifier )
{
if ( sizeof( $this->identifierQuoteChars ) === 2 )
{
$identifier =
$this->identifierQuoteChars["start"]
. str_replace(
$this->identifierQuoteChars["end"],
$this->identifierQuoteChars["end"].$this->identifierQuoteChars["end"],
$identifier
)
. $this->identifierQuoteChars["end"];
}
return $identifier;
}
|
php
|
public function quoteIdentifier( $identifier )
{
if ( sizeof( $this->identifierQuoteChars ) === 2 )
{
$identifier =
$this->identifierQuoteChars["start"]
. str_replace(
$this->identifierQuoteChars["end"],
$this->identifierQuoteChars["end"].$this->identifierQuoteChars["end"],
$identifier
)
. $this->identifierQuoteChars["end"];
}
return $identifier;
}
|
[
"public",
"function",
"quoteIdentifier",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"identifierQuoteChars",
")",
"===",
"2",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"identifierQuoteChars",
"[",
"\"start\"",
"]",
".",
"str_replace",
"(",
"$",
"this",
"->",
"identifierQuoteChars",
"[",
"\"end\"",
"]",
",",
"$",
"this",
"->",
"identifierQuoteChars",
"[",
"\"end\"",
"]",
".",
"$",
"this",
"->",
"identifierQuoteChars",
"[",
"\"end\"",
"]",
",",
"$",
"identifier",
")",
".",
"$",
"this",
"->",
"identifierQuoteChars",
"[",
"\"end\"",
"]",
";",
"}",
"return",
"$",
"identifier",
";",
"}"
] |
Returns the quoted version of an identifier to be used in an SQL query.
This method takes a given identifier and quotes it, so it can safely be
used in SQL queries.
@param string $identifier The identifier to quote.
@return string The quoted identifier.
|
[
"Returns",
"the",
"quoted",
"version",
"of",
"an",
"identifier",
"to",
"be",
"used",
"in",
"an",
"SQL",
"query",
".",
"This",
"method",
"takes",
"a",
"given",
"identifier",
"and",
"quotes",
"it",
"so",
"it",
"can",
"safely",
"be",
"used",
"in",
"SQL",
"queries",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/handler.php#L327-L341
|
20,228 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/unique_index_name.php
|
ezcDbSchemaUniqueIndexNameValidator.validate
|
static public function validate( ezcDbSchema $schema )
{
$indexes = array();
$errors = array();
/* For each table we check all auto increment fields. */
foreach ( $schema->getSchema() as $tableName => $table )
{
foreach ( $table->indexes as $indexName => $dummy )
{
$indexes[$indexName][] = $tableName;
}
}
foreach ( $indexes as $indexName => $tableList )
{
if ( count( $tableList ) > 1 )
{
$errors[] = "The index name '$indexName' is not unique. It exists for the tables: '" . join( "', '", $tableList ) . "'.";
}
}
return $errors;
}
|
php
|
static public function validate( ezcDbSchema $schema )
{
$indexes = array();
$errors = array();
/* For each table we check all auto increment fields. */
foreach ( $schema->getSchema() as $tableName => $table )
{
foreach ( $table->indexes as $indexName => $dummy )
{
$indexes[$indexName][] = $tableName;
}
}
foreach ( $indexes as $indexName => $tableList )
{
if ( count( $tableList ) > 1 )
{
$errors[] = "The index name '$indexName' is not unique. It exists for the tables: '" . join( "', '", $tableList ) . "'.";
}
}
return $errors;
}
|
[
"static",
"public",
"function",
"validate",
"(",
"ezcDbSchema",
"$",
"schema",
")",
"{",
"$",
"indexes",
"=",
"array",
"(",
")",
";",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/* For each table we check all auto increment fields. */",
"foreach",
"(",
"$",
"schema",
"->",
"getSchema",
"(",
")",
"as",
"$",
"tableName",
"=>",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"indexes",
"as",
"$",
"indexName",
"=>",
"$",
"dummy",
")",
"{",
"$",
"indexes",
"[",
"$",
"indexName",
"]",
"[",
"]",
"=",
"$",
"tableName",
";",
"}",
"}",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"indexName",
"=>",
"$",
"tableList",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"tableList",
")",
">",
"1",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"The index name '$indexName' is not unique. It exists for the tables: '\"",
".",
"join",
"(",
"\"', '\"",
",",
"$",
"tableList",
")",
".",
"\"'.\"",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Validates if all the index names used are unique accross the schema.
This method loops over all the indexes in all tables and checks whether
they have been used before.
@param ezcDbSchema $schema
@return array(string)
|
[
"Validates",
"if",
"all",
"the",
"index",
"names",
"used",
"are",
"unique",
"accross",
"the",
"schema",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/unique_index_name.php#L29-L52
|
20,229 |
hametuha/wpametu
|
src/WPametu/API/Rest/WpApi.php
|
WpApi.rest_api_init
|
public function rest_api_init() {
$register = [];
foreach ( [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTION' ] as $method ) {
$method_name = strtolower( "handle_{$method}" );
if ( ! method_exists( $this, $method_name ) ) {
continue;
}
$register[] = [
'methods' => $method,
'callback' => [ $this, 'invoke' ],
'args' => $this->get_arguments( $method ),
'permission_callback' => [ $this, 'permission_callback' ],
];
}
if ( ! $register ) {
throw new \Exception( sprintf( 'Class %s has no handler.', get_called_class() ), 500 );
} else {
register_rest_route( $this->namespace, $this->get_route(), $register );
}
}
|
php
|
public function rest_api_init() {
$register = [];
foreach ( [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTION' ] as $method ) {
$method_name = strtolower( "handle_{$method}" );
if ( ! method_exists( $this, $method_name ) ) {
continue;
}
$register[] = [
'methods' => $method,
'callback' => [ $this, 'invoke' ],
'args' => $this->get_arguments( $method ),
'permission_callback' => [ $this, 'permission_callback' ],
];
}
if ( ! $register ) {
throw new \Exception( sprintf( 'Class %s has no handler.', get_called_class() ), 500 );
} else {
register_rest_route( $this->namespace, $this->get_route(), $register );
}
}
|
[
"public",
"function",
"rest_api_init",
"(",
")",
"{",
"$",
"register",
"=",
"[",
"]",
";",
"foreach",
"(",
"[",
"'GET'",
",",
"'POST'",
",",
"'PUT'",
",",
"'PATCH'",
",",
"'DELETE'",
",",
"'HEAD'",
",",
"'OPTION'",
"]",
"as",
"$",
"method",
")",
"{",
"$",
"method_name",
"=",
"strtolower",
"(",
"\"handle_{$method}\"",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method_name",
")",
")",
"{",
"continue",
";",
"}",
"$",
"register",
"[",
"]",
"=",
"[",
"'methods'",
"=>",
"$",
"method",
",",
"'callback'",
"=>",
"[",
"$",
"this",
",",
"'invoke'",
"]",
",",
"'args'",
"=>",
"$",
"this",
"->",
"get_arguments",
"(",
"$",
"method",
")",
",",
"'permission_callback'",
"=>",
"[",
"$",
"this",
",",
"'permission_callback'",
"]",
",",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"register",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Class %s has no handler.'",
",",
"get_called_class",
"(",
")",
")",
",",
"500",
")",
";",
"}",
"else",
"{",
"register_rest_route",
"(",
"$",
"this",
"->",
"namespace",
",",
"$",
"this",
"->",
"get_route",
"(",
")",
",",
"$",
"register",
")",
";",
"}",
"}"
] |
Register rest endpoints
@throws \Exception If no handler is set, throws error.
|
[
"Register",
"rest",
"endpoints"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/WpApi.php#L40-L59
|
20,230 |
interactivesolutions/honeycomb-core
|
src/models/HCModel.php
|
HCModel.getTableEnumList
|
public static function getTableEnumList(string $field, string $labelKey = null, string $translationCode = null)
{
$type = DB::select(
DB::raw('SHOW COLUMNS FROM ' . self::getTableName() . ' WHERE Field = "' . $field . '"')
)[0]->Type;
preg_match('/^enum\((.*)\)$/', $type, $matches);
$values = [];
foreach (explode(',', $matches[1]) as $value) {
$value = trim($value, "'");
if (is_null($labelKey)) {
$values[] = $value;
} else {
$values[] = [
'id' => $value,
$labelKey => trans($translationCode . $value),
];
}
}
return $values;
}
|
php
|
public static function getTableEnumList(string $field, string $labelKey = null, string $translationCode = null)
{
$type = DB::select(
DB::raw('SHOW COLUMNS FROM ' . self::getTableName() . ' WHERE Field = "' . $field . '"')
)[0]->Type;
preg_match('/^enum\((.*)\)$/', $type, $matches);
$values = [];
foreach (explode(',', $matches[1]) as $value) {
$value = trim($value, "'");
if (is_null($labelKey)) {
$values[] = $value;
} else {
$values[] = [
'id' => $value,
$labelKey => trans($translationCode . $value),
];
}
}
return $values;
}
|
[
"public",
"static",
"function",
"getTableEnumList",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"labelKey",
"=",
"null",
",",
"string",
"$",
"translationCode",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"DB",
"::",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'SHOW COLUMNS FROM '",
".",
"self",
"::",
"getTableName",
"(",
")",
".",
"' WHERE Field = \"'",
".",
"$",
"field",
".",
"'\"'",
")",
")",
"[",
"0",
"]",
"->",
"Type",
";",
"preg_match",
"(",
"'/^enum\\((.*)\\)$/'",
",",
"$",
"type",
",",
"$",
"matches",
")",
";",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"matches",
"[",
"1",
"]",
")",
"as",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
",",
"\"'\"",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"labelKey",
")",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"values",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"value",
",",
"$",
"labelKey",
"=>",
"trans",
"(",
"$",
"translationCode",
".",
"$",
"value",
")",
",",
"]",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] |
Get table enum field list with translations or not
@param string $field
@param null|string $labelKey
@param string $translationCode
@return array
|
[
"Get",
"table",
"enum",
"field",
"list",
"with",
"translations",
"or",
"not"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/models/HCModel.php#L55-L79
|
20,231 |
ouropencode/dachi
|
src/Modules.php
|
Modules.get
|
public static function get($module) {
if(self::$modules === array())
self::initialize();
if(!isset(self::$modules[$module]))
return false;
return self::$modules[$module];
}
|
php
|
public static function get($module) {
if(self::$modules === array())
self::initialize();
if(!isset(self::$modules[$module]))
return false;
return self::$modules[$module];
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"module",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"modules",
"===",
"array",
"(",
")",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"modules",
"[",
"$",
"module",
"]",
")",
")",
"return",
"false",
";",
"return",
"self",
"::",
"$",
"modules",
"[",
"$",
"module",
"]",
";",
"}"
] |
Retrieve module information.
@param string $module Module shortname
@return Module
|
[
"Retrieve",
"module",
"information",
"."
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Modules.php#L36-L44
|
20,232 |
LIN3S/Distribution
|
src/Php/Composer/Wordpress.php
|
Wordpress.installRequiredFiles
|
public static function installRequiredFiles()
{
$htaccess = __DIR__ . '/../../../../../../.htaccess';
$robots = __DIR__ . '/../../../../../../robots.txt';
$wpConfig = __DIR__ . '/../../../../../../wp-config-custom';
$fileSystem = new Filesystem();
try {
if (false === $fileSystem->exists($htaccess)) {
$fileSystem->copy($htaccess . '.dist', $htaccess);
}
if (false === $fileSystem->exists($robots)) {
$fileSystem->copy($robots . '.dist', $robots);
}
if (false === $fileSystem->exists($wpConfig . '.php')) {
$fileSystem->copy($wpConfig . '-sample.php', $wpConfig . '.php');
}
} catch (\Exception $exception) {
echo sprintf("Something wrong happens during process: \n%s\n", $exception->getMessage());
}
}
|
php
|
public static function installRequiredFiles()
{
$htaccess = __DIR__ . '/../../../../../../.htaccess';
$robots = __DIR__ . '/../../../../../../robots.txt';
$wpConfig = __DIR__ . '/../../../../../../wp-config-custom';
$fileSystem = new Filesystem();
try {
if (false === $fileSystem->exists($htaccess)) {
$fileSystem->copy($htaccess . '.dist', $htaccess);
}
if (false === $fileSystem->exists($robots)) {
$fileSystem->copy($robots . '.dist', $robots);
}
if (false === $fileSystem->exists($wpConfig . '.php')) {
$fileSystem->copy($wpConfig . '-sample.php', $wpConfig . '.php');
}
} catch (\Exception $exception) {
echo sprintf("Something wrong happens during process: \n%s\n", $exception->getMessage());
}
}
|
[
"public",
"static",
"function",
"installRequiredFiles",
"(",
")",
"{",
"$",
"htaccess",
"=",
"__DIR__",
".",
"'/../../../../../../.htaccess'",
";",
"$",
"robots",
"=",
"__DIR__",
".",
"'/../../../../../../robots.txt'",
";",
"$",
"wpConfig",
"=",
"__DIR__",
".",
"'/../../../../../../wp-config-custom'",
";",
"$",
"fileSystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"try",
"{",
"if",
"(",
"false",
"===",
"$",
"fileSystem",
"->",
"exists",
"(",
"$",
"htaccess",
")",
")",
"{",
"$",
"fileSystem",
"->",
"copy",
"(",
"$",
"htaccess",
".",
"'.dist'",
",",
"$",
"htaccess",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"fileSystem",
"->",
"exists",
"(",
"$",
"robots",
")",
")",
"{",
"$",
"fileSystem",
"->",
"copy",
"(",
"$",
"robots",
".",
"'.dist'",
",",
"$",
"robots",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"fileSystem",
"->",
"exists",
"(",
"$",
"wpConfig",
".",
"'.php'",
")",
")",
"{",
"$",
"fileSystem",
"->",
"copy",
"(",
"$",
"wpConfig",
".",
"'-sample.php'",
",",
"$",
"wpConfig",
".",
"'.php'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"echo",
"sprintf",
"(",
"\"Something wrong happens during process: \\n%s\\n\"",
",",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Static method that creates .htaccess, robots.txt and wp-config-custom.php files if they do not exist.
|
[
"Static",
"method",
"that",
"creates",
".",
"htaccess",
"robots",
".",
"txt",
"and",
"wp",
"-",
"config",
"-",
"custom",
".",
"php",
"files",
"if",
"they",
"do",
"not",
"exist",
"."
] |
294cda1c2128fa967b3b316f01f202e4e46d2e5b
|
https://github.com/LIN3S/Distribution/blob/294cda1c2128fa967b3b316f01f202e4e46d2e5b/src/Php/Composer/Wordpress.php#L26-L46
|
20,233 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntitySelector.php
|
EntitySelector.decorateWhere
|
protected function decorateWhere($method, &$args)
{
$column = $args[0];
$expression = isset($args[1]) ? $args[1] : null;
$value = isset($args[2]) ? $args[2] : null;
if (!$expression instanceof Entity && !$value instanceof Entity) {
return;
}
$entity_class = $this->entity_class;
$relation = $entity_class::getRelationDefinition($column);
$column = $relation[3];
$relation_column = $relation[2];
if ($expression instanceof Entity) {
$expression = $expression->getRaw($relation_column);
} else {
$value = $value->getRaw($relation_column);
}
$args = [$column, $expression, $value];
}
|
php
|
protected function decorateWhere($method, &$args)
{
$column = $args[0];
$expression = isset($args[1]) ? $args[1] : null;
$value = isset($args[2]) ? $args[2] : null;
if (!$expression instanceof Entity && !$value instanceof Entity) {
return;
}
$entity_class = $this->entity_class;
$relation = $entity_class::getRelationDefinition($column);
$column = $relation[3];
$relation_column = $relation[2];
if ($expression instanceof Entity) {
$expression = $expression->getRaw($relation_column);
} else {
$value = $value->getRaw($relation_column);
}
$args = [$column, $expression, $value];
}
|
[
"protected",
"function",
"decorateWhere",
"(",
"$",
"method",
",",
"&",
"$",
"args",
")",
"{",
"$",
"column",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"expression",
"=",
"isset",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"?",
"$",
"args",
"[",
"1",
"]",
":",
"null",
";",
"$",
"value",
"=",
"isset",
"(",
"$",
"args",
"[",
"2",
"]",
")",
"?",
"$",
"args",
"[",
"2",
"]",
":",
"null",
";",
"if",
"(",
"!",
"$",
"expression",
"instanceof",
"Entity",
"&&",
"!",
"$",
"value",
"instanceof",
"Entity",
")",
"{",
"return",
";",
"}",
"$",
"entity_class",
"=",
"$",
"this",
"->",
"entity_class",
";",
"$",
"relation",
"=",
"$",
"entity_class",
"::",
"getRelationDefinition",
"(",
"$",
"column",
")",
";",
"$",
"column",
"=",
"$",
"relation",
"[",
"3",
"]",
";",
"$",
"relation_column",
"=",
"$",
"relation",
"[",
"2",
"]",
";",
"if",
"(",
"$",
"expression",
"instanceof",
"Entity",
")",
"{",
"$",
"expression",
"=",
"$",
"expression",
"->",
"getRaw",
"(",
"$",
"relation_column",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getRaw",
"(",
"$",
"relation_column",
")",
";",
"}",
"$",
"args",
"=",
"[",
"$",
"column",
",",
"$",
"expression",
",",
"$",
"value",
"]",
";",
"}"
] |
Modify the arguments of a where method to account for selecting
by entity objects.
@param $method The where method being called
@param $args The arguments
|
[
"Modify",
"the",
"arguments",
"of",
"a",
"where",
"method",
"to",
"account",
"for",
"selecting",
"by",
"entity",
"objects",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntitySelector.php#L111-L132
|
20,234 |
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntitySelector.php
|
EntitySelector.execute
|
public function execute()
{
if ($this->counting) {
return $this->executeCount();
}
if ($this->single) {
return $this->executeSingle($this->entity_class);
}
return $this->executeCollection($this->entity_class);
}
|
php
|
public function execute()
{
if ($this->counting) {
return $this->executeCount();
}
if ($this->single) {
return $this->executeSingle($this->entity_class);
}
return $this->executeCollection($this->entity_class);
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"counting",
")",
"{",
"return",
"$",
"this",
"->",
"executeCount",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"single",
")",
"{",
"return",
"$",
"this",
"->",
"executeSingle",
"(",
"$",
"this",
"->",
"entity_class",
")",
";",
"}",
"return",
"$",
"this",
"->",
"executeCollection",
"(",
"$",
"this",
"->",
"entity_class",
")",
";",
"}"
] |
Execute the query and return the result.
@return mixed An EntityCollection, Entity or integer.
|
[
"Execute",
"the",
"query",
"and",
"return",
"the",
"result",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntitySelector.php#L139-L150
|
20,235 |
surebert/surebert-framework
|
src/sb/XMPP/Message.php
|
Message.setBody
|
public function setBody($body)
{
$node = $this->getBody(false);
if(!$node){
$node = $this->createElement('body');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($body);
}
|
php
|
public function setBody($body)
{
$node = $this->getBody(false);
if(!$node){
$node = $this->createElement('body');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($body);
}
|
[
"public",
"function",
"setBody",
"(",
"$",
"body",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getBody",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'body'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"body",
")",
";",
"}"
] |
Sets the body of the message to be send
@param string $body
|
[
"Sets",
"the",
"body",
"of",
"the",
"message",
"to",
"be",
"send"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L104-L112
|
20,236 |
surebert/surebert-framework
|
src/sb/XMPP/Message.php
|
Message.setSubject
|
public function setSubject($subject)
{
$node = $this->getSubject(false);
if(!$node){
$node = $this->createElement('subject');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($subject);
}
|
php
|
public function setSubject($subject)
{
$node = $this->getSubject(false);
if(!$node){
$node = $this->createElement('subject');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($subject);
}
|
[
"public",
"function",
"setSubject",
"(",
"$",
"subject",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getSubject",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'subject'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"subject",
")",
";",
"}"
] |
Set the subject of the message
@param string $subject
|
[
"Set",
"the",
"subject",
"of",
"the",
"message"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L118-L126
|
20,237 |
surebert/surebert-framework
|
src/sb/XMPP/Message.php
|
Message.setHTML
|
public function setHTML($html)
{
$node = $this->createDocumentFragment();
$node->appendXML('<html xmlns="http://www.w3.org/1999/xhtml">'.$html.'</html>');
$this->doc->appendChild($node);
}
|
php
|
public function setHTML($html)
{
$node = $this->createDocumentFragment();
$node->appendXML('<html xmlns="http://www.w3.org/1999/xhtml">'.$html.'</html>');
$this->doc->appendChild($node);
}
|
[
"public",
"function",
"setHTML",
"(",
"$",
"html",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createDocumentFragment",
"(",
")",
";",
"$",
"node",
"->",
"appendXML",
"(",
"'<html xmlns=\"http://www.w3.org/1999/xhtml\">'",
".",
"$",
"html",
".",
"'</html>'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}"
] |
Sets the html node of the message, expiremental
@param string $html
|
[
"Sets",
"the",
"html",
"node",
"of",
"the",
"message",
"expiremental"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L132-L137
|
20,238 |
surebert/surebert-framework
|
src/sb/XMPP/Message.php
|
Message.reply
|
public function reply($str)
{
$message = new \sb\XMPP\Message();
$message->setTo($this->getFrom());
$message->setFrom($this->getTo());
$message->setBody($str);
$this->client->sendMessage($message);
}
|
php
|
public function reply($str)
{
$message = new \sb\XMPP\Message();
$message->setTo($this->getFrom());
$message->setFrom($this->getTo());
$message->setBody($str);
$this->client->sendMessage($message);
}
|
[
"public",
"function",
"reply",
"(",
"$",
"str",
")",
"{",
"$",
"message",
"=",
"new",
"\\",
"sb",
"\\",
"XMPP",
"\\",
"Message",
"(",
")",
";",
"$",
"message",
"->",
"setTo",
"(",
"$",
"this",
"->",
"getFrom",
"(",
")",
")",
";",
"$",
"message",
"->",
"setFrom",
"(",
"$",
"this",
"->",
"getTo",
"(",
")",
")",
";",
"$",
"message",
"->",
"setBody",
"(",
"$",
"str",
")",
";",
"$",
"this",
"->",
"client",
"->",
"sendMessage",
"(",
"$",
"message",
")",
";",
"}"
] |
Creates a reply message and sends it to the user that sent the
original message. This can be used only on \sb\XMPP\Message instances
that came over the socket and were passed to the onMessage method.
@param string $str
|
[
"Creates",
"a",
"reply",
"message",
"and",
"sends",
"it",
"to",
"the",
"user",
"that",
"sent",
"the",
"original",
"message",
".",
"This",
"can",
"be",
"used",
"only",
"on",
"\\",
"sb",
"\\",
"XMPP",
"\\",
"Message",
"instances",
"that",
"came",
"over",
"the",
"socket",
"and",
"were",
"passed",
"to",
"the",
"onMessage",
"method",
"."
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Message.php#L145-L152
|
20,239 |
ekuiter/feature-php
|
FeaturePhp/Helper/Logic.php
|
Logic.is
|
public static function is($feature) {
return function ($features) use ($feature) {
return fphp\Model\Feature::has($features, $feature);
};
}
|
php
|
public static function is($feature) {
return function ($features) use ($feature) {
return fphp\Model\Feature::has($features, $feature);
};
}
|
[
"public",
"static",
"function",
"is",
"(",
"$",
"feature",
")",
"{",
"return",
"function",
"(",
"$",
"features",
")",
"use",
"(",
"$",
"feature",
")",
"{",
"return",
"fphp",
"\\",
"Model",
"\\",
"Feature",
"::",
"has",
"(",
"$",
"features",
",",
"$",
"feature",
")",
";",
"}",
";",
"}"
] |
Returns a formula that tests for the presence of a feature.
@param Feature $feature
@return callable
|
[
"Returns",
"a",
"formula",
"that",
"tests",
"for",
"the",
"presence",
"of",
"a",
"feature",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L27-L31
|
20,240 |
ekuiter/feature-php
|
FeaturePhp/Helper/Logic.php
|
Logic._and
|
public static function _and(/* ... */) {
$args = func_get_args();
return function ($features) use ($args) {
$acc = true;
foreach ($args as $arg)
$acc = $acc && $arg($features);
return $acc;
};
}
|
php
|
public static function _and(/* ... */) {
$args = func_get_args();
return function ($features) use ($args) {
$acc = true;
foreach ($args as $arg)
$acc = $acc && $arg($features);
return $acc;
};
}
|
[
"public",
"static",
"function",
"_and",
"(",
"/* ... */",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"features",
")",
"use",
"(",
"$",
"args",
")",
"{",
"$",
"acc",
"=",
"true",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"$",
"acc",
"=",
"$",
"acc",
"&&",
"$",
"arg",
"(",
"$",
"features",
")",
";",
"return",
"$",
"acc",
";",
"}",
";",
"}"
] |
Returns a formula that is the conjunction of other formulas.
Formulas can be supplied variadically.
@return callable
|
[
"Returns",
"a",
"formula",
"that",
"is",
"the",
"conjunction",
"of",
"other",
"formulas",
".",
"Formulas",
"can",
"be",
"supplied",
"variadically",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L49-L57
|
20,241 |
ekuiter/feature-php
|
FeaturePhp/Helper/Logic.php
|
Logic._or
|
public static function _or(/* ... */) {
$args = func_get_args();
return function ($features) use ($args) {
$acc = false;
foreach ($args as $arg)
$acc = $acc || $arg($features);
return $acc;
};
}
|
php
|
public static function _or(/* ... */) {
$args = func_get_args();
return function ($features) use ($args) {
$acc = false;
foreach ($args as $arg)
$acc = $acc || $arg($features);
return $acc;
};
}
|
[
"public",
"static",
"function",
"_or",
"(",
"/* ... */",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"return",
"function",
"(",
"$",
"features",
")",
"use",
"(",
"$",
"args",
")",
"{",
"$",
"acc",
"=",
"false",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"$",
"acc",
"=",
"$",
"acc",
"||",
"$",
"arg",
"(",
"$",
"features",
")",
";",
"return",
"$",
"acc",
";",
"}",
";",
"}"
] |
Returns a formula that is the disjunction of other formulas.
Formulas can be supplied variadically.
@return callable
|
[
"Returns",
"a",
"formula",
"that",
"is",
"the",
"disjunction",
"of",
"other",
"formulas",
".",
"Formulas",
"can",
"be",
"supplied",
"variadically",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L64-L72
|
20,242 |
ekuiter/feature-php
|
FeaturePhp/Helper/Logic.php
|
Logic.equiv
|
public static function equiv($constraintA, $constraintB) {
return function ($features) use ($constraintA, $constraintB) {
return $constraintA($features) === $constraintB($features);
};
}
|
php
|
public static function equiv($constraintA, $constraintB) {
return function ($features) use ($constraintA, $constraintB) {
return $constraintA($features) === $constraintB($features);
};
}
|
[
"public",
"static",
"function",
"equiv",
"(",
"$",
"constraintA",
",",
"$",
"constraintB",
")",
"{",
"return",
"function",
"(",
"$",
"features",
")",
"use",
"(",
"$",
"constraintA",
",",
"$",
"constraintB",
")",
"{",
"return",
"$",
"constraintA",
"(",
"$",
"features",
")",
"===",
"$",
"constraintB",
"(",
"$",
"features",
")",
";",
"}",
";",
"}"
] |
Returns a formula that is the biconditional of two formulas.
@param callable $constraintA
@param callable $constraintB
@return callable
|
[
"Returns",
"a",
"formula",
"that",
"is",
"the",
"biconditional",
"of",
"two",
"formulas",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L80-L84
|
20,243 |
ekuiter/feature-php
|
FeaturePhp/Helper/Logic.php
|
Logic.implies
|
public static function implies($constraintA, $constraintB) {
return function ($features) use ($constraintA, $constraintB) {
return !$constraintA($features) || $constraintB($features);
};
}
|
php
|
public static function implies($constraintA, $constraintB) {
return function ($features) use ($constraintA, $constraintB) {
return !$constraintA($features) || $constraintB($features);
};
}
|
[
"public",
"static",
"function",
"implies",
"(",
"$",
"constraintA",
",",
"$",
"constraintB",
")",
"{",
"return",
"function",
"(",
"$",
"features",
")",
"use",
"(",
"$",
"constraintA",
",",
"$",
"constraintB",
")",
"{",
"return",
"!",
"$",
"constraintA",
"(",
"$",
"features",
")",
"||",
"$",
"constraintB",
"(",
"$",
"features",
")",
";",
"}",
";",
"}"
] |
Returns a formula that is the material conditional of two formulas.
@param callable $constraintA
@param callable $constraintB
@return callable
|
[
"Returns",
"a",
"formula",
"that",
"is",
"the",
"material",
"conditional",
"of",
"two",
"formulas",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Logic.php#L92-L96
|
20,244 |
Eresus/EresusCMS
|
src/core/Feed/Writer.php
|
Eresus_Feed_Writer.generateHead
|
private function generateHead()
{
$out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
if ($this->version == self::RSS2)
{
$out .= '<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
>' . PHP_EOL;
}
elseif ($this->version == self::RSS1)
{
$out .= '<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>' . PHP_EOL;
}
elseif ($this->version == self::ATOM)
{
$out .= '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL;
}
return $out;
}
|
php
|
private function generateHead()
{
$out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
if ($this->version == self::RSS2)
{
$out .= '<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
>' . PHP_EOL;
}
elseif ($this->version == self::RSS1)
{
$out .= '<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>' . PHP_EOL;
}
elseif ($this->version == self::ATOM)
{
$out .= '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL;
}
return $out;
}
|
[
"private",
"function",
"generateHead",
"(",
")",
"{",
"$",
"out",
"=",
"'<?xml version=\"1.0\" encoding=\"utf-8\"?>'",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"version",
"==",
"self",
"::",
"RSS2",
")",
"{",
"$",
"out",
".=",
"'<rss version=\"2.0\"\n\t\t\t\t\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n\t\t\t\t\txmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"\n\t\t\t\t >'",
".",
"PHP_EOL",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"version",
"==",
"self",
"::",
"RSS1",
")",
"{",
"$",
"out",
".=",
"'<rdf:RDF\n\t\t\t\t\t xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n\t\t\t\t\t xmlns=\"http://purl.org/rss/1.0/\"\n\t\t\t\t\t xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n\t\t\t\t\t>'",
".",
"PHP_EOL",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"version",
"==",
"self",
"::",
"ATOM",
")",
"{",
"$",
"out",
".=",
"'<feed xmlns=\"http://www.w3.org/2005/Atom\">'",
".",
"PHP_EOL",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Prints the xml and rss namespace
@return string
|
[
"Prints",
"the",
"xml",
"and",
"rss",
"namespace"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer.php#L254-L278
|
20,245 |
Eresus/EresusCMS
|
src/core/Feed/Writer.php
|
Eresus_Feed_Writer.makeNode
|
private function makeNode($tagName, $tagContent, $attributes = null)
{
$nodeText = '';
$attrText = '';
if (is_array($attributes))
{
foreach ($attributes as $key => $value)
{
$attrText .= " $key=\"$value\" ";
}
}
if (is_array($tagContent) && $this->version == self::RSS1)
{
$attrText = ' rdf:parseType="Resource"';
}
$attrText .= (in_array($tagName, $this->CDATAEncoding) && $this->version == self::ATOM)?
' type="html" ' : '';
$nodeText .= (in_array($tagName, $this->CDATAEncoding))?
"<{$tagName}{$attrText}><![CDATA[" : "<{$tagName}{$attrText}>";
if (is_array($tagContent))
{
foreach ($tagContent as $key => $value)
{
$nodeText .= $this->makeNode($key, $value);
}
}
else
{
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ?
$this->sanitizeCDATA($tagContent) :
htmlspecialchars($tagContent);
}
$nodeText .= (in_array($tagName, $this->CDATAEncoding))? "]]></$tagName>" : "</$tagName>";
return $nodeText . PHP_EOL;
}
|
php
|
private function makeNode($tagName, $tagContent, $attributes = null)
{
$nodeText = '';
$attrText = '';
if (is_array($attributes))
{
foreach ($attributes as $key => $value)
{
$attrText .= " $key=\"$value\" ";
}
}
if (is_array($tagContent) && $this->version == self::RSS1)
{
$attrText = ' rdf:parseType="Resource"';
}
$attrText .= (in_array($tagName, $this->CDATAEncoding) && $this->version == self::ATOM)?
' type="html" ' : '';
$nodeText .= (in_array($tagName, $this->CDATAEncoding))?
"<{$tagName}{$attrText}><![CDATA[" : "<{$tagName}{$attrText}>";
if (is_array($tagContent))
{
foreach ($tagContent as $key => $value)
{
$nodeText .= $this->makeNode($key, $value);
}
}
else
{
$nodeText .= (in_array($tagName, $this->CDATAEncoding)) ?
$this->sanitizeCDATA($tagContent) :
htmlspecialchars($tagContent);
}
$nodeText .= (in_array($tagName, $this->CDATAEncoding))? "]]></$tagName>" : "</$tagName>";
return $nodeText . PHP_EOL;
}
|
[
"private",
"function",
"makeNode",
"(",
"$",
"tagName",
",",
"$",
"tagContent",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"nodeText",
"=",
"''",
";",
"$",
"attrText",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"attributes",
")",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"attrText",
".=",
"\" $key=\\\"$value\\\" \"",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"tagContent",
")",
"&&",
"$",
"this",
"->",
"version",
"==",
"self",
"::",
"RSS1",
")",
"{",
"$",
"attrText",
"=",
"' rdf:parseType=\"Resource\"'",
";",
"}",
"$",
"attrText",
".=",
"(",
"in_array",
"(",
"$",
"tagName",
",",
"$",
"this",
"->",
"CDATAEncoding",
")",
"&&",
"$",
"this",
"->",
"version",
"==",
"self",
"::",
"ATOM",
")",
"?",
"' type=\"html\" '",
":",
"''",
";",
"$",
"nodeText",
".=",
"(",
"in_array",
"(",
"$",
"tagName",
",",
"$",
"this",
"->",
"CDATAEncoding",
")",
")",
"?",
"\"<{$tagName}{$attrText}><![CDATA[\"",
":",
"\"<{$tagName}{$attrText}>\"",
";",
"if",
"(",
"is_array",
"(",
"$",
"tagContent",
")",
")",
"{",
"foreach",
"(",
"$",
"tagContent",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"nodeText",
".=",
"$",
"this",
"->",
"makeNode",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"else",
"{",
"$",
"nodeText",
".=",
"(",
"in_array",
"(",
"$",
"tagName",
",",
"$",
"this",
"->",
"CDATAEncoding",
")",
")",
"?",
"$",
"this",
"->",
"sanitizeCDATA",
"(",
"$",
"tagContent",
")",
":",
"htmlspecialchars",
"(",
"$",
"tagContent",
")",
";",
"}",
"$",
"nodeText",
".=",
"(",
"in_array",
"(",
"$",
"tagName",
",",
"$",
"this",
"->",
"CDATAEncoding",
")",
")",
"?",
"\"]]></$tagName>\"",
":",
"\"</$tagName>\"",
";",
"return",
"$",
"nodeText",
".",
"PHP_EOL",
";",
"}"
] |
Creates a single node as xml format
@param string $tagName name of the tag
@param mixed $tagContent tag value as string or array of nested tags in 'tagName' => 'tagValue' format
@param array $attributes Attributes (if any) in 'attrName' => 'attrValue' format
@return string formatted xml tag
|
[
"Creates",
"a",
"single",
"node",
"as",
"xml",
"format"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer.php#L316-L357
|
20,246 |
texthtml/oauth2-provider
|
src/OAuth2AuthenticationListener.php
|
OAuth2AuthenticationListener.handle
|
public function handle(GetResponseEvent $event)
{
$request = BridgeRequest::createFromRequest($event->getRequest());
$response = new BridgeResponse;
if (!$this->oauth2Server->verifyResourceRequest($request, $response)) {
return;
}
try {
$token = $this->oauth2Server->getAccessTokenData($request);
$token = $this->authenticationManager->authenticate(
new OAuth2Token(
$token['client_id'],
$token['user_id'],
$token['access_token'],
$this->providerKey,
[],
explode(" ", $token['scope'])
)
);
$this->tokenStorage->setToken($token);
} catch (AuthenticationException $failed) {
$this->handleAuthenticationError($event, $request, $failed);
}
}
|
php
|
public function handle(GetResponseEvent $event)
{
$request = BridgeRequest::createFromRequest($event->getRequest());
$response = new BridgeResponse;
if (!$this->oauth2Server->verifyResourceRequest($request, $response)) {
return;
}
try {
$token = $this->oauth2Server->getAccessTokenData($request);
$token = $this->authenticationManager->authenticate(
new OAuth2Token(
$token['client_id'],
$token['user_id'],
$token['access_token'],
$this->providerKey,
[],
explode(" ", $token['scope'])
)
);
$this->tokenStorage->setToken($token);
} catch (AuthenticationException $failed) {
$this->handleAuthenticationError($event, $request, $failed);
}
}
|
[
"public",
"function",
"handle",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"BridgeRequest",
"::",
"createFromRequest",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
")",
";",
"$",
"response",
"=",
"new",
"BridgeResponse",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"oauth2Server",
"->",
"verifyResourceRequest",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"oauth2Server",
"->",
"getAccessTokenData",
"(",
"$",
"request",
")",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"authenticationManager",
"->",
"authenticate",
"(",
"new",
"OAuth2Token",
"(",
"$",
"token",
"[",
"'client_id'",
"]",
",",
"$",
"token",
"[",
"'user_id'",
"]",
",",
"$",
"token",
"[",
"'access_token'",
"]",
",",
"$",
"this",
"->",
"providerKey",
",",
"[",
"]",
",",
"explode",
"(",
"\" \"",
",",
"$",
"token",
"[",
"'scope'",
"]",
")",
")",
")",
";",
"$",
"this",
"->",
"tokenStorage",
"->",
"setToken",
"(",
"$",
"token",
")",
";",
"}",
"catch",
"(",
"AuthenticationException",
"$",
"failed",
")",
"{",
"$",
"this",
"->",
"handleAuthenticationError",
"(",
"$",
"event",
",",
"$",
"request",
",",
"$",
"failed",
")",
";",
"}",
"}"
] |
Handles basic authentication.
@param GetResponseEvent $event A GetResponseEvent instance
|
[
"Handles",
"basic",
"authentication",
"."
] |
a216205b8466ae16e0b8e17249ce89b90db1f5d4
|
https://github.com/texthtml/oauth2-provider/blob/a216205b8466ae16e0b8e17249ce89b90db1f5d4/src/OAuth2AuthenticationListener.php#L52-L77
|
20,247 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Block/Plugin.php
|
Dwoo_Block_Plugin.preProcessing
|
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
{
return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.Dwoo_Compiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.Dwoo_Compiler::PHP_CLOSE;
}
|
php
|
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
{
return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.Dwoo_Compiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.Dwoo_Compiler::PHP_CLOSE;
}
|
[
"public",
"static",
"function",
"preProcessing",
"(",
"Dwoo_Compiler",
"$",
"compiler",
",",
"array",
"$",
"params",
",",
"$",
"prepend",
",",
"$",
"append",
",",
"$",
"type",
")",
"{",
"return",
"Dwoo_Compiler",
"::",
"PHP_OPEN",
".",
"$",
"prepend",
".",
"'$this->addStack(\"'",
".",
"$",
"type",
".",
"'\", array('",
".",
"Dwoo_Compiler",
"::",
"implode_r",
"(",
"$",
"compiler",
"->",
"getCompiledParams",
"(",
"$",
"params",
")",
")",
".",
"'));'",
".",
"$",
"append",
".",
"Dwoo_Compiler",
"::",
"PHP_CLOSE",
";",
"}"
] |
called at compile time to define what the block should output in the compiled template code, happens when the block is declared
basically this will replace the {block arg arg arg} tag in the template
@param Dwoo_Compiler $compiler the compiler instance that calls this function
@param array $params an array containing original and compiled parameters
@param string $prepend that is just meant to allow a child class to call
parent::postProcessing($compiler, $params, "foo();") to add a command before the
default commands are executed
@param string $append that is just meant to allow a child class to call
parent::postProcessing($compiler, $params, null, "foo();") to add a command after the
default commands are executed
@param string $type the type is the plugin class name used
|
[
"called",
"at",
"compile",
"time",
"to",
"define",
"what",
"the",
"block",
"should",
"output",
"in",
"the",
"compiled",
"template",
"code",
"happens",
"when",
"the",
"block",
"is",
"declared"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Block/Plugin.php#L78-L81
|
20,248 |
ekuiter/feature-php
|
FeaturePhp/Exporter/DownloadZipExporter.php
|
DownloadZipExporter.download
|
private function download($productLineName) {
$productLineName = str_replace("\"", "", $productLineName);
if (headers_sent())
throw new DownloadZipExporterException("could download zip archive");
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"$productLineName.zip\"");
set_time_limit(0);
$file = @fopen($this->target, "rb");
while(!feof($file)) {
print(@fread($file, 1024*8));
ob_flush();
flush();
}
}
|
php
|
private function download($productLineName) {
$productLineName = str_replace("\"", "", $productLineName);
if (headers_sent())
throw new DownloadZipExporterException("could download zip archive");
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"$productLineName.zip\"");
set_time_limit(0);
$file = @fopen($this->target, "rb");
while(!feof($file)) {
print(@fread($file, 1024*8));
ob_flush();
flush();
}
}
|
[
"private",
"function",
"download",
"(",
"$",
"productLineName",
")",
"{",
"$",
"productLineName",
"=",
"str_replace",
"(",
"\"\\\"\"",
",",
"\"\"",
",",
"$",
"productLineName",
")",
";",
"if",
"(",
"headers_sent",
"(",
")",
")",
"throw",
"new",
"DownloadZipExporterException",
"(",
"\"could download zip archive\"",
")",
";",
"header",
"(",
"\"Content-Type: application/zip\"",
")",
";",
"header",
"(",
"\"Content-Disposition: attachment; filename=\\\"$productLineName.zip\\\"\"",
")",
";",
"set_time_limit",
"(",
"0",
")",
";",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"target",
",",
"\"rb\"",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"file",
")",
")",
"{",
"print",
"(",
"@",
"fread",
"(",
"$",
"file",
",",
"1024",
"*",
"8",
")",
")",
";",
"ob_flush",
"(",
")",
";",
"flush",
"(",
")",
";",
"}",
"}"
] |
Downloads the temporary ZIP archive.
This only works when no headers and no output have been sent yet, otherwise users receive
corrupted ZIP files.
@param string $productLineName the name of the product line, used as the ZIP archive file name
|
[
"Downloads",
"the",
"temporary",
"ZIP",
"archive",
".",
"This",
"only",
"works",
"when",
"no",
"headers",
"and",
"no",
"output",
"have",
"been",
"sent",
"yet",
"otherwise",
"users",
"receive",
"corrupted",
"ZIP",
"files",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/DownloadZipExporter.php#L55-L68
|
20,249 |
ekuiter/feature-php
|
FeaturePhp/Exporter/DownloadZipExporter.php
|
DownloadZipExporter.export
|
public function export($product) {
try {
parent::export($product);
$this->download($product->getProductLine()->getName());
} catch (\Exception $e) {}
try {
$this->remove();
} catch (\Exception $e) {}
}
|
php
|
public function export($product) {
try {
parent::export($product);
$this->download($product->getProductLine()->getName());
} catch (\Exception $e) {}
try {
$this->remove();
} catch (\Exception $e) {}
}
|
[
"public",
"function",
"export",
"(",
"$",
"product",
")",
"{",
"try",
"{",
"parent",
"::",
"export",
"(",
"$",
"product",
")",
";",
"$",
"this",
"->",
"download",
"(",
"$",
"product",
"->",
"getProductLine",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"try",
"{",
"$",
"this",
"->",
"remove",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"}"
] |
Exports a product as a ZIP archive and offers it for downloading.
This only works when no headers and no output have been sent yet.
Note that any occurring errors are ignored so that the downloaded archive will not be
corrupted. There is currently no way to obtain error information in this case because
feature-php does not have an external log file.
@param \FeaturePhp\ProductLine\Product $product
|
[
"Exports",
"a",
"product",
"as",
"a",
"ZIP",
"archive",
"and",
"offers",
"it",
"for",
"downloading",
".",
"This",
"only",
"works",
"when",
"no",
"headers",
"and",
"no",
"output",
"have",
"been",
"sent",
"yet",
".",
"Note",
"that",
"any",
"occurring",
"errors",
"are",
"ignored",
"so",
"that",
"the",
"downloaded",
"archive",
"will",
"not",
"be",
"corrupted",
".",
"There",
"is",
"currently",
"no",
"way",
"to",
"obtain",
"error",
"information",
"in",
"this",
"case",
"because",
"feature",
"-",
"php",
"does",
"not",
"have",
"an",
"external",
"log",
"file",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/DownloadZipExporter.php#L78-L87
|
20,250 |
VincentChalnot/SidusDataGridBundle
|
DependencyInjection/SidusDataGridExtension.php
|
SidusDataGridExtension.finalizeConfiguration
|
protected function finalizeConfiguration(
string $code,
array $dataGridConfiguration
): array {
// Handle possible parent configuration @todo find a better way to do this
if (isset($dataGridConfiguration['parent'])) {
$parent = $dataGridConfiguration['parent'];
if (empty($this->globalConfiguration['configurations'][$parent])) {
throw new UnexpectedValueException("Unknown configuration {$parent}");
}
$parentConfig = $this->globalConfiguration['configurations'][$parent];
$dataGridConfiguration = array_merge($parentConfig, $dataGridConfiguration);
}
unset($dataGridConfiguration['parent']);
// Set default values from global configuration
if (empty($dataGridConfiguration['form_theme'])) {
$dataGridConfiguration['form_theme'] = $this->globalConfiguration['default_form_theme'];
}
if (empty($dataGridConfiguration['template'])) {
$dataGridConfiguration['template'] = $this->globalConfiguration['default_datagrid_template'];
}
if (empty($dataGridConfiguration['column_value_renderer'])) {
$dataGridConfiguration['column_value_renderer'] = $this->globalConfiguration['default_column_value_renderer'];
}
if (empty($dataGridConfiguration['column_label_renderer'])) {
$dataGridConfiguration['column_label_renderer'] = $this->globalConfiguration['default_column_label_renderer'];
}
if (isset($dataGridConfiguration['query_handler'])) {
// Allow either a service or a direct configuration for filters
if (\is_array($dataGridConfiguration['query_handler'])) {
$dataGridConfiguration['query_handler'] = $this->finalizeFilterConfiguration(
$code,
$dataGridConfiguration['query_handler']
);
} elseif (0 === strpos($dataGridConfiguration['query_handler'], '@')) {
$dataGridConfiguration['query_handler'] = new Reference(
ltrim($dataGridConfiguration['query_handler'], '@')
);
} else {
throw new UnexpectedValueException(
'query_handler option must be either a service or a valid filter configuration'
);
}
}
return $dataGridConfiguration;
}
|
php
|
protected function finalizeConfiguration(
string $code,
array $dataGridConfiguration
): array {
// Handle possible parent configuration @todo find a better way to do this
if (isset($dataGridConfiguration['parent'])) {
$parent = $dataGridConfiguration['parent'];
if (empty($this->globalConfiguration['configurations'][$parent])) {
throw new UnexpectedValueException("Unknown configuration {$parent}");
}
$parentConfig = $this->globalConfiguration['configurations'][$parent];
$dataGridConfiguration = array_merge($parentConfig, $dataGridConfiguration);
}
unset($dataGridConfiguration['parent']);
// Set default values from global configuration
if (empty($dataGridConfiguration['form_theme'])) {
$dataGridConfiguration['form_theme'] = $this->globalConfiguration['default_form_theme'];
}
if (empty($dataGridConfiguration['template'])) {
$dataGridConfiguration['template'] = $this->globalConfiguration['default_datagrid_template'];
}
if (empty($dataGridConfiguration['column_value_renderer'])) {
$dataGridConfiguration['column_value_renderer'] = $this->globalConfiguration['default_column_value_renderer'];
}
if (empty($dataGridConfiguration['column_label_renderer'])) {
$dataGridConfiguration['column_label_renderer'] = $this->globalConfiguration['default_column_label_renderer'];
}
if (isset($dataGridConfiguration['query_handler'])) {
// Allow either a service or a direct configuration for filters
if (\is_array($dataGridConfiguration['query_handler'])) {
$dataGridConfiguration['query_handler'] = $this->finalizeFilterConfiguration(
$code,
$dataGridConfiguration['query_handler']
);
} elseif (0 === strpos($dataGridConfiguration['query_handler'], '@')) {
$dataGridConfiguration['query_handler'] = new Reference(
ltrim($dataGridConfiguration['query_handler'], '@')
);
} else {
throw new UnexpectedValueException(
'query_handler option must be either a service or a valid filter configuration'
);
}
}
return $dataGridConfiguration;
}
|
[
"protected",
"function",
"finalizeConfiguration",
"(",
"string",
"$",
"code",
",",
"array",
"$",
"dataGridConfiguration",
")",
":",
"array",
"{",
"// Handle possible parent configuration @todo find a better way to do this",
"if",
"(",
"isset",
"(",
"$",
"dataGridConfiguration",
"[",
"'parent'",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"dataGridConfiguration",
"[",
"'parent'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"globalConfiguration",
"[",
"'configurations'",
"]",
"[",
"$",
"parent",
"]",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"Unknown configuration {$parent}\"",
")",
";",
"}",
"$",
"parentConfig",
"=",
"$",
"this",
"->",
"globalConfiguration",
"[",
"'configurations'",
"]",
"[",
"$",
"parent",
"]",
";",
"$",
"dataGridConfiguration",
"=",
"array_merge",
"(",
"$",
"parentConfig",
",",
"$",
"dataGridConfiguration",
")",
";",
"}",
"unset",
"(",
"$",
"dataGridConfiguration",
"[",
"'parent'",
"]",
")",
";",
"// Set default values from global configuration",
"if",
"(",
"empty",
"(",
"$",
"dataGridConfiguration",
"[",
"'form_theme'",
"]",
")",
")",
"{",
"$",
"dataGridConfiguration",
"[",
"'form_theme'",
"]",
"=",
"$",
"this",
"->",
"globalConfiguration",
"[",
"'default_form_theme'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"dataGridConfiguration",
"[",
"'template'",
"]",
")",
")",
"{",
"$",
"dataGridConfiguration",
"[",
"'template'",
"]",
"=",
"$",
"this",
"->",
"globalConfiguration",
"[",
"'default_datagrid_template'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"dataGridConfiguration",
"[",
"'column_value_renderer'",
"]",
")",
")",
"{",
"$",
"dataGridConfiguration",
"[",
"'column_value_renderer'",
"]",
"=",
"$",
"this",
"->",
"globalConfiguration",
"[",
"'default_column_value_renderer'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"dataGridConfiguration",
"[",
"'column_label_renderer'",
"]",
")",
")",
"{",
"$",
"dataGridConfiguration",
"[",
"'column_label_renderer'",
"]",
"=",
"$",
"this",
"->",
"globalConfiguration",
"[",
"'default_column_label_renderer'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
")",
")",
"{",
"// Allow either a service or a direct configuration for filters",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
")",
")",
"{",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
"=",
"$",
"this",
"->",
"finalizeFilterConfiguration",
"(",
"$",
"code",
",",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
")",
";",
"}",
"elseif",
"(",
"0",
"===",
"strpos",
"(",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
",",
"'@'",
")",
")",
"{",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
"=",
"new",
"Reference",
"(",
"ltrim",
"(",
"$",
"dataGridConfiguration",
"[",
"'query_handler'",
"]",
",",
"'@'",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'query_handler option must be either a service or a valid filter configuration'",
")",
";",
"}",
"}",
"return",
"$",
"dataGridConfiguration",
";",
"}"
] |
Handle configuration parsing logic not handled by the semantic configuration definition
@param string $code
@param array $dataGridConfiguration
@throws \Exception
@return array
|
[
"Handle",
"configuration",
"parsing",
"logic",
"not",
"handled",
"by",
"the",
"semantic",
"configuration",
"definition"
] |
aa929113e2208ed335f514d2891affaf7fddf3f6
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/DependencyInjection/SidusDataGridExtension.php#L62-L110
|
20,251 |
SachaMorard/phalcon-model-annotations
|
Library/Phalcon/Annotations/ModelListener.php
|
ModelListener.afterInitialize
|
public function afterInitialize(Event $event, ModelsManager $manager, $model)
{
//Reflector
/** @var \Phalcon\Annotations\Reflection $reflector */
$reflector = $this->annotations->get($model);
/**
* Read the annotations in the class' docblock
*/
$annotations = $reflector->getClassAnnotations();
if ($annotations) {
/**
* Traverse the annotations
*/
foreach ($annotations as $annotation) {
switch ($annotation->getName()) {
/**
* Initializes the model's source
*/
case 'Source':
$arguments = $annotation->getArguments();
$model->setConnectionService($arguments[0]);
$manager->setModelSource($model, $arguments[1]);
break;
/**
* Initializes Has-Many relations
*/
case 'HasMany':
$arguments = $annotation->getArguments();
if (!isset($arguments[3])) {
$arguments[3] = null;
}
$manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
/**
* Initializes Has-Many-To-Many relations
*/
case 'HasManyToMany':
$arguments = $annotation->getArguments();
if (!isset($arguments[6])) {
$arguments[6] = null;
}
$manager->addHasManyToMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]);
break;
/**
* Initializes Has-One relations
*/
case 'HasOne':
$arguments = $annotation->getArguments();
if (!isset($arguments[3])) {
$arguments[3] = null;
}
$manager->addHasOne($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
/**
* Initializes Has-Many relations
*/
case 'BelongsTo':
$arguments = $annotation->getArguments();
if (!isset($arguments[3])) {
$arguments[3] = null;
}
$manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
}
}
}
}
|
php
|
public function afterInitialize(Event $event, ModelsManager $manager, $model)
{
//Reflector
/** @var \Phalcon\Annotations\Reflection $reflector */
$reflector = $this->annotations->get($model);
/**
* Read the annotations in the class' docblock
*/
$annotations = $reflector->getClassAnnotations();
if ($annotations) {
/**
* Traverse the annotations
*/
foreach ($annotations as $annotation) {
switch ($annotation->getName()) {
/**
* Initializes the model's source
*/
case 'Source':
$arguments = $annotation->getArguments();
$model->setConnectionService($arguments[0]);
$manager->setModelSource($model, $arguments[1]);
break;
/**
* Initializes Has-Many relations
*/
case 'HasMany':
$arguments = $annotation->getArguments();
if (!isset($arguments[3])) {
$arguments[3] = null;
}
$manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
/**
* Initializes Has-Many-To-Many relations
*/
case 'HasManyToMany':
$arguments = $annotation->getArguments();
if (!isset($arguments[6])) {
$arguments[6] = null;
}
$manager->addHasManyToMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]);
break;
/**
* Initializes Has-One relations
*/
case 'HasOne':
$arguments = $annotation->getArguments();
if (!isset($arguments[3])) {
$arguments[3] = null;
}
$manager->addHasOne($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
/**
* Initializes Has-Many relations
*/
case 'BelongsTo':
$arguments = $annotation->getArguments();
if (!isset($arguments[3])) {
$arguments[3] = null;
}
$manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
}
}
}
}
|
[
"public",
"function",
"afterInitialize",
"(",
"Event",
"$",
"event",
",",
"ModelsManager",
"$",
"manager",
",",
"$",
"model",
")",
"{",
"//Reflector",
"/** @var \\Phalcon\\Annotations\\Reflection $reflector */",
"$",
"reflector",
"=",
"$",
"this",
"->",
"annotations",
"->",
"get",
"(",
"$",
"model",
")",
";",
"/**\n * Read the annotations in the class' docblock\n */",
"$",
"annotations",
"=",
"$",
"reflector",
"->",
"getClassAnnotations",
"(",
")",
";",
"if",
"(",
"$",
"annotations",
")",
"{",
"/**\n * Traverse the annotations\n */",
"foreach",
"(",
"$",
"annotations",
"as",
"$",
"annotation",
")",
"{",
"switch",
"(",
"$",
"annotation",
"->",
"getName",
"(",
")",
")",
"{",
"/**\n * Initializes the model's source\n */",
"case",
"'Source'",
":",
"$",
"arguments",
"=",
"$",
"annotation",
"->",
"getArguments",
"(",
")",
";",
"$",
"model",
"->",
"setConnectionService",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
";",
"$",
"manager",
"->",
"setModelSource",
"(",
"$",
"model",
",",
"$",
"arguments",
"[",
"1",
"]",
")",
";",
"break",
";",
"/**\n * Initializes Has-Many relations\n */",
"case",
"'HasMany'",
":",
"$",
"arguments",
"=",
"$",
"annotation",
"->",
"getArguments",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
"[",
"3",
"]",
")",
")",
"{",
"$",
"arguments",
"[",
"3",
"]",
"=",
"null",
";",
"}",
"$",
"manager",
"->",
"addHasMany",
"(",
"$",
"model",
",",
"$",
"arguments",
"[",
"0",
"]",
",",
"$",
"arguments",
"[",
"1",
"]",
",",
"$",
"arguments",
"[",
"2",
"]",
",",
"$",
"arguments",
"[",
"3",
"]",
")",
";",
"break",
";",
"/**\n * Initializes Has-Many-To-Many relations\n */",
"case",
"'HasManyToMany'",
":",
"$",
"arguments",
"=",
"$",
"annotation",
"->",
"getArguments",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
"[",
"6",
"]",
")",
")",
"{",
"$",
"arguments",
"[",
"6",
"]",
"=",
"null",
";",
"}",
"$",
"manager",
"->",
"addHasManyToMany",
"(",
"$",
"model",
",",
"$",
"arguments",
"[",
"0",
"]",
",",
"$",
"arguments",
"[",
"1",
"]",
",",
"$",
"arguments",
"[",
"2",
"]",
",",
"$",
"arguments",
"[",
"3",
"]",
",",
"$",
"arguments",
"[",
"4",
"]",
",",
"$",
"arguments",
"[",
"5",
"]",
",",
"$",
"arguments",
"[",
"6",
"]",
")",
";",
"break",
";",
"/**\n * Initializes Has-One relations\n */",
"case",
"'HasOne'",
":",
"$",
"arguments",
"=",
"$",
"annotation",
"->",
"getArguments",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
"[",
"3",
"]",
")",
")",
"{",
"$",
"arguments",
"[",
"3",
"]",
"=",
"null",
";",
"}",
"$",
"manager",
"->",
"addHasOne",
"(",
"$",
"model",
",",
"$",
"arguments",
"[",
"0",
"]",
",",
"$",
"arguments",
"[",
"1",
"]",
",",
"$",
"arguments",
"[",
"2",
"]",
",",
"$",
"arguments",
"[",
"3",
"]",
")",
";",
"break",
";",
"/**\n * Initializes Has-Many relations\n */",
"case",
"'BelongsTo'",
":",
"$",
"arguments",
"=",
"$",
"annotation",
"->",
"getArguments",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
"[",
"3",
"]",
")",
")",
"{",
"$",
"arguments",
"[",
"3",
"]",
"=",
"null",
";",
"}",
"$",
"manager",
"->",
"addBelongsTo",
"(",
"$",
"model",
",",
"$",
"arguments",
"[",
"0",
"]",
",",
"$",
"arguments",
"[",
"1",
"]",
",",
"$",
"arguments",
"[",
"2",
"]",
",",
"$",
"arguments",
"[",
"3",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
This is called after initialize the model
@param Event $event
@param ModelsManager $manager
@param $model
|
[
"This",
"is",
"called",
"after",
"initialize",
"the",
"model"
] |
64cb04903f101c1fd85e8067c0dcdfc6ca133fb5
|
https://github.com/SachaMorard/phalcon-model-annotations/blob/64cb04903f101c1fd85e8067c0dcdfc6ca133fb5/Library/Phalcon/Annotations/ModelListener.php#L25-L91
|
20,252 |
krakphp/job
|
src/Queue/Doctrine/DoctrineQueue.php
|
DoctrineQueue.dequeue
|
public function dequeue() {
if (!count($this->cached_jobs)) {
$this->cached_jobs = $this->repo->getAvailableJobs($this->name);
}
if (!count($this->cached_jobs)) {
return;
}
$job_row = array_shift($this->cached_jobs);
$job = Job\WrappedJob::fromString($job_row['job'])->withAddedPayload([
'_doctrine' => ['id' => $job_row['id']]
])->withQueueProvider('doctrine');
$this->repo->processJob($job);
return $job;
}
|
php
|
public function dequeue() {
if (!count($this->cached_jobs)) {
$this->cached_jobs = $this->repo->getAvailableJobs($this->name);
}
if (!count($this->cached_jobs)) {
return;
}
$job_row = array_shift($this->cached_jobs);
$job = Job\WrappedJob::fromString($job_row['job'])->withAddedPayload([
'_doctrine' => ['id' => $job_row['id']]
])->withQueueProvider('doctrine');
$this->repo->processJob($job);
return $job;
}
|
[
"public",
"function",
"dequeue",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"cached_jobs",
")",
")",
"{",
"$",
"this",
"->",
"cached_jobs",
"=",
"$",
"this",
"->",
"repo",
"->",
"getAvailableJobs",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"cached_jobs",
")",
")",
"{",
"return",
";",
"}",
"$",
"job_row",
"=",
"array_shift",
"(",
"$",
"this",
"->",
"cached_jobs",
")",
";",
"$",
"job",
"=",
"Job",
"\\",
"WrappedJob",
"::",
"fromString",
"(",
"$",
"job_row",
"[",
"'job'",
"]",
")",
"->",
"withAddedPayload",
"(",
"[",
"'_doctrine'",
"=>",
"[",
"'id'",
"=>",
"$",
"job_row",
"[",
"'id'",
"]",
"]",
"]",
")",
"->",
"withQueueProvider",
"(",
"'doctrine'",
")",
";",
"$",
"this",
"->",
"repo",
"->",
"processJob",
"(",
"$",
"job",
")",
";",
"return",
"$",
"job",
";",
"}"
] |
take a job off of the queue
|
[
"take",
"a",
"job",
"off",
"of",
"the",
"queue"
] |
0c16020c1baa13d91f819ecba8334861ba7c4d6c
|
https://github.com/krakphp/job/blob/0c16020c1baa13d91f819ecba8334861ba7c4d6c/src/Queue/Doctrine/DoctrineQueue.php#L24-L38
|
20,253 |
shabbyrobe/amiss
|
src/Filter.php
|
Filter.getChildren
|
public function getChildren($objects, $path)
{
$array = array();
if (!is_array($path)) {
$path = explode('/', $path);
}
if (!is_array($objects)) {
$objects = array($objects);
}
$ret = $objects;
foreach ($path as $child) {
$array = [];
$meta = null;
$properties = null;
if ($ret && is_object(current($ret))) {
$meta = $this->mapper->getMeta(get_class(current($ret)), !'strict');
if ($meta) {
$properties = $meta->getProperties();
}
}
foreach ($ret as $o) {
$field = isset($properties[$child]) ? $properties[$child] : null;
if (!$field || !isset($field['getter'])) {
$value = $o->{$child};
} else {
$g = [$o, $field['getter']];
$value = $g();
}
if (is_array($value) || $value instanceof \Traversable) {
$array = array_merge($array, $value);
}
elseif ($value !== null) {
$array[] = $value;
}
}
$ret = $array;
}
return $ret;
}
|
php
|
public function getChildren($objects, $path)
{
$array = array();
if (!is_array($path)) {
$path = explode('/', $path);
}
if (!is_array($objects)) {
$objects = array($objects);
}
$ret = $objects;
foreach ($path as $child) {
$array = [];
$meta = null;
$properties = null;
if ($ret && is_object(current($ret))) {
$meta = $this->mapper->getMeta(get_class(current($ret)), !'strict');
if ($meta) {
$properties = $meta->getProperties();
}
}
foreach ($ret as $o) {
$field = isset($properties[$child]) ? $properties[$child] : null;
if (!$field || !isset($field['getter'])) {
$value = $o->{$child};
} else {
$g = [$o, $field['getter']];
$value = $g();
}
if (is_array($value) || $value instanceof \Traversable) {
$array = array_merge($array, $value);
}
elseif ($value !== null) {
$array[] = $value;
}
}
$ret = $array;
}
return $ret;
}
|
[
"public",
"function",
"getChildren",
"(",
"$",
"objects",
",",
"$",
"path",
")",
"{",
"$",
"array",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"objects",
")",
")",
"{",
"$",
"objects",
"=",
"array",
"(",
"$",
"objects",
")",
";",
"}",
"$",
"ret",
"=",
"$",
"objects",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"child",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"$",
"meta",
"=",
"null",
";",
"$",
"properties",
"=",
"null",
";",
"if",
"(",
"$",
"ret",
"&&",
"is_object",
"(",
"current",
"(",
"$",
"ret",
")",
")",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getMeta",
"(",
"get_class",
"(",
"current",
"(",
"$",
"ret",
")",
")",
",",
"!",
"'strict'",
")",
";",
"if",
"(",
"$",
"meta",
")",
"{",
"$",
"properties",
"=",
"$",
"meta",
"->",
"getProperties",
"(",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"ret",
"as",
"$",
"o",
")",
"{",
"$",
"field",
"=",
"isset",
"(",
"$",
"properties",
"[",
"$",
"child",
"]",
")",
"?",
"$",
"properties",
"[",
"$",
"child",
"]",
":",
"null",
";",
"if",
"(",
"!",
"$",
"field",
"||",
"!",
"isset",
"(",
"$",
"field",
"[",
"'getter'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"o",
"->",
"{",
"$",
"child",
"}",
";",
"}",
"else",
"{",
"$",
"g",
"=",
"[",
"$",
"o",
",",
"$",
"field",
"[",
"'getter'",
"]",
"]",
";",
"$",
"value",
"=",
"$",
"g",
"(",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"array",
"=",
"array_merge",
"(",
"$",
"array",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"ret",
"=",
"$",
"array",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Retrieve all object child values through a property path.
Path can be an array: ['prop', 'childProp', 'veryChildProp']
Or a '/' delimited string: prop/childProp/veryChildProp
@param object[] $objects
@param string|array $path
@return array
|
[
"Retrieve",
"all",
"object",
"child",
"values",
"through",
"a",
"property",
"path",
"."
] |
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
|
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Filter.php#L23-L68
|
20,254 |
shabbyrobe/amiss
|
src/Filter.php
|
Filter.indexBy
|
public function indexBy($list, $property, $meta=null, $allowDupes=null, $ignoreNulls=null)
{
$allowDupes = $allowDupes !== null ? $allowDupes : false;
$ignoreNulls = $ignoreNulls !== null ? $ignoreNulls : true;
if (!$list) {
return [];
}
if ($meta) {
$meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
}
else {
if (!($first = current($list))) {
throw new \UnexpectedValueException();
}
$meta = $this->mapper->getMeta(get_class($first));
}
$index = array();
$props = $meta ? $meta->getProperties() : [];
foreach ($list as $object) {
$propDef = !isset($props[$property]) ? null : $props[$property];
$value = !$propDef || !isset($propDef['getter'])
? $object->{$property}
: call_user_func(array($object, $propDef['getter']));
if ($value === null && $ignoreNulls) {
continue;
}
if (!$allowDupes && isset($index[$value])) {
throw new \UnexpectedValueException("Duplicate value for property $property");
}
$index[$value] = $object;
}
return $index;
}
|
php
|
public function indexBy($list, $property, $meta=null, $allowDupes=null, $ignoreNulls=null)
{
$allowDupes = $allowDupes !== null ? $allowDupes : false;
$ignoreNulls = $ignoreNulls !== null ? $ignoreNulls : true;
if (!$list) {
return [];
}
if ($meta) {
$meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
}
else {
if (!($first = current($list))) {
throw new \UnexpectedValueException();
}
$meta = $this->mapper->getMeta(get_class($first));
}
$index = array();
$props = $meta ? $meta->getProperties() : [];
foreach ($list as $object) {
$propDef = !isset($props[$property]) ? null : $props[$property];
$value = !$propDef || !isset($propDef['getter'])
? $object->{$property}
: call_user_func(array($object, $propDef['getter']));
if ($value === null && $ignoreNulls) {
continue;
}
if (!$allowDupes && isset($index[$value])) {
throw new \UnexpectedValueException("Duplicate value for property $property");
}
$index[$value] = $object;
}
return $index;
}
|
[
"public",
"function",
"indexBy",
"(",
"$",
"list",
",",
"$",
"property",
",",
"$",
"meta",
"=",
"null",
",",
"$",
"allowDupes",
"=",
"null",
",",
"$",
"ignoreNulls",
"=",
"null",
")",
"{",
"$",
"allowDupes",
"=",
"$",
"allowDupes",
"!==",
"null",
"?",
"$",
"allowDupes",
":",
"false",
";",
"$",
"ignoreNulls",
"=",
"$",
"ignoreNulls",
"!==",
"null",
"?",
"$",
"ignoreNulls",
":",
"true",
";",
"if",
"(",
"!",
"$",
"list",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"meta",
")",
"{",
"$",
"meta",
"=",
"!",
"$",
"meta",
"instanceof",
"Meta",
"?",
"$",
"this",
"->",
"mapper",
"->",
"getMeta",
"(",
"$",
"meta",
")",
":",
"$",
"meta",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"(",
"$",
"first",
"=",
"current",
"(",
"$",
"list",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
")",
";",
"}",
"$",
"meta",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getMeta",
"(",
"get_class",
"(",
"$",
"first",
")",
")",
";",
"}",
"$",
"index",
"=",
"array",
"(",
")",
";",
"$",
"props",
"=",
"$",
"meta",
"?",
"$",
"meta",
"->",
"getProperties",
"(",
")",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"object",
")",
"{",
"$",
"propDef",
"=",
"!",
"isset",
"(",
"$",
"props",
"[",
"$",
"property",
"]",
")",
"?",
"null",
":",
"$",
"props",
"[",
"$",
"property",
"]",
";",
"$",
"value",
"=",
"!",
"$",
"propDef",
"||",
"!",
"isset",
"(",
"$",
"propDef",
"[",
"'getter'",
"]",
")",
"?",
"$",
"object",
"->",
"{",
"$",
"property",
"}",
":",
"call_user_func",
"(",
"array",
"(",
"$",
"object",
",",
"$",
"propDef",
"[",
"'getter'",
"]",
")",
")",
";",
"if",
"(",
"$",
"value",
"===",
"null",
"&&",
"$",
"ignoreNulls",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"allowDupes",
"&&",
"isset",
"(",
"$",
"index",
"[",
"$",
"value",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Duplicate value for property $property\"",
")",
";",
"}",
"$",
"index",
"[",
"$",
"value",
"]",
"=",
"$",
"object",
";",
"}",
"return",
"$",
"index",
";",
"}"
] |
Iterate over an array of objects and returns an array of objects
indexed by a property
@return array
|
[
"Iterate",
"over",
"an",
"array",
"of",
"objects",
"and",
"returns",
"an",
"array",
"of",
"objects",
"indexed",
"by",
"a",
"property"
] |
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
|
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Filter.php#L76-L113
|
20,255 |
shabbyrobe/amiss
|
src/Filter.php
|
Filter.groupBy
|
public function groupBy($list, $property, $meta=null)
{
if (!$list) {
return [];
}
if (!$meta) {
if (!($first = current($list))) {
throw new \UnexpectedValueException();
}
$meta = $this->mapper->getMeta(get_class($first));
}
$groups = [];
$props = $meta->getProperties();
foreach ($list as $object) {
$propDef = !isset($props[$property]) ? null : $props[$property];
$value = !$propDef || !isset($propDef['getter'])
? $object->{$property}
: call_user_func(array($object, $propDef['getter']));
$groups[$value][] = $object;
}
return $groups;
}
|
php
|
public function groupBy($list, $property, $meta=null)
{
if (!$list) {
return [];
}
if (!$meta) {
if (!($first = current($list))) {
throw new \UnexpectedValueException();
}
$meta = $this->mapper->getMeta(get_class($first));
}
$groups = [];
$props = $meta->getProperties();
foreach ($list as $object) {
$propDef = !isset($props[$property]) ? null : $props[$property];
$value = !$propDef || !isset($propDef['getter'])
? $object->{$property}
: call_user_func(array($object, $propDef['getter']));
$groups[$value][] = $object;
}
return $groups;
}
|
[
"public",
"function",
"groupBy",
"(",
"$",
"list",
",",
"$",
"property",
",",
"$",
"meta",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"list",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"meta",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"first",
"=",
"current",
"(",
"$",
"list",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
")",
";",
"}",
"$",
"meta",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getMeta",
"(",
"get_class",
"(",
"$",
"first",
")",
")",
";",
"}",
"$",
"groups",
"=",
"[",
"]",
";",
"$",
"props",
"=",
"$",
"meta",
"->",
"getProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"object",
")",
"{",
"$",
"propDef",
"=",
"!",
"isset",
"(",
"$",
"props",
"[",
"$",
"property",
"]",
")",
"?",
"null",
":",
"$",
"props",
"[",
"$",
"property",
"]",
";",
"$",
"value",
"=",
"!",
"$",
"propDef",
"||",
"!",
"isset",
"(",
"$",
"propDef",
"[",
"'getter'",
"]",
")",
"?",
"$",
"object",
"->",
"{",
"$",
"property",
"}",
":",
"call_user_func",
"(",
"array",
"(",
"$",
"object",
",",
"$",
"propDef",
"[",
"'getter'",
"]",
")",
")",
";",
"$",
"groups",
"[",
"$",
"value",
"]",
"[",
"]",
"=",
"$",
"object",
";",
"}",
"return",
"$",
"groups",
";",
"}"
] |
Iterate over an array of objects and group them by the value of a property
@return array[group] = class[]
|
[
"Iterate",
"over",
"an",
"array",
"of",
"objects",
"and",
"group",
"them",
"by",
"the",
"value",
"of",
"a",
"property"
] |
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
|
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Filter.php#L120-L144
|
20,256 |
mridang/magazine
|
lib/magento/Archive/Helper/File/Bz.php
|
Mage_Archive_Helper_File_Bz._open
|
protected function _open($mode)
{
$this->_fileHandler = @bzopen($this->_filePath, $mode);
if (false === $this->_fileHandler) {
throw new Mage_Exception('Failed to open file ' . $this->_filePath);
}
}
|
php
|
protected function _open($mode)
{
$this->_fileHandler = @bzopen($this->_filePath, $mode);
if (false === $this->_fileHandler) {
throw new Mage_Exception('Failed to open file ' . $this->_filePath);
}
}
|
[
"protected",
"function",
"_open",
"(",
"$",
"mode",
")",
"{",
"$",
"this",
"->",
"_fileHandler",
"=",
"@",
"bzopen",
"(",
"$",
"this",
"->",
"_filePath",
",",
"$",
"mode",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"_fileHandler",
")",
"{",
"throw",
"new",
"Mage_Exception",
"(",
"'Failed to open file '",
".",
"$",
"this",
"->",
"_filePath",
")",
";",
"}",
"}"
] |
Open bz archive file
@throws Mage_Exception
@param string $mode
|
[
"Open",
"bz",
"archive",
"file"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Archive/Helper/File/Bz.php#L42-L49
|
20,257 |
mridang/magazine
|
lib/magento/Archive/Helper/File/Bz.php
|
Mage_Archive_Helper_File_Bz._read
|
protected function _read($length)
{
$data = bzread($this->_fileHandler, $length);
if (false === $data) {
throw new Mage_Exception('Failed to read data from ' . $this->_filePath);
}
return $data;
}
|
php
|
protected function _read($length)
{
$data = bzread($this->_fileHandler, $length);
if (false === $data) {
throw new Mage_Exception('Failed to read data from ' . $this->_filePath);
}
return $data;
}
|
[
"protected",
"function",
"_read",
"(",
"$",
"length",
")",
"{",
"$",
"data",
"=",
"bzread",
"(",
"$",
"this",
"->",
"_fileHandler",
",",
"$",
"length",
")",
";",
"if",
"(",
"false",
"===",
"$",
"data",
")",
"{",
"throw",
"new",
"Mage_Exception",
"(",
"'Failed to read data from '",
".",
"$",
"this",
"->",
"_filePath",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Read data from bz archive
@throws Mage_Exception
@param int $length
@return string
|
[
"Read",
"data",
"from",
"bz",
"archive"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Archive/Helper/File/Bz.php#L73-L82
|
20,258 |
oroinc/OroLayoutComponent
|
OptionValueBag.php
|
OptionValueBag.buildValue
|
public function buildValue()
{
$actions = [
'add' => [],
'replace' => [],
'remove' => [],
];
foreach ($this->actions as $action) {
switch ($action->getName()) {
case 'add':
$actions['add'][] = [$action->getArgument(0)];
break;
case 'replace':
$actions['replace'][] = [$action->getArgument(0), $action->getArgument(1)];
break;
case 'remove':
$actions['remove'][] = [$action->getArgument(0)];
break;
}
}
$builder = $this->getBuilder();
foreach ($actions as $action => $calls) {
foreach ($calls as $arguments) {
call_user_func_array([$builder, $action], $arguments);
}
}
return $builder->get();
}
|
php
|
public function buildValue()
{
$actions = [
'add' => [],
'replace' => [],
'remove' => [],
];
foreach ($this->actions as $action) {
switch ($action->getName()) {
case 'add':
$actions['add'][] = [$action->getArgument(0)];
break;
case 'replace':
$actions['replace'][] = [$action->getArgument(0), $action->getArgument(1)];
break;
case 'remove':
$actions['remove'][] = [$action->getArgument(0)];
break;
}
}
$builder = $this->getBuilder();
foreach ($actions as $action => $calls) {
foreach ($calls as $arguments) {
call_user_func_array([$builder, $action], $arguments);
}
}
return $builder->get();
}
|
[
"public",
"function",
"buildValue",
"(",
")",
"{",
"$",
"actions",
"=",
"[",
"'add'",
"=>",
"[",
"]",
",",
"'replace'",
"=>",
"[",
"]",
",",
"'remove'",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"actions",
"as",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
"->",
"getName",
"(",
")",
")",
"{",
"case",
"'add'",
":",
"$",
"actions",
"[",
"'add'",
"]",
"[",
"]",
"=",
"[",
"$",
"action",
"->",
"getArgument",
"(",
"0",
")",
"]",
";",
"break",
";",
"case",
"'replace'",
":",
"$",
"actions",
"[",
"'replace'",
"]",
"[",
"]",
"=",
"[",
"$",
"action",
"->",
"getArgument",
"(",
"0",
")",
",",
"$",
"action",
"->",
"getArgument",
"(",
"1",
")",
"]",
";",
"break",
";",
"case",
"'remove'",
":",
"$",
"actions",
"[",
"'remove'",
"]",
"[",
"]",
"=",
"[",
"$",
"action",
"->",
"getArgument",
"(",
"0",
")",
"]",
";",
"break",
";",
"}",
"}",
"$",
"builder",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
"=>",
"$",
"calls",
")",
"{",
"foreach",
"(",
"$",
"calls",
"as",
"$",
"arguments",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"builder",
",",
"$",
"action",
"]",
",",
"$",
"arguments",
")",
";",
"}",
"}",
"return",
"$",
"builder",
"->",
"get",
"(",
")",
";",
"}"
] |
Builds a block option value using the given builder
@return mixed The built value
|
[
"Builds",
"a",
"block",
"option",
"value",
"using",
"the",
"given",
"builder"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/OptionValueBag.php#L59-L90
|
20,259 |
oroinc/OroLayoutComponent
|
OptionValueBag.php
|
OptionValueBag.getBuilder
|
protected function getBuilder()
{
$isArray = false;
// guess builder type based on arguments
if ($this->actions) {
/** @var Action $action */
$action = reset($this->actions);
$arguments = $action->getArguments();
if ($arguments) {
$argument = reset($arguments);
if (is_array($argument)) {
$isArray = true;
}
}
}
if ($isArray) {
return new ArrayOptionValueBuilder();
}
return new StringOptionValueBuilder();
}
|
php
|
protected function getBuilder()
{
$isArray = false;
// guess builder type based on arguments
if ($this->actions) {
/** @var Action $action */
$action = reset($this->actions);
$arguments = $action->getArguments();
if ($arguments) {
$argument = reset($arguments);
if (is_array($argument)) {
$isArray = true;
}
}
}
if ($isArray) {
return new ArrayOptionValueBuilder();
}
return new StringOptionValueBuilder();
}
|
[
"protected",
"function",
"getBuilder",
"(",
")",
"{",
"$",
"isArray",
"=",
"false",
";",
"// guess builder type based on arguments",
"if",
"(",
"$",
"this",
"->",
"actions",
")",
"{",
"/** @var Action $action */",
"$",
"action",
"=",
"reset",
"(",
"$",
"this",
"->",
"actions",
")",
";",
"$",
"arguments",
"=",
"$",
"action",
"->",
"getArguments",
"(",
")",
";",
"if",
"(",
"$",
"arguments",
")",
"{",
"$",
"argument",
"=",
"reset",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"argument",
")",
")",
"{",
"$",
"isArray",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"isArray",
")",
"{",
"return",
"new",
"ArrayOptionValueBuilder",
"(",
")",
";",
"}",
"return",
"new",
"StringOptionValueBuilder",
"(",
")",
";",
"}"
] |
Returns options builder based on values in value bag
@return OptionValueBuilderInterface
|
[
"Returns",
"options",
"builder",
"based",
"on",
"values",
"in",
"value",
"bag"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/OptionValueBag.php#L97-L119
|
20,260 |
phpnfe/tools
|
src/Certificado/Dom.php
|
Dom.getNodeValue
|
public function getNodeValue($nodeName, $itemNum = 0, $extraTextBefore = '', $extraTextAfter = '')
{
$node = $this->getElementsByTagName($nodeName)->item($itemNum);
if (isset($node)) {
$texto = html_entity_decode(trim($node->nodeValue), ENT_QUOTES, 'UTF-8');
return $extraTextBefore . $texto . $extraTextAfter;
}
return '';
}
|
php
|
public function getNodeValue($nodeName, $itemNum = 0, $extraTextBefore = '', $extraTextAfter = '')
{
$node = $this->getElementsByTagName($nodeName)->item($itemNum);
if (isset($node)) {
$texto = html_entity_decode(trim($node->nodeValue), ENT_QUOTES, 'UTF-8');
return $extraTextBefore . $texto . $extraTextAfter;
}
return '';
}
|
[
"public",
"function",
"getNodeValue",
"(",
"$",
"nodeName",
",",
"$",
"itemNum",
"=",
"0",
",",
"$",
"extraTextBefore",
"=",
"''",
",",
"$",
"extraTextAfter",
"=",
"''",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getElementsByTagName",
"(",
"$",
"nodeName",
")",
"->",
"item",
"(",
"$",
"itemNum",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"node",
")",
")",
"{",
"$",
"texto",
"=",
"html_entity_decode",
"(",
"trim",
"(",
"$",
"node",
"->",
"nodeValue",
")",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
";",
"return",
"$",
"extraTextBefore",
".",
"$",
"texto",
".",
"$",
"extraTextAfter",
";",
"}",
"return",
"''",
";",
"}"
] |
getNodeValue.
Extrai o valor do node DOM.
@param string $nodeName identificador da TAG do xml
@param int $itemNum numero do item a ser retornado
@param string $extraTextBefore prefixo do retorno
@param string $extraTextAfter sufixo do retorno
@return string
|
[
"getNodeValue",
".",
"Extrai",
"o",
"valor",
"do",
"node",
"DOM",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Dom.php#L53-L63
|
20,261 |
phpnfe/tools
|
src/Certificado/Dom.php
|
Dom.getNode
|
public function getNode($nodeName, $itemNum = 0)
{
$node = $this->getElementsByTagName($nodeName)->item($itemNum);
if (isset($node)) {
return $node;
}
return '';
}
|
php
|
public function getNode($nodeName, $itemNum = 0)
{
$node = $this->getElementsByTagName($nodeName)->item($itemNum);
if (isset($node)) {
return $node;
}
return '';
}
|
[
"public",
"function",
"getNode",
"(",
"$",
"nodeName",
",",
"$",
"itemNum",
"=",
"0",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getElementsByTagName",
"(",
"$",
"nodeName",
")",
"->",
"item",
"(",
"$",
"itemNum",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"node",
";",
"}",
"return",
"''",
";",
"}"
] |
getNode
Retorna o node solicitado.
@param string $nodeName
@param int $itemNum
@return DOMElement se existir ou string vazia se não
|
[
"getNode",
"Retorna",
"o",
"node",
"solicitado",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Dom.php#L89-L97
|
20,262 |
phpnfe/tools
|
src/Certificado/Dom.php
|
Dom.appChild
|
public function appChild(&$parent, $child, $msg = '')
{
if (empty($parent)) {
throw new Exception($msg);
}
if (! empty($child)) {
$parent->appendChild($child);
}
}
|
php
|
public function appChild(&$parent, $child, $msg = '')
{
if (empty($parent)) {
throw new Exception($msg);
}
if (! empty($child)) {
$parent->appendChild($child);
}
}
|
[
"public",
"function",
"appChild",
"(",
"&",
"$",
"parent",
",",
"$",
"child",
",",
"$",
"msg",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"parent",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"child",
")",
")",
"{",
"$",
"parent",
"->",
"appendChild",
"(",
"$",
"child",
")",
";",
"}",
"}"
] |
appChild
Acrescenta DOMElement a pai DOMElement
Caso o pai esteja vazio retorna uma exception com a mensagem
O parametro "child" pode ser vazio.
@param \DOMNode $parent
@param \DOMNode $child
@param string $msg
@return void
@throws Exception
|
[
"appChild",
"Acrescenta",
"DOMElement",
"a",
"pai",
"DOMElement",
"Caso",
"o",
"pai",
"esteja",
"vazio",
"retorna",
"uma",
"exception",
"com",
"a",
"mensagem",
"O",
"parametro",
"child",
"pode",
"ser",
"vazio",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Dom.php#L158-L166
|
20,263 |
phpnfe/tools
|
src/Certificado/Dom.php
|
Dom.addArrayChild
|
public function addArrayChild(&$parent, $arr)
{
$num = 0;
if (! empty($arr) && ! empty($parent)) {
foreach ($arr as $node) {
$this->appChild($parent, $node, '');
$num++;
}
}
return $num;
}
|
php
|
public function addArrayChild(&$parent, $arr)
{
$num = 0;
if (! empty($arr) && ! empty($parent)) {
foreach ($arr as $node) {
$this->appChild($parent, $node, '');
$num++;
}
}
return $num;
}
|
[
"public",
"function",
"addArrayChild",
"(",
"&",
"$",
"parent",
",",
"$",
"arr",
")",
"{",
"$",
"num",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"arr",
")",
"&&",
"!",
"empty",
"(",
"$",
"parent",
")",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"appChild",
"(",
"$",
"parent",
",",
"$",
"node",
",",
"''",
")",
";",
"$",
"num",
"++",
";",
"}",
"}",
"return",
"$",
"num",
";",
"}"
] |
addArrayChild
Adiciona a um DOMNode parent, outros elementos passados em um array de DOMElements.
@param DOMElement $parent
@param array $arr
@return int
|
[
"addArrayChild",
"Adiciona",
"a",
"um",
"DOMNode",
"parent",
"outros",
"elementos",
"passados",
"em",
"um",
"array",
"de",
"DOMElements",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Dom.php#L175-L186
|
20,264 |
bzarzuela/modelfilter
|
src/ModelFilter.php
|
ModelFilter.setKey
|
public function setKey($key)
{
$this->key = $key;
// Initialize if we're the first instance.
if (! session()->has('bzarzuela.filters')) {
session(['bzarzuela.filters' => [$key => []]]);
}
return $this;
}
|
php
|
public function setKey($key)
{
$this->key = $key;
// Initialize if we're the first instance.
if (! session()->has('bzarzuela.filters')) {
session(['bzarzuela.filters' => [$key => []]]);
}
return $this;
}
|
[
"public",
"function",
"setKey",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"key",
"=",
"$",
"key",
";",
"// Initialize if we're the first instance.",
"if",
"(",
"!",
"session",
"(",
")",
"->",
"has",
"(",
"'bzarzuela.filters'",
")",
")",
"{",
"session",
"(",
"[",
"'bzarzuela.filters'",
"=>",
"[",
"$",
"key",
"=>",
"[",
"]",
"]",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets a unique key to hold the filter form data in the session.
@param string $key Key name. Usually the model's table name
|
[
"Sets",
"a",
"unique",
"key",
"to",
"hold",
"the",
"filter",
"form",
"data",
"in",
"the",
"session",
"."
] |
2ca04409934245b8bf5a0a9684da2f45b234dfa7
|
https://github.com/bzarzuela/modelfilter/blob/2ca04409934245b8bf5a0a9684da2f45b234dfa7/src/ModelFilter.php#L31-L41
|
20,265 |
bzarzuela/modelfilter
|
src/ModelFilter.php
|
ModelFilter.getFormData
|
public function getFormData($field = null)
{
$filters = session('bzarzuela.filters');
if (isset($filters[$this->key]['form_data'])) {
if (! is_null($field)) {
if (! isset($filters[$this->key]['form_data'][$field])) {
return null;
}
return $filters[$this->key]['form_data'][$field];
}
return $filters[$this->key]['form_data'];
}
if (! is_null($field)) {
return null;
}
return [];
}
|
php
|
public function getFormData($field = null)
{
$filters = session('bzarzuela.filters');
if (isset($filters[$this->key]['form_data'])) {
if (! is_null($field)) {
if (! isset($filters[$this->key]['form_data'][$field])) {
return null;
}
return $filters[$this->key]['form_data'][$field];
}
return $filters[$this->key]['form_data'];
}
if (! is_null($field)) {
return null;
}
return [];
}
|
[
"public",
"function",
"getFormData",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"$",
"filters",
"=",
"session",
"(",
"'bzarzuela.filters'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"filters",
"[",
"$",
"this",
"->",
"key",
"]",
"[",
"'form_data'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"filters",
"[",
"$",
"this",
"->",
"key",
"]",
"[",
"'form_data'",
"]",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"filters",
"[",
"$",
"this",
"->",
"key",
"]",
"[",
"'form_data'",
"]",
"[",
"$",
"field",
"]",
";",
"}",
"return",
"$",
"filters",
"[",
"$",
"this",
"->",
"key",
"]",
"[",
"'form_data'",
"]",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Gets either the whole form data or just a field inside.
@param null $field
@return array|null
|
[
"Gets",
"either",
"the",
"whole",
"form",
"data",
"or",
"just",
"a",
"field",
"inside",
"."
] |
2ca04409934245b8bf5a0a9684da2f45b234dfa7
|
https://github.com/bzarzuela/modelfilter/blob/2ca04409934245b8bf5a0a9684da2f45b234dfa7/src/ModelFilter.php#L87-L110
|
20,266 |
alexandresalome/journal-extension
|
src/Behat/JournalExtension/Formatter/JournalFormatter.php
|
JournalFormatter.afterStep
|
public function afterStep(StepEvent $event) {
$color = $this->getResultColorCode($event->getResult());
$capture = $this->captureAll || $color == 'failed';
if ($capture) {
try {
$screenshot = $this->driver->getScreenshot();
if ($screenshot) {
$date = new \DateTime('now');
$fileName = $this->screenShotPrefix . $date->format('Y-m-d H.i.s') . '.png';
$file = $this->screenShotDirectory . DIRECTORY_SEPARATOR . $fileName;
file_put_contents($file, $screenshot);
$this->screenShotMarkup .= '<div class="screenshot">';
$this->screenShotMarkup .= sprintf('<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $event->getStep()->getText() . '</a>');
$this->screenShotMarkup .= sprintf('<img src="%s" />', $fileName);
$this->screenShotMarkup .= '</div>';
}
} catch (\Exception $e) {
$this->screenShotMarkup .= '<div class="screenshot">';
$this->screenShotMarkup .= sprintf('<em>Error while taking screenshot for ' . $event->getStep()->getText() . ' : %s</em>', htmlspecialchars($e->getMessage()));
$this->screenShotMarkup .= '</div>';
}
}
if ($this->inBackground && $this->isBackgroundPrinted) {
return;
}
if (!$this->inBackground && $this->inOutlineExample) {
$this->delayedStepEvents[] = $event;
return;
}
$this->printStep(
$event->getStep(),
$event->getResult(),
$event->getDefinition(),
$event->getSnippet(),
$event->getException()
);
$this->writeln($this->screenShotMarkup);
$this->screenShotMarkup = '';
}
|
php
|
public function afterStep(StepEvent $event) {
$color = $this->getResultColorCode($event->getResult());
$capture = $this->captureAll || $color == 'failed';
if ($capture) {
try {
$screenshot = $this->driver->getScreenshot();
if ($screenshot) {
$date = new \DateTime('now');
$fileName = $this->screenShotPrefix . $date->format('Y-m-d H.i.s') . '.png';
$file = $this->screenShotDirectory . DIRECTORY_SEPARATOR . $fileName;
file_put_contents($file, $screenshot);
$this->screenShotMarkup .= '<div class="screenshot">';
$this->screenShotMarkup .= sprintf('<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $event->getStep()->getText() . '</a>');
$this->screenShotMarkup .= sprintf('<img src="%s" />', $fileName);
$this->screenShotMarkup .= '</div>';
}
} catch (\Exception $e) {
$this->screenShotMarkup .= '<div class="screenshot">';
$this->screenShotMarkup .= sprintf('<em>Error while taking screenshot for ' . $event->getStep()->getText() . ' : %s</em>', htmlspecialchars($e->getMessage()));
$this->screenShotMarkup .= '</div>';
}
}
if ($this->inBackground && $this->isBackgroundPrinted) {
return;
}
if (!$this->inBackground && $this->inOutlineExample) {
$this->delayedStepEvents[] = $event;
return;
}
$this->printStep(
$event->getStep(),
$event->getResult(),
$event->getDefinition(),
$event->getSnippet(),
$event->getException()
);
$this->writeln($this->screenShotMarkup);
$this->screenShotMarkup = '';
}
|
[
"public",
"function",
"afterStep",
"(",
"StepEvent",
"$",
"event",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"getResultColorCode",
"(",
"$",
"event",
"->",
"getResult",
"(",
")",
")",
";",
"$",
"capture",
"=",
"$",
"this",
"->",
"captureAll",
"||",
"$",
"color",
"==",
"'failed'",
";",
"if",
"(",
"$",
"capture",
")",
"{",
"try",
"{",
"$",
"screenshot",
"=",
"$",
"this",
"->",
"driver",
"->",
"getScreenshot",
"(",
")",
";",
"if",
"(",
"$",
"screenshot",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"screenShotPrefix",
".",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H.i.s'",
")",
".",
"'.png'",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"screenShotDirectory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"fileName",
";",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"screenshot",
")",
";",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"'<div class=\"screenshot\">'",
";",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"sprintf",
"(",
"'<a href=\"#\" class=\"screenshot-toggler\">Toggle screenshot for '",
".",
"$",
"event",
"->",
"getStep",
"(",
")",
"->",
"getText",
"(",
")",
".",
"'</a>'",
")",
";",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"sprintf",
"(",
"'<img src=\"%s\" />'",
",",
"$",
"fileName",
")",
";",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"'</div>'",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"'<div class=\"screenshot\">'",
";",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"sprintf",
"(",
"'<em>Error while taking screenshot for '",
".",
"$",
"event",
"->",
"getStep",
"(",
")",
"->",
"getText",
"(",
")",
".",
"' : %s</em>'",
",",
"htmlspecialchars",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"screenShotMarkup",
".=",
"'</div>'",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"inBackground",
"&&",
"$",
"this",
"->",
"isBackgroundPrinted",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"inBackground",
"&&",
"$",
"this",
"->",
"inOutlineExample",
")",
"{",
"$",
"this",
"->",
"delayedStepEvents",
"[",
"]",
"=",
"$",
"event",
";",
"return",
";",
"}",
"$",
"this",
"->",
"printStep",
"(",
"$",
"event",
"->",
"getStep",
"(",
")",
",",
"$",
"event",
"->",
"getResult",
"(",
")",
",",
"$",
"event",
"->",
"getDefinition",
"(",
")",
",",
"$",
"event",
"->",
"getSnippet",
"(",
")",
",",
"$",
"event",
"->",
"getException",
"(",
")",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"this",
"->",
"screenShotMarkup",
")",
";",
"$",
"this",
"->",
"screenShotMarkup",
"=",
"''",
";",
"}"
] |
Listens to "step.after" event.
@param StepEvent $event
@uses printStep()
|
[
"Listens",
"to",
"step",
".",
"after",
"event",
"."
] |
de87304abb52abfa6905f1b83d2e35cc7bc52c0d
|
https://github.com/alexandresalome/journal-extension/blob/de87304abb52abfa6905f1b83d2e35cc7bc52c0d/src/Behat/JournalExtension/Formatter/JournalFormatter.php#L68-L110
|
20,267 |
JimmDiGrizli/phalcon-config-loader
|
src/ConfigLoader.php
|
ConfigLoader.importResource
|
protected function importResource(BaseConfig $baseConfig)
{
foreach ($baseConfig as $key => $value) {
if ($value instanceof BaseConfig) {
$this->importResource($value);
} elseif (is_string($value)) {
if ($key === self::RESOURCES_KEY) {
$resources = $this->clear(
$baseConfig,
$this->create($value)
);
$baseConfig->merge($resources);
$baseConfig->offsetUnset($key);
} elseif (substr_count($value, self::RESOURCES_VALUE)) {
$baseConfig[$key] = $this->create(
substr($value, strlen(self::RESOURCES_VALUE))
);
} elseif ($key === self::MODULE_KEY) {
$resources = $this->clear(
$baseConfig,
$this->moduleConfigCreate($value)
);
$baseConfig->merge($resources);
$baseConfig->offsetUnset($key);
} elseif (substr_count($value, self::MODULE_VALUE)) {
$baseConfig[$key] =
$this->moduleConfigCreate(
substr(
$value,
strlen(self::MODULE_VALUE)
)
);
}
if (substr_count($value, self::ENVIRONMENT)) {
$baseConfig[$key] = str_replace(
self::ENVIRONMENT,
$this->environment,
$value
);
}
}
}
}
|
php
|
protected function importResource(BaseConfig $baseConfig)
{
foreach ($baseConfig as $key => $value) {
if ($value instanceof BaseConfig) {
$this->importResource($value);
} elseif (is_string($value)) {
if ($key === self::RESOURCES_KEY) {
$resources = $this->clear(
$baseConfig,
$this->create($value)
);
$baseConfig->merge($resources);
$baseConfig->offsetUnset($key);
} elseif (substr_count($value, self::RESOURCES_VALUE)) {
$baseConfig[$key] = $this->create(
substr($value, strlen(self::RESOURCES_VALUE))
);
} elseif ($key === self::MODULE_KEY) {
$resources = $this->clear(
$baseConfig,
$this->moduleConfigCreate($value)
);
$baseConfig->merge($resources);
$baseConfig->offsetUnset($key);
} elseif (substr_count($value, self::MODULE_VALUE)) {
$baseConfig[$key] =
$this->moduleConfigCreate(
substr(
$value,
strlen(self::MODULE_VALUE)
)
);
}
if (substr_count($value, self::ENVIRONMENT)) {
$baseConfig[$key] = str_replace(
self::ENVIRONMENT,
$this->environment,
$value
);
}
}
}
}
|
[
"protected",
"function",
"importResource",
"(",
"BaseConfig",
"$",
"baseConfig",
")",
"{",
"foreach",
"(",
"$",
"baseConfig",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"BaseConfig",
")",
"{",
"$",
"this",
"->",
"importResource",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"self",
"::",
"RESOURCES_KEY",
")",
"{",
"$",
"resources",
"=",
"$",
"this",
"->",
"clear",
"(",
"$",
"baseConfig",
",",
"$",
"this",
"->",
"create",
"(",
"$",
"value",
")",
")",
";",
"$",
"baseConfig",
"->",
"merge",
"(",
"$",
"resources",
")",
";",
"$",
"baseConfig",
"->",
"offsetUnset",
"(",
"$",
"key",
")",
";",
"}",
"elseif",
"(",
"substr_count",
"(",
"$",
"value",
",",
"self",
"::",
"RESOURCES_VALUE",
")",
")",
"{",
"$",
"baseConfig",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"create",
"(",
"substr",
"(",
"$",
"value",
",",
"strlen",
"(",
"self",
"::",
"RESOURCES_VALUE",
")",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"===",
"self",
"::",
"MODULE_KEY",
")",
"{",
"$",
"resources",
"=",
"$",
"this",
"->",
"clear",
"(",
"$",
"baseConfig",
",",
"$",
"this",
"->",
"moduleConfigCreate",
"(",
"$",
"value",
")",
")",
";",
"$",
"baseConfig",
"->",
"merge",
"(",
"$",
"resources",
")",
";",
"$",
"baseConfig",
"->",
"offsetUnset",
"(",
"$",
"key",
")",
";",
"}",
"elseif",
"(",
"substr_count",
"(",
"$",
"value",
",",
"self",
"::",
"MODULE_VALUE",
")",
")",
"{",
"$",
"baseConfig",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"moduleConfigCreate",
"(",
"substr",
"(",
"$",
"value",
",",
"strlen",
"(",
"self",
"::",
"MODULE_VALUE",
")",
")",
")",
";",
"}",
"if",
"(",
"substr_count",
"(",
"$",
"value",
",",
"self",
"::",
"ENVIRONMENT",
")",
")",
"{",
"$",
"baseConfig",
"[",
"$",
"key",
"]",
"=",
"str_replace",
"(",
"self",
"::",
"ENVIRONMENT",
",",
"$",
"this",
"->",
"environment",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}"
] |
Import encountered files in the configuration
@param Config $baseConfig
@throws AdapterNotFoundException
@throws ConstantDirNotFoundException
@throws ExtensionNotFoundException
|
[
"Import",
"encountered",
"files",
"in",
"the",
"configuration"
] |
9a68dc02057f16aa2431681675ca0bb876a7d571
|
https://github.com/JimmDiGrizli/phalcon-config-loader/blob/9a68dc02057f16aa2431681675ca0bb876a7d571/src/ConfigLoader.php#L156-L204
|
20,268 |
JimmDiGrizli/phalcon-config-loader
|
src/ConfigLoader.php
|
ConfigLoader.clear
|
public function clear(Config $means, Config $target)
{
foreach ($target as $key => $value) {
if ($value instanceof BaseConfig && isset($means[$key])) {
$this->clear($means[$key], $value);
} else {
if (isset($means[$key])) {
$target->offsetUnset($key);
}
}
}
return new BaseConfig($target->toArray());
}
|
php
|
public function clear(Config $means, Config $target)
{
foreach ($target as $key => $value) {
if ($value instanceof BaseConfig && isset($means[$key])) {
$this->clear($means[$key], $value);
} else {
if (isset($means[$key])) {
$target->offsetUnset($key);
}
}
}
return new BaseConfig($target->toArray());
}
|
[
"public",
"function",
"clear",
"(",
"Config",
"$",
"means",
",",
"Config",
"$",
"target",
")",
"{",
"foreach",
"(",
"$",
"target",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"BaseConfig",
"&&",
"isset",
"(",
"$",
"means",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"clear",
"(",
"$",
"means",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"means",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"target",
"->",
"offsetUnset",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}",
"return",
"new",
"BaseConfig",
"(",
"$",
"target",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] |
Delete variables that are already defined in the main configuration file
@param Config $means Main configuration file
@param Config $target Imported configuration file
@return Config
|
[
"Delete",
"variables",
"that",
"are",
"already",
"defined",
"in",
"the",
"main",
"configuration",
"file"
] |
9a68dc02057f16aa2431681675ca0bb876a7d571
|
https://github.com/JimmDiGrizli/phalcon-config-loader/blob/9a68dc02057f16aa2431681675ca0bb876a7d571/src/ConfigLoader.php#L213-L226
|
20,269 |
JimmDiGrizli/phalcon-config-loader
|
src/ConfigLoader.php
|
ConfigLoader.moduleConfigCreate
|
protected function moduleConfigCreate($path)
{
$value = explode('::', $path);
$ref = new ReflectionClass($value[0]);
if ($ref->hasConstant('DIR') === false) {
throw new ConstantDirNotFoundException(
'Not found constant DIR in class ' . $value[0]
);
}
return $this->create($value[0]::DIR . $ref->getConstant($value[1]));
}
|
php
|
protected function moduleConfigCreate($path)
{
$value = explode('::', $path);
$ref = new ReflectionClass($value[0]);
if ($ref->hasConstant('DIR') === false) {
throw new ConstantDirNotFoundException(
'Not found constant DIR in class ' . $value[0]
);
}
return $this->create($value[0]::DIR . $ref->getConstant($value[1]));
}
|
[
"protected",
"function",
"moduleConfigCreate",
"(",
"$",
"path",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"'::'",
",",
"$",
"path",
")",
";",
"$",
"ref",
"=",
"new",
"ReflectionClass",
"(",
"$",
"value",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"ref",
"->",
"hasConstant",
"(",
"'DIR'",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"ConstantDirNotFoundException",
"(",
"'Not found constant DIR in class '",
".",
"$",
"value",
"[",
"0",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"value",
"[",
"0",
"]",
"::",
"DIR",
".",
"$",
"ref",
"->",
"getConstant",
"(",
"$",
"value",
"[",
"1",
"]",
")",
")",
";",
"}"
] |
Create a configuration of the module for further imports
@param $path
@return Config
@throws AdapterNotFoundException
@throws ConstantDirNotFoundException
@throws ExtensionNotFoundException
|
[
"Create",
"a",
"configuration",
"of",
"the",
"module",
"for",
"further",
"imports"
] |
9a68dc02057f16aa2431681675ca0bb876a7d571
|
https://github.com/JimmDiGrizli/phalcon-config-loader/blob/9a68dc02057f16aa2431681675ca0bb876a7d571/src/ConfigLoader.php#L237-L250
|
20,270 |
webdevvie/pheanstalk-task-queue-bundle
|
Service/PheanstalkConnection.php
|
PheanstalkConnection.put
|
public function put(
$data,
$priority = \Pheanstalk_PheanstalkInterface::DEFAULT_PRIORITY,
$delay = \Pheanstalk_PheanstalkInterface::DEFAULT_DELAY,
$timeToRun = \Pheanstalk_PheanstalkInterface::DEFAULT_TTR
) {
$this->pheanstalk->put($data, $priority, $delay, $timeToRun);
return $this;
}
|
php
|
public function put(
$data,
$priority = \Pheanstalk_PheanstalkInterface::DEFAULT_PRIORITY,
$delay = \Pheanstalk_PheanstalkInterface::DEFAULT_DELAY,
$timeToRun = \Pheanstalk_PheanstalkInterface::DEFAULT_TTR
) {
$this->pheanstalk->put($data, $priority, $delay, $timeToRun);
return $this;
}
|
[
"public",
"function",
"put",
"(",
"$",
"data",
",",
"$",
"priority",
"=",
"\\",
"Pheanstalk_PheanstalkInterface",
"::",
"DEFAULT_PRIORITY",
",",
"$",
"delay",
"=",
"\\",
"Pheanstalk_PheanstalkInterface",
"::",
"DEFAULT_DELAY",
",",
"$",
"timeToRun",
"=",
"\\",
"Pheanstalk_PheanstalkInterface",
"::",
"DEFAULT_TTR",
")",
"{",
"$",
"this",
"->",
"pheanstalk",
"->",
"put",
"(",
"$",
"data",
",",
"$",
"priority",
",",
"$",
"delay",
",",
"$",
"timeToRun",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Puts a task string into the current
@param $data
@param int $priority
@param int $delay
@param int $timeToRun
@return $this
|
[
"Puts",
"a",
"task",
"string",
"into",
"the",
"current"
] |
db5e63a8f844e345dc2e69ce8e94b32d851020eb
|
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/PheanstalkConnection.php#L40-L48
|
20,271 |
andromeda-framework/doctrine
|
src/Doctrine/Tracy/Panel.php
|
Panel.getTab
|
public function getTab(): string
{
return '<span title="Doctrine 2">'
. '<svg viewBox="0 0 2048 2048"><path fill="#aaa" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280'
. '-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128'
. 'v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 '
. '325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103'
. '-128t280-93.5 385-34.5z"></path></svg>'
. '<span class="tracy-label">'
. count($this->queries) . ' queries' . ($this->totalTime ? ' / ' . sprintf('%0.1f', $this->totalTime * 1000) . ' ms' : '')
. '</span>'
. '</span>';
}
|
php
|
public function getTab(): string
{
return '<span title="Doctrine 2">'
. '<svg viewBox="0 0 2048 2048"><path fill="#aaa" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280'
. '-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128'
. 'v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 '
. '325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103'
. '-128t280-93.5 385-34.5z"></path></svg>'
. '<span class="tracy-label">'
. count($this->queries) . ' queries' . ($this->totalTime ? ' / ' . sprintf('%0.1f', $this->totalTime * 1000) . ' ms' : '')
. '</span>'
. '</span>';
}
|
[
"public",
"function",
"getTab",
"(",
")",
":",
"string",
"{",
"return",
"'<span title=\"Doctrine 2\">'",
".",
"'<svg viewBox=\"0 0 2048 2048\"><path fill=\"#aaa\" d=\"M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280'",
".",
"'-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128'",
".",
"'v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 '",
".",
"'325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103'",
".",
"'-128t280-93.5 385-34.5z\"></path></svg>'",
".",
"'<span class=\"tracy-label\">'",
".",
"count",
"(",
"$",
"this",
"->",
"queries",
")",
".",
"' queries'",
".",
"(",
"$",
"this",
"->",
"totalTime",
"?",
"' / '",
".",
"sprintf",
"(",
"'%0.1f'",
",",
"$",
"this",
"->",
"totalTime",
"*",
"1000",
")",
".",
"' ms'",
":",
"''",
")",
".",
"'</span>'",
".",
"'</span>'",
";",
"}"
] |
Renders tab for Tracy Debug Bar.
@return string
|
[
"Renders",
"tab",
"for",
"Tracy",
"Debug",
"Bar",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Tracy/Panel.php#L73-L85
|
20,272 |
andromeda-framework/doctrine
|
src/Doctrine/Tracy/Panel.php
|
Panel.getPanel
|
public function getPanel(): string
{
if (empty($this->queries)) {
return '';
}
$params = $this->connection->getParams();
$host = ($params['driver'] === 'pdo_sqlite' && isset($params['path']))
? 'path: ' . basename($params['path'])
: sprintf('host: %s%s/%s', $this->connection->getHost(),
(($p = $this->connection->getPort()) ? ':' . $p : ''),
$this->connection->getDatabase());
return '<style>
#nette-debug td.nette-Doctrine2Panel-sql { background: white !important}
#nette-debug .nette-Doctrine2Panel-source { color: #BBB !important }
#nette-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto }
#tracy-debug td.nette-Doctrine2Panel-sql { background: white !important}
#tracy-debug .nette-Doctrine2Panel-source { color: #BBB !important }
#tracy-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto }
</style>' .
sprintf('<h1>Queries: %s%s, %s</h1>', count($this->queries),
($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : ''), $host) .
'<div class="nette-inner tracy-inner nette-Doctrine2Panel">' .
implode('<br>', array_filter([$this->renderPanelCacheStatistics(), $this->renderPanelQueries()])) .
'</div>';
}
|
php
|
public function getPanel(): string
{
if (empty($this->queries)) {
return '';
}
$params = $this->connection->getParams();
$host = ($params['driver'] === 'pdo_sqlite' && isset($params['path']))
? 'path: ' . basename($params['path'])
: sprintf('host: %s%s/%s', $this->connection->getHost(),
(($p = $this->connection->getPort()) ? ':' . $p : ''),
$this->connection->getDatabase());
return '<style>
#nette-debug td.nette-Doctrine2Panel-sql { background: white !important}
#nette-debug .nette-Doctrine2Panel-source { color: #BBB !important }
#nette-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto }
#tracy-debug td.nette-Doctrine2Panel-sql { background: white !important}
#tracy-debug .nette-Doctrine2Panel-source { color: #BBB !important }
#tracy-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto }
</style>' .
sprintf('<h1>Queries: %s%s, %s</h1>', count($this->queries),
($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : ''), $host) .
'<div class="nette-inner tracy-inner nette-Doctrine2Panel">' .
implode('<br>', array_filter([$this->renderPanelCacheStatistics(), $this->renderPanelQueries()])) .
'</div>';
}
|
[
"public",
"function",
"getPanel",
"(",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"queries",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"params",
"=",
"$",
"this",
"->",
"connection",
"->",
"getParams",
"(",
")",
";",
"$",
"host",
"=",
"(",
"$",
"params",
"[",
"'driver'",
"]",
"===",
"'pdo_sqlite'",
"&&",
"isset",
"(",
"$",
"params",
"[",
"'path'",
"]",
")",
")",
"?",
"'path: '",
".",
"basename",
"(",
"$",
"params",
"[",
"'path'",
"]",
")",
":",
"sprintf",
"(",
"'host: %s%s/%s'",
",",
"$",
"this",
"->",
"connection",
"->",
"getHost",
"(",
")",
",",
"(",
"(",
"$",
"p",
"=",
"$",
"this",
"->",
"connection",
"->",
"getPort",
"(",
")",
")",
"?",
"':'",
".",
"$",
"p",
":",
"''",
")",
",",
"$",
"this",
"->",
"connection",
"->",
"getDatabase",
"(",
")",
")",
";",
"return",
"'<style>\n\t\t\t\t#nette-debug td.nette-Doctrine2Panel-sql { background: white !important}\n\t\t\t\t#nette-debug .nette-Doctrine2Panel-source { color: #BBB !important }\n\t\t\t\t#nette-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto }\n\t\t\t\t#tracy-debug td.nette-Doctrine2Panel-sql { background: white !important}\n\t\t\t\t#tracy-debug .nette-Doctrine2Panel-source { color: #BBB !important }\n\t\t\t\t#tracy-debug nette-Doctrine2Panel tr table { margin: 8px 0; max-height: 150px; overflow:auto }\n\t\t\t</style>'",
".",
"sprintf",
"(",
"'<h1>Queries: %s%s, %s</h1>'",
",",
"count",
"(",
"$",
"this",
"->",
"queries",
")",
",",
"(",
"$",
"this",
"->",
"totalTime",
"?",
"', time: '",
".",
"sprintf",
"(",
"'%0.3f'",
",",
"$",
"this",
"->",
"totalTime",
"*",
"1000",
")",
".",
"' ms'",
":",
"''",
")",
",",
"$",
"host",
")",
".",
"'<div class=\"nette-inner tracy-inner nette-Doctrine2Panel\">'",
".",
"implode",
"(",
"'<br>'",
",",
"array_filter",
"(",
"[",
"$",
"this",
"->",
"renderPanelCacheStatistics",
"(",
")",
",",
"$",
"this",
"->",
"renderPanelQueries",
"(",
")",
"]",
")",
")",
".",
"'</div>'",
";",
"}"
] |
Renders panel for Tracy Debug Bar.
@return string
|
[
"Renders",
"panel",
"for",
"Tracy",
"Debug",
"Bar",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Tracy/Panel.php#L93-L119
|
20,273 |
andromeda-framework/doctrine
|
src/Doctrine/Tracy/Panel.php
|
Panel.renderPanelCacheStatistics
|
private function renderPanelCacheStatistics(): string
{
if (empty($this->entityManager)) {
return '';
}
$config = $this->entityManager->getConfiguration();
if (!$config->isSecondLevelCacheEnabled()) {
return '';
}
$loggerChain = $config->getSecondLevelCacheConfiguration()->getCacheLogger();
if (!$loggerChain instanceof Doctrine\ORM\Cache\Logging\CacheLoggerChain) {
return '';
}
if (!$statistics = $loggerChain->getLogger('statistics')) {
return '';
}
return Dumper::toHtml($statistics, [Dumper::DEPTH => 5]);
}
|
php
|
private function renderPanelCacheStatistics(): string
{
if (empty($this->entityManager)) {
return '';
}
$config = $this->entityManager->getConfiguration();
if (!$config->isSecondLevelCacheEnabled()) {
return '';
}
$loggerChain = $config->getSecondLevelCacheConfiguration()->getCacheLogger();
if (!$loggerChain instanceof Doctrine\ORM\Cache\Logging\CacheLoggerChain) {
return '';
}
if (!$statistics = $loggerChain->getLogger('statistics')) {
return '';
}
return Dumper::toHtml($statistics, [Dumper::DEPTH => 5]);
}
|
[
"private",
"function",
"renderPanelCacheStatistics",
"(",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"entityManager",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getConfiguration",
"(",
")",
";",
"if",
"(",
"!",
"$",
"config",
"->",
"isSecondLevelCacheEnabled",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"loggerChain",
"=",
"$",
"config",
"->",
"getSecondLevelCacheConfiguration",
"(",
")",
"->",
"getCacheLogger",
"(",
")",
";",
"if",
"(",
"!",
"$",
"loggerChain",
"instanceof",
"Doctrine",
"\\",
"ORM",
"\\",
"Cache",
"\\",
"Logging",
"\\",
"CacheLoggerChain",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"!",
"$",
"statistics",
"=",
"$",
"loggerChain",
"->",
"getLogger",
"(",
"'statistics'",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"Dumper",
"::",
"toHtml",
"(",
"$",
"statistics",
",",
"[",
"Dumper",
"::",
"DEPTH",
"=>",
"5",
"]",
")",
";",
"}"
] |
Renders cache statistics.
@return string
|
[
"Renders",
"cache",
"statistics",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Tracy/Panel.php#L127-L149
|
20,274 |
andromeda-framework/doctrine
|
src/Doctrine/Tracy/Panel.php
|
Panel.renderPanelQueries
|
private function renderPanelQueries(): string
{
if (empty($this->queries)) {
return '';
}
$s = '';
foreach ($this->queries as $query) {
[$sql, $params, $time, $types, $source] = $query;
$q = SqlDumper::dump($sql, $params);
$q .= $source ? Helpers::editorLink($source[0], $source[1]) : '';
$s .= '<tr><td>' . sprintf('%0.3f', $time * 1000) . '</td><td class="nette-Doctrine2Panel-sql">' . $q . '</td></tr>';
}
return '<table><tr><th>ms</th><th>SQL Statement</th></tr>' . $s . '</table>';
}
|
php
|
private function renderPanelQueries(): string
{
if (empty($this->queries)) {
return '';
}
$s = '';
foreach ($this->queries as $query) {
[$sql, $params, $time, $types, $source] = $query;
$q = SqlDumper::dump($sql, $params);
$q .= $source ? Helpers::editorLink($source[0], $source[1]) : '';
$s .= '<tr><td>' . sprintf('%0.3f', $time * 1000) . '</td><td class="nette-Doctrine2Panel-sql">' . $q . '</td></tr>';
}
return '<table><tr><th>ms</th><th>SQL Statement</th></tr>' . $s . '</table>';
}
|
[
"private",
"function",
"renderPanelQueries",
"(",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"queries",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"s",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"queries",
"as",
"$",
"query",
")",
"{",
"[",
"$",
"sql",
",",
"$",
"params",
",",
"$",
"time",
",",
"$",
"types",
",",
"$",
"source",
"]",
"=",
"$",
"query",
";",
"$",
"q",
"=",
"SqlDumper",
"::",
"dump",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"$",
"q",
".=",
"$",
"source",
"?",
"Helpers",
"::",
"editorLink",
"(",
"$",
"source",
"[",
"0",
"]",
",",
"$",
"source",
"[",
"1",
"]",
")",
":",
"''",
";",
"$",
"s",
".=",
"'<tr><td>'",
".",
"sprintf",
"(",
"'%0.3f'",
",",
"$",
"time",
"*",
"1000",
")",
".",
"'</td><td class=\"nette-Doctrine2Panel-sql\">'",
".",
"$",
"q",
".",
"'</td></tr>'",
";",
"}",
"return",
"'<table><tr><th>ms</th><th>SQL Statement</th></tr>'",
".",
"$",
"s",
".",
"'</table>'",
";",
"}"
] |
Renders SQL queries.
@return string
|
[
"Renders",
"SQL",
"queries",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Tracy/Panel.php#L157-L172
|
20,275 |
andromeda-framework/doctrine
|
src/Doctrine/Tracy/Panel.php
|
Panel.setEntityManager
|
public function setEntityManager(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
$this->connection = $entityManager->getConnection();
$bar = Debugger::getBar();
$bar->addPanel($this);
$config = $this->connection->getConfiguration();
$logger = $config->getSQLLogger();
if ($logger instanceof Doctrine\DBAL\Logging\LoggerChain) {
$logger->addLogger($this);
} else {
$config->setSQLLogger($this);
}
}
|
php
|
public function setEntityManager(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
$this->connection = $entityManager->getConnection();
$bar = Debugger::getBar();
$bar->addPanel($this);
$config = $this->connection->getConfiguration();
$logger = $config->getSQLLogger();
if ($logger instanceof Doctrine\DBAL\Logging\LoggerChain) {
$logger->addLogger($this);
} else {
$config->setSQLLogger($this);
}
}
|
[
"public",
"function",
"setEntityManager",
"(",
"EntityManager",
"$",
"entityManager",
")",
"{",
"$",
"this",
"->",
"entityManager",
"=",
"$",
"entityManager",
";",
"$",
"this",
"->",
"connection",
"=",
"$",
"entityManager",
"->",
"getConnection",
"(",
")",
";",
"$",
"bar",
"=",
"Debugger",
"::",
"getBar",
"(",
")",
";",
"$",
"bar",
"->",
"addPanel",
"(",
"$",
"this",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfiguration",
"(",
")",
";",
"$",
"logger",
"=",
"$",
"config",
"->",
"getSQLLogger",
"(",
")",
";",
"if",
"(",
"$",
"logger",
"instanceof",
"Doctrine",
"\\",
"DBAL",
"\\",
"Logging",
"\\",
"LoggerChain",
")",
"{",
"$",
"logger",
"->",
"addLogger",
"(",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"config",
"->",
"setSQLLogger",
"(",
"$",
"this",
")",
";",
"}",
"}"
] |
Sets entity manager.
@param EntityManager $entityManager The Doctrine Entity Manager
|
[
"Sets",
"entity",
"manager",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Tracy/Panel.php#L236-L251
|
20,276 |
GrupaZero/api
|
src/Gzero/Api/Controller/Admin/OptionController.php
|
OptionController.show
|
public function show($key)
{
$this->authorize('read', Option::class);
try {
$option = $this->optionRepo->getOptions($key);
return $this->respondWithSuccess($option, new OptionTransformer);
} catch (RepositoryValidationException $e) {
return $this->respondWithError($e->getMessage());
}
}
|
php
|
public function show($key)
{
$this->authorize('read', Option::class);
try {
$option = $this->optionRepo->getOptions($key);
return $this->respondWithSuccess($option, new OptionTransformer);
} catch (RepositoryValidationException $e) {
return $this->respondWithError($e->getMessage());
}
}
|
[
"public",
"function",
"show",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'read'",
",",
"Option",
"::",
"class",
")",
";",
"try",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"optionRepo",
"->",
"getOptions",
"(",
"$",
"key",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"option",
",",
"new",
"OptionTransformer",
")",
";",
"}",
"catch",
"(",
"RepositoryValidationException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"respondWithError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Display all options from selected category.
@param string $key option category key
@return \Illuminate\Http\JsonResponse
|
[
"Display",
"all",
"options",
"from",
"selected",
"category",
"."
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/OptionController.php#L67-L76
|
20,277 |
phPoirot/psr7
|
HttpMessage.php
|
HttpMessage.isValid
|
static function isValid($value)
{
if (!\Poirot\Std\isStringify($value))
throw new \InvalidArgumentException(sprintf(
'Header value must be string; given: (%s).'
, \Poirot\Std\flatten($value)
));
$value = (string) $value;
// Look for:
// \n not preceded by \r, OR
// \r not followed by \n, OR
// \r\n not followed by space or horizontal tab; these are all CRLF attacks
if (preg_match("#(?:(?:(?<!\r)\n)|(?:\r(?!\n))|(?:\r\n(?![ \t])))#", $value)) {
return false;
}
// Non-visible, non-whitespace characters
// 9 === horizontal tab
// 10 === line feed
// 13 === carriage return
// 32-126, 128-254 === visible
// 127 === DEL (disallowed)
// 255 === null byte (disallowed)
if (preg_match('/[^\x09\x0a\x0d\x20-\x7E\x80-\xFE]/', $value)) {
return false;
}
return true;
}
|
php
|
static function isValid($value)
{
if (!\Poirot\Std\isStringify($value))
throw new \InvalidArgumentException(sprintf(
'Header value must be string; given: (%s).'
, \Poirot\Std\flatten($value)
));
$value = (string) $value;
// Look for:
// \n not preceded by \r, OR
// \r not followed by \n, OR
// \r\n not followed by space or horizontal tab; these are all CRLF attacks
if (preg_match("#(?:(?:(?<!\r)\n)|(?:\r(?!\n))|(?:\r\n(?![ \t])))#", $value)) {
return false;
}
// Non-visible, non-whitespace characters
// 9 === horizontal tab
// 10 === line feed
// 13 === carriage return
// 32-126, 128-254 === visible
// 127 === DEL (disallowed)
// 255 === null byte (disallowed)
if (preg_match('/[^\x09\x0a\x0d\x20-\x7E\x80-\xFE]/', $value)) {
return false;
}
return true;
}
|
[
"static",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"isStringify",
"(",
"$",
"value",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Header value must be string; given: (%s).'",
",",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"flatten",
"(",
"$",
"value",
")",
")",
")",
";",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"// Look for:",
"// \\n not preceded by \\r, OR",
"// \\r not followed by \\n, OR",
"// \\r\\n not followed by space or horizontal tab; these are all CRLF attacks",
"if",
"(",
"preg_match",
"(",
"\"#(?:(?:(?<!\\r)\\n)|(?:\\r(?!\\n))|(?:\\r\\n(?![ \\t])))#\"",
",",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Non-visible, non-whitespace characters",
"// 9 === horizontal tab",
"// 10 === line feed",
"// 13 === carriage return",
"// 32-126, 128-254 === visible",
"// 127 === DEL (disallowed)",
"// 255 === null byte (disallowed)",
"if",
"(",
"preg_match",
"(",
"'/[^\\x09\\x0a\\x0d\\x20-\\x7E\\x80-\\xFE]/'",
",",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validate a header value.
Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal
tabs are allowed in values; header continuations MUST consist of
a single CRLF sequence followed by a space or horizontal tab.
@see http://en.wikipedia.org/wiki/HTTP_response_splitting
@param string $value
@return bool
|
[
"Validate",
"a",
"header",
"value",
"."
] |
e90295e806dc2eb0cc422f315075f673c63a0780
|
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/HttpMessage.php#L320-L350
|
20,278 |
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Url.php
|
Url.addPath
|
public function addPath($relativePath)
{
if (!$relativePath || $relativePath == '/') {
return $this;
}
// Add a leading slash if needed
if ($relativePath[0] != '/') {
$relativePath = '/' . $relativePath;
}
return $this->setPath(str_replace('//', '/', $this->getPath() . $relativePath));
}
|
php
|
public function addPath($relativePath)
{
if (!$relativePath || $relativePath == '/') {
return $this;
}
// Add a leading slash if needed
if ($relativePath[0] != '/') {
$relativePath = '/' . $relativePath;
}
return $this->setPath(str_replace('//', '/', $this->getPath() . $relativePath));
}
|
[
"public",
"function",
"addPath",
"(",
"$",
"relativePath",
")",
"{",
"if",
"(",
"!",
"$",
"relativePath",
"||",
"$",
"relativePath",
"==",
"'/'",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// Add a leading slash if needed",
"if",
"(",
"$",
"relativePath",
"[",
"0",
"]",
"!=",
"'/'",
")",
"{",
"$",
"relativePath",
"=",
"'/'",
".",
"$",
"relativePath",
";",
"}",
"return",
"$",
"this",
"->",
"setPath",
"(",
"str_replace",
"(",
"'//'",
",",
"'/'",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"$",
"relativePath",
")",
")",
";",
"}"
] |
Add a relative path to the currently set path
@param string $relativePath Relative path to add
@return Url
|
[
"Add",
"a",
"relative",
"path",
"to",
"the",
"currently",
"set",
"path"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Url.php#L332-L344
|
20,279 |
philiplb/Valdi
|
src/Valdi/Validator/AbstractParametrizedValidator.php
|
AbstractParametrizedValidator.validateParameterCount
|
protected function validateParameterCount($name, $parameterAmount, array $parameters) {
if (count($parameters) !== $parameterAmount) {
throw new ValidationException('"'.$name.'" expects '.$parameterAmount.' parameter.');
}
}
|
php
|
protected function validateParameterCount($name, $parameterAmount, array $parameters) {
if (count($parameters) !== $parameterAmount) {
throw new ValidationException('"'.$name.'" expects '.$parameterAmount.' parameter.');
}
}
|
[
"protected",
"function",
"validateParameterCount",
"(",
"$",
"name",
",",
"$",
"parameterAmount",
",",
"array",
"$",
"parameters",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
"!==",
"$",
"parameterAmount",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"'\"'",
".",
"$",
"name",
".",
"'\" expects '",
".",
"$",
"parameterAmount",
".",
"' parameter.'",
")",
";",
"}",
"}"
] |
Throws an exception if the parameters don't fulfill the expected
parameter count.
@param string $name
the name of the validator
@param integer $parameterAmount
the amount of expected parameters
@param string[] $parameters
the parameters
@throws ValidationException
thrown if the amount of parameters isn't the expected one
|
[
"Throws",
"an",
"exception",
"if",
"the",
"parameters",
"don",
"t",
"fulfill",
"the",
"expected",
"parameter",
"count",
"."
] |
9927ec34a2cb00cec705e952d3c2374e2dc3c972
|
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/AbstractParametrizedValidator.php#L35-L39
|
20,280 |
interactivesolutions/honeycomb-core
|
src/errors/HCLog.php
|
HCLog.emergency
|
public function emergency(string $id, string $message, int $status = 400)
{
Log::error($id . ' : ' . $message);
return response ()->json (['success' => false, 'id' => $id, 'message' => $message], $status);
}
|
php
|
public function emergency(string $id, string $message, int $status = 400)
{
Log::error($id . ' : ' . $message);
return response ()->json (['success' => false, 'id' => $id, 'message' => $message], $status);
}
|
[
"public",
"function",
"emergency",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"message",
",",
"int",
"$",
"status",
"=",
"400",
")",
"{",
"Log",
"::",
"error",
"(",
"$",
"id",
".",
"' : '",
".",
"$",
"message",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'success'",
"=>",
"false",
",",
"'id'",
"=>",
"$",
"id",
",",
"'message'",
"=>",
"$",
"message",
"]",
",",
"$",
"status",
")",
";",
"}"
] |
Create emergency response
@param string $id
@param string $message
@param int $status
@return \Illuminate\Http\JsonResponse
|
[
"Create",
"emergency",
"response"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/errors/HCLog.php#L17-L22
|
20,281 |
interactivesolutions/honeycomb-core
|
src/errors/HCLog.php
|
HCLog.notice
|
public function notice(string $id, string $message, int $status = 400)
{
Log::info($id . ' : ' . $message);
return response ()->json (['success' => false, 'id' => $id, 'message' => $message], $status);
}
|
php
|
public function notice(string $id, string $message, int $status = 400)
{
Log::info($id . ' : ' . $message);
return response ()->json (['success' => false, 'id' => $id, 'message' => $message], $status);
}
|
[
"public",
"function",
"notice",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"message",
",",
"int",
"$",
"status",
"=",
"400",
")",
"{",
"Log",
"::",
"info",
"(",
"$",
"id",
".",
"' : '",
".",
"$",
"message",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'success'",
"=>",
"false",
",",
"'id'",
"=>",
"$",
"id",
",",
"'message'",
"=>",
"$",
"message",
"]",
",",
"$",
"status",
")",
";",
"}"
] |
Create notice response
@param string $id
@param string $message
@param int $status
@return \Illuminate\Http\JsonResponse
|
[
"Create",
"notice",
"response"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/errors/HCLog.php#L92-L97
|
20,282 |
interactivesolutions/honeycomb-core
|
src/errors/HCLog.php
|
HCLog.success
|
public function success(string $id, string $message, int $status = 200)
{
Log::info($id . ' : ' . $message);
return response ()->json (['success' => true, 'id' => $id, 'message' => $message], $status);
}
|
php
|
public function success(string $id, string $message, int $status = 200)
{
Log::info($id . ' : ' . $message);
return response ()->json (['success' => true, 'id' => $id, 'message' => $message], $status);
}
|
[
"public",
"function",
"success",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"message",
",",
"int",
"$",
"status",
"=",
"200",
")",
"{",
"Log",
"::",
"info",
"(",
"$",
"id",
".",
"' : '",
".",
"$",
"message",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'success'",
"=>",
"true",
",",
"'id'",
"=>",
"$",
"id",
",",
"'message'",
"=>",
"$",
"message",
"]",
",",
"$",
"status",
")",
";",
"}"
] |
Create success response
@param string $id
@param string $message
@param int $status
@return \Illuminate\Http\JsonResponse
|
[
"Create",
"success",
"response"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/errors/HCLog.php#L135-L140
|
20,283 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex.setOption
|
function setOption($option, $value)
{
$ret = true;
if (array_key_exists($option, $this->_options)) {
$this->_options[$option] = $value;
} else {
throw new InvalidArgumentException('Unknown option ' . $option);
}
}
|
php
|
function setOption($option, $value)
{
$ret = true;
if (array_key_exists($option, $this->_options)) {
$this->_options[$option] = $value;
} else {
throw new InvalidArgumentException('Unknown option ' . $option);
}
}
|
[
"function",
"setOption",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"$",
"ret",
"=",
"true",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"_options",
")",
")",
"{",
"$",
"this",
"->",
"_options",
"[",
"$",
"option",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unknown option '",
".",
"$",
"option",
")",
";",
"}",
"}"
] |
Sets run-time configuration options
@access public
@param string $option option name
@param mixed $value value for the option
@return mixed true on success
@throws InvalidArgumentException
|
[
"Sets",
"run",
"-",
"time",
"configuration",
"options"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L197-L205
|
20,284 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex.loadFile
|
function loadFile($filename)
{
if (file_exists($filename)) {
if (($this->content = @file_get_contents($filename)) === false) {
throw new BibtexException('Could not open file ' . $filename);
} else {
$this->_pos = 0;
$this->_oldpos = 0;
return true;
}
} else {
throw new BibtexException('Could not find file ' . $filename);
}
}
|
php
|
function loadFile($filename)
{
if (file_exists($filename)) {
if (($this->content = @file_get_contents($filename)) === false) {
throw new BibtexException('Could not open file ' . $filename);
} else {
$this->_pos = 0;
$this->_oldpos = 0;
return true;
}
} else {
throw new BibtexException('Could not find file ' . $filename);
}
}
|
[
"function",
"loadFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"content",
"=",
"@",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"BibtexException",
"(",
"'Could not open file '",
".",
"$",
"filename",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_pos",
"=",
"0",
";",
"$",
"this",
"->",
"_oldpos",
"=",
"0",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"BibtexException",
"(",
"'Could not find file '",
".",
"$",
"filename",
")",
";",
"}",
"}"
] |
Reads a give BibTex File
@access public
@param string $filename Name of the file
@return mixed true on success
@throws BibtexException
|
[
"Reads",
"a",
"give",
"BibTex",
"File"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L215-L228
|
20,285 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._checkEqualSign
|
function _checkEqualSign($entry, $position)
{
$ret = true;
//This is getting tricky
//We check the string backwards until the position and count the closing an opening braces
//If we reach the position the amount of opening and closing braces should be equal
$length = strlen($entry);
$open = 0;
for ($i = $length - 1; $i >= $position; $i--) {
$precedingchar = substr($entry, $i - 1, 1);
$char = substr($entry, $i, 1);
if (('{' == $char) && ('\\' != $precedingchar)) {
$open++;
}
if (('}' == $char) && ('\\' != $precedingchar)) {
$open--;
}
}
if (0 != $open) {
$ret = false;
}
//There is still the posibility that the entry is delimited by double quotes.
//Then it is possible that the braces are equal even if the '=' is in an equation.
if ($ret) {
$entrycopy = trim($entry);
$lastchar = $entrycopy{strlen($entrycopy) - 1};
if (',' == $lastchar) {
$lastchar = $entrycopy{strlen($entrycopy) - 2};
}
if ('"' == $lastchar) {
//The return value is set to false
//If we find the closing " before the '=' it is set to true again.
//Remember we begin to search the entry backwards so the " has to show up twice - ending and beginning delimiter
$ret = false;
$found = 0;
for ($i = $length; $i >= $position; $i--) {
$precedingchar = substr($entry, $i - 1, 1);
$char = substr($entry, $i, 1);
if (('"' == $char) && ('\\' != $precedingchar)) {
$found++;
}
if (2 == $found) {
$ret = true;
break;
}
}
}
}
return $ret;
}
|
php
|
function _checkEqualSign($entry, $position)
{
$ret = true;
//This is getting tricky
//We check the string backwards until the position and count the closing an opening braces
//If we reach the position the amount of opening and closing braces should be equal
$length = strlen($entry);
$open = 0;
for ($i = $length - 1; $i >= $position; $i--) {
$precedingchar = substr($entry, $i - 1, 1);
$char = substr($entry, $i, 1);
if (('{' == $char) && ('\\' != $precedingchar)) {
$open++;
}
if (('}' == $char) && ('\\' != $precedingchar)) {
$open--;
}
}
if (0 != $open) {
$ret = false;
}
//There is still the posibility that the entry is delimited by double quotes.
//Then it is possible that the braces are equal even if the '=' is in an equation.
if ($ret) {
$entrycopy = trim($entry);
$lastchar = $entrycopy{strlen($entrycopy) - 1};
if (',' == $lastchar) {
$lastchar = $entrycopy{strlen($entrycopy) - 2};
}
if ('"' == $lastchar) {
//The return value is set to false
//If we find the closing " before the '=' it is set to true again.
//Remember we begin to search the entry backwards so the " has to show up twice - ending and beginning delimiter
$ret = false;
$found = 0;
for ($i = $length; $i >= $position; $i--) {
$precedingchar = substr($entry, $i - 1, 1);
$char = substr($entry, $i, 1);
if (('"' == $char) && ('\\' != $precedingchar)) {
$found++;
}
if (2 == $found) {
$ret = true;
break;
}
}
}
}
return $ret;
}
|
[
"function",
"_checkEqualSign",
"(",
"$",
"entry",
",",
"$",
"position",
")",
"{",
"$",
"ret",
"=",
"true",
";",
"//This is getting tricky",
"//We check the string backwards until the position and count the closing an opening braces",
"//If we reach the position the amount of opening and closing braces should be equal",
"$",
"length",
"=",
"strlen",
"(",
"$",
"entry",
")",
";",
"$",
"open",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"length",
"-",
"1",
";",
"$",
"i",
">=",
"$",
"position",
";",
"$",
"i",
"--",
")",
"{",
"$",
"precedingchar",
"=",
"substr",
"(",
"$",
"entry",
",",
"$",
"i",
"-",
"1",
",",
"1",
")",
";",
"$",
"char",
"=",
"substr",
"(",
"$",
"entry",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"(",
"'{'",
"==",
"$",
"char",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"precedingchar",
")",
")",
"{",
"$",
"open",
"++",
";",
"}",
"if",
"(",
"(",
"'}'",
"==",
"$",
"char",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"precedingchar",
")",
")",
"{",
"$",
"open",
"--",
";",
"}",
"}",
"if",
"(",
"0",
"!=",
"$",
"open",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"}",
"//There is still the posibility that the entry is delimited by double quotes.",
"//Then it is possible that the braces are equal even if the '=' is in an equation.",
"if",
"(",
"$",
"ret",
")",
"{",
"$",
"entrycopy",
"=",
"trim",
"(",
"$",
"entry",
")",
";",
"$",
"lastchar",
"=",
"$",
"entrycopy",
"{",
"strlen",
"(",
"$",
"entrycopy",
")",
"-",
"1",
"}",
";",
"if",
"(",
"','",
"==",
"$",
"lastchar",
")",
"{",
"$",
"lastchar",
"=",
"$",
"entrycopy",
"{",
"strlen",
"(",
"$",
"entrycopy",
")",
"-",
"2",
"}",
";",
"}",
"if",
"(",
"'\"'",
"==",
"$",
"lastchar",
")",
"{",
"//The return value is set to false",
"//If we find the closing \" before the '=' it is set to true again.",
"//Remember we begin to search the entry backwards so the \" has to show up twice - ending and beginning delimiter",
"$",
"ret",
"=",
"false",
";",
"$",
"found",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"length",
";",
"$",
"i",
">=",
"$",
"position",
";",
"$",
"i",
"--",
")",
"{",
"$",
"precedingchar",
"=",
"substr",
"(",
"$",
"entry",
",",
"$",
"i",
"-",
"1",
",",
"1",
")",
";",
"$",
"char",
"=",
"substr",
"(",
"$",
"entry",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"(",
"'\"'",
"==",
"$",
"char",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"precedingchar",
")",
")",
"{",
"$",
"found",
"++",
";",
"}",
"if",
"(",
"2",
"==",
"$",
"found",
")",
"{",
"$",
"ret",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Checking whether the position of the '=' is correct
Sometimes there is a problem if a '=' is used inside an entry (for example abstract).
This method checks if the '=' is outside braces then the '=' is correct and true is returned.
If the '=' is inside braces it contains to a equation and therefore false is returned.
@access private
@param string $entry The text of the whole remaining entry
@param int the current used place of the '='
@return bool true if the '=' is correct, false if it contains to an equation
|
[
"Checking",
"whether",
"the",
"position",
"of",
"the",
"=",
"is",
"correct"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L445-L494
|
20,286 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._checkAt
|
function _checkAt($entry)
{
$ret = false;
$opening = array_keys($this->_delimiters);
$closing = array_values($this->_delimiters);
//Getting the value (at is only allowd in values)
if (strrpos($entry, '=') !== false) {
$position = strrpos($entry, '=');
$proceed = true;
if (substr($entry, $position - 1, 1) == '\\') {
$proceed = false;
}
while (!$proceed) {
$substring = substr($entry, 0, $position);
$position = strrpos($substring, '=');
$proceed = true;
if (substr($entry, $position - 1, 1) == '\\') {
$proceed = false;
}
}
$value = trim(substr($entry, $position + 1));
$open = 0;
$char = '';
$lastchar = '';
for ($i = 0; $i < strlen($value); $i++) {
$char = substr($this->content, $i, 1);
if (in_array($char, $opening) && ('\\' != $lastchar)) {
$open++;
} elseif (in_array($char, $closing) && ('\\' != $lastchar)) {
$open--;
}
$lastchar = $char;
}
//if open is grater zero were are inside an entry
if ($open > 0) {
$ret = true;
}
}
return $ret;
}
|
php
|
function _checkAt($entry)
{
$ret = false;
$opening = array_keys($this->_delimiters);
$closing = array_values($this->_delimiters);
//Getting the value (at is only allowd in values)
if (strrpos($entry, '=') !== false) {
$position = strrpos($entry, '=');
$proceed = true;
if (substr($entry, $position - 1, 1) == '\\') {
$proceed = false;
}
while (!$proceed) {
$substring = substr($entry, 0, $position);
$position = strrpos($substring, '=');
$proceed = true;
if (substr($entry, $position - 1, 1) == '\\') {
$proceed = false;
}
}
$value = trim(substr($entry, $position + 1));
$open = 0;
$char = '';
$lastchar = '';
for ($i = 0; $i < strlen($value); $i++) {
$char = substr($this->content, $i, 1);
if (in_array($char, $opening) && ('\\' != $lastchar)) {
$open++;
} elseif (in_array($char, $closing) && ('\\' != $lastchar)) {
$open--;
}
$lastchar = $char;
}
//if open is grater zero were are inside an entry
if ($open > 0) {
$ret = true;
}
}
return $ret;
}
|
[
"function",
"_checkAt",
"(",
"$",
"entry",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"$",
"opening",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"_delimiters",
")",
";",
"$",
"closing",
"=",
"array_values",
"(",
"$",
"this",
"->",
"_delimiters",
")",
";",
"//Getting the value (at is only allowd in values)",
"if",
"(",
"strrpos",
"(",
"$",
"entry",
",",
"'='",
")",
"!==",
"false",
")",
"{",
"$",
"position",
"=",
"strrpos",
"(",
"$",
"entry",
",",
"'='",
")",
";",
"$",
"proceed",
"=",
"true",
";",
"if",
"(",
"substr",
"(",
"$",
"entry",
",",
"$",
"position",
"-",
"1",
",",
"1",
")",
"==",
"'\\\\'",
")",
"{",
"$",
"proceed",
"=",
"false",
";",
"}",
"while",
"(",
"!",
"$",
"proceed",
")",
"{",
"$",
"substring",
"=",
"substr",
"(",
"$",
"entry",
",",
"0",
",",
"$",
"position",
")",
";",
"$",
"position",
"=",
"strrpos",
"(",
"$",
"substring",
",",
"'='",
")",
";",
"$",
"proceed",
"=",
"true",
";",
"if",
"(",
"substr",
"(",
"$",
"entry",
",",
"$",
"position",
"-",
"1",
",",
"1",
")",
"==",
"'\\\\'",
")",
"{",
"$",
"proceed",
"=",
"false",
";",
"}",
"}",
"$",
"value",
"=",
"trim",
"(",
"substr",
"(",
"$",
"entry",
",",
"$",
"position",
"+",
"1",
")",
")",
";",
"$",
"open",
"=",
"0",
";",
"$",
"char",
"=",
"''",
";",
"$",
"lastchar",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"value",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"char",
"=",
"substr",
"(",
"$",
"this",
"->",
"content",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"char",
",",
"$",
"opening",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"lastchar",
")",
")",
"{",
"$",
"open",
"++",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"char",
",",
"$",
"closing",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"lastchar",
")",
")",
"{",
"$",
"open",
"--",
";",
"}",
"$",
"lastchar",
"=",
"$",
"char",
";",
"}",
"//if open is grater zero were are inside an entry",
"if",
"(",
"$",
"open",
">",
"0",
")",
"{",
"$",
"ret",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Checking whether an at is outside an entry
Sometimes an entry misses an entry brace. Then the at of the next entry seems to be
inside an entry. This is checked here. When it is most likely that the at is an opening
at of the next entry this method returns true.
@access private
@param string $entry The text of the entry until the at
@return bool true if the at is correct, false if the at is likely to begin the next entry.
|
[
"Checking",
"whether",
"an",
"at",
"is",
"outside",
"an",
"entry"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L519-L558
|
20,287 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._wordwrap
|
function _wordwrap($entry)
{
if (('' != $entry) && (is_string($entry))) {
$entry = wordwrap($entry, $this->_options['wordWrapWidth'], $this->_options['wordWrapBreak'], $this->_options['wordWrapCut']);
}
return $entry;
}
|
php
|
function _wordwrap($entry)
{
if (('' != $entry) && (is_string($entry))) {
$entry = wordwrap($entry, $this->_options['wordWrapWidth'], $this->_options['wordWrapBreak'], $this->_options['wordWrapCut']);
}
return $entry;
}
|
[
"function",
"_wordwrap",
"(",
"$",
"entry",
")",
"{",
"if",
"(",
"(",
"''",
"!=",
"$",
"entry",
")",
"&&",
"(",
"is_string",
"(",
"$",
"entry",
")",
")",
")",
"{",
"$",
"entry",
"=",
"wordwrap",
"(",
"$",
"entry",
",",
"$",
"this",
"->",
"_options",
"[",
"'wordWrapWidth'",
"]",
",",
"$",
"this",
"->",
"_options",
"[",
"'wordWrapBreak'",
"]",
",",
"$",
"this",
"->",
"_options",
"[",
"'wordWrapCut'",
"]",
")",
";",
"}",
"return",
"$",
"entry",
";",
"}"
] |
Wordwrap an entry
@access private
@param string $entry The entry to wrap
@return string wrapped entry
|
[
"Wordwrap",
"an",
"entry"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L605-L611
|
20,288 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._determineCase
|
function _determineCase($word)
{
$ret = -1;
$trimmedword = trim($word);
/*We need this variable. Without the next of would not work
(trim changes the variable automatically to a string!)*/
if (is_string($word) && (strlen($trimmedword) > 0)) {
$i = 0;
$found = false;
$openbrace = 0;
while (!$found && ($i <= strlen($word))) {
$letter = substr($trimmedword, $i, 1);
$ord = ord($letter);
if ($ord == 123) { //Open brace
$openbrace++;
}
if ($ord == 125) { //Closing brace
$openbrace--;
}
if (($ord >= 65) && ($ord <= 90) && (0 == $openbrace)) { //The first character is uppercase
$ret = 1;
$found = true;
} elseif (($ord >= 97) && ($ord <= 122) && (0 == $openbrace)) { //The first character is lowercase
$ret = 0;
$found = true;
} else { //Not yet found
$i++;
}
}
} else {
throw new BibtexException('Could not determine case on word: ' . (string)$word);
}
return $ret;
}
|
php
|
function _determineCase($word)
{
$ret = -1;
$trimmedword = trim($word);
/*We need this variable. Without the next of would not work
(trim changes the variable automatically to a string!)*/
if (is_string($word) && (strlen($trimmedword) > 0)) {
$i = 0;
$found = false;
$openbrace = 0;
while (!$found && ($i <= strlen($word))) {
$letter = substr($trimmedword, $i, 1);
$ord = ord($letter);
if ($ord == 123) { //Open brace
$openbrace++;
}
if ($ord == 125) { //Closing brace
$openbrace--;
}
if (($ord >= 65) && ($ord <= 90) && (0 == $openbrace)) { //The first character is uppercase
$ret = 1;
$found = true;
} elseif (($ord >= 97) && ($ord <= 122) && (0 == $openbrace)) { //The first character is lowercase
$ret = 0;
$found = true;
} else { //Not yet found
$i++;
}
}
} else {
throw new BibtexException('Could not determine case on word: ' . (string)$word);
}
return $ret;
}
|
[
"function",
"_determineCase",
"(",
"$",
"word",
")",
"{",
"$",
"ret",
"=",
"-",
"1",
";",
"$",
"trimmedword",
"=",
"trim",
"(",
"$",
"word",
")",
";",
"/*We need this variable. Without the next of would not work\n (trim changes the variable automatically to a string!)*/",
"if",
"(",
"is_string",
"(",
"$",
"word",
")",
"&&",
"(",
"strlen",
"(",
"$",
"trimmedword",
")",
">",
"0",
")",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"found",
"=",
"false",
";",
"$",
"openbrace",
"=",
"0",
";",
"while",
"(",
"!",
"$",
"found",
"&&",
"(",
"$",
"i",
"<=",
"strlen",
"(",
"$",
"word",
")",
")",
")",
"{",
"$",
"letter",
"=",
"substr",
"(",
"$",
"trimmedword",
",",
"$",
"i",
",",
"1",
")",
";",
"$",
"ord",
"=",
"ord",
"(",
"$",
"letter",
")",
";",
"if",
"(",
"$",
"ord",
"==",
"123",
")",
"{",
"//Open brace",
"$",
"openbrace",
"++",
";",
"}",
"if",
"(",
"$",
"ord",
"==",
"125",
")",
"{",
"//Closing brace",
"$",
"openbrace",
"--",
";",
"}",
"if",
"(",
"(",
"$",
"ord",
">=",
"65",
")",
"&&",
"(",
"$",
"ord",
"<=",
"90",
")",
"&&",
"(",
"0",
"==",
"$",
"openbrace",
")",
")",
"{",
"//The first character is uppercase",
"$",
"ret",
"=",
"1",
";",
"$",
"found",
"=",
"true",
";",
"}",
"elseif",
"(",
"(",
"$",
"ord",
">=",
"97",
")",
"&&",
"(",
"$",
"ord",
"<=",
"122",
")",
"&&",
"(",
"0",
"==",
"$",
"openbrace",
")",
")",
"{",
"//The first character is lowercase",
"$",
"ret",
"=",
"0",
";",
"$",
"found",
"=",
"true",
";",
"}",
"else",
"{",
"//Not yet found",
"$",
"i",
"++",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"BibtexException",
"(",
"'Could not determine case on word: '",
".",
"(",
"string",
")",
"$",
"word",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Case Determination according to the needs of BibTex
To parse the Author(s) correctly a determination is needed
to get the Case of a word. There are three possible values:
- Upper Case (return value 1)
- Lower Case (return value 0)
- Caseless (return value -1)
@access private
@param string $word
@return int The Case
@throws BibtexException
|
[
"Case",
"Determination",
"according",
"to",
"the",
"needs",
"of",
"BibTex"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L769-L802
|
20,289 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._validateValue
|
function _validateValue($entry, $wholeentry)
{
//There is no @ allowed if the entry is enclosed by braces
if (preg_match('/^{.*@.*}$/', $entry)) {
$this->_generateWarning('WARNING_AT_IN_BRACES', $entry, $wholeentry);
}
//No escaped " allowed if the entry is enclosed by double quotes
if (preg_match('/^\".*\\".*\"$/', $entry)) {
$this->_generateWarning('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES', $entry, $wholeentry);
}
//Amount of Braces is not correct
$open = 0;
$lastchar = '';
$char = '';
for ($i = 0; $i < strlen($entry); $i++) {
$char = substr($entry, $i, 1);
if (('{' == $char) && ('\\' != $lastchar)) {
$open++;
}
if (('}' == $char) && ('\\' != $lastchar)) {
$open--;
}
$lastchar = $char;
}
if (0 != $open) {
$this->_generateWarning('WARNING_UNBALANCED_AMOUNT_OF_BRACES', $entry, $wholeentry);
}
}
|
php
|
function _validateValue($entry, $wholeentry)
{
//There is no @ allowed if the entry is enclosed by braces
if (preg_match('/^{.*@.*}$/', $entry)) {
$this->_generateWarning('WARNING_AT_IN_BRACES', $entry, $wholeentry);
}
//No escaped " allowed if the entry is enclosed by double quotes
if (preg_match('/^\".*\\".*\"$/', $entry)) {
$this->_generateWarning('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES', $entry, $wholeentry);
}
//Amount of Braces is not correct
$open = 0;
$lastchar = '';
$char = '';
for ($i = 0; $i < strlen($entry); $i++) {
$char = substr($entry, $i, 1);
if (('{' == $char) && ('\\' != $lastchar)) {
$open++;
}
if (('}' == $char) && ('\\' != $lastchar)) {
$open--;
}
$lastchar = $char;
}
if (0 != $open) {
$this->_generateWarning('WARNING_UNBALANCED_AMOUNT_OF_BRACES', $entry, $wholeentry);
}
}
|
[
"function",
"_validateValue",
"(",
"$",
"entry",
",",
"$",
"wholeentry",
")",
"{",
"//There is no @ allowed if the entry is enclosed by braces",
"if",
"(",
"preg_match",
"(",
"'/^{.*@.*}$/'",
",",
"$",
"entry",
")",
")",
"{",
"$",
"this",
"->",
"_generateWarning",
"(",
"'WARNING_AT_IN_BRACES'",
",",
"$",
"entry",
",",
"$",
"wholeentry",
")",
";",
"}",
"//No escaped \" allowed if the entry is enclosed by double quotes",
"if",
"(",
"preg_match",
"(",
"'/^\\\".*\\\\\".*\\\"$/'",
",",
"$",
"entry",
")",
")",
"{",
"$",
"this",
"->",
"_generateWarning",
"(",
"'WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES'",
",",
"$",
"entry",
",",
"$",
"wholeentry",
")",
";",
"}",
"//Amount of Braces is not correct",
"$",
"open",
"=",
"0",
";",
"$",
"lastchar",
"=",
"''",
";",
"$",
"char",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"entry",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"char",
"=",
"substr",
"(",
"$",
"entry",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"(",
"'{'",
"==",
"$",
"char",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"lastchar",
")",
")",
"{",
"$",
"open",
"++",
";",
"}",
"if",
"(",
"(",
"'}'",
"==",
"$",
"char",
")",
"&&",
"(",
"'\\\\'",
"!=",
"$",
"lastchar",
")",
")",
"{",
"$",
"open",
"--",
";",
"}",
"$",
"lastchar",
"=",
"$",
"char",
";",
"}",
"if",
"(",
"0",
"!=",
"$",
"open",
")",
"{",
"$",
"this",
"->",
"_generateWarning",
"(",
"'WARNING_UNBALANCED_AMOUNT_OF_BRACES'",
",",
"$",
"entry",
",",
"$",
"wholeentry",
")",
";",
"}",
"}"
] |
Validation of a value
There may be several problems with the value of a field.
These problems exist but do not break the parsing.
If a problem is detected a warning is appended to the array warnings.
@access private
@param string $entry The entry aka one line which which should be validated
@param string $wholeentry The whole BibTex Entry which the one line is part of
@return void
|
[
"Validation",
"of",
"a",
"value"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L816-L843
|
20,290 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._removeCurlyBraces
|
function _removeCurlyBraces($value)
{
//First we save the delimiters
$beginningdels = array_keys($this->_delimiters);
$firstchar = substr($value, 0, 1);
$lastchar = substr($value, -1, 1);
$begin = '';
$end = '';
while (in_array($firstchar, $beginningdels)) { //The first character is an opening delimiter
if ($lastchar == $this->_delimiters[$firstchar]) { //Matches to closing Delimiter
$begin .= $firstchar;
$end .= $lastchar;
$value = substr($value, 1, -1);
} else {
break;
}
$firstchar = substr($value, 0, 1);
$lastchar = substr($value, -1, 1);
}
//Now we get rid of the curly braces
$pattern = '/([^\\\\]|^)?\{(.*?[^\\\\])\}/';
$replacement = '$1$2';
$value = preg_replace($pattern, $replacement, $value);
//Reattach delimiters
$value = $begin . $value . $end;
return $value;
}
|
php
|
function _removeCurlyBraces($value)
{
//First we save the delimiters
$beginningdels = array_keys($this->_delimiters);
$firstchar = substr($value, 0, 1);
$lastchar = substr($value, -1, 1);
$begin = '';
$end = '';
while (in_array($firstchar, $beginningdels)) { //The first character is an opening delimiter
if ($lastchar == $this->_delimiters[$firstchar]) { //Matches to closing Delimiter
$begin .= $firstchar;
$end .= $lastchar;
$value = substr($value, 1, -1);
} else {
break;
}
$firstchar = substr($value, 0, 1);
$lastchar = substr($value, -1, 1);
}
//Now we get rid of the curly braces
$pattern = '/([^\\\\]|^)?\{(.*?[^\\\\])\}/';
$replacement = '$1$2';
$value = preg_replace($pattern, $replacement, $value);
//Reattach delimiters
$value = $begin . $value . $end;
return $value;
}
|
[
"function",
"_removeCurlyBraces",
"(",
"$",
"value",
")",
"{",
"//First we save the delimiters",
"$",
"beginningdels",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"_delimiters",
")",
";",
"$",
"firstchar",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
")",
";",
"$",
"lastchar",
"=",
"substr",
"(",
"$",
"value",
",",
"-",
"1",
",",
"1",
")",
";",
"$",
"begin",
"=",
"''",
";",
"$",
"end",
"=",
"''",
";",
"while",
"(",
"in_array",
"(",
"$",
"firstchar",
",",
"$",
"beginningdels",
")",
")",
"{",
"//The first character is an opening delimiter",
"if",
"(",
"$",
"lastchar",
"==",
"$",
"this",
"->",
"_delimiters",
"[",
"$",
"firstchar",
"]",
")",
"{",
"//Matches to closing Delimiter",
"$",
"begin",
".=",
"$",
"firstchar",
";",
"$",
"end",
".=",
"$",
"lastchar",
";",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"$",
"firstchar",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
")",
";",
"$",
"lastchar",
"=",
"substr",
"(",
"$",
"value",
",",
"-",
"1",
",",
"1",
")",
";",
"}",
"//Now we get rid of the curly braces",
"$",
"pattern",
"=",
"'/([^\\\\\\\\]|^)?\\{(.*?[^\\\\\\\\])\\}/'",
";",
"$",
"replacement",
"=",
"'$1$2'",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"$",
"pattern",
",",
"$",
"replacement",
",",
"$",
"value",
")",
";",
"//Reattach delimiters",
"$",
"value",
"=",
"$",
"begin",
".",
"$",
"value",
".",
"$",
"end",
";",
"return",
"$",
"value",
";",
"}"
] |
Remove curly braces from entry
@access private
@param string $value The value in which curly braces to be removed
@param string Value with removed curly braces
|
[
"Remove",
"curly",
"braces",
"from",
"entry"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L852-L878
|
20,291 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._generateWarning
|
function _generateWarning($type, $entry, $wholeentry = '')
{
$warning['warning'] = $type;
$warning['entry'] = $entry;
$warning['wholeentry'] = $wholeentry;
$this->warnings[] = $warning;
}
|
php
|
function _generateWarning($type, $entry, $wholeentry = '')
{
$warning['warning'] = $type;
$warning['entry'] = $entry;
$warning['wholeentry'] = $wholeentry;
$this->warnings[] = $warning;
}
|
[
"function",
"_generateWarning",
"(",
"$",
"type",
",",
"$",
"entry",
",",
"$",
"wholeentry",
"=",
"''",
")",
"{",
"$",
"warning",
"[",
"'warning'",
"]",
"=",
"$",
"type",
";",
"$",
"warning",
"[",
"'entry'",
"]",
"=",
"$",
"entry",
";",
"$",
"warning",
"[",
"'wholeentry'",
"]",
"=",
"$",
"wholeentry",
";",
"$",
"this",
"->",
"warnings",
"[",
"]",
"=",
"$",
"warning",
";",
"}"
] |
Generates a warning
@access private
@param string $type The type of the warning
@param string $entry The line of the entry where the warning occurred
@param string $wholeentry OPTIONAL The whole entry where the warning occurred
|
[
"Generates",
"a",
"warning"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L888-L894
|
20,292 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._formatAuthor
|
function _formatAuthor($array)
{
if (!array_key_exists('von', $array)) {
$array['von'] = '';
} else {
$array['von'] = trim($array['von']);
}
if (!array_key_exists('last', $array)) {
$array['last'] = '';
} else {
$array['last'] = trim($array['last']);
}
if (!array_key_exists('jr', $array)) {
$array['jr'] = '';
} else {
$array['jr'] = trim($array['jr']);
}
if (!array_key_exists('first', $array)) {
$array['first'] = '';
} else {
$array['first'] = trim($array['first']);
}
$ret = $this->authorstring;
$ret = str_replace("VON", $array['von'], $ret);
$ret = str_replace("LAST", $array['last'], $ret);
$ret = str_replace("JR,", $array['jr'], $ret);
$ret = str_replace("FIRST", $array['first'], $ret);
return trim(print_r($ret, 1));
}
|
php
|
function _formatAuthor($array)
{
if (!array_key_exists('von', $array)) {
$array['von'] = '';
} else {
$array['von'] = trim($array['von']);
}
if (!array_key_exists('last', $array)) {
$array['last'] = '';
} else {
$array['last'] = trim($array['last']);
}
if (!array_key_exists('jr', $array)) {
$array['jr'] = '';
} else {
$array['jr'] = trim($array['jr']);
}
if (!array_key_exists('first', $array)) {
$array['first'] = '';
} else {
$array['first'] = trim($array['first']);
}
$ret = $this->authorstring;
$ret = str_replace("VON", $array['von'], $ret);
$ret = str_replace("LAST", $array['last'], $ret);
$ret = str_replace("JR,", $array['jr'], $ret);
$ret = str_replace("FIRST", $array['first'], $ret);
return trim(print_r($ret, 1));
}
|
[
"function",
"_formatAuthor",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'von'",
",",
"$",
"array",
")",
")",
"{",
"$",
"array",
"[",
"'von'",
"]",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"'von'",
"]",
"=",
"trim",
"(",
"$",
"array",
"[",
"'von'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'last'",
",",
"$",
"array",
")",
")",
"{",
"$",
"array",
"[",
"'last'",
"]",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"'last'",
"]",
"=",
"trim",
"(",
"$",
"array",
"[",
"'last'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'jr'",
",",
"$",
"array",
")",
")",
"{",
"$",
"array",
"[",
"'jr'",
"]",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"'jr'",
"]",
"=",
"trim",
"(",
"$",
"array",
"[",
"'jr'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'first'",
",",
"$",
"array",
")",
")",
"{",
"$",
"array",
"[",
"'first'",
"]",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"'first'",
"]",
"=",
"trim",
"(",
"$",
"array",
"[",
"'first'",
"]",
")",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"authorstring",
";",
"$",
"ret",
"=",
"str_replace",
"(",
"\"VON\"",
",",
"$",
"array",
"[",
"'von'",
"]",
",",
"$",
"ret",
")",
";",
"$",
"ret",
"=",
"str_replace",
"(",
"\"LAST\"",
",",
"$",
"array",
"[",
"'last'",
"]",
",",
"$",
"ret",
")",
";",
"$",
"ret",
"=",
"str_replace",
"(",
"\"JR,\"",
",",
"$",
"array",
"[",
"'jr'",
"]",
",",
"$",
"ret",
")",
";",
"$",
"ret",
"=",
"str_replace",
"(",
"\"FIRST\"",
",",
"$",
"array",
"[",
"'first'",
"]",
",",
"$",
"ret",
")",
";",
"return",
"trim",
"(",
"print_r",
"(",
"$",
"ret",
",",
"1",
")",
")",
";",
"}"
] |
Returns the author formatted
The Author is formatted as setted in the authorstring
@access private
@param array $array Author array
@return string the formatted author string
|
[
"Returns",
"the",
"author",
"formatted"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L938-L967
|
20,293 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex.bibTex
|
function bibTex()
{
$bibtex = '';
foreach ($this->data as $entry) {
//Intro
$bibtex .= '@' . strtolower($entry['entryType']) . ' { ' . $entry['cite'] . ",\n";
//Other fields except author
foreach ($entry as $key => $val) {
if ($this->_options['wordWrapWidth'] > 0) {
$val = $this->_wordWrap($val);
}
if (!in_array($key, array('cite', 'entryType', 'author'))) {
$bibtex .= "\t" . $key . ' = {' . $this->_escape_tex($val) . "},\n";
}
}
//Author
$author = null;
if (array_key_exists('author', $entry)) {
if ($this->_options['extractAuthors']) {
$tmparray = array(); //In this array the authors are saved and the joind with an and
foreach ($entry['author'] as $authorentry) {
$tmparray[] = $this->_formatAuthor($authorentry);
}
$author = join(' and ', $tmparray);
} else {
$author = $entry['author'];
}
} else {
$author = '';
}
$bibtex .= "\tauthor = {" . $this->_escape_tex($author) . "}\n";
$bibtex .= "}\n\n";
}
return $bibtex;
}
|
php
|
function bibTex()
{
$bibtex = '';
foreach ($this->data as $entry) {
//Intro
$bibtex .= '@' . strtolower($entry['entryType']) . ' { ' . $entry['cite'] . ",\n";
//Other fields except author
foreach ($entry as $key => $val) {
if ($this->_options['wordWrapWidth'] > 0) {
$val = $this->_wordWrap($val);
}
if (!in_array($key, array('cite', 'entryType', 'author'))) {
$bibtex .= "\t" . $key . ' = {' . $this->_escape_tex($val) . "},\n";
}
}
//Author
$author = null;
if (array_key_exists('author', $entry)) {
if ($this->_options['extractAuthors']) {
$tmparray = array(); //In this array the authors are saved and the joind with an and
foreach ($entry['author'] as $authorentry) {
$tmparray[] = $this->_formatAuthor($authorentry);
}
$author = join(' and ', $tmparray);
} else {
$author = $entry['author'];
}
} else {
$author = '';
}
$bibtex .= "\tauthor = {" . $this->_escape_tex($author) . "}\n";
$bibtex .= "}\n\n";
}
return $bibtex;
}
|
[
"function",
"bibTex",
"(",
")",
"{",
"$",
"bibtex",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"entry",
")",
"{",
"//Intro",
"$",
"bibtex",
".=",
"'@'",
".",
"strtolower",
"(",
"$",
"entry",
"[",
"'entryType'",
"]",
")",
".",
"' { '",
".",
"$",
"entry",
"[",
"'cite'",
"]",
".",
"\",\\n\"",
";",
"//Other fields except author",
"foreach",
"(",
"$",
"entry",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_options",
"[",
"'wordWrapWidth'",
"]",
">",
"0",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"_wordWrap",
"(",
"$",
"val",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"array",
"(",
"'cite'",
",",
"'entryType'",
",",
"'author'",
")",
")",
")",
"{",
"$",
"bibtex",
".=",
"\"\\t\"",
".",
"$",
"key",
".",
"' = {'",
".",
"$",
"this",
"->",
"_escape_tex",
"(",
"$",
"val",
")",
".",
"\"},\\n\"",
";",
"}",
"}",
"//Author",
"$",
"author",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"'author'",
",",
"$",
"entry",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_options",
"[",
"'extractAuthors'",
"]",
")",
"{",
"$",
"tmparray",
"=",
"array",
"(",
")",
";",
"//In this array the authors are saved and the joind with an and",
"foreach",
"(",
"$",
"entry",
"[",
"'author'",
"]",
"as",
"$",
"authorentry",
")",
"{",
"$",
"tmparray",
"[",
"]",
"=",
"$",
"this",
"->",
"_formatAuthor",
"(",
"$",
"authorentry",
")",
";",
"}",
"$",
"author",
"=",
"join",
"(",
"' and '",
",",
"$",
"tmparray",
")",
";",
"}",
"else",
"{",
"$",
"author",
"=",
"$",
"entry",
"[",
"'author'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"author",
"=",
"''",
";",
"}",
"$",
"bibtex",
".=",
"\"\\tauthor = {\"",
".",
"$",
"this",
"->",
"_escape_tex",
"(",
"$",
"author",
")",
".",
"\"}\\n\"",
";",
"$",
"bibtex",
".=",
"\"}\\n\\n\"",
";",
"}",
"return",
"$",
"bibtex",
";",
"}"
] |
Converts the stored BibTex entries to a BibTex String
In the field list, the author is the last field.
@access public
@return string The BibTex string
|
[
"Converts",
"the",
"stored",
"BibTex",
"entries",
"to",
"a",
"BibTex",
"String"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L977-L1013
|
20,294 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex.rtf
|
function rtf()
{
$ret = "{\\rtf\n";
foreach ($this->data as $entry) {
$line = $this->rtfstring;
$title = '';
$journal = '';
$year = '';
$authors = '';
if (array_key_exists('title', $entry)) {
$title = $this->_unwrap($entry['title']);
}
if (array_key_exists('journal', $entry)) {
$journal = $this->_unwrap($entry['journal']);
}
if (array_key_exists('year', $entry)) {
$year = $this->_unwrap($entry['year']);
}
if (array_key_exists('author', $entry)) {
if ($this->_options['extractAuthors']) {
$tmparray = array(); //In this array the authors are saved and the joind with an and
foreach ($entry['author'] as $authorentry) {
$tmparray[] = $this->_formatAuthor($authorentry);
}
$authors = join(', ', $tmparray);
} else {
$authors = $entry['author'];
}
}
if (('' != $title) || ('' != $journal) || ('' != $year) || ('' != $authors)) {
$line = str_replace("TITLE", $title, $line);
$line = str_replace("JOURNAL", $journal, $line);
$line = str_replace("YEAR", $year, $line);
$line = str_replace("AUTHORS", $authors, $line);
$line .= "\n\\par\n";
$ret .= $line;
} else {
$this->_generateWarning('WARNING_LINE_WAS_NOT_CONVERTED', '', print_r($entry, 1));
}
}
$ret .= '}';
return $ret;
}
|
php
|
function rtf()
{
$ret = "{\\rtf\n";
foreach ($this->data as $entry) {
$line = $this->rtfstring;
$title = '';
$journal = '';
$year = '';
$authors = '';
if (array_key_exists('title', $entry)) {
$title = $this->_unwrap($entry['title']);
}
if (array_key_exists('journal', $entry)) {
$journal = $this->_unwrap($entry['journal']);
}
if (array_key_exists('year', $entry)) {
$year = $this->_unwrap($entry['year']);
}
if (array_key_exists('author', $entry)) {
if ($this->_options['extractAuthors']) {
$tmparray = array(); //In this array the authors are saved and the joind with an and
foreach ($entry['author'] as $authorentry) {
$tmparray[] = $this->_formatAuthor($authorentry);
}
$authors = join(', ', $tmparray);
} else {
$authors = $entry['author'];
}
}
if (('' != $title) || ('' != $journal) || ('' != $year) || ('' != $authors)) {
$line = str_replace("TITLE", $title, $line);
$line = str_replace("JOURNAL", $journal, $line);
$line = str_replace("YEAR", $year, $line);
$line = str_replace("AUTHORS", $authors, $line);
$line .= "\n\\par\n";
$ret .= $line;
} else {
$this->_generateWarning('WARNING_LINE_WAS_NOT_CONVERTED', '', print_r($entry, 1));
}
}
$ret .= '}';
return $ret;
}
|
[
"function",
"rtf",
"(",
")",
"{",
"$",
"ret",
"=",
"\"{\\\\rtf\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"entry",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"rtfstring",
";",
"$",
"title",
"=",
"''",
";",
"$",
"journal",
"=",
"''",
";",
"$",
"year",
"=",
"''",
";",
"$",
"authors",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'title'",
",",
"$",
"entry",
")",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"_unwrap",
"(",
"$",
"entry",
"[",
"'title'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'journal'",
",",
"$",
"entry",
")",
")",
"{",
"$",
"journal",
"=",
"$",
"this",
"->",
"_unwrap",
"(",
"$",
"entry",
"[",
"'journal'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'year'",
",",
"$",
"entry",
")",
")",
"{",
"$",
"year",
"=",
"$",
"this",
"->",
"_unwrap",
"(",
"$",
"entry",
"[",
"'year'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'author'",
",",
"$",
"entry",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_options",
"[",
"'extractAuthors'",
"]",
")",
"{",
"$",
"tmparray",
"=",
"array",
"(",
")",
";",
"//In this array the authors are saved and the joind with an and",
"foreach",
"(",
"$",
"entry",
"[",
"'author'",
"]",
"as",
"$",
"authorentry",
")",
"{",
"$",
"tmparray",
"[",
"]",
"=",
"$",
"this",
"->",
"_formatAuthor",
"(",
"$",
"authorentry",
")",
";",
"}",
"$",
"authors",
"=",
"join",
"(",
"', '",
",",
"$",
"tmparray",
")",
";",
"}",
"else",
"{",
"$",
"authors",
"=",
"$",
"entry",
"[",
"'author'",
"]",
";",
"}",
"}",
"if",
"(",
"(",
"''",
"!=",
"$",
"title",
")",
"||",
"(",
"''",
"!=",
"$",
"journal",
")",
"||",
"(",
"''",
"!=",
"$",
"year",
")",
"||",
"(",
"''",
"!=",
"$",
"authors",
")",
")",
"{",
"$",
"line",
"=",
"str_replace",
"(",
"\"TITLE\"",
",",
"$",
"title",
",",
"$",
"line",
")",
";",
"$",
"line",
"=",
"str_replace",
"(",
"\"JOURNAL\"",
",",
"$",
"journal",
",",
"$",
"line",
")",
";",
"$",
"line",
"=",
"str_replace",
"(",
"\"YEAR\"",
",",
"$",
"year",
",",
"$",
"line",
")",
";",
"$",
"line",
"=",
"str_replace",
"(",
"\"AUTHORS\"",
",",
"$",
"authors",
",",
"$",
"line",
")",
";",
"$",
"line",
".=",
"\"\\n\\\\par\\n\"",
";",
"$",
"ret",
".=",
"$",
"line",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_generateWarning",
"(",
"'WARNING_LINE_WAS_NOT_CONVERTED'",
",",
"''",
",",
"print_r",
"(",
"$",
"entry",
",",
"1",
")",
")",
";",
"}",
"}",
"$",
"ret",
".=",
"'}'",
";",
"return",
"$",
"ret",
";",
"}"
] |
Returns the stored data in RTF format
This method simply returns a RTF formatted string. This is done very
simple and is not intended for heavy using and fine formatting. This
should be done by BibTex! It is intended to give some kind of quick
preview or to send someone a reference list as word/rtf format (even
some people in the scientific field still use word). If you want to
change the default format you have to override the class variable
"rtfstring". This variable is used and the placeholders simply replaced.
Lines with no data cause an warning!
@return string the RTF Strings
|
[
"Returns",
"the",
"stored",
"data",
"in",
"RTF",
"format"
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L1063-L1105
|
20,295 |
academic/VipaBibTexBundle
|
Helper/Bibtex.php
|
Bibtex._escape_tex
|
function _escape_tex($tex)
{
$tex = str_replace("\\", "\\\\", $tex);
$tex = str_replace('#', '\#', $tex);
$tex = str_replace('$', '\$', $tex);
$tex = str_replace('%', '\%', $tex);
$tex = str_replace('^', '\^', $tex);
$tex = str_replace('&', '\&', $tex);
$tex = str_replace('_', '\_', $tex);
$tex = str_replace('{', '\{', $tex);
$tex = str_replace('}', '\}', $tex);
return ($tex);
}
|
php
|
function _escape_tex($tex)
{
$tex = str_replace("\\", "\\\\", $tex);
$tex = str_replace('#', '\#', $tex);
$tex = str_replace('$', '\$', $tex);
$tex = str_replace('%', '\%', $tex);
$tex = str_replace('^', '\^', $tex);
$tex = str_replace('&', '\&', $tex);
$tex = str_replace('_', '\_', $tex);
$tex = str_replace('{', '\{', $tex);
$tex = str_replace('}', '\}', $tex);
return ($tex);
}
|
[
"function",
"_escape_tex",
"(",
"$",
"tex",
")",
"{",
"$",
"tex",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"\\\\\\\\\"",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'#'",
",",
"'\\#'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'$'",
",",
"'\\$'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'%'",
",",
"'\\%'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'^'",
",",
"'\\^'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'&'",
",",
"'\\&'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'_'",
",",
"'\\_'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'{'",
",",
"'\\{'",
",",
"$",
"tex",
")",
";",
"$",
"tex",
"=",
"str_replace",
"(",
"'}'",
",",
"'\\}'",
",",
"$",
"tex",
")",
";",
"return",
"(",
"$",
"tex",
")",
";",
"}"
] |
Returns a string with special TeX characters escaped.
This method is to be used with any method which is exporting TeX, such
as the bibTex method. A series of string replace operations are
performed on the input string, and the escaped string is returned.
This code is taken from the Text_Wiki Pear package.
@author Jeremy Cowgar <[email protected]>
@access private
@param string $txt the TeX string
@return string the escaped TeX string
|
[
"Returns",
"a",
"string",
"with",
"special",
"TeX",
"characters",
"escaped",
"."
] |
1cd82b0961e1a9fee804a85fd774d1384c3e089b
|
https://github.com/academic/VipaBibTexBundle/blob/1cd82b0961e1a9fee804a85fd774d1384c3e089b/Helper/Bibtex.php#L1179-L1191
|
20,296 |
zicht/z
|
src/Zicht/Tool/Script/Tokenizer.php
|
Tokenizer.getTokens
|
public function getTokens($string, &$needle = 0)
{
$exprTokenizer = new ExpressionTokenizer();
$ret = array();
$depth = 0;
$needle = 0;
$len = strlen($string);
while ($needle < $len) {
$before = $needle;
$substr = substr($string, $needle);
if ($depth === 0) {
// match either '$(' or '@(' and mark that as an EXPR_START token.
if (preg_match('/^([$@])\(/', $substr, $m)) {
$needle += strlen($m[0]);
$ret[] = new Token(Token::EXPR_START, $m[0]);
// record expression depth, to make sure the usage of parentheses inside the expression doesn't
// break tokenization (e.g. '$( ("foo") )'
$depth++;
} else {
// store the current token in a temp var for appending, in case it's a DATA token
$token = end($ret);
// handle escaping of the $( syntax, '$$(' becomes '$('
if (preg_match('/^\$\$\(/', $substr, $m)) {
$value = substr($m[0], 1);
$needle += strlen($m[0]);
} else {
$value = $string{$needle};
$needle += strlen($value);
}
// if the current token is DATA, and the previous token is DATA, append the value to the previous
// and ignore the current.
if ($token && $token->match(Token::DATA)) {
$token->value .= $value;
unset($token);
} else {
$ret[] = new Token(Token::DATA, $value);
}
}
} else {
$ret = array_merge($ret, $exprTokenizer->getTokens($string, $needle));
$depth = 0;
}
if ($before === $needle) {
// safety net.
throw new \UnexpectedValueException(
"Unexpected input near token {$string{$needle}}, unsupported character"
);
}
}
return $ret;
}
|
php
|
public function getTokens($string, &$needle = 0)
{
$exprTokenizer = new ExpressionTokenizer();
$ret = array();
$depth = 0;
$needle = 0;
$len = strlen($string);
while ($needle < $len) {
$before = $needle;
$substr = substr($string, $needle);
if ($depth === 0) {
// match either '$(' or '@(' and mark that as an EXPR_START token.
if (preg_match('/^([$@])\(/', $substr, $m)) {
$needle += strlen($m[0]);
$ret[] = new Token(Token::EXPR_START, $m[0]);
// record expression depth, to make sure the usage of parentheses inside the expression doesn't
// break tokenization (e.g. '$( ("foo") )'
$depth++;
} else {
// store the current token in a temp var for appending, in case it's a DATA token
$token = end($ret);
// handle escaping of the $( syntax, '$$(' becomes '$('
if (preg_match('/^\$\$\(/', $substr, $m)) {
$value = substr($m[0], 1);
$needle += strlen($m[0]);
} else {
$value = $string{$needle};
$needle += strlen($value);
}
// if the current token is DATA, and the previous token is DATA, append the value to the previous
// and ignore the current.
if ($token && $token->match(Token::DATA)) {
$token->value .= $value;
unset($token);
} else {
$ret[] = new Token(Token::DATA, $value);
}
}
} else {
$ret = array_merge($ret, $exprTokenizer->getTokens($string, $needle));
$depth = 0;
}
if ($before === $needle) {
// safety net.
throw new \UnexpectedValueException(
"Unexpected input near token {$string{$needle}}, unsupported character"
);
}
}
return $ret;
}
|
[
"public",
"function",
"getTokens",
"(",
"$",
"string",
",",
"&",
"$",
"needle",
"=",
"0",
")",
"{",
"$",
"exprTokenizer",
"=",
"new",
"ExpressionTokenizer",
"(",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"depth",
"=",
"0",
";",
"$",
"needle",
"=",
"0",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"while",
"(",
"$",
"needle",
"<",
"$",
"len",
")",
"{",
"$",
"before",
"=",
"$",
"needle",
";",
"$",
"substr",
"=",
"substr",
"(",
"$",
"string",
",",
"$",
"needle",
")",
";",
"if",
"(",
"$",
"depth",
"===",
"0",
")",
"{",
"// match either '$(' or '@(' and mark that as an EXPR_START token.",
"if",
"(",
"preg_match",
"(",
"'/^([$@])\\(/'",
",",
"$",
"substr",
",",
"$",
"m",
")",
")",
"{",
"$",
"needle",
"+=",
"strlen",
"(",
"$",
"m",
"[",
"0",
"]",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"new",
"Token",
"(",
"Token",
"::",
"EXPR_START",
",",
"$",
"m",
"[",
"0",
"]",
")",
";",
"// record expression depth, to make sure the usage of parentheses inside the expression doesn't",
"// break tokenization (e.g. '$( (\"foo\") )'",
"$",
"depth",
"++",
";",
"}",
"else",
"{",
"// store the current token in a temp var for appending, in case it's a DATA token",
"$",
"token",
"=",
"end",
"(",
"$",
"ret",
")",
";",
"// handle escaping of the $( syntax, '$$(' becomes '$('",
"if",
"(",
"preg_match",
"(",
"'/^\\$\\$\\(/'",
",",
"$",
"substr",
",",
"$",
"m",
")",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"m",
"[",
"0",
"]",
",",
"1",
")",
";",
"$",
"needle",
"+=",
"strlen",
"(",
"$",
"m",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"string",
"{",
"$",
"needle",
"}",
";",
"$",
"needle",
"+=",
"strlen",
"(",
"$",
"value",
")",
";",
"}",
"// if the current token is DATA, and the previous token is DATA, append the value to the previous",
"// and ignore the current.",
"if",
"(",
"$",
"token",
"&&",
"$",
"token",
"->",
"match",
"(",
"Token",
"::",
"DATA",
")",
")",
"{",
"$",
"token",
"->",
"value",
".=",
"$",
"value",
";",
"unset",
"(",
"$",
"token",
")",
";",
"}",
"else",
"{",
"$",
"ret",
"[",
"]",
"=",
"new",
"Token",
"(",
"Token",
"::",
"DATA",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"ret",
"=",
"array_merge",
"(",
"$",
"ret",
",",
"$",
"exprTokenizer",
"->",
"getTokens",
"(",
"$",
"string",
",",
"$",
"needle",
")",
")",
";",
"$",
"depth",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"before",
"===",
"$",
"needle",
")",
"{",
"// safety net.",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Unexpected input near token {$string{$needle}}, unsupported character\"",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Returns an array of tokens
@param string $string
@param int &$needle
@throws \UnexpectedValueException
@return array
|
[
"Returns",
"an",
"array",
"of",
"tokens"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Tokenizer.php#L34-L87
|
20,297 |
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Controller/Model.php
|
Aoe_Layout_Controller_Model.indexAction
|
public function indexAction()
{
if ($this->getRequest()->isAjax()) {
try {
$this->loadLayout(null, false, false);
$this->getLayout()->getUpdate()->setCacheId(null);
$this->getLayout()->getUpdate()->addHandle(strtolower($this->getFullActionName()) . '_AJAX');
} catch (Exception $e) {
Mage::logException($e);
$this->getResponse()->setHeader('Content-Type', 'application/json');
$this->getResponse()->setBody(Zend_Json::encode(['error' => true, 'message' => $e->getMessage()]));
}
}
$this->loadLayout();
$this->renderLayout();
}
|
php
|
public function indexAction()
{
if ($this->getRequest()->isAjax()) {
try {
$this->loadLayout(null, false, false);
$this->getLayout()->getUpdate()->setCacheId(null);
$this->getLayout()->getUpdate()->addHandle(strtolower($this->getFullActionName()) . '_AJAX');
} catch (Exception $e) {
Mage::logException($e);
$this->getResponse()->setHeader('Content-Type', 'application/json');
$this->getResponse()->setBody(Zend_Json::encode(['error' => true, 'message' => $e->getMessage()]));
}
}
$this->loadLayout();
$this->renderLayout();
}
|
[
"public",
"function",
"indexAction",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"isAjax",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"loadLayout",
"(",
"null",
",",
"false",
",",
"false",
")",
";",
"$",
"this",
"->",
"getLayout",
"(",
")",
"->",
"getUpdate",
"(",
")",
"->",
"setCacheId",
"(",
"null",
")",
";",
"$",
"this",
"->",
"getLayout",
"(",
")",
"->",
"getUpdate",
"(",
")",
"->",
"addHandle",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"getFullActionName",
"(",
")",
")",
".",
"'_AJAX'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Mage",
"::",
"logException",
"(",
"$",
"e",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setBody",
"(",
"Zend_Json",
"::",
"encode",
"(",
"[",
"'error'",
"=>",
"true",
",",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"loadLayout",
"(",
")",
";",
"$",
"this",
"->",
"renderLayout",
"(",
")",
";",
"}"
] |
List existing records via a grid
|
[
"List",
"existing",
"records",
"via",
"a",
"grid"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/Model.php#L8-L24
|
20,298 |
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Controller/Model.php
|
Aoe_Layout_Controller_Model.viewAction
|
public function viewAction()
{
$model = $this->loadModel();
if (!$model->getId()) {
$this->_forward('noroute');
return;
}
$this->loadLayout();
$this->renderLayout();
}
|
php
|
public function viewAction()
{
$model = $this->loadModel();
if (!$model->getId()) {
$this->_forward('noroute');
return;
}
$this->loadLayout();
$this->renderLayout();
}
|
[
"public",
"function",
"viewAction",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"loadModel",
"(",
")",
";",
"if",
"(",
"!",
"$",
"model",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_forward",
"(",
"'noroute'",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"loadLayout",
"(",
")",
";",
"$",
"this",
"->",
"renderLayout",
"(",
")",
";",
"}"
] |
View existing record
|
[
"View",
"existing",
"record"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/Model.php#L29-L39
|
20,299 |
odiaseo/pagebuilder
|
src/PageBuilder/Util/Widget.php
|
Widget.widgetExist
|
public function widgetExist($name)
{
$name = strtolower($name);
return isset($this->dataStore[0][$name]) ? $this->dataStore[0][$name] : false;
}
|
php
|
public function widgetExist($name)
{
$name = strtolower($name);
return isset($this->dataStore[0][$name]) ? $this->dataStore[0][$name] : false;
}
|
[
"public",
"function",
"widgetExist",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"dataStore",
"[",
"0",
"]",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"dataStore",
"[",
"0",
"]",
"[",
"$",
"name",
"]",
":",
"false",
";",
"}"
] |
Checks if a widget exists
@param $name
@return bool
|
[
"Checks",
"if",
"a",
"widget",
"exists"
] |
88ef7cccf305368561307efe4ca07fac8e5774f3
|
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Util/Widget.php#L143-L148
|
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.