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,900 |
ouropencode/dachi
|
src/Template.php
|
Template.get
|
public static function get($template) {
if(self::$twig === null)
self::initialize();
return self::$twig->loadTemplate($template . '.twig');
}
|
php
|
public static function get($template) {
if(self::$twig === null)
self::initialize();
return self::$twig->loadTemplate($template . '.twig');
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"twig",
"===",
"null",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"return",
"self",
"::",
"$",
"twig",
"->",
"loadTemplate",
"(",
"$",
"template",
".",
"'.twig'",
")",
";",
"}"
] |
Retreive a twig template object
@param string $template The template file
@return Twig_Template
|
[
"Retreive",
"a",
"twig",
"template",
"object"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L166-L171
|
20,901 |
ouropencode/dachi
|
src/Template.php
|
Template.display
|
public static function display($template, $target_id) {
if(self::$twig === null)
self::initialize();
self::$render_actions[] = array(
"type" => "display_tpl",
"template" => $template,
"target_id" => $target_id
);
}
|
php
|
public static function display($template, $target_id) {
if(self::$twig === null)
self::initialize();
self::$render_actions[] = array(
"type" => "display_tpl",
"template" => $template,
"target_id" => $target_id
);
}
|
[
"public",
"static",
"function",
"display",
"(",
"$",
"template",
",",
"$",
"target_id",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"twig",
"===",
"null",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"self",
"::",
"$",
"render_actions",
"[",
"]",
"=",
"array",
"(",
"\"type\"",
"=>",
"\"display_tpl\"",
",",
"\"template\"",
"=>",
"$",
"template",
",",
"\"target_id\"",
"=>",
"$",
"target_id",
")",
";",
"}"
] |
Append a template render action to the render queue
@param string $template The template file
@param string $target_id The dachi-ui-block to load into
@return null
|
[
"Append",
"a",
"template",
"render",
"action",
"to",
"the",
"render",
"queue"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L179-L188
|
20,902 |
ouropencode/dachi
|
src/Template.php
|
Template.render
|
public static function render() {
$apiMode = Request::isAPI();
if(self::$twig === null)
self::initialize();
$data = Request::getAllData();
if(!$apiMode) {
$data["siteName"] = Configuration::get("dachi.siteName", "Unnamed Dachi Installation");
$data["timezone"] = Configuration::get("dachi.timezone", "Europe/London");
$data["domain"] = Configuration::get("dachi.domain", "localhost");
$data["baseURL"] = Configuration::get("dachi.baseURL", "/");
$data["assetsURL"] = str_replace("%v", Kernel::getGitHash(), Configuration::get("dachi.assetsURL", "/build/"));
$data["renderTPL"] = self::getRenderTemplate();
$data["URI"] = Request::getFullUri();
}
if($apiMode) {
$response = array(
"data" => $data,
"response" => Request::getResponseCode()
);
return json_echo($response);
} else if(Request::isAjax()) {
$response = array(
"render_tpl" => self::getRenderTemplate(),
"data" => $data,
"response" => Request::getResponseCode(),
"render_actions" => self::$render_actions
);
return json_echo($response);
} else {
$data["response"] = Request::getResponseCode();
$response = self::$twig->render(self::getRenderTemplate(true), $data);
foreach(array_reverse(self::$render_actions) as $action) {
switch($action["type"]) {
case "redirect":
if($action["soft"] !== true)
header("Location: " . $action["location"]);
break;
case "display_tpl":
$match = preg_match("/<dachi-ui-block id=[\"']" . preg_quote($action["target_id"]) . "[\"'][^>]*>([\s\S]*)<\/dachi-ui-block>/U", $response, $matches);
if($match) {
$replacement = "<dachi-ui-block id='" . $action["target_id"] . "'>" . self::$twig->render($action["template"] . '.twig', $data) . "</dachi-ui-block>";
$response = str_replace($matches[0], $replacement, $response);
}
break;
}
}
echo $response;
}
}
|
php
|
public static function render() {
$apiMode = Request::isAPI();
if(self::$twig === null)
self::initialize();
$data = Request::getAllData();
if(!$apiMode) {
$data["siteName"] = Configuration::get("dachi.siteName", "Unnamed Dachi Installation");
$data["timezone"] = Configuration::get("dachi.timezone", "Europe/London");
$data["domain"] = Configuration::get("dachi.domain", "localhost");
$data["baseURL"] = Configuration::get("dachi.baseURL", "/");
$data["assetsURL"] = str_replace("%v", Kernel::getGitHash(), Configuration::get("dachi.assetsURL", "/build/"));
$data["renderTPL"] = self::getRenderTemplate();
$data["URI"] = Request::getFullUri();
}
if($apiMode) {
$response = array(
"data" => $data,
"response" => Request::getResponseCode()
);
return json_echo($response);
} else if(Request::isAjax()) {
$response = array(
"render_tpl" => self::getRenderTemplate(),
"data" => $data,
"response" => Request::getResponseCode(),
"render_actions" => self::$render_actions
);
return json_echo($response);
} else {
$data["response"] = Request::getResponseCode();
$response = self::$twig->render(self::getRenderTemplate(true), $data);
foreach(array_reverse(self::$render_actions) as $action) {
switch($action["type"]) {
case "redirect":
if($action["soft"] !== true)
header("Location: " . $action["location"]);
break;
case "display_tpl":
$match = preg_match("/<dachi-ui-block id=[\"']" . preg_quote($action["target_id"]) . "[\"'][^>]*>([\s\S]*)<\/dachi-ui-block>/U", $response, $matches);
if($match) {
$replacement = "<dachi-ui-block id='" . $action["target_id"] . "'>" . self::$twig->render($action["template"] . '.twig', $data) . "</dachi-ui-block>";
$response = str_replace($matches[0], $replacement, $response);
}
break;
}
}
echo $response;
}
}
|
[
"public",
"static",
"function",
"render",
"(",
")",
"{",
"$",
"apiMode",
"=",
"Request",
"::",
"isAPI",
"(",
")",
";",
"if",
"(",
"self",
"::",
"$",
"twig",
"===",
"null",
")",
"self",
"::",
"initialize",
"(",
")",
";",
"$",
"data",
"=",
"Request",
"::",
"getAllData",
"(",
")",
";",
"if",
"(",
"!",
"$",
"apiMode",
")",
"{",
"$",
"data",
"[",
"\"siteName\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.siteName\"",
",",
"\"Unnamed Dachi Installation\"",
")",
";",
"$",
"data",
"[",
"\"timezone\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.timezone\"",
",",
"\"Europe/London\"",
")",
";",
"$",
"data",
"[",
"\"domain\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.domain\"",
",",
"\"localhost\"",
")",
";",
"$",
"data",
"[",
"\"baseURL\"",
"]",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.baseURL\"",
",",
"\"/\"",
")",
";",
"$",
"data",
"[",
"\"assetsURL\"",
"]",
"=",
"str_replace",
"(",
"\"%v\"",
",",
"Kernel",
"::",
"getGitHash",
"(",
")",
",",
"Configuration",
"::",
"get",
"(",
"\"dachi.assetsURL\"",
",",
"\"/build/\"",
")",
")",
";",
"$",
"data",
"[",
"\"renderTPL\"",
"]",
"=",
"self",
"::",
"getRenderTemplate",
"(",
")",
";",
"$",
"data",
"[",
"\"URI\"",
"]",
"=",
"Request",
"::",
"getFullUri",
"(",
")",
";",
"}",
"if",
"(",
"$",
"apiMode",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"\"data\"",
"=>",
"$",
"data",
",",
"\"response\"",
"=>",
"Request",
"::",
"getResponseCode",
"(",
")",
")",
";",
"return",
"json_echo",
"(",
"$",
"response",
")",
";",
"}",
"else",
"if",
"(",
"Request",
"::",
"isAjax",
"(",
")",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"\"render_tpl\"",
"=>",
"self",
"::",
"getRenderTemplate",
"(",
")",
",",
"\"data\"",
"=>",
"$",
"data",
",",
"\"response\"",
"=>",
"Request",
"::",
"getResponseCode",
"(",
")",
",",
"\"render_actions\"",
"=>",
"self",
"::",
"$",
"render_actions",
")",
";",
"return",
"json_echo",
"(",
"$",
"response",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"\"response\"",
"]",
"=",
"Request",
"::",
"getResponseCode",
"(",
")",
";",
"$",
"response",
"=",
"self",
"::",
"$",
"twig",
"->",
"render",
"(",
"self",
"::",
"getRenderTemplate",
"(",
"true",
")",
",",
"$",
"data",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"self",
"::",
"$",
"render_actions",
")",
"as",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
"[",
"\"type\"",
"]",
")",
"{",
"case",
"\"redirect\"",
":",
"if",
"(",
"$",
"action",
"[",
"\"soft\"",
"]",
"!==",
"true",
")",
"header",
"(",
"\"Location: \"",
".",
"$",
"action",
"[",
"\"location\"",
"]",
")",
";",
"break",
";",
"case",
"\"display_tpl\"",
":",
"$",
"match",
"=",
"preg_match",
"(",
"\"/<dachi-ui-block id=[\\\"']\"",
".",
"preg_quote",
"(",
"$",
"action",
"[",
"\"target_id\"",
"]",
")",
".",
"\"[\\\"'][^>]*>([\\s\\S]*)<\\/dachi-ui-block>/U\"",
",",
"$",
"response",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"replacement",
"=",
"\"<dachi-ui-block id='\"",
".",
"$",
"action",
"[",
"\"target_id\"",
"]",
".",
"\"'>\"",
".",
"self",
"::",
"$",
"twig",
"->",
"render",
"(",
"$",
"action",
"[",
"\"template\"",
"]",
".",
"'.twig'",
",",
"$",
"data",
")",
".",
"\"</dachi-ui-block>\"",
";",
"$",
"response",
"=",
"str_replace",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"$",
"replacement",
",",
"$",
"response",
")",
";",
"}",
"break",
";",
"}",
"}",
"echo",
"$",
"response",
";",
"}",
"}"
] |
Render the render queue to the browser
If the request is an ajax request, the render queue and data will be sent to the browser via JSON.
If the request is a standard request, the render queue will be rendered server-side and will be sent to the browser via HTML.
@internal
@see Router
@return null
|
[
"Render",
"the",
"render",
"queue",
"to",
"the",
"browser"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L200-L255
|
20,903 |
ouropencode/dachi
|
src/Template.php
|
Template.redirect
|
public static function redirect($location, $soft = false) {
if(substr($location, 0, 4) !== "http")
$location = Configuration::get("dachi.baseURL") . $location;
self::$render_actions[] = array(
"type" => "redirect",
"location" => $location,
"soft" => $soft
);
}
|
php
|
public static function redirect($location, $soft = false) {
if(substr($location, 0, 4) !== "http")
$location = Configuration::get("dachi.baseURL") . $location;
self::$render_actions[] = array(
"type" => "redirect",
"location" => $location,
"soft" => $soft
);
}
|
[
"public",
"static",
"function",
"redirect",
"(",
"$",
"location",
",",
"$",
"soft",
"=",
"false",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"location",
",",
"0",
",",
"4",
")",
"!==",
"\"http\"",
")",
"$",
"location",
"=",
"Configuration",
"::",
"get",
"(",
"\"dachi.baseURL\"",
")",
".",
"$",
"location",
";",
"self",
"::",
"$",
"render_actions",
"[",
"]",
"=",
"array",
"(",
"\"type\"",
"=>",
"\"redirect\"",
",",
"\"location\"",
"=>",
"$",
"location",
",",
"\"soft\"",
"=>",
"$",
"soft",
")",
";",
"}"
] |
Append a redirect action to the render queue.
If $location does not start with "http", the dachi.baseURL configuration value will be prepended
@param string $location The location to redirect to
@return null
|
[
"Append",
"a",
"redirect",
"action",
"to",
"the",
"render",
"queue",
"."
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Template.php#L265-L274
|
20,904 |
Laralum/Users
|
src/Policies/UserPolicy.php
|
UserPolicy.access
|
public function access($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.access') || $user->superAdmin();
}
|
php
|
public function access($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.access') || $user->superAdmin();
}
|
[
"public",
"function",
"access",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.access'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] |
Determine if the current user can view users module.
@param mixed $user
@return bool
|
[
"Determine",
"if",
"the",
"current",
"user",
"can",
"view",
"users",
"module",
"."
] |
788851d4cdf4bff548936faf1b12cf4697d13428
|
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L19-L24
|
20,905 |
Laralum/Users
|
src/Policies/UserPolicy.php
|
UserPolicy.view
|
public function view($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.view') || $user->superAdmin();
}
|
php
|
public function view($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.view') || $user->superAdmin();
}
|
[
"public",
"function",
"view",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.view'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] |
Determine if the current user can view users.
@param mixed $user
@return bool
|
[
"Determine",
"if",
"the",
"current",
"user",
"can",
"view",
"users",
"."
] |
788851d4cdf4bff548936faf1b12cf4697d13428
|
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L33-L38
|
20,906 |
Laralum/Users
|
src/Policies/UserPolicy.php
|
UserPolicy.create
|
public function create($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.create') || $user->superAdmin();
}
|
php
|
public function create($user)
{
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.create') || $user->superAdmin();
}
|
[
"public",
"function",
"create",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.create'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] |
Determine if the current user can create users.
@param mixed $user
@return bool
|
[
"Determine",
"if",
"the",
"current",
"user",
"can",
"create",
"users",
"."
] |
788851d4cdf4bff548936faf1b12cf4697d13428
|
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L47-L52
|
20,907 |
Laralum/Users
|
src/Policies/UserPolicy.php
|
UserPolicy.update
|
public function update($user, User $userToManage)
{
if ($userToManage->id == $user->id || $userToManage->superAdmin()) {
return false;
}
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.update') || $user->superAdmin();
}
|
php
|
public function update($user, User $userToManage)
{
if ($userToManage->id == $user->id || $userToManage->superAdmin()) {
return false;
}
$user = User::findOrFail($user->id);
return $user->hasPermission('laralum::users.update') || $user->superAdmin();
}
|
[
"public",
"function",
"update",
"(",
"$",
"user",
",",
"User",
"$",
"userToManage",
")",
"{",
"if",
"(",
"$",
"userToManage",
"->",
"id",
"==",
"$",
"user",
"->",
"id",
"||",
"$",
"userToManage",
"->",
"superAdmin",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"user",
"=",
"User",
"::",
"findOrFail",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"'laralum::users.update'",
")",
"||",
"$",
"user",
"->",
"superAdmin",
"(",
")",
";",
"}"
] |
Determine if the current user can update users.
@param mixed $user
@return bool
|
[
"Determine",
"if",
"the",
"current",
"user",
"can",
"update",
"users",
"."
] |
788851d4cdf4bff548936faf1b12cf4697d13428
|
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Policies/UserPolicy.php#L61-L70
|
20,908 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php
|
ezcDbSchemaOracleWriter.isQueryAllowed
|
public function isQueryAllowed( ezcDbHandler $db, $query )
{
if ( strstr( $query, 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later.
{
return false;
}
if ( substr( $query, 0, 10 ) == 'DROP TABLE' )
{
$tableName = substr($query, strlen( 'DROP TABLE "' ), -1 ); // get table name without quotes
$result = $db->query( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" )->fetchAll();
if ( $result[0]['count'] == 1 )
{
$sequences = $db->query( "SELECT sequence_name FROM user_sequences" )->fetchAll();
array_walk( $sequences, create_function( '&$item,$key', '$item = $item[0];' ) );
foreach ( $sequences as $sequenceName )
{
// try to drop sequences related to dropped table.
if ( substr( $sequenceName, 0, strlen($tableName) ) == $tableName )
{
$db->query( "DROP SEQUENCE \"{$sequenceName}\"" );
}
}
return true;
}
else
{
return false;
}
}
return true;
}
|
php
|
public function isQueryAllowed( ezcDbHandler $db, $query )
{
if ( strstr( $query, 'AUTO_INCREMENT' ) ) // detect AUTO_INCREMENT and return imediately. Will process later.
{
return false;
}
if ( substr( $query, 0, 10 ) == 'DROP TABLE' )
{
$tableName = substr($query, strlen( 'DROP TABLE "' ), -1 ); // get table name without quotes
$result = $db->query( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" )->fetchAll();
if ( $result[0]['count'] == 1 )
{
$sequences = $db->query( "SELECT sequence_name FROM user_sequences" )->fetchAll();
array_walk( $sequences, create_function( '&$item,$key', '$item = $item[0];' ) );
foreach ( $sequences as $sequenceName )
{
// try to drop sequences related to dropped table.
if ( substr( $sequenceName, 0, strlen($tableName) ) == $tableName )
{
$db->query( "DROP SEQUENCE \"{$sequenceName}\"" );
}
}
return true;
}
else
{
return false;
}
}
return true;
}
|
[
"public",
"function",
"isQueryAllowed",
"(",
"ezcDbHandler",
"$",
"db",
",",
"$",
"query",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"query",
",",
"'AUTO_INCREMENT'",
")",
")",
"// detect AUTO_INCREMENT and return imediately. Will process later.",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"query",
",",
"0",
",",
"10",
")",
"==",
"'DROP TABLE'",
")",
"{",
"$",
"tableName",
"=",
"substr",
"(",
"$",
"query",
",",
"strlen",
"(",
"'DROP TABLE \"'",
")",
",",
"-",
"1",
")",
";",
"// get table name without quotes",
"$",
"result",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"$",
"result",
"[",
"0",
"]",
"[",
"'count'",
"]",
"==",
"1",
")",
"{",
"$",
"sequences",
"=",
"$",
"db",
"->",
"query",
"(",
"\"SELECT sequence_name FROM user_sequences\"",
")",
"->",
"fetchAll",
"(",
")",
";",
"array_walk",
"(",
"$",
"sequences",
",",
"create_function",
"(",
"'&$item,$key'",
",",
"'$item = $item[0];'",
")",
")",
";",
"foreach",
"(",
"$",
"sequences",
"as",
"$",
"sequenceName",
")",
"{",
"// try to drop sequences related to dropped table.",
"if",
"(",
"substr",
"(",
"$",
"sequenceName",
",",
"0",
",",
"strlen",
"(",
"$",
"tableName",
")",
")",
"==",
"$",
"tableName",
")",
"{",
"$",
"db",
"->",
"query",
"(",
"\"DROP SEQUENCE \\\"{$sequenceName}\\\"\"",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if query allowed.
Perform testing if table exist for DROP TABLE query
to avoid stoping execution while try to drop not existent table.
@param ezcDbHandler $db
@param string $query
@return boolean false if query should not be executed.
|
[
"Checks",
"if",
"query",
"allowed",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L47-L80
|
20,909 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php
|
ezcDbSchemaOracleWriter.generateAdditionalDropSequenceStatements
|
protected function generateAdditionalDropSequenceStatements( ezcDbSchemaDiff $dbSchemaDiff, ezcDbHandler $db )
{
$reader = new ezcDbSchemaOracleReader();
$schema = $reader->loadFromDb( $db )->getSchema();
foreach ( $dbSchemaDiff->removedTables as $table => $true )
{
foreach ( $schema[$table]->fields as $name => $field )
{
if ( $field->autoIncrement !== true )
{
continue;
}
$seqName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $table, $name, "seq" );
if ( strpos( $seqName, $table ) !== 0 )
{
$this->queries[] = "DROP SEQUENCE \"$seqName\"";
}
}
}
}
|
php
|
protected function generateAdditionalDropSequenceStatements( ezcDbSchemaDiff $dbSchemaDiff, ezcDbHandler $db )
{
$reader = new ezcDbSchemaOracleReader();
$schema = $reader->loadFromDb( $db )->getSchema();
foreach ( $dbSchemaDiff->removedTables as $table => $true )
{
foreach ( $schema[$table]->fields as $name => $field )
{
if ( $field->autoIncrement !== true )
{
continue;
}
$seqName = ezcDbSchemaOracleHelper::generateSuffixCompositeIdentName( $table, $name, "seq" );
if ( strpos( $seqName, $table ) !== 0 )
{
$this->queries[] = "DROP SEQUENCE \"$seqName\"";
}
}
}
}
|
[
"protected",
"function",
"generateAdditionalDropSequenceStatements",
"(",
"ezcDbSchemaDiff",
"$",
"dbSchemaDiff",
",",
"ezcDbHandler",
"$",
"db",
")",
"{",
"$",
"reader",
"=",
"new",
"ezcDbSchemaOracleReader",
"(",
")",
";",
"$",
"schema",
"=",
"$",
"reader",
"->",
"loadFromDb",
"(",
"$",
"db",
")",
"->",
"getSchema",
"(",
")",
";",
"foreach",
"(",
"$",
"dbSchemaDiff",
"->",
"removedTables",
"as",
"$",
"table",
"=>",
"$",
"true",
")",
"{",
"foreach",
"(",
"$",
"schema",
"[",
"$",
"table",
"]",
"->",
"fields",
"as",
"$",
"name",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"autoIncrement",
"!==",
"true",
")",
"{",
"continue",
";",
"}",
"$",
"seqName",
"=",
"ezcDbSchemaOracleHelper",
"::",
"generateSuffixCompositeIdentName",
"(",
"$",
"table",
",",
"$",
"name",
",",
"\"seq\"",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"seqName",
",",
"$",
"table",
")",
"!==",
"0",
")",
"{",
"$",
"this",
"->",
"queries",
"[",
"]",
"=",
"\"DROP SEQUENCE \\\"$seqName\\\"\"",
";",
"}",
"}",
"}",
"}"
] |
Generate additional drop sequence statements
Some sequences might not be dropped automatically, this method generates
additional DROP SEQUENCE queries for those.
Since Oracle only allows sequence identifiers up to 30 characters
sequences for long table / column names may be shortened. In this case
the sequence name does not started with the table name any more, thus
does not get dropped together with the table automatically.
This method requires a DB connection to check which sequences have been
defined in the database, because the information about fields is not
available otherwise.
@param ezcDbSchemaDiff $dbSchemaDiff
@param ezcDbHandler $db
@return void
|
[
"Generate",
"additional",
"drop",
"sequence",
"statements"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/oracle/writer.php#L252-L272
|
20,910 |
novaway/open-graph
|
src/OpenGraphGeneratorBuilder.php
|
OpenGraphGeneratorBuilder.build
|
public function build()
{
$annotationReader = $this->annotationReader;
if (null === $annotationReader) {
$annotationReader = new AnnotationReader();
if (null !== $this->cacheDirectory) {
$cacheDirectory = sprintf('%s/annotations', $this->cacheDirectory);
$this->createDirectory($cacheDirectory);
$annotationReader = new CachedReader($annotationReader, new FilesystemCache($cacheDirectory));
}
}
$metadataDriver = $this->driverFactory->createDriver($this->metadataDirectories, $annotationReader);
$metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
$metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
if (null !== $this->cacheDirectory) {
$directory = sprintf('%s/metadata', $this->cacheDirectory);
$this->createDirectory($directory);
$metadataFactory->setCache(new FileCache($directory));
}
return new OpenGraphGenerator($metadataFactory);
}
|
php
|
public function build()
{
$annotationReader = $this->annotationReader;
if (null === $annotationReader) {
$annotationReader = new AnnotationReader();
if (null !== $this->cacheDirectory) {
$cacheDirectory = sprintf('%s/annotations', $this->cacheDirectory);
$this->createDirectory($cacheDirectory);
$annotationReader = new CachedReader($annotationReader, new FilesystemCache($cacheDirectory));
}
}
$metadataDriver = $this->driverFactory->createDriver($this->metadataDirectories, $annotationReader);
$metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
$metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
if (null !== $this->cacheDirectory) {
$directory = sprintf('%s/metadata', $this->cacheDirectory);
$this->createDirectory($directory);
$metadataFactory->setCache(new FileCache($directory));
}
return new OpenGraphGenerator($metadataFactory);
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"annotationReader",
"=",
"$",
"this",
"->",
"annotationReader",
";",
"if",
"(",
"null",
"===",
"$",
"annotationReader",
")",
"{",
"$",
"annotationReader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"cacheDirectory",
")",
"{",
"$",
"cacheDirectory",
"=",
"sprintf",
"(",
"'%s/annotations'",
",",
"$",
"this",
"->",
"cacheDirectory",
")",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"cacheDirectory",
")",
";",
"$",
"annotationReader",
"=",
"new",
"CachedReader",
"(",
"$",
"annotationReader",
",",
"new",
"FilesystemCache",
"(",
"$",
"cacheDirectory",
")",
")",
";",
"}",
"}",
"$",
"metadataDriver",
"=",
"$",
"this",
"->",
"driverFactory",
"->",
"createDriver",
"(",
"$",
"this",
"->",
"metadataDirectories",
",",
"$",
"annotationReader",
")",
";",
"$",
"metadataFactory",
"=",
"new",
"MetadataFactory",
"(",
"$",
"metadataDriver",
",",
"null",
",",
"$",
"this",
"->",
"debug",
")",
";",
"$",
"metadataFactory",
"->",
"setIncludeInterfaces",
"(",
"$",
"this",
"->",
"includeInterfaceMetadata",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"cacheDirectory",
")",
"{",
"$",
"directory",
"=",
"sprintf",
"(",
"'%s/metadata'",
",",
"$",
"this",
"->",
"cacheDirectory",
")",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"directory",
")",
";",
"$",
"metadataFactory",
"->",
"setCache",
"(",
"new",
"FileCache",
"(",
"$",
"directory",
")",
")",
";",
"}",
"return",
"new",
"OpenGraphGenerator",
"(",
"$",
"metadataFactory",
")",
";",
"}"
] |
Create open graph object
|
[
"Create",
"open",
"graph",
"object"
] |
19817bee4b91cf26ca3fe44883ad58b32328e464
|
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGeneratorBuilder.php#L59-L85
|
20,911 |
novaway/open-graph
|
src/OpenGraphGeneratorBuilder.php
|
OpenGraphGeneratorBuilder.setCacheDirectory
|
public function setCacheDirectory($directory)
{
if (!is_dir($directory)) {
$this->createDirectory($directory);
}
if (!is_writable($directory)) {
throw new \InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir));
}
$this->cacheDirectory = $directory;
return $this;
}
|
php
|
public function setCacheDirectory($directory)
{
if (!is_dir($directory)) {
$this->createDirectory($directory);
}
if (!is_writable($directory)) {
throw new \InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir));
}
$this->cacheDirectory = $directory;
return $this;
}
|
[
"public",
"function",
"setCacheDirectory",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"directory",
")",
";",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The cache directory \"%s\" is not writable.'",
",",
"$",
"dir",
")",
")",
";",
"}",
"$",
"this",
"->",
"cacheDirectory",
"=",
"$",
"directory",
";",
"return",
"$",
"this",
";",
"}"
] |
Set cache directory
@param string $directory
@return OpenGraphGeneratorBuilder
|
[
"Set",
"cache",
"directory"
] |
19817bee4b91cf26ca3fe44883ad58b32328e464
|
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGeneratorBuilder.php#L132-L145
|
20,912 |
jasny/controller
|
src/Controller/Session.php
|
Session.useSession
|
public function useSession()
{
$this->session = $this->getRequest()->getAttribute('session');
if (!isset($this->session)) {
$this->session =& $_SESSION;
}
}
|
php
|
public function useSession()
{
$this->session = $this->getRequest()->getAttribute('session');
if (!isset($this->session)) {
$this->session =& $_SESSION;
}
}
|
[
"public",
"function",
"useSession",
"(",
")",
"{",
"$",
"this",
"->",
"session",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getAttribute",
"(",
"'session'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"session",
")",
")",
"{",
"$",
"this",
"->",
"session",
"=",
"&",
"$",
"_SESSION",
";",
"}",
"}"
] |
Link the session to the session property in the controller
|
[
"Link",
"the",
"session",
"to",
"the",
"session",
"property",
"in",
"the",
"controller"
] |
28edf64343f1d8218c166c0c570128e1ee6153d8
|
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session.php#L36-L43
|
20,913 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.factoryReference
|
public static function factoryReference($reference) {
$className = $reference[2];
if (!class_exists($className)) {
throw new Exceptions\EntityClassNotFoundException(
"factoryReference called for a class that can't be found, $className."
);
}
$entity = call_user_func([$className, 'factory']);
$entity->referenceSleep($reference);
return $entity;
}
|
php
|
public static function factoryReference($reference) {
$className = $reference[2];
if (!class_exists($className)) {
throw new Exceptions\EntityClassNotFoundException(
"factoryReference called for a class that can't be found, $className."
);
}
$entity = call_user_func([$className, 'factory']);
$entity->referenceSleep($reference);
return $entity;
}
|
[
"public",
"static",
"function",
"factoryReference",
"(",
"$",
"reference",
")",
"{",
"$",
"className",
"=",
"$",
"reference",
"[",
"2",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"(",
"\"factoryReference called for a class that can't be found, $className.\"",
")",
";",
"}",
"$",
"entity",
"=",
"call_user_func",
"(",
"[",
"$",
"className",
",",
"'factory'",
"]",
")",
";",
"$",
"entity",
"->",
"referenceSleep",
"(",
"$",
"reference",
")",
";",
"return",
"$",
"entity",
";",
"}"
] |
Create a new sleeping reference instance.
Sleeping references won't retrieve their data from the database until it
is actually used.
@param array $reference The Nymph Entity Reference to use to wake.
@return \Nymph\Entity The new instance.
|
[
"Create",
"a",
"new",
"sleeping",
"reference",
"instance",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L309-L319
|
20,914 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.&
|
public function &__get($name) {
if ($name === 'guid') {
return $this->$name;
}
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return $this->$name;
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
// Check for an entity first.
if (isset($this->entityCache[$name])) {
if ($this->data[$name][0] === 'nymph_entity_reference') {
if ($this->entityCache[$name] === 0) {
// The entity hasn't been loaded yet, so load it now.
$className = $this->data[$name][2];
if (!class_exists($className)) {
throw new Exceptions\EntityCorruptedException(
"Entity reference refers to a class that can't be found, ".
"$className."
);
}
$this->entityCache[$name] =
$className::factoryReference($this->data[$name]);
$this->entityCache[$name]->useSkipAc($this->useSkipAc);
}
return $this->entityCache[$name];
} else {
throw new Exceptions\EntityCorruptedException(
"Entity data has become corrupt and cannot be determined."
);
}
}
// Check if it's set.
if (!isset($this->data[$name])) {
// Since we must return by reference, we have to use a constant here. If
// we return $this->data[$name], an entry will be created in data.
return $this->NULL_CONST;
}
// If it's not an entity, return the regular value.
try {
if (is_array($this->data[$name])) {
// But, if it's an array, check all the values for entity references,
// and change them.
array_walk($this->data[$name], [$this, 'referenceToEntity']);
} elseif (is_object($this->data[$name])
&& !(
(
is_a($this->data[$name], '\Nymph\Entity')
|| is_a($this->data[$name], '\SciActive\HookOverride')
)
&& is_callable([$this->data[$name], 'toReference'])
)) {
// Only do this for non-entity objects.
foreach ($this->data[$name] as &$curProperty) {
$this->referenceToEntity($curProperty, null);
}
unset($curProperty);
}
} catch (Exceptions\EntityClassNotFoundException $e) {
throw new Exceptions\EntityCorruptedException($e->getMessage());
}
return $this->data[$name];
}
|
php
|
public function &__get($name) {
if ($name === 'guid') {
return $this->$name;
}
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return $this->$name;
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
// Check for an entity first.
if (isset($this->entityCache[$name])) {
if ($this->data[$name][0] === 'nymph_entity_reference') {
if ($this->entityCache[$name] === 0) {
// The entity hasn't been loaded yet, so load it now.
$className = $this->data[$name][2];
if (!class_exists($className)) {
throw new Exceptions\EntityCorruptedException(
"Entity reference refers to a class that can't be found, ".
"$className."
);
}
$this->entityCache[$name] =
$className::factoryReference($this->data[$name]);
$this->entityCache[$name]->useSkipAc($this->useSkipAc);
}
return $this->entityCache[$name];
} else {
throw new Exceptions\EntityCorruptedException(
"Entity data has become corrupt and cannot be determined."
);
}
}
// Check if it's set.
if (!isset($this->data[$name])) {
// Since we must return by reference, we have to use a constant here. If
// we return $this->data[$name], an entry will be created in data.
return $this->NULL_CONST;
}
// If it's not an entity, return the regular value.
try {
if (is_array($this->data[$name])) {
// But, if it's an array, check all the values for entity references,
// and change them.
array_walk($this->data[$name], [$this, 'referenceToEntity']);
} elseif (is_object($this->data[$name])
&& !(
(
is_a($this->data[$name], '\Nymph\Entity')
|| is_a($this->data[$name], '\SciActive\HookOverride')
)
&& is_callable([$this->data[$name], 'toReference'])
)) {
// Only do this for non-entity objects.
foreach ($this->data[$name] as &$curProperty) {
$this->referenceToEntity($curProperty, null);
}
unset($curProperty);
}
} catch (Exceptions\EntityClassNotFoundException $e) {
throw new Exceptions\EntityCorruptedException($e->getMessage());
}
return $this->data[$name];
}
|
[
"public",
"function",
"&",
"__get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'guid'",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"name",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"'cdate'",
"||",
"$",
"name",
"===",
"'mdate'",
"||",
"$",
"name",
"===",
"'tags'",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"name",
";",
"}",
"// Unserialize.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"unserialize",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"}",
"// Check for an entity first.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"[",
"0",
"]",
"===",
"'nymph_entity_reference'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
"===",
"0",
")",
"{",
"// The entity hasn't been loaded yet, so load it now.",
"$",
"className",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"[",
"2",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityCorruptedException",
"(",
"\"Entity reference refers to a class that can't be found, \"",
".",
"\"$className.\"",
")",
";",
"}",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
"=",
"$",
"className",
"::",
"factoryReference",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
";",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
"->",
"useSkipAc",
"(",
"$",
"this",
"->",
"useSkipAc",
")",
";",
"}",
"return",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityCorruptedException",
"(",
"\"Entity data has become corrupt and cannot be determined.\"",
")",
";",
"}",
"}",
"// Check if it's set.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// Since we must return by reference, we have to use a constant here. If",
"// we return $this->data[$name], an entry will be created in data.",
"return",
"$",
"this",
"->",
"NULL_CONST",
";",
"}",
"// If it's not an entity, return the regular value.",
"try",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"// But, if it's an array, check all the values for entity references,",
"// and change them.",
"array_walk",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"[",
"$",
"this",
",",
"'referenceToEntity'",
"]",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"(",
"(",
"is_a",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
",",
"'toReference'",
"]",
")",
")",
")",
"{",
"// Only do this for non-entity objects.",
"foreach",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"as",
"&",
"$",
"curProperty",
")",
"{",
"$",
"this",
"->",
"referenceToEntity",
"(",
"$",
"curProperty",
",",
"null",
")",
";",
"}",
"unset",
"(",
"$",
"curProperty",
")",
";",
"}",
"}",
"catch",
"(",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityCorruptedException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
";",
"}"
] |
Retrieve a variable.
You do not need to explicitly call this method. It is called by PHP when
you access the variable normally.
@param string $name The name of the variable.
@return mixed The value of the variable or null if it doesn't exist.
|
[
"Retrieve",
"a",
"variable",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L330-L401
|
20,915 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.__isset
|
public function __isset($name) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'guid'
|| $name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return isset($this->$name);
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
return isset($this->data[$name]);
}
|
php
|
public function __isset($name) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ($name === 'guid'
|| $name === 'cdate'
|| $name === 'mdate'
|| $name === 'tags'
) {
return isset($this->$name);
}
// Unserialize.
if (isset($this->sdata[$name])) {
$this->data[$name] = unserialize($this->sdata[$name]);
unset($this->sdata[$name]);
}
return isset($this->data[$name]);
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"'guid'",
"||",
"$",
"name",
"===",
"'cdate'",
"||",
"$",
"name",
"===",
"'mdate'",
"||",
"$",
"name",
"===",
"'tags'",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"$",
"name",
")",
";",
"}",
"// Unserialize.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"unserialize",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"sdata",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
";",
"}"
] |
Checks whether a variable is set.
You do not need to explicitly call this method. It is called by PHP when
you access the variable normally.
@param string $name The name of the variable.
@return bool
@todo Check that a referenced entity has not been deleted.
|
[
"Checks",
"whether",
"a",
"variable",
"is",
"set",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L413-L430
|
20,916 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.entityToReference
|
private function entityToReference(&$item, $key) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& isset($item->guid) && is_callable([$item, 'toReference'])) {
// This is an entity, so we should put it in the entity cache.
if (!isset($this->entityCache["referenceGuid__{$item->guid}"])) {
$this->entityCache["referenceGuid__{$item->guid}"] = clone $item;
}
// Make a reference to the entity (its GUID and the class the entity was
// loaded as).
$item = $item->toReference();
}
}
|
php
|
private function entityToReference(&$item, $key) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& isset($item->guid) && is_callable([$item, 'toReference'])) {
// This is an entity, so we should put it in the entity cache.
if (!isset($this->entityCache["referenceGuid__{$item->guid}"])) {
$this->entityCache["referenceGuid__{$item->guid}"] = clone $item;
}
// Make a reference to the entity (its GUID and the class the entity was
// loaded as).
$item = $item->toReference();
}
}
|
[
"private",
"function",
"entityToReference",
"(",
"&",
"$",
"item",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"(",
"is_a",
"(",
"$",
"item",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"item",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"isset",
"(",
"$",
"item",
"->",
"guid",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"item",
",",
"'toReference'",
"]",
")",
")",
"{",
"// This is an entity, so we should put it in the entity cache.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item->guid}\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entityCache",
"[",
"\"referenceGuid__{$item->guid}\"",
"]",
"=",
"clone",
"$",
"item",
";",
"}",
"// Make a reference to the entity (its GUID and the class the entity was",
"// loaded as).",
"$",
"item",
"=",
"$",
"item",
"->",
"toReference",
"(",
")",
";",
"}",
"}"
] |
Check if an item is an entity, and if it is, convert it to a reference.
@param mixed &$item The item to check.
@param mixed $key Unused, but can't be removed because array_walk_recursive
will fail.
@access private
|
[
"Check",
"if",
"an",
"item",
"is",
"an",
"entity",
"and",
"if",
"it",
"is",
"convert",
"it",
"to",
"a",
"reference",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L605-L619
|
20,917 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.getDataReference
|
private function getDataReference($item) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& is_callable([$item, 'toReference'])) {
// Convert entities to references.
return $item->toReference();
} elseif (is_array($item)) {
// Recurse into lower arrays.
return array_map([$this, 'getDataReference'], $item);
} elseif (is_object($item)) {
foreach ($item as &$curProperty) {
$curProperty = $this->getDataReference($curProperty);
}
unset($curProperty);
}
// Not an entity or array, just return it.
return $item;
}
|
php
|
private function getDataReference($item) {
if ($this->isASleepingReference) {
$this->referenceWake();
}
if ((is_a($item, '\Nymph\Entity') || is_a($item, '\SciActive\HookOverride'))
&& is_callable([$item, 'toReference'])) {
// Convert entities to references.
return $item->toReference();
} elseif (is_array($item)) {
// Recurse into lower arrays.
return array_map([$this, 'getDataReference'], $item);
} elseif (is_object($item)) {
foreach ($item as &$curProperty) {
$curProperty = $this->getDataReference($curProperty);
}
unset($curProperty);
}
// Not an entity or array, just return it.
return $item;
}
|
[
"private",
"function",
"getDataReference",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"$",
"this",
"->",
"referenceWake",
"(",
")",
";",
"}",
"if",
"(",
"(",
"is_a",
"(",
"$",
"item",
",",
"'\\Nymph\\Entity'",
")",
"||",
"is_a",
"(",
"$",
"item",
",",
"'\\SciActive\\HookOverride'",
")",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"item",
",",
"'toReference'",
"]",
")",
")",
"{",
"// Convert entities to references.",
"return",
"$",
"item",
"->",
"toReference",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"// Recurse into lower arrays.",
"return",
"array_map",
"(",
"[",
"$",
"this",
",",
"'getDataReference'",
"]",
",",
"$",
"item",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"&",
"$",
"curProperty",
")",
"{",
"$",
"curProperty",
"=",
"$",
"this",
"->",
"getDataReference",
"(",
"$",
"curProperty",
")",
";",
"}",
"unset",
"(",
"$",
"curProperty",
")",
";",
"}",
"// Not an entity or array, just return it.",
"return",
"$",
"item",
";",
"}"
] |
Convert entities to references and return the result.
@param mixed $item The item to convert.
@return mixed The resulting item.
|
[
"Convert",
"entities",
"to",
"references",
"and",
"return",
"the",
"result",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L673-L692
|
20,918 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.referenceSleep
|
public function referenceSleep($reference) {
if (count($reference) !== 3
|| $reference[0] !== 'nymph_entity_reference'
|| !is_int($reference[1])
|| !is_string($reference[2])) {
throw new Exceptions\InvalidParametersException(
'referenceSleep expects parameter 1 to be a valid Nymph entity '.
'reference.'
);
}
$thisClass = get_class($this);
if ($reference[2] !== $thisClass) {
throw new Exceptions\InvalidParametersException(
"referenceSleep can only be called with an entity reference of the ".
"same class. Given class: {$reference[2]}; this class: $thisClass."
);
}
$this->isASleepingReference = true;
$this->guid = $reference[1];
$this->sleepingReference = $reference;
}
|
php
|
public function referenceSleep($reference) {
if (count($reference) !== 3
|| $reference[0] !== 'nymph_entity_reference'
|| !is_int($reference[1])
|| !is_string($reference[2])) {
throw new Exceptions\InvalidParametersException(
'referenceSleep expects parameter 1 to be a valid Nymph entity '.
'reference.'
);
}
$thisClass = get_class($this);
if ($reference[2] !== $thisClass) {
throw new Exceptions\InvalidParametersException(
"referenceSleep can only be called with an entity reference of the ".
"same class. Given class: {$reference[2]}; this class: $thisClass."
);
}
$this->isASleepingReference = true;
$this->guid = $reference[1];
$this->sleepingReference = $reference;
}
|
[
"public",
"function",
"referenceSleep",
"(",
"$",
"reference",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"reference",
")",
"!==",
"3",
"||",
"$",
"reference",
"[",
"0",
"]",
"!==",
"'nymph_entity_reference'",
"||",
"!",
"is_int",
"(",
"$",
"reference",
"[",
"1",
"]",
")",
"||",
"!",
"is_string",
"(",
"$",
"reference",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidParametersException",
"(",
"'referenceSleep expects parameter 1 to be a valid Nymph entity '",
".",
"'reference.'",
")",
";",
"}",
"$",
"thisClass",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"reference",
"[",
"2",
"]",
"!==",
"$",
"thisClass",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidParametersException",
"(",
"\"referenceSleep can only be called with an entity reference of the \"",
".",
"\"same class. Given class: {$reference[2]}; this class: $thisClass.\"",
")",
";",
"}",
"$",
"this",
"->",
"isASleepingReference",
"=",
"true",
";",
"$",
"this",
"->",
"guid",
"=",
"$",
"reference",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"sleepingReference",
"=",
"$",
"reference",
";",
"}"
] |
Set up a sleeping reference.
@param array $reference The reference to use to wake.
|
[
"Set",
"up",
"a",
"sleeping",
"reference",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L927-L947
|
20,919 |
sciactive/nymph-server
|
src/Entity.php
|
Entity.referenceWake
|
private function referenceWake() {
if (!$this->isASleepingReference) {
return true;
}
if (!class_exists($this->sleepingReference[2])) {
throw new Exceptions\EntityClassNotFoundException(
"Tried to wake sleeping reference entity that refers to a class ".
"that can't be found, {$this->sleepingReference[2]}."
);
}
$entity = Nymph::getEntity(
['class' => $this->sleepingReference[2], 'skip_ac' => $this->useSkipAc],
['&', 'guid' => $this->sleepingReference[1]]
);
if (!isset($entity)) {
return false;
}
$this->isASleepingReference = false;
$this->sleepingReference = null;
$this->guid = $entity->guid;
$this->tags = $entity->tags;
$this->cdate = $entity->cdate;
$this->mdate = $entity->mdate;
$this->putData($entity->getData(), $entity->getSData());
return true;
}
|
php
|
private function referenceWake() {
if (!$this->isASleepingReference) {
return true;
}
if (!class_exists($this->sleepingReference[2])) {
throw new Exceptions\EntityClassNotFoundException(
"Tried to wake sleeping reference entity that refers to a class ".
"that can't be found, {$this->sleepingReference[2]}."
);
}
$entity = Nymph::getEntity(
['class' => $this->sleepingReference[2], 'skip_ac' => $this->useSkipAc],
['&', 'guid' => $this->sleepingReference[1]]
);
if (!isset($entity)) {
return false;
}
$this->isASleepingReference = false;
$this->sleepingReference = null;
$this->guid = $entity->guid;
$this->tags = $entity->tags;
$this->cdate = $entity->cdate;
$this->mdate = $entity->mdate;
$this->putData($entity->getData(), $entity->getSData());
return true;
}
|
[
"private",
"function",
"referenceWake",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isASleepingReference",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"sleepingReference",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EntityClassNotFoundException",
"(",
"\"Tried to wake sleeping reference entity that refers to a class \"",
".",
"\"that can't be found, {$this->sleepingReference[2]}.\"",
")",
";",
"}",
"$",
"entity",
"=",
"Nymph",
"::",
"getEntity",
"(",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"sleepingReference",
"[",
"2",
"]",
",",
"'skip_ac'",
"=>",
"$",
"this",
"->",
"useSkipAc",
"]",
",",
"[",
"'&'",
",",
"'guid'",
"=>",
"$",
"this",
"->",
"sleepingReference",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"isASleepingReference",
"=",
"false",
";",
"$",
"this",
"->",
"sleepingReference",
"=",
"null",
";",
"$",
"this",
"->",
"guid",
"=",
"$",
"entity",
"->",
"guid",
";",
"$",
"this",
"->",
"tags",
"=",
"$",
"entity",
"->",
"tags",
";",
"$",
"this",
"->",
"cdate",
"=",
"$",
"entity",
"->",
"cdate",
";",
"$",
"this",
"->",
"mdate",
"=",
"$",
"entity",
"->",
"mdate",
";",
"$",
"this",
"->",
"putData",
"(",
"$",
"entity",
"->",
"getData",
"(",
")",
",",
"$",
"entity",
"->",
"getSData",
"(",
")",
")",
";",
"return",
"true",
";",
"}"
] |
Wake from a sleeping reference.
@return bool True on success, false on failure.
|
[
"Wake",
"from",
"a",
"sleeping",
"reference",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Entity.php#L1000-L1025
|
20,920 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php
|
ezcMailFileParser.appendStreamFilters
|
private function appendStreamFilters( $line )
{
// append the correct decoding filter
switch ( strtolower( $this->headers['Content-Transfer-Encoding'] ) )
{
case 'base64':
stream_filter_append( $this->fp, 'convert.base64-decode' );
break;
case 'quoted-printable':
// fetch the type of linebreak
preg_match( "/(\r\n|\r|\n)$/", $line, $matches );
$lb = count( $matches ) > 0 ? $matches[0] : ezcMailTools::lineBreak();
$param = array( 'line-break-chars' => $lb );
stream_filter_append( $this->fp, 'convert.quoted-printable-decode',
STREAM_FILTER_WRITE, $param );
break;
case '7bit':
case '8bit':
// do nothing here, file is already just binary
break;
default:
// 7bit default
break;
}
}
|
php
|
private function appendStreamFilters( $line )
{
// append the correct decoding filter
switch ( strtolower( $this->headers['Content-Transfer-Encoding'] ) )
{
case 'base64':
stream_filter_append( $this->fp, 'convert.base64-decode' );
break;
case 'quoted-printable':
// fetch the type of linebreak
preg_match( "/(\r\n|\r|\n)$/", $line, $matches );
$lb = count( $matches ) > 0 ? $matches[0] : ezcMailTools::lineBreak();
$param = array( 'line-break-chars' => $lb );
stream_filter_append( $this->fp, 'convert.quoted-printable-decode',
STREAM_FILTER_WRITE, $param );
break;
case '7bit':
case '8bit':
// do nothing here, file is already just binary
break;
default:
// 7bit default
break;
}
}
|
[
"private",
"function",
"appendStreamFilters",
"(",
"$",
"line",
")",
"{",
"// append the correct decoding filter",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"headers",
"[",
"'Content-Transfer-Encoding'",
"]",
")",
")",
"{",
"case",
"'base64'",
":",
"stream_filter_append",
"(",
"$",
"this",
"->",
"fp",
",",
"'convert.base64-decode'",
")",
";",
"break",
";",
"case",
"'quoted-printable'",
":",
"// fetch the type of linebreak",
"preg_match",
"(",
"\"/(\\r\\n|\\r|\\n)$/\"",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"$",
"lb",
"=",
"count",
"(",
"$",
"matches",
")",
">",
"0",
"?",
"$",
"matches",
"[",
"0",
"]",
":",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
";",
"$",
"param",
"=",
"array",
"(",
"'line-break-chars'",
"=>",
"$",
"lb",
")",
";",
"stream_filter_append",
"(",
"$",
"this",
"->",
"fp",
",",
"'convert.quoted-printable-decode'",
",",
"STREAM_FILTER_WRITE",
",",
"$",
"param",
")",
";",
"break",
";",
"case",
"'7bit'",
":",
"case",
"'8bit'",
":",
"// do nothing here, file is already just binary",
"break",
";",
"default",
":",
"// 7bit default",
"break",
";",
"}",
"}"
] |
Sets the correct stream filters for the attachment.
$line should contain one line of data that should be written to file.
It is used to correctly determine the type of linebreak used in the mail.
@param string $line
|
[
"Sets",
"the",
"correct",
"stream",
"filters",
"for",
"the",
"attachment",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L190-L215
|
20,921 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php
|
ezcMailFileParser.parseBody
|
public function parseBody( $line )
{
if ( $line !== '' )
{
if ( $this->dataWritten === false )
{
$this->appendStreamFilters( $line );
$this->dataWritten = true;
}
fwrite( $this->fp, $line );
}
}
|
php
|
public function parseBody( $line )
{
if ( $line !== '' )
{
if ( $this->dataWritten === false )
{
$this->appendStreamFilters( $line );
$this->dataWritten = true;
}
fwrite( $this->fp, $line );
}
}
|
[
"public",
"function",
"parseBody",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
"!==",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dataWritten",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"appendStreamFilters",
"(",
"$",
"line",
")",
";",
"$",
"this",
"->",
"dataWritten",
"=",
"true",
";",
"}",
"fwrite",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"line",
")",
";",
"}",
"}"
] |
Parse the body of a message line by line.
This method is called by the parent part on a push basis. When there
are no more lines the parent part will call finish() to retrieve the
mailPart.
The file will be decoded and saved to the given temporary directory within
a directory based on the process ID and the time.
@param string $line
|
[
"Parse",
"the",
"body",
"of",
"a",
"message",
"line",
"by",
"line",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L230-L242
|
20,922 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php
|
ezcMailFileParser.finish
|
public function finish()
{
fclose( $this->fp );
$this->fp = null;
// FIXME: DIRTY PGP HACK
// When we have PGP support these lines should be removed. They are here now to hide
// PGP parts since they will show up as file attachments if not.
if ( $this->mainType == "application" &&
( $this->subType == 'pgp-signature'
|| $this->subType == 'pgp-keys'
|| $this->subType == 'pgp-encrypted' ) )
{
return null;
}
// END DIRTY PGP HACK
$filePart = new self::$fileClass( $this->fileName );
// set content type
$filePart->setHeaders( $this->headers->getCaseSensitiveArray() );
ezcMailPartParser::parsePartHeaders( $this->headers, $filePart );
switch ( strtolower( $this->mainType ) )
{
case 'image':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_IMAGE;
break;
case 'audio':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_AUDIO;
break;
case 'video':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_VIDEO;
break;
case 'application':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_APPLICATION;
break;
}
// set mime type
$filePart->mimeType = $this->subType;
// set inline disposition mode if set.
$matches = array();
if ( preg_match( '/^\s*inline;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_INLINE;
}
if ( preg_match( '/^\s*attachment;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_ATTACHMENT;
}
$filePart->size = filesize( $this->fileName );
return $filePart;
}
|
php
|
public function finish()
{
fclose( $this->fp );
$this->fp = null;
// FIXME: DIRTY PGP HACK
// When we have PGP support these lines should be removed. They are here now to hide
// PGP parts since they will show up as file attachments if not.
if ( $this->mainType == "application" &&
( $this->subType == 'pgp-signature'
|| $this->subType == 'pgp-keys'
|| $this->subType == 'pgp-encrypted' ) )
{
return null;
}
// END DIRTY PGP HACK
$filePart = new self::$fileClass( $this->fileName );
// set content type
$filePart->setHeaders( $this->headers->getCaseSensitiveArray() );
ezcMailPartParser::parsePartHeaders( $this->headers, $filePart );
switch ( strtolower( $this->mainType ) )
{
case 'image':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_IMAGE;
break;
case 'audio':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_AUDIO;
break;
case 'video':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_VIDEO;
break;
case 'application':
$filePart->contentType = ezcMailFile::CONTENT_TYPE_APPLICATION;
break;
}
// set mime type
$filePart->mimeType = $this->subType;
// set inline disposition mode if set.
$matches = array();
if ( preg_match( '/^\s*inline;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_INLINE;
}
if ( preg_match( '/^\s*attachment;?/i',
$this->headers['Content-Disposition'], $matches ) )
{
$filePart->dispositionType = ezcMailFile::DISPLAY_ATTACHMENT;
}
$filePart->size = filesize( $this->fileName );
return $filePart;
}
|
[
"public",
"function",
"finish",
"(",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"// FIXME: DIRTY PGP HACK",
"// When we have PGP support these lines should be removed. They are here now to hide",
"// PGP parts since they will show up as file attachments if not.",
"if",
"(",
"$",
"this",
"->",
"mainType",
"==",
"\"application\"",
"&&",
"(",
"$",
"this",
"->",
"subType",
"==",
"'pgp-signature'",
"||",
"$",
"this",
"->",
"subType",
"==",
"'pgp-keys'",
"||",
"$",
"this",
"->",
"subType",
"==",
"'pgp-encrypted'",
")",
")",
"{",
"return",
"null",
";",
"}",
"// END DIRTY PGP HACK",
"$",
"filePart",
"=",
"new",
"self",
"::",
"$",
"fileClass",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"// set content type",
"$",
"filePart",
"->",
"setHeaders",
"(",
"$",
"this",
"->",
"headers",
"->",
"getCaseSensitiveArray",
"(",
")",
")",
";",
"ezcMailPartParser",
"::",
"parsePartHeaders",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"filePart",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"mainType",
")",
")",
"{",
"case",
"'image'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_IMAGE",
";",
"break",
";",
"case",
"'audio'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_AUDIO",
";",
"break",
";",
"case",
"'video'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_VIDEO",
";",
"break",
";",
"case",
"'application'",
":",
"$",
"filePart",
"->",
"contentType",
"=",
"ezcMailFile",
"::",
"CONTENT_TYPE_APPLICATION",
";",
"break",
";",
"}",
"// set mime type",
"$",
"filePart",
"->",
"mimeType",
"=",
"$",
"this",
"->",
"subType",
";",
"// set inline disposition mode if set.",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^\\s*inline;?/i'",
",",
"$",
"this",
"->",
"headers",
"[",
"'Content-Disposition'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"filePart",
"->",
"dispositionType",
"=",
"ezcMailFile",
"::",
"DISPLAY_INLINE",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^\\s*attachment;?/i'",
",",
"$",
"this",
"->",
"headers",
"[",
"'Content-Disposition'",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"filePart",
"->",
"dispositionType",
"=",
"ezcMailFile",
"::",
"DISPLAY_ATTACHMENT",
";",
"}",
"$",
"filePart",
"->",
"size",
"=",
"filesize",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"filePart",
";",
"}"
] |
Return the result of the parsed file part.
This method is called automatically by the parent part.
@return ezcMailFile
|
[
"Return",
"the",
"result",
"of",
"the",
"parsed",
"file",
"part",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/file_parser.php#L251-L307
|
20,923 |
infusephp/infuse
|
src/Application.php
|
Application.map
|
public function map($method, $route, $handler)
{
$this['router']->map($method, $route, $handler);
return $this;
}
|
php
|
public function map($method, $route, $handler)
{
$this['router']->map($method, $route, $handler);
return $this;
}
|
[
"public",
"function",
"map",
"(",
"$",
"method",
",",
"$",
"route",
",",
"$",
"handler",
")",
"{",
"$",
"this",
"[",
"'router'",
"]",
"->",
"map",
"(",
"$",
"method",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a handler to the routing table for a given route.
@param string $method HTTP method
@param string $route path pattern
@param mixed $handler route handler
@return self
|
[
"Adds",
"a",
"handler",
"to",
"the",
"routing",
"table",
"for",
"a",
"given",
"route",
"."
] |
7520b237c69f3d8a07d95d7481b26027ced2ed83
|
https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L232-L237
|
20,924 |
infusephp/infuse
|
src/Application.php
|
Application.handleRequest
|
public function handleRequest(Request $req)
{
// set host name from request if not already set
$config = $this['config'];
if (!$config->get('app.hostname')) {
$config->set('app.hostname', $req->host());
}
$res = new Response();
try {
// determine route by dispatching to router
$routeInfo = $this['router']->dispatch($req->method(), $req->path());
$this['routeInfo'] = $routeInfo;
// set any route arguments on the request
if (isset($routeInfo[2])) {
$req->setParams($routeInfo[2]);
}
// the dispatch middleware is the final step
$dispatch = new DispatchMiddleware();
$dispatch->setApp($this);
$this->middleware($dispatch);
// the request is handled by returning the response
// generated by the middleware chain
return $this->runMiddleware($req, $res);
} catch (\Exception $e) {
return $this['exception_handler']($req, $res, $e);
} catch (\Error $e) {
return $this['php_error_handler']($req, $res, $e);
}
}
|
php
|
public function handleRequest(Request $req)
{
// set host name from request if not already set
$config = $this['config'];
if (!$config->get('app.hostname')) {
$config->set('app.hostname', $req->host());
}
$res = new Response();
try {
// determine route by dispatching to router
$routeInfo = $this['router']->dispatch($req->method(), $req->path());
$this['routeInfo'] = $routeInfo;
// set any route arguments on the request
if (isset($routeInfo[2])) {
$req->setParams($routeInfo[2]);
}
// the dispatch middleware is the final step
$dispatch = new DispatchMiddleware();
$dispatch->setApp($this);
$this->middleware($dispatch);
// the request is handled by returning the response
// generated by the middleware chain
return $this->runMiddleware($req, $res);
} catch (\Exception $e) {
return $this['exception_handler']($req, $res, $e);
} catch (\Error $e) {
return $this['php_error_handler']($req, $res, $e);
}
}
|
[
"public",
"function",
"handleRequest",
"(",
"Request",
"$",
"req",
")",
"{",
"// set host name from request if not already set",
"$",
"config",
"=",
"$",
"this",
"[",
"'config'",
"]",
";",
"if",
"(",
"!",
"$",
"config",
"->",
"get",
"(",
"'app.hostname'",
")",
")",
"{",
"$",
"config",
"->",
"set",
"(",
"'app.hostname'",
",",
"$",
"req",
"->",
"host",
"(",
")",
")",
";",
"}",
"$",
"res",
"=",
"new",
"Response",
"(",
")",
";",
"try",
"{",
"// determine route by dispatching to router",
"$",
"routeInfo",
"=",
"$",
"this",
"[",
"'router'",
"]",
"->",
"dispatch",
"(",
"$",
"req",
"->",
"method",
"(",
")",
",",
"$",
"req",
"->",
"path",
"(",
")",
")",
";",
"$",
"this",
"[",
"'routeInfo'",
"]",
"=",
"$",
"routeInfo",
";",
"// set any route arguments on the request",
"if",
"(",
"isset",
"(",
"$",
"routeInfo",
"[",
"2",
"]",
")",
")",
"{",
"$",
"req",
"->",
"setParams",
"(",
"$",
"routeInfo",
"[",
"2",
"]",
")",
";",
"}",
"// the dispatch middleware is the final step",
"$",
"dispatch",
"=",
"new",
"DispatchMiddleware",
"(",
")",
";",
"$",
"dispatch",
"->",
"setApp",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"middleware",
"(",
"$",
"dispatch",
")",
";",
"// the request is handled by returning the response",
"// generated by the middleware chain",
"return",
"$",
"this",
"->",
"runMiddleware",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"[",
"'exception_handler'",
"]",
"(",
"$",
"req",
",",
"$",
"res",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"\\",
"Error",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"[",
"'php_error_handler'",
"]",
"(",
"$",
"req",
",",
"$",
"res",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Builds a response to an incoming request by routing
it through the application.
@param Request $req
@return Response
|
[
"Builds",
"a",
"response",
"to",
"an",
"incoming",
"request",
"by",
"routing",
"it",
"through",
"the",
"application",
"."
] |
7520b237c69f3d8a07d95d7481b26027ced2ed83
|
https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L265-L297
|
20,925 |
infusephp/infuse
|
src/Application.php
|
Application.runMiddleware
|
public function runMiddleware(Request $req, Response $res)
{
$this->initMiddleware()->rewind();
return $this->nextMiddleware($req, $res);
}
|
php
|
public function runMiddleware(Request $req, Response $res)
{
$this->initMiddleware()->rewind();
return $this->nextMiddleware($req, $res);
}
|
[
"public",
"function",
"runMiddleware",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"this",
"->",
"initMiddleware",
"(",
")",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"this",
"->",
"nextMiddleware",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}"
] |
Runs the middleware chain.
@param Request $req
@param Response $res
@return Response $res
|
[
"Runs",
"the",
"middleware",
"chain",
"."
] |
7520b237c69f3d8a07d95d7481b26027ced2ed83
|
https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L335-L340
|
20,926 |
infusephp/infuse
|
src/Application.php
|
Application.nextMiddleware
|
public function nextMiddleware(Request $req, Response $res)
{
$middleware = $this->middleware->current();
// base case - no middleware left
if (!$middleware) {
return $res;
}
// otherwise, call next middleware
$this->middleware->next();
return $middleware($req, $res, [$this, 'nextMiddleware']);
}
|
php
|
public function nextMiddleware(Request $req, Response $res)
{
$middleware = $this->middleware->current();
// base case - no middleware left
if (!$middleware) {
return $res;
}
// otherwise, call next middleware
$this->middleware->next();
return $middleware($req, $res, [$this, 'nextMiddleware']);
}
|
[
"public",
"function",
"nextMiddleware",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"middleware",
"=",
"$",
"this",
"->",
"middleware",
"->",
"current",
"(",
")",
";",
"// base case - no middleware left",
"if",
"(",
"!",
"$",
"middleware",
")",
"{",
"return",
"$",
"res",
";",
"}",
"// otherwise, call next middleware",
"$",
"this",
"->",
"middleware",
"->",
"next",
"(",
")",
";",
"return",
"$",
"middleware",
"(",
"$",
"req",
",",
"$",
"res",
",",
"[",
"$",
"this",
",",
"'nextMiddleware'",
"]",
")",
";",
"}"
] |
Calls the next middleware in the chain.
DO NOT call directly.
@param Request $req
@param Response $res
@return Response
|
[
"Calls",
"the",
"next",
"middleware",
"in",
"the",
"chain",
".",
"DO",
"NOT",
"call",
"directly",
"."
] |
7520b237c69f3d8a07d95d7481b26027ced2ed83
|
https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/Application.php#L366-L379
|
20,927 |
traderinteractive/filter-dates-php
|
src/Filter/DateTimeZone.php
|
DateTimeZone.filter
|
public static function filter($value, bool $allowNull = false)
{
if (self::valueIsNullAndValid($allowNull, $value)) {
return null;
}
if ($value instanceof \DateTimeZone) {
return $value;
}
if (!is_string($value) || trim($value) == '') {
throw new FilterException('$value not a non-empty string');
}
try {
return new \DateTimeZone($value);
} catch (\Exception $e) {
throw new FilterException($e->getMessage(), $e->getCode(), $e);
}
}
|
php
|
public static function filter($value, bool $allowNull = false)
{
if (self::valueIsNullAndValid($allowNull, $value)) {
return null;
}
if ($value instanceof \DateTimeZone) {
return $value;
}
if (!is_string($value) || trim($value) == '') {
throw new FilterException('$value not a non-empty string');
}
try {
return new \DateTimeZone($value);
} catch (\Exception $e) {
throw new FilterException($e->getMessage(), $e->getCode(), $e);
}
}
|
[
"public",
"static",
"function",
"filter",
"(",
"$",
"value",
",",
"bool",
"$",
"allowNull",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"valueIsNullAndValid",
"(",
"$",
"allowNull",
",",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTimeZone",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"||",
"trim",
"(",
"$",
"value",
")",
"==",
"''",
")",
"{",
"throw",
"new",
"FilterException",
"(",
"'$value not a non-empty string'",
")",
";",
"}",
"try",
"{",
"return",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"FilterException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Filters the given value into a \DateTimeZone object.
@param mixed $value The value to be filtered.
@param boolean $allowNull True to allow nulls through, and false (default) if nulls should not be allowed.
@return \DateTimeZone|null
@throws FilterException if the value did not pass validation.
|
[
"Filters",
"the",
"given",
"value",
"into",
"a",
"\\",
"DateTimeZone",
"object",
"."
] |
f9e60f139da3ebb565317c5d62a6fb0c347be4ee
|
https://github.com/traderinteractive/filter-dates-php/blob/f9e60f139da3ebb565317c5d62a6fb0c347be4ee/src/Filter/DateTimeZone.php#L22-L41
|
20,928 |
lukasz-adamski/teamspeak3-framework
|
src/TeamSpeak3/Helper/Convert.php
|
Convert.logEntry
|
public static function logEntry($entry)
{
$parts = explode("|", $entry, 5);
$array = array();
if(count($parts) != 5)
{
$array["timestamp"] = 0;
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
$array["channel"] = "ParamParser";
$array["server_id"] = "";
$array["msg"] = Str::factory("convert error (" . trim($entry) . ")");
$array["msg_plain"] = $entry;
$array["malformed"] = TRUE;
}
else
{
$array["timestamp"] = strtotime(trim($parts[0]));
$array["level"] = self::logLevel(trim($parts[1]));
$array["channel"] = trim($parts[2]);
$array["server_id"] = trim($parts[3]);
$array["msg"] = Str::factory(trim($parts[4]));
$array["msg_plain"] = $entry;
$array["malformed"] = FALSE;
}
return $array;
}
|
php
|
public static function logEntry($entry)
{
$parts = explode("|", $entry, 5);
$array = array();
if(count($parts) != 5)
{
$array["timestamp"] = 0;
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
$array["channel"] = "ParamParser";
$array["server_id"] = "";
$array["msg"] = Str::factory("convert error (" . trim($entry) . ")");
$array["msg_plain"] = $entry;
$array["malformed"] = TRUE;
}
else
{
$array["timestamp"] = strtotime(trim($parts[0]));
$array["level"] = self::logLevel(trim($parts[1]));
$array["channel"] = trim($parts[2]);
$array["server_id"] = trim($parts[3]);
$array["msg"] = Str::factory(trim($parts[4]));
$array["msg_plain"] = $entry;
$array["malformed"] = FALSE;
}
return $array;
}
|
[
"public",
"static",
"function",
"logEntry",
"(",
"$",
"entry",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\"|\"",
",",
"$",
"entry",
",",
"5",
")",
";",
"$",
"array",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"!=",
"5",
")",
"{",
"$",
"array",
"[",
"\"timestamp\"",
"]",
"=",
"0",
";",
"$",
"array",
"[",
"\"level\"",
"]",
"=",
"TeamSpeak3",
"::",
"LOGLEVEL_ERROR",
";",
"$",
"array",
"[",
"\"channel\"",
"]",
"=",
"\"ParamParser\"",
";",
"$",
"array",
"[",
"\"server_id\"",
"]",
"=",
"\"\"",
";",
"$",
"array",
"[",
"\"msg\"",
"]",
"=",
"Str",
"::",
"factory",
"(",
"\"convert error (\"",
".",
"trim",
"(",
"$",
"entry",
")",
".",
"\")\"",
")",
";",
"$",
"array",
"[",
"\"msg_plain\"",
"]",
"=",
"$",
"entry",
";",
"$",
"array",
"[",
"\"malformed\"",
"]",
"=",
"TRUE",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"\"timestamp\"",
"]",
"=",
"strtotime",
"(",
"trim",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
")",
";",
"$",
"array",
"[",
"\"level\"",
"]",
"=",
"self",
"::",
"logLevel",
"(",
"trim",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
";",
"$",
"array",
"[",
"\"channel\"",
"]",
"=",
"trim",
"(",
"$",
"parts",
"[",
"2",
"]",
")",
";",
"$",
"array",
"[",
"\"server_id\"",
"]",
"=",
"trim",
"(",
"$",
"parts",
"[",
"3",
"]",
")",
";",
"$",
"array",
"[",
"\"msg\"",
"]",
"=",
"Str",
"::",
"factory",
"(",
"trim",
"(",
"$",
"parts",
"[",
"4",
"]",
")",
")",
";",
"$",
"array",
"[",
"\"msg_plain\"",
"]",
"=",
"$",
"entry",
";",
"$",
"array",
"[",
"\"malformed\"",
"]",
"=",
"FALSE",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Converts a specified log entry string into an array containing the data.
@param string $entry
@return array
|
[
"Converts",
"a",
"specified",
"log",
"entry",
"string",
"into",
"an",
"array",
"containing",
"the",
"data",
"."
] |
39a56eca608da6b56b6aa386a7b5b31dc576c41a
|
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Convert.php#L258-L285
|
20,929 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.startWithNode
|
public static function startWithNode(
string $variable = null,
array $labels = []
): self {
$path = new self;
$path->elements = $path->elements->add(
new Node($variable, $labels)
);
$path->lastOperation = Node::class;
return $path;
}
|
php
|
public static function startWithNode(
string $variable = null,
array $labels = []
): self {
$path = new self;
$path->elements = $path->elements->add(
new Node($variable, $labels)
);
$path->lastOperation = Node::class;
return $path;
}
|
[
"public",
"static",
"function",
"startWithNode",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"path",
"->",
"elements",
"->",
"add",
"(",
"new",
"Node",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
")",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"Node",
"::",
"class",
";",
"return",
"$",
"path",
";",
"}"
] |
Start the path with the given node
@param string $variable
@param array $labels
@return self
|
[
"Start",
"the",
"path",
"with",
"the",
"given",
"node"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L35-L46
|
20,930 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.linkedTo
|
public function linkedTo(string $variable = null, array $labels = []): self
{
$path = new self;
$path->elements = $this
->elements
->add(Relationship::both())
->add(new Node($variable, $labels));
$path->lastOperation = Node::class;
return $path;
}
|
php
|
public function linkedTo(string $variable = null, array $labels = []): self
{
$path = new self;
$path->elements = $this
->elements
->add(Relationship::both())
->add(new Node($variable, $labels));
$path->lastOperation = Node::class;
return $path;
}
|
[
"public",
"function",
"linkedTo",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"add",
"(",
"Relationship",
"::",
"both",
"(",
")",
")",
"->",
"add",
"(",
"new",
"Node",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
")",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"Node",
"::",
"class",
";",
"return",
"$",
"path",
";",
"}"
] |
Create a relationship to the given node
@param string $variable
@param array $labels
@return self
|
[
"Create",
"a",
"relationship",
"to",
"the",
"given",
"node"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L56-L66
|
20,931 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.through
|
public function through(
string $variable = null,
string $type = null,
string $direction = 'BOTH'
): self {
if ($this->elements->size() < 3) {
throw new LogicException;
}
$direction = \strtolower($direction);
$path = new self;
$path->elements = $this
->elements
->dropEnd(2)
->add(Relationship::$direction($variable, $type))
->add($this->elements->last());
$path->lastOperation = Relationship::class;
return $path;
}
|
php
|
public function through(
string $variable = null,
string $type = null,
string $direction = 'BOTH'
): self {
if ($this->elements->size() < 3) {
throw new LogicException;
}
$direction = \strtolower($direction);
$path = new self;
$path->elements = $this
->elements
->dropEnd(2)
->add(Relationship::$direction($variable, $type))
->add($this->elements->last());
$path->lastOperation = Relationship::class;
return $path;
}
|
[
"public",
"function",
"through",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"string",
"$",
"type",
"=",
"null",
",",
"string",
"$",
"direction",
"=",
"'BOTH'",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"size",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"LogicException",
";",
"}",
"$",
"direction",
"=",
"\\",
"strtolower",
"(",
"$",
"direction",
")",
";",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"Relationship",
"::",
"$",
"direction",
"(",
"$",
"variable",
",",
"$",
"type",
")",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"Relationship",
"::",
"class",
";",
"return",
"$",
"path",
";",
"}"
] |
Type the last declared relationship in the path
@param string $variable
@param string $type
@param string $direction
@throws LogicException If no relationship in the path
@return self
|
[
"Type",
"the",
"last",
"declared",
"relationship",
"in",
"the",
"path"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L79-L99
|
20,932 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.withADistanceOfAtLeast
|
public function withADistanceOfAtLeast(int $distance): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withADistanceOfAtLeast($distance)
)
->add($this->elements->last());
return $path;
}
|
php
|
public function withADistanceOfAtLeast(int $distance): self
{
if ($this->elements->size() < 3) {
throw new LogicException;
}
$path = clone $this;
$path->elements = $this
->elements
->dropEnd(2)
->add(
$this->elements->dropEnd(1)->last()->withADistanceOfAtLeast($distance)
)
->add($this->elements->last());
return $path;
}
|
[
"public",
"function",
"withADistanceOfAtLeast",
"(",
"int",
"$",
"distance",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"elements",
"->",
"size",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"LogicException",
";",
"}",
"$",
"path",
"=",
"clone",
"$",
"this",
";",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
"->",
"withADistanceOfAtLeast",
"(",
"$",
"distance",
")",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"return",
"$",
"path",
";",
"}"
] |
Define the minimum deepness of the relationship
@param int $distance
@throws LogicException If no relationship in the path
@return self
|
[
"Define",
"the",
"minimum",
"deepness",
"of",
"the",
"relationship"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L165-L181
|
20,933 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.withParameter
|
public function withParameter(string $key, $value): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withParameter($key, $value);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
}
|
php
|
public function withParameter(string $key, $value): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withParameter($key, $value);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
}
|
[
"public",
"function",
"withParameter",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
";",
"}",
"else",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
";",
"}",
"$",
"element",
"=",
"$",
"element",
"->",
"withParameter",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"$",
"this",
"->",
"lastOperation",
";",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"element",
")",
";",
"}",
"else",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"element",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Add the given parameter to the last operation
@param string $key
@param mixed $value
@return self
|
[
"Add",
"the",
"given",
"parameter",
"to",
"the",
"last",
"operation"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L245-L271
|
20,934 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.withProperty
|
public function withProperty(string $property, string $cypher): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withProperty($property, $cypher);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
}
|
php
|
public function withProperty(string $property, string $cypher): self
{
if ($this->lastOperation === Node::class) {
$element = $this->elements->last();
} else {
$element = $this->elements->dropEnd(1)->last();
}
$element = $element->withProperty($property, $cypher);
$path = new self;
$path->lastOperation = $this->lastOperation;
if ($this->lastOperation === Node::class) {
$path->elements = $this
->elements
->dropEnd(1)
->add($element);
} else {
$path->elements = $this
->elements
->dropEnd(2)
->add($element)
->add($this->elements->last());
}
return $path;
}
|
[
"public",
"function",
"withProperty",
"(",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
";",
"}",
"else",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"last",
"(",
")",
";",
"}",
"$",
"element",
"=",
"$",
"element",
"->",
"withProperty",
"(",
"$",
"property",
",",
"$",
"cypher",
")",
";",
"$",
"path",
"=",
"new",
"self",
";",
"$",
"path",
"->",
"lastOperation",
"=",
"$",
"this",
"->",
"lastOperation",
";",
"if",
"(",
"$",
"this",
"->",
"lastOperation",
"===",
"Node",
"::",
"class",
")",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"element",
")",
";",
"}",
"else",
"{",
"$",
"path",
"->",
"elements",
"=",
"$",
"this",
"->",
"elements",
"->",
"dropEnd",
"(",
"2",
")",
"->",
"add",
"(",
"$",
"element",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"elements",
"->",
"last",
"(",
")",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Add the given property to the last operation
@param string $property
@param string $cypher
@return self
|
[
"Add",
"the",
"given",
"property",
"to",
"the",
"last",
"operation"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L281-L307
|
20,935 |
Innmind/neo4j-dbal
|
src/Clause/Expression/Path.php
|
Path.parameters
|
public function parameters(): MapInterface
{
if ($this->parameters) {
return $this->parameters;
}
return $this->parameters = $this->elements->reduce(
new Map('string', Parameter::class),
function(Map $carry, $element): Map {
return $carry->merge($element->parameters());
}
);
}
|
php
|
public function parameters(): MapInterface
{
if ($this->parameters) {
return $this->parameters;
}
return $this->parameters = $this->elements->reduce(
new Map('string', Parameter::class),
function(Map $carry, $element): Map {
return $carry->merge($element->parameters());
}
);
}
|
[
"public",
"function",
"parameters",
"(",
")",
":",
"MapInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"parameters",
";",
"}",
"return",
"$",
"this",
"->",
"parameters",
"=",
"$",
"this",
"->",
"elements",
"->",
"reduce",
"(",
"new",
"Map",
"(",
"'string'",
",",
"Parameter",
"::",
"class",
")",
",",
"function",
"(",
"Map",
"$",
"carry",
",",
"$",
"element",
")",
":",
"Map",
"{",
"return",
"$",
"carry",
"->",
"merge",
"(",
"$",
"element",
"->",
"parameters",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Return all the parameters of the path
@return MapInterface<string, Parameter>
|
[
"Return",
"all",
"the",
"parameters",
"of",
"the",
"path"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/Expression/Path.php#L314-L326
|
20,936 |
OKTOTV/OktolabMediaBundle
|
Model/EncodeEpisodeJob.php
|
EncodeEpisodeJob.executeFFmpegForMedia
|
private function executeFFmpegForMedia($cmd, $format, $resolution, $media) {
$ffmpeg_start = microtime(true);
$this->getContainer()->get('oktolab_media_ffmpeg')
->executeFFmpegForMedia(
$resolution['encoder'],
$cmd,
$media
)
;
$ffmpeg_stop = microtime(true);
$media->setStatus(Media::OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED);
$media->setPublic($resolution['public']);
$this->em->persist($media);
$this->em->flush();
$this->logbook->info(
'oktolab_media.episode_end_saving_media',
[
'%format%' => $format,
'%seconds%' => round($ffmpeg_stop - $ffmpeg_start)
],
$this->args['uniqID']
);
// move encoded media from "cache" to config adapter or adapter of the original file
$this->getContainer()->get('bprs.asset')->moveAsset(
$media->getAsset(),
$resolution['adapter'] ? $resolution['adapter'] : $media->getEpisode()->getVideo()->getAdapter()
);
// add finalize episode job, set new episode status
if (!$this->added_finalize) {
$this->finalizeEpisode($media->getEpisode());
$this->added_finalize = true;
}
}
|
php
|
private function executeFFmpegForMedia($cmd, $format, $resolution, $media) {
$ffmpeg_start = microtime(true);
$this->getContainer()->get('oktolab_media_ffmpeg')
->executeFFmpegForMedia(
$resolution['encoder'],
$cmd,
$media
)
;
$ffmpeg_stop = microtime(true);
$media->setStatus(Media::OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED);
$media->setPublic($resolution['public']);
$this->em->persist($media);
$this->em->flush();
$this->logbook->info(
'oktolab_media.episode_end_saving_media',
[
'%format%' => $format,
'%seconds%' => round($ffmpeg_stop - $ffmpeg_start)
],
$this->args['uniqID']
);
// move encoded media from "cache" to config adapter or adapter of the original file
$this->getContainer()->get('bprs.asset')->moveAsset(
$media->getAsset(),
$resolution['adapter'] ? $resolution['adapter'] : $media->getEpisode()->getVideo()->getAdapter()
);
// add finalize episode job, set new episode status
if (!$this->added_finalize) {
$this->finalizeEpisode($media->getEpisode());
$this->added_finalize = true;
}
}
|
[
"private",
"function",
"executeFFmpegForMedia",
"(",
"$",
"cmd",
",",
"$",
"format",
",",
"$",
"resolution",
",",
"$",
"media",
")",
"{",
"$",
"ffmpeg_start",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'oktolab_media_ffmpeg'",
")",
"->",
"executeFFmpegForMedia",
"(",
"$",
"resolution",
"[",
"'encoder'",
"]",
",",
"$",
"cmd",
",",
"$",
"media",
")",
";",
"$",
"ffmpeg_stop",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"media",
"->",
"setStatus",
"(",
"Media",
"::",
"OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED",
")",
";",
"$",
"media",
"->",
"setPublic",
"(",
"$",
"resolution",
"[",
"'public'",
"]",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"media",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"logbook",
"->",
"info",
"(",
"'oktolab_media.episode_end_saving_media'",
",",
"[",
"'%format%'",
"=>",
"$",
"format",
",",
"'%seconds%'",
"=>",
"round",
"(",
"$",
"ffmpeg_stop",
"-",
"$",
"ffmpeg_start",
")",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"// move encoded media from \"cache\" to config adapter or adapter of the original file",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'bprs.asset'",
")",
"->",
"moveAsset",
"(",
"$",
"media",
"->",
"getAsset",
"(",
")",
",",
"$",
"resolution",
"[",
"'adapter'",
"]",
"?",
"$",
"resolution",
"[",
"'adapter'",
"]",
":",
"$",
"media",
"->",
"getEpisode",
"(",
")",
"->",
"getVideo",
"(",
")",
"->",
"getAdapter",
"(",
")",
")",
";",
"// add finalize episode job, set new episode status",
"if",
"(",
"!",
"$",
"this",
"->",
"added_finalize",
")",
"{",
"$",
"this",
"->",
"finalizeEpisode",
"(",
"$",
"media",
"->",
"getEpisode",
"(",
")",
")",
";",
"$",
"this",
"->",
"added_finalize",
"=",
"true",
";",
"}",
"}"
] |
creates a media object and runs the ffmpeg command for the given resolution.
the command will be tracked to update the progress from 0 - 100 in realtime.
will move the asset from the cache adapter to the adapter in the resolution if defined.
triggers the finalize episode function once for the whole job
|
[
"creates",
"a",
"media",
"object",
"and",
"runs",
"the",
"ffmpeg",
"command",
"for",
"the",
"given",
"resolution",
".",
"the",
"command",
"will",
"be",
"tracked",
"to",
"update",
"the",
"progress",
"from",
"0",
"-",
"100",
"in",
"realtime",
".",
"will",
"move",
"the",
"asset",
"from",
"the",
"cache",
"adapter",
"to",
"the",
"adapter",
"in",
"the",
"resolution",
"if",
"defined",
".",
"triggers",
"the",
"finalize",
"episode",
"function",
"once",
"for",
"the",
"whole",
"job"
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L251-L287
|
20,937 |
OKTOTV/OktolabMediaBundle
|
Model/EncodeEpisodeJob.php
|
EncodeEpisodeJob.finalizeEpisode
|
private function finalizeEpisode($episode) {
$event = new EncodedEpisodeEvent($episode);
$this->getContainer()->get('event_dispatcher')->dispatch(
OktolabMediaEvent::ENCODED_EPISODE,
$event
);
$this->oktolab_media->addFinalizeEpisodeJob(
$episode->getUniqID(),
false,
true
);
}
|
php
|
private function finalizeEpisode($episode) {
$event = new EncodedEpisodeEvent($episode);
$this->getContainer()->get('event_dispatcher')->dispatch(
OktolabMediaEvent::ENCODED_EPISODE,
$event
);
$this->oktolab_media->addFinalizeEpisodeJob(
$episode->getUniqID(),
false,
true
);
}
|
[
"private",
"function",
"finalizeEpisode",
"(",
"$",
"episode",
")",
"{",
"$",
"event",
"=",
"new",
"EncodedEpisodeEvent",
"(",
"$",
"episode",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'event_dispatcher'",
")",
"->",
"dispatch",
"(",
"OktolabMediaEvent",
"::",
"ENCODED_EPISODE",
",",
"$",
"event",
")",
";",
"$",
"this",
"->",
"oktolab_media",
"->",
"addFinalizeEpisodeJob",
"(",
"$",
"episode",
"->",
"getUniqID",
"(",
")",
",",
"false",
",",
"true",
")",
";",
"}"
] |
adds finalize job
and dispatches encoded_episode event
|
[
"adds",
"finalize",
"job",
"and",
"dispatches",
"encoded_episode",
"event"
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L312-L324
|
20,938 |
OKTOTV/OktolabMediaBundle
|
Model/EncodeEpisodeJob.php
|
EncodeEpisodeJob.createNewCacheAssetForResolution
|
private function createNewCacheAssetForResolution($episode, $resolution) {
$asset = $this->getContainer()->get('bprs.asset')->createAsset();
$asset->setFilekey(
sprintf('%s.%s',$asset->getFilekey(), $resolution['container'])
);
$asset->setAdapter(
$this->getContainer()->getParameter(
'oktolab_media.encoding_filesystem'
)
);
$asset->setName($episode->getVideo()->getName());
$asset->setMimetype($resolution['mimetype']);
return $asset;
}
|
php
|
private function createNewCacheAssetForResolution($episode, $resolution) {
$asset = $this->getContainer()->get('bprs.asset')->createAsset();
$asset->setFilekey(
sprintf('%s.%s',$asset->getFilekey(), $resolution['container'])
);
$asset->setAdapter(
$this->getContainer()->getParameter(
'oktolab_media.encoding_filesystem'
)
);
$asset->setName($episode->getVideo()->getName());
$asset->setMimetype($resolution['mimetype']);
return $asset;
}
|
[
"private",
"function",
"createNewCacheAssetForResolution",
"(",
"$",
"episode",
",",
"$",
"resolution",
")",
"{",
"$",
"asset",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'bprs.asset'",
")",
"->",
"createAsset",
"(",
")",
";",
"$",
"asset",
"->",
"setFilekey",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"asset",
"->",
"getFilekey",
"(",
")",
",",
"$",
"resolution",
"[",
"'container'",
"]",
")",
")",
";",
"$",
"asset",
"->",
"setAdapter",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'oktolab_media.encoding_filesystem'",
")",
")",
";",
"$",
"asset",
"->",
"setName",
"(",
"$",
"episode",
"->",
"getVideo",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"$",
"asset",
"->",
"setMimetype",
"(",
"$",
"resolution",
"[",
"'mimetype'",
"]",
")",
";",
"return",
"$",
"asset",
";",
"}"
] |
returns an empty asset to be used in an encoding situation.
the filekey, mimetype and adapter are already set for ffmpeg
|
[
"returns",
"an",
"empty",
"asset",
"to",
"be",
"used",
"in",
"an",
"encoding",
"situation",
".",
"the",
"filekey",
"mimetype",
"and",
"adapter",
"are",
"already",
"set",
"for",
"ffmpeg"
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EncodeEpisodeJob.php#L330-L344
|
20,939 |
ShaoZeMing/laravel-merchant
|
src/Grid/Exporters/AbstractExporter.php
|
AbstractExporter.withScope
|
public function withScope($scope)
{
if ($scope == Grid\Exporter::SCOPE_ALL) {
return $this;
}
list($scope, $args) = explode(':', $scope);
if ($scope == Grid\Exporter::SCOPE_CURRENT_PAGE) {
$this->grid->model()->usePaginate(true);
}
if ($scope == Grid\Exporter::SCOPE_SELECTED_ROWS) {
$selected = explode(',', $args);
$this->grid->model()->whereIn($this->grid->getKeyName(), $selected);
}
return $this;
}
|
php
|
public function withScope($scope)
{
if ($scope == Grid\Exporter::SCOPE_ALL) {
return $this;
}
list($scope, $args) = explode(':', $scope);
if ($scope == Grid\Exporter::SCOPE_CURRENT_PAGE) {
$this->grid->model()->usePaginate(true);
}
if ($scope == Grid\Exporter::SCOPE_SELECTED_ROWS) {
$selected = explode(',', $args);
$this->grid->model()->whereIn($this->grid->getKeyName(), $selected);
}
return $this;
}
|
[
"public",
"function",
"withScope",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"$",
"scope",
"==",
"Grid",
"\\",
"Exporter",
"::",
"SCOPE_ALL",
")",
"{",
"return",
"$",
"this",
";",
"}",
"list",
"(",
"$",
"scope",
",",
"$",
"args",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"scope",
")",
";",
"if",
"(",
"$",
"scope",
"==",
"Grid",
"\\",
"Exporter",
"::",
"SCOPE_CURRENT_PAGE",
")",
"{",
"$",
"this",
"->",
"grid",
"->",
"model",
"(",
")",
"->",
"usePaginate",
"(",
"true",
")",
";",
"}",
"if",
"(",
"$",
"scope",
"==",
"Grid",
"\\",
"Exporter",
"::",
"SCOPE_SELECTED_ROWS",
")",
"{",
"$",
"selected",
"=",
"explode",
"(",
"','",
",",
"$",
"args",
")",
";",
"$",
"this",
"->",
"grid",
"->",
"model",
"(",
")",
"->",
"whereIn",
"(",
"$",
"this",
"->",
"grid",
"->",
"getKeyName",
"(",
")",
",",
"$",
"selected",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Export data with scope.
@param string $scope
@return $this
|
[
"Export",
"data",
"with",
"scope",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Grid/Exporters/AbstractExporter.php#L78-L96
|
20,940 |
NuclearCMS/Hierarchy
|
src/Repositories/NodeTypeRepository.php
|
NodeTypeRepository.create
|
public function create(array $attributes)
{
$model = $this->getModelName();
$nodeType = $model::create($attributes);
$this->builderService->buildTable(
$nodeType->getName(),
$nodeType->getKey()
);
return $nodeType;
}
|
php
|
public function create(array $attributes)
{
$model = $this->getModelName();
$nodeType = $model::create($attributes);
$this->builderService->buildTable(
$nodeType->getName(),
$nodeType->getKey()
);
return $nodeType;
}
|
[
"public",
"function",
"create",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"$",
"nodeType",
"=",
"$",
"model",
"::",
"create",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"builderService",
"->",
"buildTable",
"(",
"$",
"nodeType",
"->",
"getName",
"(",
")",
",",
"$",
"nodeType",
"->",
"getKey",
"(",
")",
")",
";",
"return",
"$",
"nodeType",
";",
"}"
] |
Creates a node type
@param array $attributes
@return NodeTypeContract
|
[
"Creates",
"a",
"node",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Repositories/NodeTypeRepository.php#L14-L26
|
20,941 |
NuclearCMS/Hierarchy
|
src/Repositories/NodeTypeRepository.php
|
NodeTypeRepository.destroy
|
public function destroy($id)
{
$model = $this->getModelName();
$nodeType = $model::findOrFail($id);
$this->builderService->destroyTable(
$nodeType->getName(),
$nodeType->getFieldKeys(),
$nodeType->getKey()
);
$nodeType->delete();
return $nodeType;
}
|
php
|
public function destroy($id)
{
$model = $this->getModelName();
$nodeType = $model::findOrFail($id);
$this->builderService->destroyTable(
$nodeType->getName(),
$nodeType->getFieldKeys(),
$nodeType->getKey()
);
$nodeType->delete();
return $nodeType;
}
|
[
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"$",
"nodeType",
"=",
"$",
"model",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"builderService",
"->",
"destroyTable",
"(",
"$",
"nodeType",
"->",
"getName",
"(",
")",
",",
"$",
"nodeType",
"->",
"getFieldKeys",
"(",
")",
",",
"$",
"nodeType",
"->",
"getKey",
"(",
")",
")",
";",
"$",
"nodeType",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"nodeType",
";",
"}"
] |
Destroys a node type
@param int $id
@return NodeTypeContract
|
[
"Destroys",
"a",
"node",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Repositories/NodeTypeRepository.php#L34-L49
|
20,942 |
NuclearCMS/Hierarchy
|
src/Repositories/NodeTypeRepository.php
|
NodeTypeRepository.getNodeTypesByIds
|
public function getNodeTypesByIds($ids)
{
if (empty($ids))
{
return null;
}
if (is_string($ids))
{
$ids = json_decode($ids, true);
}
if (is_array($ids) && ! empty($ids))
{
$model = $this->getModelName();
$placeholders = implode(',', array_fill(0, count($ids), '?'));
$nodeTypes = $model::whereIn('id', $ids)
->orderByRaw('field(id,' . $placeholders . ')', $ids)
->get();
return (count($nodeTypes) > 0) ? $nodeTypes : null;
}
return null;
}
|
php
|
public function getNodeTypesByIds($ids)
{
if (empty($ids))
{
return null;
}
if (is_string($ids))
{
$ids = json_decode($ids, true);
}
if (is_array($ids) && ! empty($ids))
{
$model = $this->getModelName();
$placeholders = implode(',', array_fill(0, count($ids), '?'));
$nodeTypes = $model::whereIn('id', $ids)
->orderByRaw('field(id,' . $placeholders . ')', $ids)
->get();
return (count($nodeTypes) > 0) ? $nodeTypes : null;
}
return null;
}
|
[
"public",
"function",
"getNodeTypesByIds",
"(",
"$",
"ids",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"ids",
")",
")",
"{",
"$",
"ids",
"=",
"json_decode",
"(",
"$",
"ids",
",",
"true",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"ids",
")",
"&&",
"!",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"$",
"placeholders",
"=",
"implode",
"(",
"','",
",",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"ids",
")",
",",
"'?'",
")",
")",
";",
"$",
"nodeTypes",
"=",
"$",
"model",
"::",
"whereIn",
"(",
"'id'",
",",
"$",
"ids",
")",
"->",
"orderByRaw",
"(",
"'field(id,'",
".",
"$",
"placeholders",
".",
"')'",
",",
"$",
"ids",
")",
"->",
"get",
"(",
")",
";",
"return",
"(",
"count",
"(",
"$",
"nodeTypes",
")",
">",
"0",
")",
"?",
"$",
"nodeTypes",
":",
"null",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns node types by ids
@param array|string $ids
@return Collection
|
[
"Returns",
"node",
"types",
"by",
"ids"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Repositories/NodeTypeRepository.php#L57-L83
|
20,943 |
Danzabar/config-builder
|
src/Data/Extensions/YamlTranslator.php
|
YamlTranslator.validate
|
public function validate()
{
try
{
Yaml\Yaml::parse($this->data);
} catch(\Exception $e)
{
return false;
}
return true;
}
|
php
|
public function validate()
{
try
{
Yaml\Yaml::parse($this->data);
} catch(\Exception $e)
{
return false;
}
return true;
}
|
[
"public",
"function",
"validate",
"(",
")",
"{",
"try",
"{",
"Yaml",
"\\",
"Yaml",
"::",
"parse",
"(",
"$",
"this",
"->",
"data",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates a Yaml string
@return Boolean
@author Dan Cox
|
[
"Validates",
"a",
"Yaml",
"string"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/Extensions/YamlTranslator.php#L65-L77
|
20,944 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.configureComposerJson
|
public function configureComposerJson(Event $event)
{
static::$plugin->getInstanceOf(ComposerConfigurator::class)->configure($event->getComposer(), $event->getIO());
}
|
php
|
public function configureComposerJson(Event $event)
{
static::$plugin->getInstanceOf(ComposerConfigurator::class)->configure($event->getComposer(), $event->getIO());
}
|
[
"public",
"function",
"configureComposerJson",
"(",
"Event",
"$",
"event",
")",
"{",
"static",
"::",
"$",
"plugin",
"->",
"getInstanceOf",
"(",
"ComposerConfigurator",
"::",
"class",
")",
"->",
"configure",
"(",
"$",
"event",
"->",
"getComposer",
"(",
")",
",",
"$",
"event",
"->",
"getIO",
"(",
")",
")",
";",
"}"
] |
Configure the composer sonfiguration file.
@param \Composer\EventDispatcher\Event $event
@return void
|
[
"Configure",
"the",
"composer",
"sonfiguration",
"file",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L85-L88
|
20,945 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.setWordPressInstallDirectory
|
public function setWordPressInstallDirectory(PackageEvent $event)
{
if ($this->getPackageName($event) != 'johnpbloch/wordpress') {
return;
}
$composer = $event->getComposer();
$rootPkg = $composer->getPackage();
if (! $rootPkg) {
return;
}
$extra = $rootPkg->getExtra();
if (isset($extra['wordpress-install-dir']) && $extra['wordpress-install-dir']) {
return;
}
$extra['wordpress-install-dir'] = static::$plugin->getPublicDirectory() . '/wp';
$rootPkg->setExtra($extra);
$composer->setPackage($rootPkg);
}
|
php
|
public function setWordPressInstallDirectory(PackageEvent $event)
{
if ($this->getPackageName($event) != 'johnpbloch/wordpress') {
return;
}
$composer = $event->getComposer();
$rootPkg = $composer->getPackage();
if (! $rootPkg) {
return;
}
$extra = $rootPkg->getExtra();
if (isset($extra['wordpress-install-dir']) && $extra['wordpress-install-dir']) {
return;
}
$extra['wordpress-install-dir'] = static::$plugin->getPublicDirectory() . '/wp';
$rootPkg->setExtra($extra);
$composer->setPackage($rootPkg);
}
|
[
"public",
"function",
"setWordPressInstallDirectory",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPackageName",
"(",
"$",
"event",
")",
"!=",
"'johnpbloch/wordpress'",
")",
"{",
"return",
";",
"}",
"$",
"composer",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
";",
"$",
"rootPkg",
"=",
"$",
"composer",
"->",
"getPackage",
"(",
")",
";",
"if",
"(",
"!",
"$",
"rootPkg",
")",
"{",
"return",
";",
"}",
"$",
"extra",
"=",
"$",
"rootPkg",
"->",
"getExtra",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"extra",
"[",
"'wordpress-install-dir'",
"]",
")",
"&&",
"$",
"extra",
"[",
"'wordpress-install-dir'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"extra",
"[",
"'wordpress-install-dir'",
"]",
"=",
"static",
"::",
"$",
"plugin",
"->",
"getPublicDirectory",
"(",
")",
".",
"'/wp'",
";",
"$",
"rootPkg",
"->",
"setExtra",
"(",
"$",
"extra",
")",
";",
"$",
"composer",
"->",
"setPackage",
"(",
"$",
"rootPkg",
")",
";",
"}"
] |
Set the WordPress installation directory.
@param \Composer\EventDispatcher\Event $event
@return void
|
[
"Set",
"the",
"WordPress",
"installation",
"directory",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L96-L119
|
20,946 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.cleanWordPressInstallation
|
public function cleanWordPressInstallation(PackageEvent $event)
{
if ($this->getPackageName($event) != 'johnpbloch/wordpress') {
return;
}
static::$plugin->getInstanceOf(WordPressInstallationCleaner::class)->clean($event->getComposer(), $event->getIO());
}
|
php
|
public function cleanWordPressInstallation(PackageEvent $event)
{
if ($this->getPackageName($event) != 'johnpbloch/wordpress') {
return;
}
static::$plugin->getInstanceOf(WordPressInstallationCleaner::class)->clean($event->getComposer(), $event->getIO());
}
|
[
"public",
"function",
"cleanWordPressInstallation",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPackageName",
"(",
"$",
"event",
")",
"!=",
"'johnpbloch/wordpress'",
")",
"{",
"return",
";",
"}",
"static",
"::",
"$",
"plugin",
"->",
"getInstanceOf",
"(",
"WordPressInstallationCleaner",
"::",
"class",
")",
"->",
"clean",
"(",
"$",
"event",
"->",
"getComposer",
"(",
")",
",",
"$",
"event",
"->",
"getIO",
"(",
")",
")",
";",
"}"
] |
Clean the WordPress installation.
@param \Composer\Installer\PackageEvent $event
@return void
|
[
"Clean",
"the",
"WordPress",
"installation",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L127-L134
|
20,947 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.activateWordPressPlugin
|
public function activateWordPressPlugin(PackageEvent $event)
{
if (! $this->isWordPressPlugin($this->getPackage($event))) {
return;
}
static::$plugin->getInstanceOf(PluginInteractor::class)->activate(
$event->getComposer(),
$event->getIO(),
preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
);
}
|
php
|
public function activateWordPressPlugin(PackageEvent $event)
{
if (! $this->isWordPressPlugin($this->getPackage($event))) {
return;
}
static::$plugin->getInstanceOf(PluginInteractor::class)->activate(
$event->getComposer(),
$event->getIO(),
preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
);
}
|
[
"public",
"function",
"activateWordPressPlugin",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isWordPressPlugin",
"(",
"$",
"this",
"->",
"getPackage",
"(",
"$",
"event",
")",
")",
")",
"{",
"return",
";",
"}",
"static",
"::",
"$",
"plugin",
"->",
"getInstanceOf",
"(",
"PluginInteractor",
"::",
"class",
")",
"->",
"activate",
"(",
"$",
"event",
"->",
"getComposer",
"(",
")",
",",
"$",
"event",
"->",
"getIO",
"(",
")",
",",
"preg_replace",
"(",
"'/^wpackagist-plugin\\//'",
",",
"''",
",",
"$",
"this",
"->",
"getPackageName",
"(",
"$",
"event",
")",
")",
")",
";",
"}"
] |
Activate a WordPress plugin.
@param \Composer\Installer\PackageEvent $event
@return void
|
[
"Activate",
"a",
"WordPress",
"plugin",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L142-L153
|
20,948 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.deactivateWordPressPlugin
|
public function deactivateWordPressPlugin(PackageEvent $event)
{
if (! $this->isWordPressPlugin($this->getPackage($event))) {
return;
}
static::$plugin->getInstanceOf(PluginInteractor::class)->deactivate(
$event->getComposer(),
$event->getIO(),
preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
);
}
|
php
|
public function deactivateWordPressPlugin(PackageEvent $event)
{
if (! $this->isWordPressPlugin($this->getPackage($event))) {
return;
}
static::$plugin->getInstanceOf(PluginInteractor::class)->deactivate(
$event->getComposer(),
$event->getIO(),
preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
);
}
|
[
"public",
"function",
"deactivateWordPressPlugin",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isWordPressPlugin",
"(",
"$",
"this",
"->",
"getPackage",
"(",
"$",
"event",
")",
")",
")",
"{",
"return",
";",
"}",
"static",
"::",
"$",
"plugin",
"->",
"getInstanceOf",
"(",
"PluginInteractor",
"::",
"class",
")",
"->",
"deactivate",
"(",
"$",
"event",
"->",
"getComposer",
"(",
")",
",",
"$",
"event",
"->",
"getIO",
"(",
")",
",",
"preg_replace",
"(",
"'/^wpackagist-plugin\\//'",
",",
"''",
",",
"$",
"this",
"->",
"getPackageName",
"(",
"$",
"event",
")",
")",
")",
";",
"}"
] |
Deactivate a WordPress plugin.
@param \Composer\Installer\PackageEvent $event
@return void
|
[
"Deactivate",
"a",
"WordPress",
"plugin",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L161-L172
|
20,949 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.uninstallWordPressPlugin
|
public function uninstallWordPressPlugin(PackageEvent $event)
{
if (! $this->isWordPressPlugin($this->getPackage($event))) {
return;
}
static::$plugin->getInstanceOf(PluginInteractor::class)->uninstall(
$event->getComposer(),
$event->getIO(),
preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
);
}
|
php
|
public function uninstallWordPressPlugin(PackageEvent $event)
{
if (! $this->isWordPressPlugin($this->getPackage($event))) {
return;
}
static::$plugin->getInstanceOf(PluginInteractor::class)->uninstall(
$event->getComposer(),
$event->getIO(),
preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
);
}
|
[
"public",
"function",
"uninstallWordPressPlugin",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isWordPressPlugin",
"(",
"$",
"this",
"->",
"getPackage",
"(",
"$",
"event",
")",
")",
")",
"{",
"return",
";",
"}",
"static",
"::",
"$",
"plugin",
"->",
"getInstanceOf",
"(",
"PluginInteractor",
"::",
"class",
")",
"->",
"uninstall",
"(",
"$",
"event",
"->",
"getComposer",
"(",
")",
",",
"$",
"event",
"->",
"getIO",
"(",
")",
",",
"preg_replace",
"(",
"'/^wpackagist-plugin\\//'",
",",
"''",
",",
"$",
"this",
"->",
"getPackageName",
"(",
"$",
"event",
")",
")",
")",
";",
"}"
] |
Uninstall a WordPress plugin.
@param \Composer\Installer\PackageEvent $event
@return void
|
[
"Uninstall",
"a",
"WordPress",
"plugin",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L180-L191
|
20,950 |
CupOfTea696/WordPress-Composer
|
src/EventSubscriber.php
|
EventSubscriber.getPackage
|
protected function getPackage(PackageEvent $event)
{
$operation = $event->getOperation();
if (method_exists($operation, 'getPackage')) {
return $operation->getPackage();
}
return $operation->getTargetPackage();
}
|
php
|
protected function getPackage(PackageEvent $event)
{
$operation = $event->getOperation();
if (method_exists($operation, 'getPackage')) {
return $operation->getPackage();
}
return $operation->getTargetPackage();
}
|
[
"protected",
"function",
"getPackage",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"$",
"operation",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"operation",
",",
"'getPackage'",
")",
")",
"{",
"return",
"$",
"operation",
"->",
"getPackage",
"(",
")",
";",
"}",
"return",
"$",
"operation",
"->",
"getTargetPackage",
"(",
")",
";",
"}"
] |
Get the PackageInterface from a PackageEvent.
@param \Composer\Installer\PackageEvent $event
@return \Composer\Package\PackageInterface
|
[
"Get",
"the",
"PackageInterface",
"from",
"a",
"PackageEvent",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/EventSubscriber.php#L199-L208
|
20,951 |
novaway/open-graph
|
src/Metadata/Driver/AnnotationDriver.php
|
AnnotationDriver.loadMetadataForClass
|
public function loadMetadataForClass(\ReflectionClass $class)
{
$classMetadata = new ClassMetadata($class->name);
$classMetadata->fileResources[] = $class->getFileName();
foreach ($this->reader->getClassAnnotations($class) as $annotation) {
if ($annotation instanceof NamespaceNode) {
$classMetadata->addGraphNamespace($annotation);
}
if ($annotation instanceof GraphNode) {
$classMetadata->addGraphMetadata($annotation, new MetadataValue($annotation->value));
}
}
foreach ($class->getProperties() as $property) {
foreach ($this->reader->getPropertyAnnotations($property) as $annotation) {
if ($annotation instanceof GraphNode) {
$classMetadata->addGraphMetadata($annotation, new PropertyMetadata($class->name, $property->name));
}
}
}
foreach ($class->getMethods() as $method) {
foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
if ($annotation instanceof GraphNode) {
$classMetadata->addGraphMetadata($annotation, new MethodMetadata($class->name, $method->name));
}
}
}
return $classMetadata;
}
|
php
|
public function loadMetadataForClass(\ReflectionClass $class)
{
$classMetadata = new ClassMetadata($class->name);
$classMetadata->fileResources[] = $class->getFileName();
foreach ($this->reader->getClassAnnotations($class) as $annotation) {
if ($annotation instanceof NamespaceNode) {
$classMetadata->addGraphNamespace($annotation);
}
if ($annotation instanceof GraphNode) {
$classMetadata->addGraphMetadata($annotation, new MetadataValue($annotation->value));
}
}
foreach ($class->getProperties() as $property) {
foreach ($this->reader->getPropertyAnnotations($property) as $annotation) {
if ($annotation instanceof GraphNode) {
$classMetadata->addGraphMetadata($annotation, new PropertyMetadata($class->name, $property->name));
}
}
}
foreach ($class->getMethods() as $method) {
foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
if ($annotation instanceof GraphNode) {
$classMetadata->addGraphMetadata($annotation, new MethodMetadata($class->name, $method->name));
}
}
}
return $classMetadata;
}
|
[
"public",
"function",
"loadMetadataForClass",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
"{",
"$",
"classMetadata",
"=",
"new",
"ClassMetadata",
"(",
"$",
"class",
"->",
"name",
")",
";",
"$",
"classMetadata",
"->",
"fileResources",
"[",
"]",
"=",
"$",
"class",
"->",
"getFileName",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"reader",
"->",
"getClassAnnotations",
"(",
"$",
"class",
")",
"as",
"$",
"annotation",
")",
"{",
"if",
"(",
"$",
"annotation",
"instanceof",
"NamespaceNode",
")",
"{",
"$",
"classMetadata",
"->",
"addGraphNamespace",
"(",
"$",
"annotation",
")",
";",
"}",
"if",
"(",
"$",
"annotation",
"instanceof",
"GraphNode",
")",
"{",
"$",
"classMetadata",
"->",
"addGraphMetadata",
"(",
"$",
"annotation",
",",
"new",
"MetadataValue",
"(",
"$",
"annotation",
"->",
"value",
")",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"class",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"reader",
"->",
"getPropertyAnnotations",
"(",
"$",
"property",
")",
"as",
"$",
"annotation",
")",
"{",
"if",
"(",
"$",
"annotation",
"instanceof",
"GraphNode",
")",
"{",
"$",
"classMetadata",
"->",
"addGraphMetadata",
"(",
"$",
"annotation",
",",
"new",
"PropertyMetadata",
"(",
"$",
"class",
"->",
"name",
",",
"$",
"property",
"->",
"name",
")",
")",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"class",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"reader",
"->",
"getMethodAnnotations",
"(",
"$",
"method",
")",
"as",
"$",
"annotation",
")",
"{",
"if",
"(",
"$",
"annotation",
"instanceof",
"GraphNode",
")",
"{",
"$",
"classMetadata",
"->",
"addGraphMetadata",
"(",
"$",
"annotation",
",",
"new",
"MethodMetadata",
"(",
"$",
"class",
"->",
"name",
",",
"$",
"method",
"->",
"name",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"classMetadata",
";",
"}"
] |
Load metadata class
@param \ReflectionClass $class
@return ClassMetadata
|
[
"Load",
"metadata",
"class"
] |
19817bee4b91cf26ca3fe44883ad58b32328e464
|
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/Metadata/Driver/AnnotationDriver.php#L36-L68
|
20,952 |
heidelpay/PhpDoc
|
src/phpDocumentor/Compiler/Pass/ElementsIndexBuilder.php
|
ElementsIndexBuilder.getIndexKey
|
protected function getIndexKey($element)
{
$key = $element->getFullyQualifiedStructuralElementName();
// properties should have an additional $ before the property name
if ($element instanceof PropertyInterface) {
list($fqcn, $propertyName) = explode('::', $key);
$key = $fqcn . '::$' . $propertyName;
}
return $key;
}
|
php
|
protected function getIndexKey($element)
{
$key = $element->getFullyQualifiedStructuralElementName();
// properties should have an additional $ before the property name
if ($element instanceof PropertyInterface) {
list($fqcn, $propertyName) = explode('::', $key);
$key = $fqcn . '::$' . $propertyName;
}
return $key;
}
|
[
"protected",
"function",
"getIndexKey",
"(",
"$",
"element",
")",
"{",
"$",
"key",
"=",
"$",
"element",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
";",
"// properties should have an additional $ before the property name",
"if",
"(",
"$",
"element",
"instanceof",
"PropertyInterface",
")",
"{",
"list",
"(",
"$",
"fqcn",
",",
"$",
"propertyName",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"key",
")",
";",
"$",
"key",
"=",
"$",
"fqcn",
".",
"'::$'",
".",
"$",
"propertyName",
";",
"}",
"return",
"$",
"key",
";",
"}"
] |
Retrieves a key for the index for the provided element.
@param DescriptorAbstract $element
@return string
|
[
"Retrieves",
"a",
"key",
"for",
"the",
"index",
"for",
"the",
"provided",
"element",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ElementsIndexBuilder.php#L146-L157
|
20,953 |
heidelpay/PhpDoc
|
src/phpDocumentor/Partials/Collection.php
|
Collection.set
|
public function set($index, $item)
{
$this->offsetSet($index, $this->parser->text($item));
}
|
php
|
public function set($index, $item)
{
$this->offsetSet($index, $this->parser->text($item));
}
|
[
"public",
"function",
"set",
"(",
"$",
"index",
",",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"parser",
"->",
"text",
"(",
"$",
"item",
")",
")",
";",
"}"
] |
Sets a new object onto the collection or clear it using null.
@param string|integer $index An index value to recognize this item with.
@param string $item The item to store, generally a Descriptor but may be something else.
@return void
|
[
"Sets",
"a",
"new",
"object",
"onto",
"the",
"collection",
"or",
"clear",
"it",
"using",
"null",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Partials/Collection.php#L42-L45
|
20,954 |
superjimpupcake/Pupcake
|
src/Pupcake/Event.php
|
Event.register
|
public function register()
{
$this->helper_callbacks = array();
$arguments= func_get_args();
if(count($arguments) > 0){
foreach($arguments as $argument){
if($argument instanceof Plugin){ //this is a plugin object
$callback = $argument->getEventHelperCallback($this->getName());
if(is_callable($callback)){
$this->helper_callbacks[] = $callback;
}
}
else if(is_callable($argument)){ //this is a closure
$this->helper_callbacks[] = $argument;
}
}
}
return $this; //return the event object reference to allow chainable calls
}
|
php
|
public function register()
{
$this->helper_callbacks = array();
$arguments= func_get_args();
if(count($arguments) > 0){
foreach($arguments as $argument){
if($argument instanceof Plugin){ //this is a plugin object
$callback = $argument->getEventHelperCallback($this->getName());
if(is_callable($callback)){
$this->helper_callbacks[] = $callback;
}
}
else if(is_callable($argument)){ //this is a closure
$this->helper_callbacks[] = $argument;
}
}
}
return $this; //return the event object reference to allow chainable calls
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"helper_callbacks",
"=",
"array",
"(",
")",
";",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arguments",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"argument",
")",
"{",
"if",
"(",
"$",
"argument",
"instanceof",
"Plugin",
")",
"{",
"//this is a plugin object",
"$",
"callback",
"=",
"$",
"argument",
"->",
"getEventHelperCallback",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"this",
"->",
"helper_callbacks",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"}",
"else",
"if",
"(",
"is_callable",
"(",
"$",
"argument",
")",
")",
"{",
"//this is a closure",
"$",
"this",
"->",
"helper_callbacks",
"[",
"]",
"=",
"$",
"argument",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"//return the event object reference to allow chainable calls",
"}"
] |
register an array of plugins objects and allow the plugins to join the process of handling this event
|
[
"register",
"an",
"array",
"of",
"plugins",
"objects",
"and",
"allow",
"the",
"plugins",
"to",
"join",
"the",
"process",
"of",
"handling",
"this",
"event"
] |
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
|
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Event.php#L76-L95
|
20,955 |
superjimpupcake/Pupcake
|
src/Pupcake/Event.php
|
Event.start
|
public function start()
{
$result = array();
if(count($this->helper_callbacks) > 0){
foreach($this->helper_callbacks as $callback){
$return_value = call_user_func_array($callback, array($this));
$result[] = $return_value;
}
}
return $result;
}
|
php
|
public function start()
{
$result = array();
if(count($this->helper_callbacks) > 0){
foreach($this->helper_callbacks as $callback){
$return_value = call_user_func_array($callback, array($this));
$result[] = $return_value;
}
}
return $result;
}
|
[
"public",
"function",
"start",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"helper_callbacks",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"helper_callbacks",
"as",
"$",
"callback",
")",
"{",
"$",
"return_value",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"array",
"(",
"$",
"this",
")",
")",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"return_value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
start this event
|
[
"start",
"this",
"event"
] |
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
|
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Event.php#L118-L128
|
20,956 |
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php
|
CurlMulti.executeHandles
|
private function executeHandles(&$active, &$mrc, $timeout = 1)
{
do {
$mrc = curl_multi_exec($this->multiHandle, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM && $active);
$this->checkCurlResult($mrc);
// @codeCoverageIgnoreStart
// Select the curl handles until there is any activity on any of the open file descriptors
// See https://github.com/php/php-src/blob/master/ext/curl/multi.c#L170
if ($active && $mrc == CURLM_OK && curl_multi_select($this->multiHandle, $timeout) == -1) {
// Perform a usleep if a previously executed select returned -1
// @see https://bugs.php.net/bug.php?id=61141
usleep(100);
}
// @codeCoverageIgnoreEnd
}
|
php
|
private function executeHandles(&$active, &$mrc, $timeout = 1)
{
do {
$mrc = curl_multi_exec($this->multiHandle, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM && $active);
$this->checkCurlResult($mrc);
// @codeCoverageIgnoreStart
// Select the curl handles until there is any activity on any of the open file descriptors
// See https://github.com/php/php-src/blob/master/ext/curl/multi.c#L170
if ($active && $mrc == CURLM_OK && curl_multi_select($this->multiHandle, $timeout) == -1) {
// Perform a usleep if a previously executed select returned -1
// @see https://bugs.php.net/bug.php?id=61141
usleep(100);
}
// @codeCoverageIgnoreEnd
}
|
[
"private",
"function",
"executeHandles",
"(",
"&",
"$",
"active",
",",
"&",
"$",
"mrc",
",",
"$",
"timeout",
"=",
"1",
")",
"{",
"do",
"{",
"$",
"mrc",
"=",
"curl_multi_exec",
"(",
"$",
"this",
"->",
"multiHandle",
",",
"$",
"active",
")",
";",
"}",
"while",
"(",
"$",
"mrc",
"==",
"CURLM_CALL_MULTI_PERFORM",
"&&",
"$",
"active",
")",
";",
"$",
"this",
"->",
"checkCurlResult",
"(",
"$",
"mrc",
")",
";",
"// @codeCoverageIgnoreStart",
"// Select the curl handles until there is any activity on any of the open file descriptors",
"// See https://github.com/php/php-src/blob/master/ext/curl/multi.c#L170",
"if",
"(",
"$",
"active",
"&&",
"$",
"mrc",
"==",
"CURLM_OK",
"&&",
"curl_multi_select",
"(",
"$",
"this",
"->",
"multiHandle",
",",
"$",
"timeout",
")",
"==",
"-",
"1",
")",
"{",
"// Perform a usleep if a previously executed select returned -1",
"// @see https://bugs.php.net/bug.php?id=61141",
"usleep",
"(",
"100",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"}"
] |
Execute and select curl handles until there is activity
@param int $active Active value to update
@param int $mrc Multi result value to update
@param int $timeout Select timeout in seconds
|
[
"Execute",
"and",
"select",
"curl",
"handles",
"until",
"there",
"is",
"activity"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php#L257-L273
|
20,957 |
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php
|
CurlMulti.removeErroredRequest
|
protected function removeErroredRequest(RequestInterface $request, \Exception $e = null, $buffer = true)
{
if ($buffer) {
$this->exceptions[] = array('request' => $request, 'exception' => $e);
}
$this->remove($request);
$this->dispatch(self::MULTI_EXCEPTION, array('exception' => $e, 'all_exceptions' => $this->exceptions));
}
|
php
|
protected function removeErroredRequest(RequestInterface $request, \Exception $e = null, $buffer = true)
{
if ($buffer) {
$this->exceptions[] = array('request' => $request, 'exception' => $e);
}
$this->remove($request);
$this->dispatch(self::MULTI_EXCEPTION, array('exception' => $e, 'all_exceptions' => $this->exceptions));
}
|
[
"protected",
"function",
"removeErroredRequest",
"(",
"RequestInterface",
"$",
"request",
",",
"\\",
"Exception",
"$",
"e",
"=",
"null",
",",
"$",
"buffer",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"buffer",
")",
"{",
"$",
"this",
"->",
"exceptions",
"[",
"]",
"=",
"array",
"(",
"'request'",
"=>",
"$",
"request",
",",
"'exception'",
"=>",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"remove",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"self",
"::",
"MULTI_EXCEPTION",
",",
"array",
"(",
"'exception'",
"=>",
"$",
"e",
",",
"'all_exceptions'",
"=>",
"$",
"this",
"->",
"exceptions",
")",
")",
";",
"}"
] |
Remove a request that encountered an exception
@param RequestInterface $request Request to remove
@param \Exception $e Exception encountered
@param bool $buffer Set to false to not buffer the exception
|
[
"Remove",
"a",
"request",
"that",
"encountered",
"an",
"exception"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php#L282-L290
|
20,958 |
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php
|
CurlMulti.processResponse
|
protected function processResponse(RequestInterface $request, CurlHandle $handle, array $curl)
{
// Set the transfer stats on the response
$handle->updateRequestFromTransfer($request);
// Check if a cURL exception occurred, and if so, notify things
$curlException = $this->isCurlException($request, $handle, $curl);
// Always remove completed curl handles. They can be added back again
// via events if needed (e.g. ExponentialBackoffPlugin)
$this->removeHandle($request);
if (!$curlException) {
$state = $request->setState(RequestInterface::STATE_COMPLETE, array('handle' => $handle));
// Only remove the request if it wasn't resent as a result of the state change
if ($state != RequestInterface::STATE_TRANSFER) {
$this->remove($request);
}
} else {
// Set the state of the request to an error
$state = $request->setState(RequestInterface::STATE_ERROR, array('exception' => $curlException));
// Allow things to ignore the error if possible
if ($state != RequestInterface::STATE_TRANSFER) {
$this->remove($request);
}
// The error was not handled, so fail
if ($state == RequestInterface::STATE_ERROR) {
/** @var CurlException $curlException */
throw $curlException;
}
}
}
|
php
|
protected function processResponse(RequestInterface $request, CurlHandle $handle, array $curl)
{
// Set the transfer stats on the response
$handle->updateRequestFromTransfer($request);
// Check if a cURL exception occurred, and if so, notify things
$curlException = $this->isCurlException($request, $handle, $curl);
// Always remove completed curl handles. They can be added back again
// via events if needed (e.g. ExponentialBackoffPlugin)
$this->removeHandle($request);
if (!$curlException) {
$state = $request->setState(RequestInterface::STATE_COMPLETE, array('handle' => $handle));
// Only remove the request if it wasn't resent as a result of the state change
if ($state != RequestInterface::STATE_TRANSFER) {
$this->remove($request);
}
} else {
// Set the state of the request to an error
$state = $request->setState(RequestInterface::STATE_ERROR, array('exception' => $curlException));
// Allow things to ignore the error if possible
if ($state != RequestInterface::STATE_TRANSFER) {
$this->remove($request);
}
// The error was not handled, so fail
if ($state == RequestInterface::STATE_ERROR) {
/** @var CurlException $curlException */
throw $curlException;
}
}
}
|
[
"protected",
"function",
"processResponse",
"(",
"RequestInterface",
"$",
"request",
",",
"CurlHandle",
"$",
"handle",
",",
"array",
"$",
"curl",
")",
"{",
"// Set the transfer stats on the response",
"$",
"handle",
"->",
"updateRequestFromTransfer",
"(",
"$",
"request",
")",
";",
"// Check if a cURL exception occurred, and if so, notify things",
"$",
"curlException",
"=",
"$",
"this",
"->",
"isCurlException",
"(",
"$",
"request",
",",
"$",
"handle",
",",
"$",
"curl",
")",
";",
"// Always remove completed curl handles. They can be added back again",
"// via events if needed (e.g. ExponentialBackoffPlugin)",
"$",
"this",
"->",
"removeHandle",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"curlException",
")",
"{",
"$",
"state",
"=",
"$",
"request",
"->",
"setState",
"(",
"RequestInterface",
"::",
"STATE_COMPLETE",
",",
"array",
"(",
"'handle'",
"=>",
"$",
"handle",
")",
")",
";",
"// Only remove the request if it wasn't resent as a result of the state change",
"if",
"(",
"$",
"state",
"!=",
"RequestInterface",
"::",
"STATE_TRANSFER",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"request",
")",
";",
"}",
"}",
"else",
"{",
"// Set the state of the request to an error",
"$",
"state",
"=",
"$",
"request",
"->",
"setState",
"(",
"RequestInterface",
"::",
"STATE_ERROR",
",",
"array",
"(",
"'exception'",
"=>",
"$",
"curlException",
")",
")",
";",
"// Allow things to ignore the error if possible",
"if",
"(",
"$",
"state",
"!=",
"RequestInterface",
"::",
"STATE_TRANSFER",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"request",
")",
";",
"}",
"// The error was not handled, so fail",
"if",
"(",
"$",
"state",
"==",
"RequestInterface",
"::",
"STATE_ERROR",
")",
"{",
"/** @var CurlException $curlException */",
"throw",
"$",
"curlException",
";",
"}",
"}",
"}"
] |
Check for errors and fix headers of a request based on a curl response
@param RequestInterface $request Request to process
@param CurlHandle $handle Curl handle object
@param array $curl Array returned from curl_multi_info_read
@throws CurlException on Curl error
|
[
"Check",
"for",
"errors",
"and",
"fix",
"headers",
"of",
"a",
"request",
"based",
"on",
"a",
"curl",
"response"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php#L301-L331
|
20,959 |
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php
|
CurlMulti.removeHandle
|
protected function removeHandle(RequestInterface $request)
{
if (isset($this->handles[$request])) {
$handle = $this->handles[$request];
unset($this->handles[$request]);
unset($this->resourceHash[(int) $handle->getHandle()]);
curl_multi_remove_handle($this->multiHandle, $handle->getHandle());
$handle->close();
}
}
|
php
|
protected function removeHandle(RequestInterface $request)
{
if (isset($this->handles[$request])) {
$handle = $this->handles[$request];
unset($this->handles[$request]);
unset($this->resourceHash[(int) $handle->getHandle()]);
curl_multi_remove_handle($this->multiHandle, $handle->getHandle());
$handle->close();
}
}
|
[
"protected",
"function",
"removeHandle",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"handles",
"[",
"$",
"request",
"]",
")",
")",
"{",
"$",
"handle",
"=",
"$",
"this",
"->",
"handles",
"[",
"$",
"request",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"handles",
"[",
"$",
"request",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"resourceHash",
"[",
"(",
"int",
")",
"$",
"handle",
"->",
"getHandle",
"(",
")",
"]",
")",
";",
"curl_multi_remove_handle",
"(",
"$",
"this",
"->",
"multiHandle",
",",
"$",
"handle",
"->",
"getHandle",
"(",
")",
")",
";",
"$",
"handle",
"->",
"close",
"(",
")",
";",
"}",
"}"
] |
Remove a curl handle from the curl multi object
@param RequestInterface $request Request that owns the handle
|
[
"Remove",
"a",
"curl",
"handle",
"from",
"the",
"curl",
"multi",
"object"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Curl/CurlMulti.php#L338-L347
|
20,960 |
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Command/Project/TransformCommand.php
|
TransformCommand.getTemplates
|
protected function getTemplates(InputInterface $input)
{
/** @var ConfigurationHelper $configurationHelper */
$configurationHelper = $this->getHelper('phpdocumentor_configuration');
$templates = $input->getOption('template');
if (!$templates) {
/** @var Template[] $templatesFromConfig */
$templatesFromConfig = $configurationHelper->getConfigValueFromPath('transformations/templates');
foreach ($templatesFromConfig as $template) {
$templates[] = $template->getName();
}
}
if (!$templates) {
$templates = array('clean');
}
return $templates;
}
|
php
|
protected function getTemplates(InputInterface $input)
{
/** @var ConfigurationHelper $configurationHelper */
$configurationHelper = $this->getHelper('phpdocumentor_configuration');
$templates = $input->getOption('template');
if (!$templates) {
/** @var Template[] $templatesFromConfig */
$templatesFromConfig = $configurationHelper->getConfigValueFromPath('transformations/templates');
foreach ($templatesFromConfig as $template) {
$templates[] = $template->getName();
}
}
if (!$templates) {
$templates = array('clean');
}
return $templates;
}
|
[
"protected",
"function",
"getTemplates",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"/** @var ConfigurationHelper $configurationHelper */",
"$",
"configurationHelper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'phpdocumentor_configuration'",
")",
";",
"$",
"templates",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'template'",
")",
";",
"if",
"(",
"!",
"$",
"templates",
")",
"{",
"/** @var Template[] $templatesFromConfig */",
"$",
"templatesFromConfig",
"=",
"$",
"configurationHelper",
"->",
"getConfigValueFromPath",
"(",
"'transformations/templates'",
")",
";",
"foreach",
"(",
"$",
"templatesFromConfig",
"as",
"$",
"template",
")",
"{",
"$",
"templates",
"[",
"]",
"=",
"$",
"template",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"templates",
")",
"{",
"$",
"templates",
"=",
"array",
"(",
"'clean'",
")",
";",
"}",
"return",
"$",
"templates",
";",
"}"
] |
Retrieves the templates to be used by analyzing the options and the configuration.
@param InputInterface $input
@return string[]
|
[
"Retrieves",
"the",
"templates",
"to",
"be",
"used",
"by",
"analyzing",
"the",
"options",
"and",
"the",
"configuration",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Command/Project/TransformCommand.php#L233-L252
|
20,961 |
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Command/Project/TransformCommand.php
|
TransformCommand.loadTransformations
|
public function loadTransformations(Transformer $transformer)
{
/** @var ConfigurationHelper $configurationHelper */
$configurationHelper = $this->getHelper('phpdocumentor_configuration');
$received = array();
$transformations = $configurationHelper->getConfigValueFromPath('transformations/transformations');
if (is_array($transformations)) {
if (isset($transformations['writer'])) {
$received[] = $this->createTransformation($transformations);
} else {
foreach ($transformations as $transformation) {
if (is_array($transformation)) {
$received[] = $this->createTransformation($transformations);
}
}
}
}
$this->appendReceivedTransformations($transformer, $received);
}
|
php
|
public function loadTransformations(Transformer $transformer)
{
/** @var ConfigurationHelper $configurationHelper */
$configurationHelper = $this->getHelper('phpdocumentor_configuration');
$received = array();
$transformations = $configurationHelper->getConfigValueFromPath('transformations/transformations');
if (is_array($transformations)) {
if (isset($transformations['writer'])) {
$received[] = $this->createTransformation($transformations);
} else {
foreach ($transformations as $transformation) {
if (is_array($transformation)) {
$received[] = $this->createTransformation($transformations);
}
}
}
}
$this->appendReceivedTransformations($transformer, $received);
}
|
[
"public",
"function",
"loadTransformations",
"(",
"Transformer",
"$",
"transformer",
")",
"{",
"/** @var ConfigurationHelper $configurationHelper */",
"$",
"configurationHelper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'phpdocumentor_configuration'",
")",
";",
"$",
"received",
"=",
"array",
"(",
")",
";",
"$",
"transformations",
"=",
"$",
"configurationHelper",
"->",
"getConfigValueFromPath",
"(",
"'transformations/transformations'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"transformations",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"transformations",
"[",
"'writer'",
"]",
")",
")",
"{",
"$",
"received",
"[",
"]",
"=",
"$",
"this",
"->",
"createTransformation",
"(",
"$",
"transformations",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"transformations",
"as",
"$",
"transformation",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"transformation",
")",
")",
"{",
"$",
"received",
"[",
"]",
"=",
"$",
"this",
"->",
"createTransformation",
"(",
"$",
"transformations",
")",
";",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"appendReceivedTransformations",
"(",
"$",
"transformer",
",",
"$",
"received",
")",
";",
"}"
] |
Load custom defined transformations.
@param Transformer $transformer
@todo this is an ugly implementation done for speed of development, should be refactored
@return void
|
[
"Load",
"custom",
"defined",
"transformations",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Command/Project/TransformCommand.php#L263-L283
|
20,962 |
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Command/Project/TransformCommand.php
|
TransformCommand.createTransformation
|
protected function createTransformation(array $transformations)
{
return new Transformation(
isset($transformations['query']) ? $transformations['query'] : '',
$transformations['writer'],
isset($transformations['source']) ? $transformations['source'] : '',
isset($transformations['artifact']) ? $transformations['artifact'] : ''
);
}
|
php
|
protected function createTransformation(array $transformations)
{
return new Transformation(
isset($transformations['query']) ? $transformations['query'] : '',
$transformations['writer'],
isset($transformations['source']) ? $transformations['source'] : '',
isset($transformations['artifact']) ? $transformations['artifact'] : ''
);
}
|
[
"protected",
"function",
"createTransformation",
"(",
"array",
"$",
"transformations",
")",
"{",
"return",
"new",
"Transformation",
"(",
"isset",
"(",
"$",
"transformations",
"[",
"'query'",
"]",
")",
"?",
"$",
"transformations",
"[",
"'query'",
"]",
":",
"''",
",",
"$",
"transformations",
"[",
"'writer'",
"]",
",",
"isset",
"(",
"$",
"transformations",
"[",
"'source'",
"]",
")",
"?",
"$",
"transformations",
"[",
"'source'",
"]",
":",
"''",
",",
"isset",
"(",
"$",
"transformations",
"[",
"'artifact'",
"]",
")",
"?",
"$",
"transformations",
"[",
"'artifact'",
"]",
":",
"''",
")",
";",
"}"
] |
Create Transformation instance.
@param array $transformations
@return \phpDocumentor\Transformer\Transformation
|
[
"Create",
"Transformation",
"instance",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Command/Project/TransformCommand.php#L292-L300
|
20,963 |
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Command/Project/TransformCommand.php
|
TransformCommand.appendReceivedTransformations
|
protected function appendReceivedTransformations(Transformer $transformer, $received)
{
if (!empty($received)) {
$template = new Template('__');
foreach ($received as $transformation) {
$template[] = $transformation;
}
$transformer->getTemplates()->append($template);
}
}
|
php
|
protected function appendReceivedTransformations(Transformer $transformer, $received)
{
if (!empty($received)) {
$template = new Template('__');
foreach ($received as $transformation) {
$template[] = $transformation;
}
$transformer->getTemplates()->append($template);
}
}
|
[
"protected",
"function",
"appendReceivedTransformations",
"(",
"Transformer",
"$",
"transformer",
",",
"$",
"received",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"received",
")",
")",
"{",
"$",
"template",
"=",
"new",
"Template",
"(",
"'__'",
")",
";",
"foreach",
"(",
"$",
"received",
"as",
"$",
"transformation",
")",
"{",
"$",
"template",
"[",
"]",
"=",
"$",
"transformation",
";",
"}",
"$",
"transformer",
"->",
"getTemplates",
"(",
")",
"->",
"append",
"(",
"$",
"template",
")",
";",
"}",
"}"
] |
Append received transformations.
@param Transformer $transformer
@param array $received
@return void
|
[
"Append",
"received",
"transformations",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Command/Project/TransformCommand.php#L310-L319
|
20,964 |
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Command/Project/TransformCommand.php
|
TransformCommand.getProgressBar
|
protected function getProgressBar(InputInterface $input)
{
$progress = parent::getProgressBar($input);
if (!$progress) {
return null;
}
/** @var Dispatcher $eventDispatcher */
$eventDispatcher = $this->getService('event_dispatcher');
$eventDispatcher->addListener(
'transformer.transformation.post',
function () use ($progress) {
$progress->advance();
}
);
return $progress;
}
|
php
|
protected function getProgressBar(InputInterface $input)
{
$progress = parent::getProgressBar($input);
if (!$progress) {
return null;
}
/** @var Dispatcher $eventDispatcher */
$eventDispatcher = $this->getService('event_dispatcher');
$eventDispatcher->addListener(
'transformer.transformation.post',
function () use ($progress) {
$progress->advance();
}
);
return $progress;
}
|
[
"protected",
"function",
"getProgressBar",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"$",
"progress",
"=",
"parent",
"::",
"getProgressBar",
"(",
"$",
"input",
")",
";",
"if",
"(",
"!",
"$",
"progress",
")",
"{",
"return",
"null",
";",
"}",
"/** @var Dispatcher $eventDispatcher */",
"$",
"eventDispatcher",
"=",
"$",
"this",
"->",
"getService",
"(",
"'event_dispatcher'",
")",
";",
"$",
"eventDispatcher",
"->",
"addListener",
"(",
"'transformer.transformation.post'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"progress",
")",
"{",
"$",
"progress",
"->",
"advance",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"progress",
";",
"}"
] |
Adds the transformer.transformation.post event to advance the progressbar.
@param InputInterface $input
@return HelperInterface|null
|
[
"Adds",
"the",
"transformer",
".",
"transformation",
".",
"post",
"event",
"to",
"advance",
"the",
"progressbar",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Command/Project/TransformCommand.php#L328-L345
|
20,965 |
caffeinated/beverage
|
src/Filesystem.php
|
Filesystem.rsearch
|
public function rsearch($folder, $pattern)
{
$dir = new RecursiveDirectoryIterator($folder);
$iterator = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iterator, $pattern, RegexIterator::GET_MATCH);
$fileList = [];
foreach ($files as $file) {
$fileList = array_merge($fileList, $file);
}
return $fileList;
}
|
php
|
public function rsearch($folder, $pattern)
{
$dir = new RecursiveDirectoryIterator($folder);
$iterator = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iterator, $pattern, RegexIterator::GET_MATCH);
$fileList = [];
foreach ($files as $file) {
$fileList = array_merge($fileList, $file);
}
return $fileList;
}
|
[
"public",
"function",
"rsearch",
"(",
"$",
"folder",
",",
"$",
"pattern",
")",
"{",
"$",
"dir",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"folder",
")",
";",
"$",
"iterator",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"dir",
")",
";",
"$",
"files",
"=",
"new",
"RegexIterator",
"(",
"$",
"iterator",
",",
"$",
"pattern",
",",
"RegexIterator",
"::",
"GET_MATCH",
")",
";",
"$",
"fileList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"fileList",
"=",
"array_merge",
"(",
"$",
"fileList",
",",
"$",
"file",
")",
";",
"}",
"return",
"$",
"fileList",
";",
"}"
] |
Search the given folder recursively for files using
a regular expression pattern.
@param string $folder
@param string $pattern
@return array
|
[
"Search",
"the",
"given",
"folder",
"recursively",
"for",
"files",
"using",
"a",
"regular",
"expression",
"pattern",
"."
] |
c7d612a1d3bc1baddc97fec60ab17224550efaf3
|
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Filesystem.php#L66-L78
|
20,966 |
tystuyfzand/flysystem-seaweedfs
|
src/Seaweed.php
|
Seaweed.getUrl
|
public function getUrl($path) {
$mapping = $this->mapper->get($path);
if (!$mapping) {
return false;
}
try {
$volume = $this->client->lookup($mapping['fid']);
return $this->client->buildVolumeUrl($volume->getPublicUrl(), $mapping['fid']);
} catch (SeaweedFSException $e) {
return false;
}
}
|
php
|
public function getUrl($path) {
$mapping = $this->mapper->get($path);
if (!$mapping) {
return false;
}
try {
$volume = $this->client->lookup($mapping['fid']);
return $this->client->buildVolumeUrl($volume->getPublicUrl(), $mapping['fid']);
} catch (SeaweedFSException $e) {
return false;
}
}
|
[
"public",
"function",
"getUrl",
"(",
"$",
"path",
")",
"{",
"$",
"mapping",
"=",
"$",
"this",
"->",
"mapper",
"->",
"get",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"mapping",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"volume",
"=",
"$",
"this",
"->",
"client",
"->",
"lookup",
"(",
"$",
"mapping",
"[",
"'fid'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"buildVolumeUrl",
"(",
"$",
"volume",
"->",
"getPublicUrl",
"(",
")",
",",
"$",
"mapping",
"[",
"'fid'",
"]",
")",
";",
"}",
"catch",
"(",
"SeaweedFSException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Get the public URL of a path.
@param $path
@return string|bool
|
[
"Get",
"the",
"public",
"URL",
"of",
"a",
"path",
"."
] |
992334ba1d8e26fe6bbb9e33feedbf66b4872613
|
https://github.com/tystuyfzand/flysystem-seaweedfs/blob/992334ba1d8e26fe6bbb9e33feedbf66b4872613/src/Seaweed.php#L325-L339
|
20,967 |
mothership-ec/composer
|
src/Composer/Util/SpdxLicense.php
|
SpdxLicense.getLicenseByIdentifier
|
public function getLicenseByIdentifier($identifier)
{
if (!isset($this->licenses[$identifier])) {
return;
}
$license = $this->licenses[$identifier];
// add URL for the license text (it's not included in the json)
$license[2] = 'http://spdx.org/licenses/' . $identifier . '#licenseText';
return $license;
}
|
php
|
public function getLicenseByIdentifier($identifier)
{
if (!isset($this->licenses[$identifier])) {
return;
}
$license = $this->licenses[$identifier];
// add URL for the license text (it's not included in the json)
$license[2] = 'http://spdx.org/licenses/' . $identifier . '#licenseText';
return $license;
}
|
[
"public",
"function",
"getLicenseByIdentifier",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"licenses",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"license",
"=",
"$",
"this",
"->",
"licenses",
"[",
"$",
"identifier",
"]",
";",
"// add URL for the license text (it's not included in the json)",
"$",
"license",
"[",
"2",
"]",
"=",
"'http://spdx.org/licenses/'",
".",
"$",
"identifier",
".",
"'#licenseText'",
";",
"return",
"$",
"license",
";",
"}"
] |
Returns license metadata by license identifier.
@param string $identifier
@return array|null
|
[
"Returns",
"license",
"metadata",
"by",
"license",
"identifier",
"."
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Util/SpdxLicense.php#L54-L66
|
20,968 |
mothership-ec/composer
|
src/Composer/Util/SpdxLicense.php
|
SpdxLicense.getIdentifierByName
|
public function getIdentifierByName($name)
{
foreach ($this->licenses as $identifier => $licenseData) {
if ($licenseData[0] === $name) { // key 0 = fullname
return $identifier;
}
}
}
|
php
|
public function getIdentifierByName($name)
{
foreach ($this->licenses as $identifier => $licenseData) {
if ($licenseData[0] === $name) { // key 0 = fullname
return $identifier;
}
}
}
|
[
"public",
"function",
"getIdentifierByName",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"licenses",
"as",
"$",
"identifier",
"=>",
"$",
"licenseData",
")",
"{",
"if",
"(",
"$",
"licenseData",
"[",
"0",
"]",
"===",
"$",
"name",
")",
"{",
"// key 0 = fullname",
"return",
"$",
"identifier",
";",
"}",
"}",
"}"
] |
Returns the short identifier of a license by full name.
@param string $identifier
@return string
|
[
"Returns",
"the",
"short",
"identifier",
"of",
"a",
"license",
"by",
"full",
"name",
"."
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Util/SpdxLicense.php#L75-L82
|
20,969 |
antaresproject/notifications
|
src/Listener/NotificationsListener.php
|
NotificationsListener.listen
|
public function listen()
{
$notifications = $this->repository->findSendable()->toArray();
foreach ($notifications as $notification) {
$this->listenNotificationsEvents($notification);
}
}
|
php
|
public function listen()
{
$notifications = $this->repository->findSendable()->toArray();
foreach ($notifications as $notification) {
$this->listenNotificationsEvents($notification);
}
}
|
[
"public",
"function",
"listen",
"(",
")",
"{",
"$",
"notifications",
"=",
"$",
"this",
"->",
"repository",
"->",
"findSendable",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"notifications",
"as",
"$",
"notification",
")",
"{",
"$",
"this",
"->",
"listenNotificationsEvents",
"(",
"$",
"notification",
")",
";",
"}",
"}"
] |
Listening for notifications
|
[
"Listening",
"for",
"notifications"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Listener/NotificationsListener.php#L62-L69
|
20,970 |
antaresproject/notifications
|
src/Listener/NotificationsListener.php
|
NotificationsListener.listenNotificationsEvents
|
protected function listenNotificationsEvents(array $notification)
{
$events = Arr::get($notification, 'event');
if($events === null && isset($notification['classname'])) {
$events = app()->make($notification['classname'])->getEvents();
}
foreach ((array) $events as $event) {
$this->runNotificationListener($event, $notification);
}
}
|
php
|
protected function listenNotificationsEvents(array $notification)
{
$events = Arr::get($notification, 'event');
if($events === null && isset($notification['classname'])) {
$events = app()->make($notification['classname'])->getEvents();
}
foreach ((array) $events as $event) {
$this->runNotificationListener($event, $notification);
}
}
|
[
"protected",
"function",
"listenNotificationsEvents",
"(",
"array",
"$",
"notification",
")",
"{",
"$",
"events",
"=",
"Arr",
"::",
"get",
"(",
"$",
"notification",
",",
"'event'",
")",
";",
"if",
"(",
"$",
"events",
"===",
"null",
"&&",
"isset",
"(",
"$",
"notification",
"[",
"'classname'",
"]",
")",
")",
"{",
"$",
"events",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"$",
"notification",
"[",
"'classname'",
"]",
")",
"->",
"getEvents",
"(",
")",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"runNotificationListener",
"(",
"$",
"event",
",",
"$",
"notification",
")",
";",
"}",
"}"
] |
Runs notification events.
@param array $notification
|
[
"Runs",
"notification",
"events",
"."
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Listener/NotificationsListener.php#L76-L87
|
20,971 |
antaresproject/notifications
|
src/Listener/NotificationsListener.php
|
NotificationsListener.runNotificationListener
|
protected function runNotificationListener(string $event, array $notification)
{
app('events')->listen($event, function(array $variables = null, array $recipients = null) use($notification) {
$this->eventDispatcher->run($notification, $variables, $recipients);
});
}
|
php
|
protected function runNotificationListener(string $event, array $notification)
{
app('events')->listen($event, function(array $variables = null, array $recipients = null) use($notification) {
$this->eventDispatcher->run($notification, $variables, $recipients);
});
}
|
[
"protected",
"function",
"runNotificationListener",
"(",
"string",
"$",
"event",
",",
"array",
"$",
"notification",
")",
"{",
"app",
"(",
"'events'",
")",
"->",
"listen",
"(",
"$",
"event",
",",
"function",
"(",
"array",
"$",
"variables",
"=",
"null",
",",
"array",
"$",
"recipients",
"=",
"null",
")",
"use",
"(",
"$",
"notification",
")",
"{",
"$",
"this",
"->",
"eventDispatcher",
"->",
"run",
"(",
"$",
"notification",
",",
"$",
"variables",
",",
"$",
"recipients",
")",
";",
"}",
")",
";",
"}"
] |
Runs notification listener.
@param string $event
@param array $notification
|
[
"Runs",
"notification",
"listener",
"."
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Listener/NotificationsListener.php#L95-L100
|
20,972 |
lukasz-adamski/teamspeak3-framework
|
src/TeamSpeak3/Helper/Char.php
|
Char.fromHex
|
public static function fromHex($hex)
{
if(strlen($hex) != 2)
{
throw new Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
}
return new self(chr(hexdec($hex)));
}
|
php
|
public static function fromHex($hex)
{
if(strlen($hex) != 2)
{
throw new Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
}
return new self(chr(hexdec($hex)));
}
|
[
"public",
"static",
"function",
"fromHex",
"(",
"$",
"hex",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"!=",
"2",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"given parameter '\"",
".",
"$",
"hex",
".",
"\"' is not a valid hexadecimal number\"",
")",
";",
"}",
"return",
"new",
"self",
"(",
"chr",
"(",
"hexdec",
"(",
"$",
"hex",
")",
")",
")",
";",
"}"
] |
Returns the Char based on a given hex value.
@param string $hex
@throws Exception
@return Char
|
[
"Returns",
"the",
"Char",
"based",
"on",
"a",
"given",
"hex",
"value",
"."
] |
39a56eca608da6b56b6aa386a7b5b31dc576c41a
|
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Helper/Char.php#L231-L239
|
20,973 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.discoverFields
|
public function discoverFields() {
if (!empty($this->fields)) {
return; // Already configured.
}
$sm = $this->db()->getSchemaManager();
$columns = $sm->listTableColumns($this->table);
foreach ($columns as $column) {
$this->fields[$column->getName()] = array(
'name' => $column->getName(),
'type' => $column->getType(),
);
}
try {
$this->fks = $sm->listTableForeignKeys($this->table);
} catch (\DBALException $e) {
//Platform does not support foreign keys.
$this->fks = array();
}
}
|
php
|
public function discoverFields() {
if (!empty($this->fields)) {
return; // Already configured.
}
$sm = $this->db()->getSchemaManager();
$columns = $sm->listTableColumns($this->table);
foreach ($columns as $column) {
$this->fields[$column->getName()] = array(
'name' => $column->getName(),
'type' => $column->getType(),
);
}
try {
$this->fks = $sm->listTableForeignKeys($this->table);
} catch (\DBALException $e) {
//Platform does not support foreign keys.
$this->fks = array();
}
}
|
[
"public",
"function",
"discoverFields",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"fields",
")",
")",
"{",
"return",
";",
"// Already configured.",
"}",
"$",
"sm",
"=",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"getSchemaManager",
"(",
")",
";",
"$",
"columns",
"=",
"$",
"sm",
"->",
"listTableColumns",
"(",
"$",
"this",
"->",
"table",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"$",
"column",
"->",
"getType",
"(",
")",
",",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"fks",
"=",
"$",
"sm",
"->",
"listTableForeignKeys",
"(",
"$",
"this",
"->",
"table",
")",
";",
"}",
"catch",
"(",
"\\",
"DBALException",
"$",
"e",
")",
"{",
"//Platform does not support foreign keys.",
"$",
"this",
"->",
"fks",
"=",
"array",
"(",
")",
";",
"}",
"}"
] |
Gets info of the fields from the table.
|
[
"Gets",
"info",
"of",
"the",
"fields",
"from",
"the",
"table",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L25-L45
|
20,974 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.setField
|
public function setField($name, $value) {
if (isset($this->fields[$name])) {
$this->isDirty = TRUE;
return $this->record[$name] = $value;
}
throw new \Exception('Not a valid Field for Set ' . $name);
}
|
php
|
public function setField($name, $value) {
if (isset($this->fields[$name])) {
$this->isDirty = TRUE;
return $this->record[$name] = $value;
}
throw new \Exception('Not a valid Field for Set ' . $name);
}
|
[
"public",
"function",
"setField",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"isDirty",
"=",
"TRUE",
";",
"return",
"$",
"this",
"->",
"record",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Not a valid Field for Set '",
".",
"$",
"name",
")",
";",
"}"
] |
Sets a field to the record.
@param $name
@param $value
@return mixed
@throws \Exception
|
[
"Sets",
"a",
"field",
"to",
"the",
"record",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L88-L95
|
20,975 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.getField
|
public function getField($name) {
if (isset($this->fields[$name])) {
return $this->record[$name];
}
if (isset($this->fetchedRecord[$name])) {
return $this->fetchedRecord[$name];
}
throw new \Exception('Not a valid Field for Get ' . $name);
}
|
php
|
public function getField($name) {
if (isset($this->fields[$name])) {
return $this->record[$name];
}
if (isset($this->fetchedRecord[$name])) {
return $this->fetchedRecord[$name];
}
throw new \Exception('Not a valid Field for Get ' . $name);
}
|
[
"public",
"function",
"getField",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"record",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fetchedRecord",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fetchedRecord",
"[",
"$",
"name",
"]",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Not a valid Field for Get '",
".",
"$",
"name",
")",
";",
"}"
] |
Gets a Field from Record.
If the field is not in record will check in fetchedRecord, fetched record may have
some fields from the last query that you will need, like related records.
@param $name
@return mixed
@throws \Exception
|
[
"Gets",
"a",
"Field",
"from",
"Record",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L107-L117
|
20,976 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.insert
|
public function insert() {
$this->db()->insert($this->table, $this->record);
$id = $this->db()->lastInsertId();
$this->record[$this->id_name] = $id;
$this->isDirty = FALSE;
return $this;
}
|
php
|
public function insert() {
$this->db()->insert($this->table, $this->record);
$id = $this->db()->lastInsertId();
$this->record[$this->id_name] = $id;
$this->isDirty = FALSE;
return $this;
}
|
[
"public",
"function",
"insert",
"(",
")",
"{",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"insert",
"(",
"$",
"this",
"->",
"table",
",",
"$",
"this",
"->",
"record",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"lastInsertId",
"(",
")",
";",
"$",
"this",
"->",
"record",
"[",
"$",
"this",
"->",
"id_name",
"]",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"isDirty",
"=",
"FALSE",
";",
"return",
"$",
"this",
";",
"}"
] |
Inserts the record.
@return $this
|
[
"Inserts",
"the",
"record",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L124-L131
|
20,977 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.update
|
public function update() {
$this->db()->update($this->table, $this->record, $this->identifier());
$this->isDirty = FALSE;
return $this;
}
|
php
|
public function update() {
$this->db()->update($this->table, $this->record, $this->identifier());
$this->isDirty = FALSE;
return $this;
}
|
[
"public",
"function",
"update",
"(",
")",
"{",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"update",
"(",
"$",
"this",
"->",
"table",
",",
"$",
"this",
"->",
"record",
",",
"$",
"this",
"->",
"identifier",
"(",
")",
")",
";",
"$",
"this",
"->",
"isDirty",
"=",
"FALSE",
";",
"return",
"$",
"this",
";",
"}"
] |
Updates the record.
@return $this
|
[
"Updates",
"the",
"record",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L138-L143
|
20,978 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.delete
|
public function delete() {
if ($this->isNew()) {
throw new \Exception('ID is not setted for Delete');
}
$this->db()->delete($this->table, $this->identifier());
$this->isDeleted = TRUE;
return $this;
}
|
php
|
public function delete() {
if ($this->isNew()) {
throw new \Exception('ID is not setted for Delete');
}
$this->db()->delete($this->table, $this->identifier());
$this->isDeleted = TRUE;
return $this;
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'ID is not setted for Delete'",
")",
";",
"}",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"table",
",",
"$",
"this",
"->",
"identifier",
"(",
")",
")",
";",
"$",
"this",
"->",
"isDeleted",
"=",
"TRUE",
";",
"return",
"$",
"this",
";",
"}"
] |
Deletes the record.
@return $this
@throws \Exception
|
[
"Deletes",
"the",
"record",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L168-L177
|
20,979 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.identifier
|
public function identifier() {
if (empty($this->record[$this->id_name])) {
return FALSE;
}
return array($this->id_name => $this->record[$this->id_name]);
}
|
php
|
public function identifier() {
if (empty($this->record[$this->id_name])) {
return FALSE;
}
return array($this->id_name => $this->record[$this->id_name]);
}
|
[
"public",
"function",
"identifier",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"record",
"[",
"$",
"this",
"->",
"id_name",
"]",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"return",
"array",
"(",
"$",
"this",
"->",
"id_name",
"=>",
"$",
"this",
"->",
"record",
"[",
"$",
"this",
"->",
"id_name",
"]",
")",
";",
"}"
] |
Provides the Id in array format column-value.
False if is a new object.
@return array|bool
|
[
"Provides",
"the",
"Id",
"in",
"array",
"format",
"column",
"-",
"value",
".",
"False",
"if",
"is",
"a",
"new",
"object",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L207-L213
|
20,980 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.getId
|
public function getId() {
if (empty($this->record[$this->id_name])) {
return FALSE;
}
return $this->record[$this->id_name];
}
|
php
|
public function getId() {
if (empty($this->record[$this->id_name])) {
return FALSE;
}
return $this->record[$this->id_name];
}
|
[
"public",
"function",
"getId",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"record",
"[",
"$",
"this",
"->",
"id_name",
"]",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"return",
"$",
"this",
"->",
"record",
"[",
"$",
"this",
"->",
"id_name",
"]",
";",
"}"
] |
Gets the ID value or false.
@return mixed ID Value or false.
|
[
"Gets",
"the",
"ID",
"value",
"or",
"false",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L220-L226
|
20,981 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.setRecord
|
public function setRecord($record) {
$this->resetObject();
$newRecord = array();
foreach ($this->fields as $field_name => $field) {
if (!empty($record[$field_name])) {
$newRecord[$field_name] = $record[$field_name];
}
else {
$newRecord[$field_name] = ''; //Adds the field but with empty string.
}
}
$this->record = $newRecord;
$this->fetchedRecord = $record;
return $this;
}
|
php
|
public function setRecord($record) {
$this->resetObject();
$newRecord = array();
foreach ($this->fields as $field_name => $field) {
if (!empty($record[$field_name])) {
$newRecord[$field_name] = $record[$field_name];
}
else {
$newRecord[$field_name] = ''; //Adds the field but with empty string.
}
}
$this->record = $newRecord;
$this->fetchedRecord = $record;
return $this;
}
|
[
"public",
"function",
"setRecord",
"(",
"$",
"record",
")",
"{",
"$",
"this",
"->",
"resetObject",
"(",
")",
";",
"$",
"newRecord",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field_name",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"record",
"[",
"$",
"field_name",
"]",
")",
")",
"{",
"$",
"newRecord",
"[",
"$",
"field_name",
"]",
"=",
"$",
"record",
"[",
"$",
"field_name",
"]",
";",
"}",
"else",
"{",
"$",
"newRecord",
"[",
"$",
"field_name",
"]",
"=",
"''",
";",
"//Adds the field but with empty string.",
"}",
"}",
"$",
"this",
"->",
"record",
"=",
"$",
"newRecord",
";",
"$",
"this",
"->",
"fetchedRecord",
"=",
"$",
"record",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the internal record with a new record.
@param $record
@return \Towel\Model\BaseModel
|
[
"Sets",
"the",
"internal",
"record",
"with",
"a",
"new",
"record",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L244-L259
|
20,982 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.mergeRecord
|
public function mergeRecord($record) {
if ($this->isNew()) {
throw new \Exception('Can not merge, is new');
}
foreach ($this->fields as $field_name => $field) {
if (!empty($record[$field_name])) {
$this->record[$field_name] = $record[$field_name];
}
$this->isDirty = TRUE;
}
return $this;
}
|
php
|
public function mergeRecord($record) {
if ($this->isNew()) {
throw new \Exception('Can not merge, is new');
}
foreach ($this->fields as $field_name => $field) {
if (!empty($record[$field_name])) {
$this->record[$field_name] = $record[$field_name];
}
$this->isDirty = TRUE;
}
return $this;
}
|
[
"public",
"function",
"mergeRecord",
"(",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Can not merge, is new'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field_name",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"record",
"[",
"$",
"field_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"record",
"[",
"$",
"field_name",
"]",
"=",
"$",
"record",
"[",
"$",
"field_name",
"]",
";",
"}",
"$",
"this",
"->",
"isDirty",
"=",
"TRUE",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Update partial values of the record and keep the current
non modified values.
@param $record
@return $this
@throws \Exception
|
[
"Update",
"partial",
"values",
"of",
"the",
"record",
"and",
"keep",
"the",
"current",
"non",
"modified",
"values",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L270-L282
|
20,983 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.fetchOne
|
public function fetchOne($sql, $params = array()) {
$result = $this->db()->fetchAssoc($sql, $params);
if (!empty($result)) {
$this->setRecord($result);
return $this;
}
return FALSE;
}
|
php
|
public function fetchOne($sql, $params = array()) {
$result = $this->db()->fetchAssoc($sql, $params);
if (!empty($result)) {
$this->setRecord($result);
return $this;
}
return FALSE;
}
|
[
"public",
"function",
"fetchOne",
"(",
"$",
"sql",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"fetchAssoc",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"setRecord",
"(",
"$",
"result",
")",
";",
"return",
"$",
"this",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Fetchs one record with the given query.
If success sets the record in the current object and return $this.
If fails return false.
@param $sql
@param $params
@return The current instance with the record setted internally.
|
[
"Fetchs",
"one",
"record",
"with",
"the",
"given",
"query",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L304-L314
|
20,984 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.hydrate
|
public function hydrate(PDOStatement $results) {
if (method_exists($this, 'preHydrate')) {
$results = $this->preHydrate($results);
}
$return = array();
if ($results) {
$arrayResults = $results->fetchAll();
foreach ($arrayResults as $arrayResult) {
$className = get_class($this);
$object = new $className();
$return[$arrayResult[$this->id_name]] = $object->setRecord($arrayResult);
}
}
if (method_exists($this, 'postHydrate')) {
$return = $this->preHydrate($return);
}
return $return;
}
|
php
|
public function hydrate(PDOStatement $results) {
if (method_exists($this, 'preHydrate')) {
$results = $this->preHydrate($results);
}
$return = array();
if ($results) {
$arrayResults = $results->fetchAll();
foreach ($arrayResults as $arrayResult) {
$className = get_class($this);
$object = new $className();
$return[$arrayResult[$this->id_name]] = $object->setRecord($arrayResult);
}
}
if (method_exists($this, 'postHydrate')) {
$return = $this->preHydrate($return);
}
return $return;
}
|
[
"public",
"function",
"hydrate",
"(",
"PDOStatement",
"$",
"results",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'preHydrate'",
")",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"preHydrate",
"(",
"$",
"results",
")",
";",
"}",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"results",
")",
"{",
"$",
"arrayResults",
"=",
"$",
"results",
"->",
"fetchAll",
"(",
")",
";",
"foreach",
"(",
"$",
"arrayResults",
"as",
"$",
"arrayResult",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"object",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"return",
"[",
"$",
"arrayResult",
"[",
"$",
"this",
"->",
"id_name",
"]",
"]",
"=",
"$",
"object",
"->",
"setRecord",
"(",
"$",
"arrayResult",
")",
";",
"}",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'postHydrate'",
")",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"preHydrate",
"(",
"$",
"return",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Default Hydrate.
Use preHydrate and postHydrate methods to change the default behavior.
You can override this method too if you need.
@param PDOStatement $results
@return Array of Model Objects
|
[
"Default",
"Hydrate",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L400-L422
|
20,985 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.findRelatedModel
|
public function findRelatedModel($modelName, $field, $id = NULL) {
$relatedModel = $this->getInstance($modelName);
if ($this->isNew() && $id === NULL) {
throw new \Exception('No id for related');
}
if ($id === NULL) {
$id = $this->getField($field);
}
$result = $relatedModel->findById($id);
return $result;
}
|
php
|
public function findRelatedModel($modelName, $field, $id = NULL) {
$relatedModel = $this->getInstance($modelName);
if ($this->isNew() && $id === NULL) {
throw new \Exception('No id for related');
}
if ($id === NULL) {
$id = $this->getField($field);
}
$result = $relatedModel->findById($id);
return $result;
}
|
[
"public",
"function",
"findRelatedModel",
"(",
"$",
"modelName",
",",
"$",
"field",
",",
"$",
"id",
"=",
"NULL",
")",
"{",
"$",
"relatedModel",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"$",
"modelName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"$",
"id",
"===",
"NULL",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No id for related'",
")",
";",
"}",
"if",
"(",
"$",
"id",
"===",
"NULL",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"field",
")",
";",
"}",
"$",
"result",
"=",
"$",
"relatedModel",
"->",
"findById",
"(",
"$",
"id",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Finds a related model instance by the given field name and the id value.
Use it in a 1 to N relation, with an object instance of the N side to the get 1 related model.
@param $modelName : The related model name.
@param $field : The field that must be used to relate.
@param $id : Optional, the ID the related model, if is not given the value of the field in the executor object will be used.
@throws \Exception : if a invalid model is given.
@return Related Instance.
|
[
"Finds",
"a",
"related",
"model",
"instance",
"by",
"the",
"given",
"field",
"name",
"and",
"the",
"id",
"value",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L437-L451
|
20,986 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.findRelatedModels
|
public function findRelatedModels($modelName, $field, $id = NULL) {
$relatedModel = $this->getInstance($modelName);
if ($this->isNew() && $id === NULL) {
throw new \Exception('No id for related');
}
if ($id === NULL) {
$id = $this->getId();
}
$result = $relatedModel->findByField($field, $id);
return $result;
}
|
php
|
public function findRelatedModels($modelName, $field, $id = NULL) {
$relatedModel = $this->getInstance($modelName);
if ($this->isNew() && $id === NULL) {
throw new \Exception('No id for related');
}
if ($id === NULL) {
$id = $this->getId();
}
$result = $relatedModel->findByField($field, $id);
return $result;
}
|
[
"public",
"function",
"findRelatedModels",
"(",
"$",
"modelName",
",",
"$",
"field",
",",
"$",
"id",
"=",
"NULL",
")",
"{",
"$",
"relatedModel",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"$",
"modelName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"$",
"id",
"===",
"NULL",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No id for related'",
")",
";",
"}",
"if",
"(",
"$",
"id",
"===",
"NULL",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"}",
"$",
"result",
"=",
"$",
"relatedModel",
"->",
"findByField",
"(",
"$",
"field",
",",
"$",
"id",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Finds related models instances using the field name and the id value.
Use it in a 1 to N relation, with an object instance of the 1 side to the get N related models.
@param $modelName : The related model name.
@param $field : The field that must be used to relate.
@param $id : Optional, the ID the related model, if is not given the value of the field in the executor object will be used.
@throws \Exception : if a invalid model is given.
@return Related Instance.
|
[
"Finds",
"related",
"models",
"instances",
"using",
"the",
"field",
"name",
"and",
"the",
"id",
"value",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L466-L480
|
20,987 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.plain
|
static public function plain($objects) {
$data = array();
foreach ($objects as $object) {
$data[] = $object->getRecord();
}
return $data;
}
|
php
|
static public function plain($objects) {
$data = array();
foreach ($objects as $object) {
$data[] = $object->getRecord();
}
return $data;
}
|
[
"static",
"public",
"function",
"plain",
"(",
"$",
"objects",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"object",
"->",
"getRecord",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Convert the array of objects into a plain array.
@param $objects
@return array
|
[
"Convert",
"the",
"array",
"of",
"objects",
"into",
"a",
"plain",
"array",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L516-L523
|
20,988 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.createQuery
|
public function createQuery() {
$query = $this->db()->createQueryBuilder();
$query->select('t.*')
->from($this->table, 't');
return $query;
}
|
php
|
public function createQuery() {
$query = $this->db()->createQueryBuilder();
$query->select('t.*')
->from($this->table, 't');
return $query;
}
|
[
"public",
"function",
"createQuery",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"db",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'t.*'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"table",
",",
"'t'",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Creates a QueryBuilder with the table selected.
@return \Doctrine\DBAL\Query\QueryBuilder
|
[
"Creates",
"a",
"QueryBuilder",
"with",
"the",
"table",
"selected",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L530-L536
|
20,989 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.findAllPaged
|
public function findAllPaged($page = 0, $limit = 20) {
$results = $this->findAllWithoutFetchPaged($page, $limit);
$return = $this->hydrate($results);
return $return;
}
|
php
|
public function findAllPaged($page = 0, $limit = 20) {
$results = $this->findAllWithoutFetchPaged($page, $limit);
$return = $this->hydrate($results);
return $return;
}
|
[
"public",
"function",
"findAllPaged",
"(",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"20",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"findAllWithoutFetchPaged",
"(",
"$",
"page",
",",
"$",
"limit",
")",
";",
"$",
"return",
"=",
"$",
"this",
"->",
"hydrate",
"(",
"$",
"results",
")",
";",
"return",
"$",
"return",
";",
"}"
] |
Finds all records of a table paged.
@param int $page
@param int $limit
@return mixed : Array with results.
|
[
"Finds",
"all",
"records",
"of",
"a",
"table",
"paged",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L556-L561
|
20,990 |
42mate/towel
|
src/Towel/Model/BaseModel.php
|
BaseModel.findAllWithoutFetchPaged
|
public function findAllWithoutFetchPaged($page = 0, $limit = 20) {
$offset = $page * $limit;
$results = $this->createQuery()
->setFirstResult($offset)
->setMaxResults($limit)
->execute();
return $results;
}
|
php
|
public function findAllWithoutFetchPaged($page = 0, $limit = 20) {
$offset = $page * $limit;
$results = $this->createQuery()
->setFirstResult($offset)
->setMaxResults($limit)
->execute();
return $results;
}
|
[
"public",
"function",
"findAllWithoutFetchPaged",
"(",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"20",
")",
"{",
"$",
"offset",
"=",
"$",
"page",
"*",
"$",
"limit",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"createQuery",
"(",
")",
"->",
"setFirstResult",
"(",
"$",
"offset",
")",
"->",
"setMaxResults",
"(",
"$",
"limit",
")",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Finds all records of a table.
@param int $page
@param int $limit
@return mixed : PDOStatement with results.
|
[
"Finds",
"all",
"records",
"of",
"a",
"table",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Model/BaseModel.php#L572-L579
|
20,991 |
ShaoZeMing/laravel-merchant
|
src/Form.php
|
Form.redirectAfterUpdate
|
protected function redirectAfterUpdate()
{
merchant_toastr(trans('merchant.update_succeeded'));
$url = Input::get(Builder::PREVIOUS_URL_KEY) ?: $this->resource(-1);
return redirect($url);
}
|
php
|
protected function redirectAfterUpdate()
{
merchant_toastr(trans('merchant.update_succeeded'));
$url = Input::get(Builder::PREVIOUS_URL_KEY) ?: $this->resource(-1);
return redirect($url);
}
|
[
"protected",
"function",
"redirectAfterUpdate",
"(",
")",
"{",
"merchant_toastr",
"(",
"trans",
"(",
"'merchant.update_succeeded'",
")",
")",
";",
"$",
"url",
"=",
"Input",
"::",
"get",
"(",
"Builder",
"::",
"PREVIOUS_URL_KEY",
")",
"?",
":",
"$",
"this",
"->",
"resource",
"(",
"-",
"1",
")",
";",
"return",
"redirect",
"(",
"$",
"url",
")",
";",
"}"
] |
Get RedirectResponse after update.
@return \Illuminate\Http\RedirectResponse
|
[
"Get",
"RedirectResponse",
"after",
"update",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form.php#L559-L566
|
20,992 |
Humanized/yii2-location
|
controllers/AdminController.php
|
AdminController.actionIndex
|
public function actionIndex()
{
$model = new Location();
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
$model = new Location(); //reset model
}
$searchModel = new LocationSearch(['pagination' => TRUE]);
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'model' => $model,
]);
}
|
php
|
public function actionIndex()
{
$model = new Location();
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
$model = new Location(); //reset model
}
$searchModel = new LocationSearch(['pagination' => TRUE]);
$dataProvider = $searchModel->search(\Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'model' => $model,
]);
}
|
[
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"Location",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"$",
"model",
"=",
"new",
"Location",
"(",
")",
";",
"//reset model",
"}",
"$",
"searchModel",
"=",
"new",
"LocationSearch",
"(",
"[",
"'pagination'",
"=>",
"TRUE",
"]",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParams",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] |
Lists all Location models.
@return mixed
|
[
"Lists",
"all",
"Location",
"models",
"."
] |
48ac12ceab741fc4c82ac8e979415a11bf9175f2
|
https://github.com/Humanized/yii2-location/blob/48ac12ceab741fc4c82ac8e979415a11bf9175f2/controllers/AdminController.php#L38-L53
|
20,993 |
raideer/twitch-api
|
src/Resources/Resource.php
|
Resource.resolveOptions
|
public function resolveOptions($options, $defaults, $required = [], $allowedTypes = [])
{
$resolver = new OptionsResolver();
$resolver->setDefaults($defaults);
if (!empty($required)) {
$resolver->setRequired($required);
}
if (!empty($allowedTypes)) {
foreach ($allowedTypes as $type => $value) {
$resolver->setAllowedValues($type, $value);
}
}
return $resolver->resolve($options);
}
|
php
|
public function resolveOptions($options, $defaults, $required = [], $allowedTypes = [])
{
$resolver = new OptionsResolver();
$resolver->setDefaults($defaults);
if (!empty($required)) {
$resolver->setRequired($required);
}
if (!empty($allowedTypes)) {
foreach ($allowedTypes as $type => $value) {
$resolver->setAllowedValues($type, $value);
}
}
return $resolver->resolve($options);
}
|
[
"public",
"function",
"resolveOptions",
"(",
"$",
"options",
",",
"$",
"defaults",
",",
"$",
"required",
"=",
"[",
"]",
",",
"$",
"allowedTypes",
"=",
"[",
"]",
")",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"resolver",
"->",
"setDefaults",
"(",
"$",
"defaults",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"required",
")",
")",
"{",
"$",
"resolver",
"->",
"setRequired",
"(",
"$",
"required",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"allowedTypes",
")",
")",
"{",
"foreach",
"(",
"$",
"allowedTypes",
"as",
"$",
"type",
"=>",
"$",
"value",
")",
"{",
"$",
"resolver",
"->",
"setAllowedValues",
"(",
"$",
"type",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"resolver",
"->",
"resolve",
"(",
"$",
"options",
")",
";",
"}"
] |
Helper function for resolving parameters.
@param array $options Passed params
@param array $defaults Default values
@param array $required Required fields
@param array $allowedTypes Allowed field values
@return array
|
[
"Helper",
"function",
"for",
"resolving",
"parameters",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Resource.php#L45-L61
|
20,994 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Shipping.php
|
Shipping.setSeller
|
public function setSeller(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Seller $seller = null)
{
$this->seller = $seller;
return $this;
}
|
php
|
public function setSeller(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Seller $seller = null)
{
$this->seller = $seller;
return $this;
}
|
[
"public",
"function",
"setSeller",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Seller",
"$",
"seller",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"seller",
"=",
"$",
"seller",
";",
"return",
"$",
"this",
";",
"}"
] |
Set seller.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Seller $seller
@return Shipping
|
[
"Set",
"seller",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L685-L690
|
20,995 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Shipping.php
|
Shipping.addProduct
|
public function addProduct(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product)
{
$this->products[] = $product;
return $this;
}
|
php
|
public function addProduct(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product)
{
$this->products[] = $product;
return $this;
}
|
[
"public",
"function",
"addProduct",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Product",
"\\",
"Product",
"$",
"product",
")",
"{",
"$",
"this",
"->",
"products",
"[",
"]",
"=",
"$",
"product",
";",
"return",
"$",
"this",
";",
"}"
] |
Add product.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product
@return Shipping
|
[
"Add",
"product",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L709-L714
|
20,996 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Shipping.php
|
Shipping.removeProduct
|
public function removeProduct(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product)
{
return $this->products->removeElement($product);
}
|
php
|
public function removeProduct(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product)
{
return $this->products->removeElement($product);
}
|
[
"public",
"function",
"removeProduct",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Product",
"\\",
"Product",
"$",
"product",
")",
"{",
"return",
"$",
"this",
"->",
"products",
"->",
"removeElement",
"(",
"$",
"product",
")",
";",
"}"
] |
Remove product.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product
@return bool TRUE if this collection contained the specified element, FALSE otherwise
|
[
"Remove",
"product",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L723-L726
|
20,997 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Shipping.php
|
Shipping.addTransport
|
public function addTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
{
$this->transports[] = $transport;
return $this;
}
|
php
|
public function addTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
{
$this->transports[] = $transport;
return $this;
}
|
[
"public",
"function",
"addTransport",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Transport",
"\\",
"Transport",
"$",
"transport",
")",
"{",
"$",
"this",
"->",
"transports",
"[",
"]",
"=",
"$",
"transport",
";",
"return",
"$",
"this",
";",
"}"
] |
Add transport.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport
@return Shipping
|
[
"Add",
"transport",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L745-L750
|
20,998 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Shipping.php
|
Shipping.removeTransport
|
public function removeTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
{
return $this->transports->removeElement($transport);
}
|
php
|
public function removeTransport(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport)
{
return $this->transports->removeElement($transport);
}
|
[
"public",
"function",
"removeTransport",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Transport",
"\\",
"Transport",
"$",
"transport",
")",
"{",
"return",
"$",
"this",
"->",
"transports",
"->",
"removeElement",
"(",
"$",
"transport",
")",
";",
"}"
] |
Remove transport.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Transport\Transport $transport
@return bool TRUE if this collection contained the specified element, FALSE otherwise
|
[
"Remove",
"transport",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L759-L762
|
20,999 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Shipping.php
|
Shipping.addInvoice
|
public function addInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
{
$this->invoices[] = $invoice;
return $this;
}
|
php
|
public function addInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
{
$this->invoices[] = $invoice;
return $this;
}
|
[
"public",
"function",
"addInvoice",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Invoice",
"\\",
"Invoice",
"$",
"invoice",
")",
"{",
"$",
"this",
"->",
"invoices",
"[",
"]",
"=",
"$",
"invoice",
";",
"return",
"$",
"this",
";",
"}"
] |
Add invoice.
@param \Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice
@return Shipping
|
[
"Add",
"invoice",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Shipping.php#L781-L786
|
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.