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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
224,700
|
acacha/users
|
src/Observers/UserObserver.php
|
UserObserver.deleted
|
public function deleted(User $user)
{
\DB::table((new Revision())->getTable())->insert([
[
'revisionable_type' => $user->getMorphClass(),
'revisionable_id' => $user->id,
'key' => 'deleted_at',
'old_value' => $user,
'new_value' => new \DateTime(),
'user_id' => (\Auth::check() ? \Auth::user()->id : null),
'created_at' => new \DateTime(),
'updated_at' => new \DateTime(),
]
]);
}
|
php
|
public function deleted(User $user)
{
\DB::table((new Revision())->getTable())->insert([
[
'revisionable_type' => $user->getMorphClass(),
'revisionable_id' => $user->id,
'key' => 'deleted_at',
'old_value' => $user,
'new_value' => new \DateTime(),
'user_id' => (\Auth::check() ? \Auth::user()->id : null),
'created_at' => new \DateTime(),
'updated_at' => new \DateTime(),
]
]);
}
|
[
"public",
"function",
"deleted",
"(",
"User",
"$",
"user",
")",
"{",
"\\",
"DB",
"::",
"table",
"(",
"(",
"new",
"Revision",
"(",
")",
")",
"->",
"getTable",
"(",
")",
")",
"->",
"insert",
"(",
"[",
"[",
"'revisionable_type'",
"=>",
"$",
"user",
"->",
"getMorphClass",
"(",
")",
",",
"'revisionable_id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'key'",
"=>",
"'deleted_at'",
",",
"'old_value'",
"=>",
"$",
"user",
",",
"'new_value'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"'user_id'",
"=>",
"(",
"\\",
"Auth",
"::",
"check",
"(",
")",
"?",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"id",
":",
"null",
")",
",",
"'created_at'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"'updated_at'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"]",
"]",
")",
";",
"}"
] |
Listen to the User deleted event.
|
[
"Listen",
"to",
"the",
"User",
"deleted",
"event",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Observers/UserObserver.php#L28-L42
|
224,701
|
atorscho/membership
|
src/Handlable.php
|
Handlable.bootHandlable
|
protected static function bootHandlable()
{
static::creating(function ($model) {
if (!$model->handle) {
$model->handle = '';
}
});
static::updating(function ($model) {
if (!$model->handle) {
$model->handle = '';
}
});
}
|
php
|
protected static function bootHandlable()
{
static::creating(function ($model) {
if (!$model->handle) {
$model->handle = '';
}
});
static::updating(function ($model) {
if (!$model->handle) {
$model->handle = '';
}
});
}
|
[
"protected",
"static",
"function",
"bootHandlable",
"(",
")",
"{",
"static",
"::",
"creating",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"->",
"handle",
")",
"{",
"$",
"model",
"->",
"handle",
"=",
"''",
";",
"}",
"}",
")",
";",
"static",
"::",
"updating",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"->",
"handle",
")",
"{",
"$",
"model",
"->",
"handle",
"=",
"''",
";",
"}",
"}",
")",
";",
"}"
] |
Set the handle if missing.
|
[
"Set",
"the",
"handle",
"if",
"missing",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Handlable.php#L19-L32
|
224,702
|
atorscho/membership
|
src/Handlable.php
|
Handlable.setHandleAttribute
|
public function setHandleAttribute(?string $handle): void
{
$this->attributes['handle'] = str_slug($handle ?: $this->name);
}
|
php
|
public function setHandleAttribute(?string $handle): void
{
$this->attributes['handle'] = str_slug($handle ?: $this->name);
}
|
[
"public",
"function",
"setHandleAttribute",
"(",
"?",
"string",
"$",
"handle",
")",
":",
"void",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'handle'",
"]",
"=",
"str_slug",
"(",
"$",
"handle",
"?",
":",
"$",
"this",
"->",
"name",
")",
";",
"}"
] |
Set model's handle if none was provided.
|
[
"Set",
"model",
"s",
"handle",
"if",
"none",
"was",
"provided",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Handlable.php#L37-L40
|
224,703
|
fojuth/plupload
|
src/Fojuth/Plupload/TwigExtension.php
|
TwigExtension.getFunctions
|
public function getFunctions() {
return [
new Twig_SimpleFunction(
'plupload',
function($view = null, $browse_button = null, $prefix = null, $additional_data = array()){
$view = (true === is_null($view)) ? \Config::get('plupload::plupload.view') : $view;
$prefix = (true === is_null($prefix)) ? 'plupload_'.uniqid() : $prefix;
$browse_button = (true === is_null($browse_button)) ? $prefix.'_browse' : $browse_button;
return \View::make($view, array(
'upload_handler' => \Config::get('plupload::plupload.upload_handler'),
'browse_button_id' => $browse_button,
'prefix' => $prefix,
'handler_gate' => \Config::get('plupload::plupload.upload_handler_gate'),
'max_file_size' => \Config::get('plupload::plupload.max_file_size'),
'additional_data' => $additional_data,
));
}
)
];
}
|
php
|
public function getFunctions() {
return [
new Twig_SimpleFunction(
'plupload',
function($view = null, $browse_button = null, $prefix = null, $additional_data = array()){
$view = (true === is_null($view)) ? \Config::get('plupload::plupload.view') : $view;
$prefix = (true === is_null($prefix)) ? 'plupload_'.uniqid() : $prefix;
$browse_button = (true === is_null($browse_button)) ? $prefix.'_browse' : $browse_button;
return \View::make($view, array(
'upload_handler' => \Config::get('plupload::plupload.upload_handler'),
'browse_button_id' => $browse_button,
'prefix' => $prefix,
'handler_gate' => \Config::get('plupload::plupload.upload_handler_gate'),
'max_file_size' => \Config::get('plupload::plupload.max_file_size'),
'additional_data' => $additional_data,
));
}
)
];
}
|
[
"public",
"function",
"getFunctions",
"(",
")",
"{",
"return",
"[",
"new",
"Twig_SimpleFunction",
"(",
"'plupload'",
",",
"function",
"(",
"$",
"view",
"=",
"null",
",",
"$",
"browse_button",
"=",
"null",
",",
"$",
"prefix",
"=",
"null",
",",
"$",
"additional_data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"view",
"=",
"(",
"true",
"===",
"is_null",
"(",
"$",
"view",
")",
")",
"?",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.view'",
")",
":",
"$",
"view",
";",
"$",
"prefix",
"=",
"(",
"true",
"===",
"is_null",
"(",
"$",
"prefix",
")",
")",
"?",
"'plupload_'",
".",
"uniqid",
"(",
")",
":",
"$",
"prefix",
";",
"$",
"browse_button",
"=",
"(",
"true",
"===",
"is_null",
"(",
"$",
"browse_button",
")",
")",
"?",
"$",
"prefix",
".",
"'_browse'",
":",
"$",
"browse_button",
";",
"return",
"\\",
"View",
"::",
"make",
"(",
"$",
"view",
",",
"array",
"(",
"'upload_handler'",
"=>",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.upload_handler'",
")",
",",
"'browse_button_id'",
"=>",
"$",
"browse_button",
",",
"'prefix'",
"=>",
"$",
"prefix",
",",
"'handler_gate'",
"=>",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.upload_handler_gate'",
")",
",",
"'max_file_size'",
"=>",
"\\",
"Config",
"::",
"get",
"(",
"'plupload::plupload.max_file_size'",
")",
",",
"'additional_data'",
"=>",
"$",
"additional_data",
",",
")",
")",
";",
"}",
")",
"]",
";",
"}"
] |
Registers the Twig functions.
|
[
"Registers",
"the",
"Twig",
"functions",
"."
] |
9d27e62516761352863cd08b7a2342326d69dd5c
|
https://github.com/fojuth/plupload/blob/9d27e62516761352863cd08b7a2342326d69dd5c/src/Fojuth/Plupload/TwigExtension.php#L22-L43
|
224,704
|
JeroenBoersma/php-normalize
|
src/Normalize.php
|
Normalize.normalize
|
public function normalize(string $string) : string
{
if (isset($this->cache[$string])) {
return $this->cache[$string];
}
$result = $this->normalizeChain($string);
$toCache = array_map(function(RuleInterface $rule) use (&$result) {
return $result = $rule->apply($result);
}, $this->rules);
// Add cache for variants
array_map(function($index) use ($result) {
$this->cache[$index] = $result;
}, $toCache);
$this->cache[$string] = $result;
return $result;
}
|
php
|
public function normalize(string $string) : string
{
if (isset($this->cache[$string])) {
return $this->cache[$string];
}
$result = $this->normalizeChain($string);
$toCache = array_map(function(RuleInterface $rule) use (&$result) {
return $result = $rule->apply($result);
}, $this->rules);
// Add cache for variants
array_map(function($index) use ($result) {
$this->cache[$index] = $result;
}, $toCache);
$this->cache[$string] = $result;
return $result;
}
|
[
"public",
"function",
"normalize",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"string",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"string",
"]",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"normalizeChain",
"(",
"$",
"string",
")",
";",
"$",
"toCache",
"=",
"array_map",
"(",
"function",
"(",
"RuleInterface",
"$",
"rule",
")",
"use",
"(",
"&",
"$",
"result",
")",
"{",
"return",
"$",
"result",
"=",
"$",
"rule",
"->",
"apply",
"(",
"$",
"result",
")",
";",
"}",
",",
"$",
"this",
"->",
"rules",
")",
";",
"// Add cache for variants",
"array_map",
"(",
"function",
"(",
"$",
"index",
")",
"use",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"$",
"index",
"]",
"=",
"$",
"result",
";",
"}",
",",
"$",
"toCache",
")",
";",
"$",
"this",
"->",
"cache",
"[",
"$",
"string",
"]",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] |
Return normalized string
@param string $string
@return string
|
[
"Return",
"normalized",
"string"
] |
254fdcc50bfd8cbf3eba8dae93439c07e28e0396
|
https://github.com/JeroenBoersma/php-normalize/blob/254fdcc50bfd8cbf3eba8dae93439c07e28e0396/src/Normalize.php#L47-L66
|
224,705
|
JeroenBoersma/php-normalize
|
src/Normalize.php
|
Normalize.normalizeChain
|
protected function normalizeChain(string $string): string
{
if (null === $this->chain) {
return $string;
}
return $this->chain
->normalize($string);
}
|
php
|
protected function normalizeChain(string $string): string
{
if (null === $this->chain) {
return $string;
}
return $this->chain
->normalize($string);
}
|
[
"protected",
"function",
"normalizeChain",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"chain",
")",
"{",
"return",
"$",
"string",
";",
"}",
"return",
"$",
"this",
"->",
"chain",
"->",
"normalize",
"(",
"$",
"string",
")",
";",
"}"
] |
Normalize parent if exists
@param string $string
@return string
|
[
"Normalize",
"parent",
"if",
"exists"
] |
254fdcc50bfd8cbf3eba8dae93439c07e28e0396
|
https://github.com/JeroenBoersma/php-normalize/blob/254fdcc50bfd8cbf3eba8dae93439c07e28e0396/src/Normalize.php#L74-L82
|
224,706
|
acacha/users
|
src/Http/Controllers/RevisionableController.php
|
RevisionableController.trackModel
|
public function trackModel(TrackModelRequest $request)
{
$model = $request->input('model');
$revisions = Revision::where(['revisionable_type' => $model])
->orderBy('created_at','desv')->get();
$result = [];
$lastDate = '';
foreach ($revisions as $revision) {
$date = $revision->created_at->toDateString();
if ($lastDate != $date) {
$result[] = [
'time' => $revision->created_at->toDateString(),
'type' => 'time-label'
];
}
$result[] = [
'time' => $revision->created_at->toTimeString(),
'icon' => 'fa-user',
'iconBackground' => $this->getIconBackground($revision),
'header' => $this->getMessage($revision)
];
$lastDate = $date;
}
return $result;
}
|
php
|
public function trackModel(TrackModelRequest $request)
{
$model = $request->input('model');
$revisions = Revision::where(['revisionable_type' => $model])
->orderBy('created_at','desv')->get();
$result = [];
$lastDate = '';
foreach ($revisions as $revision) {
$date = $revision->created_at->toDateString();
if ($lastDate != $date) {
$result[] = [
'time' => $revision->created_at->toDateString(),
'type' => 'time-label'
];
}
$result[] = [
'time' => $revision->created_at->toTimeString(),
'icon' => 'fa-user',
'iconBackground' => $this->getIconBackground($revision),
'header' => $this->getMessage($revision)
];
$lastDate = $date;
}
return $result;
}
|
[
"public",
"function",
"trackModel",
"(",
"TrackModelRequest",
"$",
"request",
")",
"{",
"$",
"model",
"=",
"$",
"request",
"->",
"input",
"(",
"'model'",
")",
";",
"$",
"revisions",
"=",
"Revision",
"::",
"where",
"(",
"[",
"'revisionable_type'",
"=>",
"$",
"model",
"]",
")",
"->",
"orderBy",
"(",
"'created_at'",
",",
"'desv'",
")",
"->",
"get",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"lastDate",
"=",
"''",
";",
"foreach",
"(",
"$",
"revisions",
"as",
"$",
"revision",
")",
"{",
"$",
"date",
"=",
"$",
"revision",
"->",
"created_at",
"->",
"toDateString",
"(",
")",
";",
"if",
"(",
"$",
"lastDate",
"!=",
"$",
"date",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"[",
"'time'",
"=>",
"$",
"revision",
"->",
"created_at",
"->",
"toDateString",
"(",
")",
",",
"'type'",
"=>",
"'time-label'",
"]",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"[",
"'time'",
"=>",
"$",
"revision",
"->",
"created_at",
"->",
"toTimeString",
"(",
")",
",",
"'icon'",
"=>",
"'fa-user'",
",",
"'iconBackground'",
"=>",
"$",
"this",
"->",
"getIconBackground",
"(",
"$",
"revision",
")",
",",
"'header'",
"=>",
"$",
"this",
"->",
"getMessage",
"(",
"$",
"revision",
")",
"]",
";",
"$",
"lastDate",
"=",
"$",
"date",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Obtain tracking info for a Model.
@param TrackModelRequest $request
@return array
|
[
"Obtain",
"tracking",
"info",
"for",
"a",
"Model",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/RevisionableController.php#L22-L51
|
224,707
|
acacha/users
|
src/Http/Controllers/RevisionableController.php
|
RevisionableController.getMessage
|
private function getMessage($revision)
{
switch ($revision->key) {
case 'created_at':
return $this->getResponsibleInfo($revision) . ' created user '
. $this->getAffectedResourceName($revision) . ' (' . $revision->revisionable_id . ')';
case 'deleted_at':
return $this->getResponsibleInfo($revision) . ' deleted user '
. $this->getAffectedResourceName($revision) . ' (' . $revision->revisionable_id . ')';
default:
return $this->getResponsibleInfo($revision) . ' changed user '
. $this->getAffectedResourceName($revision) . ' (' . $revision->revisionable_id . ')'
. ' field ' . $revision->fieldName() . ' from ' .$revision->oldValue() . ' to ' .
$revision->newValue();
}
}
|
php
|
private function getMessage($revision)
{
switch ($revision->key) {
case 'created_at':
return $this->getResponsibleInfo($revision) . ' created user '
. $this->getAffectedResourceName($revision) . ' (' . $revision->revisionable_id . ')';
case 'deleted_at':
return $this->getResponsibleInfo($revision) . ' deleted user '
. $this->getAffectedResourceName($revision) . ' (' . $revision->revisionable_id . ')';
default:
return $this->getResponsibleInfo($revision) . ' changed user '
. $this->getAffectedResourceName($revision) . ' (' . $revision->revisionable_id . ')'
. ' field ' . $revision->fieldName() . ' from ' .$revision->oldValue() . ' to ' .
$revision->newValue();
}
}
|
[
"private",
"function",
"getMessage",
"(",
"$",
"revision",
")",
"{",
"switch",
"(",
"$",
"revision",
"->",
"key",
")",
"{",
"case",
"'created_at'",
":",
"return",
"$",
"this",
"->",
"getResponsibleInfo",
"(",
"$",
"revision",
")",
".",
"' created user '",
".",
"$",
"this",
"->",
"getAffectedResourceName",
"(",
"$",
"revision",
")",
".",
"' ('",
".",
"$",
"revision",
"->",
"revisionable_id",
".",
"')'",
";",
"case",
"'deleted_at'",
":",
"return",
"$",
"this",
"->",
"getResponsibleInfo",
"(",
"$",
"revision",
")",
".",
"' deleted user '",
".",
"$",
"this",
"->",
"getAffectedResourceName",
"(",
"$",
"revision",
")",
".",
"' ('",
".",
"$",
"revision",
"->",
"revisionable_id",
".",
"')'",
";",
"default",
":",
"return",
"$",
"this",
"->",
"getResponsibleInfo",
"(",
"$",
"revision",
")",
".",
"' changed user '",
".",
"$",
"this",
"->",
"getAffectedResourceName",
"(",
"$",
"revision",
")",
".",
"' ('",
".",
"$",
"revision",
"->",
"revisionable_id",
".",
"')'",
".",
"' field '",
".",
"$",
"revision",
"->",
"fieldName",
"(",
")",
".",
"' from '",
".",
"$",
"revision",
"->",
"oldValue",
"(",
")",
".",
"' to '",
".",
"$",
"revision",
"->",
"newValue",
"(",
")",
";",
"}",
"}"
] |
Get icon background.
@param $revision
@return string
|
[
"Get",
"icon",
"background",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/RevisionableController.php#L59-L74
|
224,708
|
acacha/users
|
src/Http/Controllers/RevisionableController.php
|
RevisionableController.getResponsibleInfo
|
private function getResponsibleInfo($revision)
{
$username = $this->getResponsibleUsername($revision);
return '<span title="'. $username . ' (' . $revision->user_id . ')' . '" class="responsibleUser"
model="' . $revision->revisionable_type . '">' . $username . '</span>';
}
|
php
|
private function getResponsibleInfo($revision)
{
$username = $this->getResponsibleUsername($revision);
return '<span title="'. $username . ' (' . $revision->user_id . ')' . '" class="responsibleUser"
model="' . $revision->revisionable_type . '">' . $username . '</span>';
}
|
[
"private",
"function",
"getResponsibleInfo",
"(",
"$",
"revision",
")",
"{",
"$",
"username",
"=",
"$",
"this",
"->",
"getResponsibleUsername",
"(",
"$",
"revision",
")",
";",
"return",
"'<span title=\"'",
".",
"$",
"username",
".",
"' ('",
".",
"$",
"revision",
"->",
"user_id",
".",
"')'",
".",
"'\" class=\"responsibleUser\" \n model=\"'",
".",
"$",
"revision",
"->",
"revisionable_type",
".",
"'\">'",
".",
"$",
"username",
".",
"'</span>'",
";",
"}"
] |
Get responsible info.
@param $revision
@return string
|
[
"Get",
"responsible",
"info",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/RevisionableController.php#L82-L87
|
224,709
|
acacha/users
|
src/Http/Controllers/RevisionableController.php
|
RevisionableController.getAffectedResourceName
|
private function getAffectedResourceName($revision)
{
if ($revision->historyOf()) {
return $revision->historyOf()->name;
}
if ($revision->key == 'deleted_at') {
$oldUser = json_decode($revision->old_value);
if($oldUser) {
return $oldUser->name;
}
}
return 'Non existing user';
}
|
php
|
private function getAffectedResourceName($revision)
{
if ($revision->historyOf()) {
return $revision->historyOf()->name;
}
if ($revision->key == 'deleted_at') {
$oldUser = json_decode($revision->old_value);
if($oldUser) {
return $oldUser->name;
}
}
return 'Non existing user';
}
|
[
"private",
"function",
"getAffectedResourceName",
"(",
"$",
"revision",
")",
"{",
"if",
"(",
"$",
"revision",
"->",
"historyOf",
"(",
")",
")",
"{",
"return",
"$",
"revision",
"->",
"historyOf",
"(",
")",
"->",
"name",
";",
"}",
"if",
"(",
"$",
"revision",
"->",
"key",
"==",
"'deleted_at'",
")",
"{",
"$",
"oldUser",
"=",
"json_decode",
"(",
"$",
"revision",
"->",
"old_value",
")",
";",
"if",
"(",
"$",
"oldUser",
")",
"{",
"return",
"$",
"oldUser",
"->",
"name",
";",
"}",
"}",
"return",
"'Non existing user'",
";",
"}"
] |
Get affected resource name.
@param $revision
@return string
|
[
"Get",
"affected",
"resource",
"name",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/RevisionableController.php#L109-L121
|
224,710
|
burnbright/silverstripe-importexport
|
code/CSVPreviewer.php
|
CSVPreviewer.loadCSV
|
public function loadCSV()
{
$parser = new CSVParser($this->file);
$count = 0;
foreach ($parser as $row) {
$this->rows[]= $row;
$count++;
if ($count == $this->previewcount) {
break;
}
}
$firstrow = array_keys($this->rows[0]);
//hack to include first row as a
array_unshift($this->rows, array_combine($firstrow, $firstrow));
if (count($this->rows) > 0) {
$this->headings = $firstrow;
}
}
|
php
|
public function loadCSV()
{
$parser = new CSVParser($this->file);
$count = 0;
foreach ($parser as $row) {
$this->rows[]= $row;
$count++;
if ($count == $this->previewcount) {
break;
}
}
$firstrow = array_keys($this->rows[0]);
//hack to include first row as a
array_unshift($this->rows, array_combine($firstrow, $firstrow));
if (count($this->rows) > 0) {
$this->headings = $firstrow;
}
}
|
[
"public",
"function",
"loadCSV",
"(",
")",
"{",
"$",
"parser",
"=",
"new",
"CSVParser",
"(",
"$",
"this",
"->",
"file",
")",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"parser",
"as",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"rows",
"[",
"]",
"=",
"$",
"row",
";",
"$",
"count",
"++",
";",
"if",
"(",
"$",
"count",
"==",
"$",
"this",
"->",
"previewcount",
")",
"{",
"break",
";",
"}",
"}",
"$",
"firstrow",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"rows",
"[",
"0",
"]",
")",
";",
"//hack to include first row as a",
"array_unshift",
"(",
"$",
"this",
"->",
"rows",
",",
"array_combine",
"(",
"$",
"firstrow",
",",
"$",
"firstrow",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"rows",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"headings",
"=",
"$",
"firstrow",
";",
"}",
"}"
] |
Extract preview of CSV from file
|
[
"Extract",
"preview",
"of",
"CSV",
"from",
"file"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/CSVPreviewer.php#L34-L53
|
224,711
|
burnbright/silverstripe-importexport
|
code/CSVPreviewer.php
|
CSVPreviewer.getHeadings
|
public function getHeadings()
{
if (!$this->headings) {
return;
}
$out = new ArrayList();
foreach ($this->headings as $heading) {
$out->push(
new ArrayData(array(
"Label" => $heading
))
);
}
return $out;
}
|
php
|
public function getHeadings()
{
if (!$this->headings) {
return;
}
$out = new ArrayList();
foreach ($this->headings as $heading) {
$out->push(
new ArrayData(array(
"Label" => $heading
))
);
}
return $out;
}
|
[
"public",
"function",
"getHeadings",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"headings",
")",
"{",
"return",
";",
"}",
"$",
"out",
"=",
"new",
"ArrayList",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headings",
"as",
"$",
"heading",
")",
"{",
"$",
"out",
"->",
"push",
"(",
"new",
"ArrayData",
"(",
"array",
"(",
"\"Label\"",
"=>",
"$",
"heading",
")",
")",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Get the CSV headings for use in template
@return ArrayList
|
[
"Get",
"the",
"CSV",
"headings",
"for",
"use",
"in",
"template"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/CSVPreviewer.php#L71-L85
|
224,712
|
acacha/users
|
src/Services/GoogleApps/GoogleAppsService.php
|
GoogleAppsService.getConnectionState
|
public function getConnectionState()
{
$directory = Google::make('directory');
try {
$r = $directory->users->get($email = config('users.google_apps_user_email_to_check_connection'));
if($r) {
$state = 'connected';
} else {
echo 'User does not exists: $email<br/>';
}
} catch (\Exception $e) {
$state = 'error';
$message = json_decode($e->getMessage());
}
$result = [
'state' => $state
];
if ($state != 'connected') $result['message'] = $message;
return $result;
}
|
php
|
public function getConnectionState()
{
$directory = Google::make('directory');
try {
$r = $directory->users->get($email = config('users.google_apps_user_email_to_check_connection'));
if($r) {
$state = 'connected';
} else {
echo 'User does not exists: $email<br/>';
}
} catch (\Exception $e) {
$state = 'error';
$message = json_decode($e->getMessage());
}
$result = [
'state' => $state
];
if ($state != 'connected') $result['message'] = $message;
return $result;
}
|
[
"public",
"function",
"getConnectionState",
"(",
")",
"{",
"$",
"directory",
"=",
"Google",
"::",
"make",
"(",
"'directory'",
")",
";",
"try",
"{",
"$",
"r",
"=",
"$",
"directory",
"->",
"users",
"->",
"get",
"(",
"$",
"email",
"=",
"config",
"(",
"'users.google_apps_user_email_to_check_connection'",
")",
")",
";",
"if",
"(",
"$",
"r",
")",
"{",
"$",
"state",
"=",
"'connected'",
";",
"}",
"else",
"{",
"echo",
"'User does not exists: $email<br/>'",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"state",
"=",
"'error'",
";",
"$",
"message",
"=",
"json_decode",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"result",
"=",
"[",
"'state'",
"=>",
"$",
"state",
"]",
";",
"if",
"(",
"$",
"state",
"!=",
"'connected'",
")",
"$",
"result",
"[",
"'message'",
"]",
"=",
"$",
"message",
";",
"return",
"$",
"result",
";",
"}"
] |
Get connection state.
@return string
|
[
"Get",
"connection",
"state",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Services/GoogleApps/GoogleAppsService.php#L22-L45
|
224,713
|
acacha/users
|
src/Services/GoogleApps/GoogleAppsService.php
|
GoogleAppsService.allUsers
|
protected function allUsers()
{
$directory = Google::make('directory');
$pageToken = null;
$users = [];
do {
try {
$r = $directory->users->listUsers([
'domain' => config('users.google_apps_domain'),
'maxResults' => config('users.google_apps_users_maxResults'),
'pageToken' => $pageToken
]);
$pageToken = $r->nextPageToken;
$users = array_merge($users, $r->users);
} catch (\Exception $e) {
return json_decode($e->getMessage());
}
} while ($pageToken);
return $users;
}
|
php
|
protected function allUsers()
{
$directory = Google::make('directory');
$pageToken = null;
$users = [];
do {
try {
$r = $directory->users->listUsers([
'domain' => config('users.google_apps_domain'),
'maxResults' => config('users.google_apps_users_maxResults'),
'pageToken' => $pageToken
]);
$pageToken = $r->nextPageToken;
$users = array_merge($users, $r->users);
} catch (\Exception $e) {
return json_decode($e->getMessage());
}
} while ($pageToken);
return $users;
}
|
[
"protected",
"function",
"allUsers",
"(",
")",
"{",
"$",
"directory",
"=",
"Google",
"::",
"make",
"(",
"'directory'",
")",
";",
"$",
"pageToken",
"=",
"null",
";",
"$",
"users",
"=",
"[",
"]",
";",
"do",
"{",
"try",
"{",
"$",
"r",
"=",
"$",
"directory",
"->",
"users",
"->",
"listUsers",
"(",
"[",
"'domain'",
"=>",
"config",
"(",
"'users.google_apps_domain'",
")",
",",
"'maxResults'",
"=>",
"config",
"(",
"'users.google_apps_users_maxResults'",
")",
",",
"'pageToken'",
"=>",
"$",
"pageToken",
"]",
")",
";",
"$",
"pageToken",
"=",
"$",
"r",
"->",
"nextPageToken",
";",
"$",
"users",
"=",
"array_merge",
"(",
"$",
"users",
",",
"$",
"r",
"->",
"users",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"json_decode",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"while",
"(",
"$",
"pageToken",
")",
";",
"return",
"$",
"users",
";",
"}"
] |
Get all users from google apps.
@return array|mixed
|
[
"Get",
"all",
"users",
"from",
"google",
"apps",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Services/GoogleApps/GoogleAppsService.php#L60-L79
|
224,714
|
acacha/users
|
src/Services/GoogleApps/GoogleAppsService.php
|
GoogleAppsService.localSync
|
public function localSync()
{
$users = Cache::rememberForever('google_app_users', function () {
return $this->allUsers();
});
try {
foreach ($users as $user) {
$user = GoogleUser::firstOrCreate([
'customerId' => $user->customerId,
'kind' => $user->kind,
'google_id'=> $user->id,
'etag'=> $user->etag,
'primaryEmail'=> $user->primaryEmail,
'givenName'=> $user->name->givenName,
'familyName'=> $user->name->familyName,
'fullName'=> $user->name->fullName,
'orgUnitPath'=> $user->orgUnitPath,
'organizations'=> json_decode($user->organizations),
'isAdmin'=> $user->isAdmin,
'isDelegatedAdmin'=> $user->isDelegatedAdmin,
'lastLoginTime'=> $user->lastLoginTime,
'creationTime'=> $user->creationTime,
'deletionTime'=> $user->deletionTime,
'agreedToTerms'=> $user->agreedToTerms,
'password'=> $user->password,
'hashFunction'=> $user->hashFunction,
'suspended'=> $user->suspended,
'suspensionReason'=> $user->suspensionReason,
'changePasswordAtNextLogin'=> $user->changePasswordAtNextLogin,
'emails'=> json_encode($user->emails),
]);
}
} catch (\Exception $e) {
return [
'completed' => 'false',
'message' => $e->getMessage()
];
}
return [
'completed' => 'true'
];
}
|
php
|
public function localSync()
{
$users = Cache::rememberForever('google_app_users', function () {
return $this->allUsers();
});
try {
foreach ($users as $user) {
$user = GoogleUser::firstOrCreate([
'customerId' => $user->customerId,
'kind' => $user->kind,
'google_id'=> $user->id,
'etag'=> $user->etag,
'primaryEmail'=> $user->primaryEmail,
'givenName'=> $user->name->givenName,
'familyName'=> $user->name->familyName,
'fullName'=> $user->name->fullName,
'orgUnitPath'=> $user->orgUnitPath,
'organizations'=> json_decode($user->organizations),
'isAdmin'=> $user->isAdmin,
'isDelegatedAdmin'=> $user->isDelegatedAdmin,
'lastLoginTime'=> $user->lastLoginTime,
'creationTime'=> $user->creationTime,
'deletionTime'=> $user->deletionTime,
'agreedToTerms'=> $user->agreedToTerms,
'password'=> $user->password,
'hashFunction'=> $user->hashFunction,
'suspended'=> $user->suspended,
'suspensionReason'=> $user->suspensionReason,
'changePasswordAtNextLogin'=> $user->changePasswordAtNextLogin,
'emails'=> json_encode($user->emails),
]);
}
} catch (\Exception $e) {
return [
'completed' => 'false',
'message' => $e->getMessage()
];
}
return [
'completed' => 'true'
];
}
|
[
"public",
"function",
"localSync",
"(",
")",
"{",
"$",
"users",
"=",
"Cache",
"::",
"rememberForever",
"(",
"'google_app_users'",
",",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"allUsers",
"(",
")",
";",
"}",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"GoogleUser",
"::",
"firstOrCreate",
"(",
"[",
"'customerId'",
"=>",
"$",
"user",
"->",
"customerId",
",",
"'kind'",
"=>",
"$",
"user",
"->",
"kind",
",",
"'google_id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'etag'",
"=>",
"$",
"user",
"->",
"etag",
",",
"'primaryEmail'",
"=>",
"$",
"user",
"->",
"primaryEmail",
",",
"'givenName'",
"=>",
"$",
"user",
"->",
"name",
"->",
"givenName",
",",
"'familyName'",
"=>",
"$",
"user",
"->",
"name",
"->",
"familyName",
",",
"'fullName'",
"=>",
"$",
"user",
"->",
"name",
"->",
"fullName",
",",
"'orgUnitPath'",
"=>",
"$",
"user",
"->",
"orgUnitPath",
",",
"'organizations'",
"=>",
"json_decode",
"(",
"$",
"user",
"->",
"organizations",
")",
",",
"'isAdmin'",
"=>",
"$",
"user",
"->",
"isAdmin",
",",
"'isDelegatedAdmin'",
"=>",
"$",
"user",
"->",
"isDelegatedAdmin",
",",
"'lastLoginTime'",
"=>",
"$",
"user",
"->",
"lastLoginTime",
",",
"'creationTime'",
"=>",
"$",
"user",
"->",
"creationTime",
",",
"'deletionTime'",
"=>",
"$",
"user",
"->",
"deletionTime",
",",
"'agreedToTerms'",
"=>",
"$",
"user",
"->",
"agreedToTerms",
",",
"'password'",
"=>",
"$",
"user",
"->",
"password",
",",
"'hashFunction'",
"=>",
"$",
"user",
"->",
"hashFunction",
",",
"'suspended'",
"=>",
"$",
"user",
"->",
"suspended",
",",
"'suspensionReason'",
"=>",
"$",
"user",
"->",
"suspensionReason",
",",
"'changePasswordAtNextLogin'",
"=>",
"$",
"user",
"->",
"changePasswordAtNextLogin",
",",
"'emails'",
"=>",
"json_encode",
"(",
"$",
"user",
"->",
"emails",
")",
",",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"[",
"'completed'",
"=>",
"'false'",
",",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
";",
"}",
"return",
"[",
"'completed'",
"=>",
"'true'",
"]",
";",
"}"
] |
Sync local database with remote Google apps info.
|
[
"Sync",
"local",
"database",
"with",
"remote",
"Google",
"apps",
"info",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Services/GoogleApps/GoogleAppsService.php#L84-L127
|
224,715
|
acacha/users
|
src/Services/GoogleApps/GoogleAppsService.php
|
GoogleAppsService.getUsers
|
public function getUsers($perPage = 15)
{
$directory = Google::make('directory');
try {
$r = $directory->users->listUsers([
'domain' => config('users.google_apps_domain'),
'maxResults' => $perPage
]);
} catch (\Exception $e) {
return json_decode($e->getMessage());
}
return $r->users;
}
|
php
|
public function getUsers($perPage = 15)
{
$directory = Google::make('directory');
try {
$r = $directory->users->listUsers([
'domain' => config('users.google_apps_domain'),
'maxResults' => $perPage
]);
} catch (\Exception $e) {
return json_decode($e->getMessage());
}
return $r->users;
}
|
[
"public",
"function",
"getUsers",
"(",
"$",
"perPage",
"=",
"15",
")",
"{",
"$",
"directory",
"=",
"Google",
"::",
"make",
"(",
"'directory'",
")",
";",
"try",
"{",
"$",
"r",
"=",
"$",
"directory",
"->",
"users",
"->",
"listUsers",
"(",
"[",
"'domain'",
"=>",
"config",
"(",
"'users.google_apps_domain'",
")",
",",
"'maxResults'",
"=>",
"$",
"perPage",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"json_decode",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"r",
"->",
"users",
";",
"}"
] |
Get users.
@param int $perPage
@return int|mixed
|
[
"Get",
"users",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Services/GoogleApps/GoogleAppsService.php#L135-L148
|
224,716
|
joomla-framework/github-api
|
src/Package/Issues/Comments.php
|
Comments.getList
|
public function getList($owner, $repo, $issueId, $page = 0, $limit = 0, \DateTime $since = null)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo . '/issues/' . (int) $issueId . '/comments';
$uri = new Uri($this->fetchUrl($path, $page, $limit));
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::RFC3339));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getList($owner, $repo, $issueId, $page = 0, $limit = 0, \DateTime $since = null)
{
// Build the request path.
$path = '/repos/' . $owner . '/' . $repo . '/issues/' . (int) $issueId . '/comments';
$uri = new Uri($this->fetchUrl($path, $page, $limit));
if ($since)
{
$uri->setVar('since', $since->format(\DateTime::RFC3339));
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getList",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"issueId",
",",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
",",
"\\",
"DateTime",
"$",
"since",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"owner",
".",
"'/'",
".",
"$",
"repo",
".",
"'/issues/'",
".",
"(",
"int",
")",
"$",
"issueId",
".",
"'/comments'",
";",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
",",
"$",
"page",
",",
"$",
"limit",
")",
")",
";",
"if",
"(",
"$",
"since",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'since'",
",",
"$",
"since",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"RFC3339",
")",
")",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
List comments on an issue.
@param string $owner The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $issueId The issue number.
@param integer $page The page number from which to get items.
@param integer $limit The number of items on a page.
@param \DateTime $since Only comments updated at or after this time are returned.
@return object
@since 1.0
@throws \DomainException
|
[
"List",
"comments",
"on",
"an",
"issue",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Comments.php#L41-L55
|
224,717
|
joomla-framework/github-api
|
src/Package/Gists.php
|
Gists.create
|
public function create($files, $public = false, $description = null)
{
// Build the request path.
$path = '/gists';
// Build the request data.
$data = json_encode(
array(
'files' => $this->buildFileData((array) $files),
'public' => (bool) $public,
'description' => $description,
)
);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
php
|
public function create($files, $public = false, $description = null)
{
// Build the request path.
$path = '/gists';
// Build the request data.
$data = json_encode(
array(
'files' => $this->buildFileData((array) $files),
'public' => (bool) $public,
'description' => $description,
)
);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
[
"public",
"function",
"create",
"(",
"$",
"files",
",",
"$",
"public",
"=",
"false",
",",
"$",
"description",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/gists'",
";",
"// Build the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'files'",
"=>",
"$",
"this",
"->",
"buildFileData",
"(",
"(",
"array",
")",
"$",
"files",
")",
",",
"'public'",
"=>",
"(",
"bool",
")",
"$",
"public",
",",
"'description'",
"=>",
"$",
"description",
",",
")",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Create a gist.
@param mixed $files Either an array of file paths or a single file path as a string.
@param boolean $public True if the gist should be public.
@param string $description The optional description of the gist.
@return object
@since 1.0
@throws \DomainException
|
[
"Create",
"a",
"gist",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Gists.php#L38-L54
|
224,718
|
joomla-framework/github-api
|
src/Package/Gists.php
|
Gists.edit
|
public function edit($gistId, $files = null, $public = null, $description = null)
{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Create the data object.
$data = new \stdClass;
// If a description is set add it to the data object.
if (isset($description))
{
$data->description = $description;
}
// If the public flag is set add it to the data object.
if (isset($public))
{
$data->public = $public;
}
// If a state is set add it to the data object.
if (isset($files))
{
$data->files = $this->buildFileData((array) $files);
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
php
|
public function edit($gistId, $files = null, $public = null, $description = null)
{
// Build the request path.
$path = '/gists/' . (int) $gistId;
// Create the data object.
$data = new \stdClass;
// If a description is set add it to the data object.
if (isset($description))
{
$data->description = $description;
}
// If the public flag is set add it to the data object.
if (isset($public))
{
$data->public = $public;
}
// If a state is set add it to the data object.
if (isset($files))
{
$data->files = $this->buildFileData((array) $files);
}
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
[
"public",
"function",
"edit",
"(",
"$",
"gistId",
",",
"$",
"files",
"=",
"null",
",",
"$",
"public",
"=",
"null",
",",
"$",
"description",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/gists/'",
".",
"(",
"int",
")",
"$",
"gistId",
";",
"// Create the data object.",
"$",
"data",
"=",
"new",
"\\",
"stdClass",
";",
"// If a description is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"description",
")",
")",
"{",
"$",
"data",
"->",
"description",
"=",
"$",
"description",
";",
"}",
"// If the public flag is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"public",
")",
")",
"{",
"$",
"data",
"->",
"public",
"=",
"$",
"public",
";",
"}",
"// If a state is set add it to the data object.",
"if",
"(",
"isset",
"(",
"$",
"files",
")",
")",
"{",
"$",
"data",
"->",
"files",
"=",
"$",
"this",
"->",
"buildFileData",
"(",
"(",
"array",
")",
"$",
"files",
")",
";",
"}",
"// Encode the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Edit a gist.
@param integer $gistId The gist number.
@param mixed $files Either an array of file paths or a single file path as a string.
@param boolean $public True if the gist should be public.
@param string $description The description of the gist.
@return object
@since 1.0
@throws \DomainException
|
[
"Edit",
"a",
"gist",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Gists.php#L88-L119
|
224,719
|
joomla-framework/github-api
|
src/Package/Gists.php
|
Gists.fork
|
public function fork($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/forks';
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), ''), 201);
}
|
php
|
public function fork($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/forks';
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), ''), 201);
}
|
[
"public",
"function",
"fork",
"(",
"$",
"gistId",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/gists/'",
".",
"(",
"int",
")",
"$",
"gistId",
".",
"'/forks'",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"''",
")",
",",
"201",
")",
";",
"}"
] |
Fork a gist.
@param integer $gistId The gist number.
@return object
@since 1.0
@throws \DomainException
|
[
"Fork",
"a",
"gist",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Gists.php#L131-L138
|
224,720
|
joomla-framework/github-api
|
src/Package/Gists.php
|
Gists.getRevision
|
public function getRevision($gistId, $sha)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/' . $sha;
// Send the request.
return $this->processResponse($this->client->get($this->fetchUrl($path)));
}
|
php
|
public function getRevision($gistId, $sha)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/' . $sha;
// Send the request.
return $this->processResponse($this->client->get($this->fetchUrl($path)));
}
|
[
"public",
"function",
"getRevision",
"(",
"$",
"gistId",
",",
"$",
"sha",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/gists/'",
".",
"(",
"int",
")",
"$",
"gistId",
".",
"'/'",
".",
"$",
"sha",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
")",
";",
"}"
] |
Get a specific revision of a gist.
@param integer $gistId The gist number.
@param string $sha The SHA for the revision to get.
@return object
@since 1.4.0
@throws \DomainException
|
[
"Get",
"a",
"specific",
"revision",
"of",
"a",
"gist",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Gists.php#L314-L321
|
224,721
|
joomla-framework/github-api
|
src/Package/Gists.php
|
Gists.star
|
public function star($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$this->processResponse($this->client->put($this->fetchUrl($path), ''), 204);
}
|
php
|
public function star($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$this->processResponse($this->client->put($this->fetchUrl($path), ''), 204);
}
|
[
"public",
"function",
"star",
"(",
"$",
"gistId",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/gists/'",
".",
"(",
"int",
")",
"$",
"gistId",
".",
"'/star'",
";",
"// Send the request.",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"put",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"''",
")",
",",
"204",
")",
";",
"}"
] |
Star a gist.
@param integer $gistId The gist number.
@return void
@since 1.0
@throws \DomainException
|
[
"Star",
"a",
"gist",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Gists.php#L369-L376
|
224,722
|
joomla-framework/github-api
|
src/Package/Gists.php
|
Gists.unstar
|
public function unstar($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
php
|
public function unstar($gistId)
{
// Build the request path.
$path = '/gists/' . (int) $gistId . '/star';
// Send the request.
$this->processResponse($this->client->delete($this->fetchUrl($path)), 204);
}
|
[
"public",
"function",
"unstar",
"(",
"$",
"gistId",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/gists/'",
".",
"(",
"int",
")",
"$",
"gistId",
".",
"'/star'",
";",
"// Send the request.",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"delete",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
",",
"204",
")",
";",
"}"
] |
Unstar a gist.
@param integer $gistId The gist number.
@return void
@since 1.0
@throws \DomainException
|
[
"Unstar",
"a",
"gist",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Gists.php#L388-L395
|
224,723
|
joomla-framework/github-api
|
src/Package/Issues/Milestones.php
|
Milestones.getList
|
public function getList($user, $repo, $state = 'open', $sort = 'due_date', $direction = 'desc', $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/milestones';
$uri = new Uri($this->fetchUrl($path, $page, $limit));
$uri->setVar('state', $state);
$uri->setVar('sort', $sort);
$uri->setVar('direction', $direction);
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getList($user, $repo, $state = 'open', $sort = 'due_date', $direction = 'desc', $page = 0, $limit = 0)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/milestones';
$uri = new Uri($this->fetchUrl($path, $page, $limit));
$uri->setVar('state', $state);
$uri->setVar('sort', $sort);
$uri->setVar('direction', $direction);
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getList",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"state",
"=",
"'open'",
",",
"$",
"sort",
"=",
"'due_date'",
",",
"$",
"direction",
"=",
"'desc'",
",",
"$",
"page",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/milestones'",
";",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
",",
"$",
"page",
",",
"$",
"limit",
")",
")",
";",
"$",
"uri",
"->",
"setVar",
"(",
"'state'",
",",
"$",
"state",
")",
";",
"$",
"uri",
"->",
"setVar",
"(",
"'sort'",
",",
"$",
"sort",
")",
";",
"$",
"uri",
"->",
"setVar",
"(",
"'direction'",
",",
"$",
"direction",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
List milestones for a repository.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $state The milestone state to retrieved. Open (default) or closed.
@param string $sort Sort can be due_date (default) or completeness.
@param string $direction Direction is asc or desc (default).
@param integer $page The page number from which to get items.
@param integer $limit The number of items on a page.
@return object
@since 1.0
@throws \DomainException
|
[
"List",
"milestones",
"for",
"a",
"repository",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Milestones.php#L39-L51
|
224,724
|
joomla-framework/github-api
|
src/Package/Issues/Milestones.php
|
Milestones.create
|
public function create($user, $repo, $title, $state = null, $description = null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/milestones';
// Build the request data.
$data = array(
'title' => $title,
);
if ($state !== null)
{
$data['state'] = $state;
}
if ($description !== null)
{
$data['description'] = $description;
}
if ($dueOn !== null)
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
php
|
public function create($user, $repo, $title, $state = null, $description = null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/milestones';
// Build the request data.
$data = array(
'title' => $title,
);
if ($state !== null)
{
$data['state'] = $state;
}
if ($description !== null)
{
$data['description'] = $description;
}
if ($dueOn !== null)
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
[
"public",
"function",
"create",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"title",
",",
"$",
"state",
"=",
"null",
",",
"$",
"description",
"=",
"null",
",",
"$",
"dueOn",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/milestones'",
";",
"// Build the request data.",
"$",
"data",
"=",
"array",
"(",
"'title'",
"=>",
"$",
"title",
",",
")",
";",
"if",
"(",
"$",
"state",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'state'",
"]",
"=",
"$",
"state",
";",
"}",
"if",
"(",
"$",
"description",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'description'",
"]",
"=",
"$",
"description",
";",
"}",
"if",
"(",
"$",
"dueOn",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'due_on'",
"]",
"=",
"$",
"dueOn",
";",
"}",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Create a milestone.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $title The title of the milestone.
@param string $state Can be open (default) or closed.
@param string $description Optional description for milestone.
@param string $dueOn The milestone due date. This is a timestamp in ISO 8601 format.
@return object
@note As of 2.0 the $dueOn parameter will be typehinted to a \DateTime object
@since 1.0
@throws \DomainException
|
[
"Create",
"a",
"milestone",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Milestones.php#L90-L119
|
224,725
|
joomla-framework/github-api
|
src/Package/Issues/Milestones.php
|
Milestones.edit
|
public function edit($user, $repo, $milestoneId, $title = null, $state = null, $description = null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId;
// Build the request data.
$data = array();
if ($title !== null)
{
$data['title'] = $title;
}
if ($state !== null)
{
$data['state'] = $state;
}
if ($description !== null)
{
$data['description'] = $description;
}
if ($dueOn !== null)
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
php
|
public function edit($user, $repo, $milestoneId, $title = null, $state = null, $description = null, $dueOn = null)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/milestones/' . (int) $milestoneId;
// Build the request data.
$data = array();
if ($title !== null)
{
$data['title'] = $title;
}
if ($state !== null)
{
$data['state'] = $state;
}
if ($description !== null)
{
$data['description'] = $description;
}
if ($dueOn !== null)
{
$data['due_on'] = $dueOn;
}
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
[
"public",
"function",
"edit",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"milestoneId",
",",
"$",
"title",
"=",
"null",
",",
"$",
"state",
"=",
"null",
",",
"$",
"description",
"=",
"null",
",",
"$",
"dueOn",
"=",
"null",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/milestones/'",
".",
"(",
"int",
")",
"$",
"milestoneId",
";",
"// Build the request data.",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"title",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"}",
"if",
"(",
"$",
"state",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'state'",
"]",
"=",
"$",
"state",
";",
"}",
"if",
"(",
"$",
"description",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'description'",
"]",
"=",
"$",
"description",
";",
"}",
"if",
"(",
"$",
"dueOn",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"'due_on'",
"]",
"=",
"$",
"dueOn",
";",
"}",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Update a milestone.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param integer $milestoneId The id of the comment to update.
@param integer $title Optional title of the milestone.
@param string $state Can be open (default) or closed.
@param string $description Optional description for milestone.
@param string $dueOn The milestone due date. This is a timestamp in ISO 8601 format.
@return object
@note As of 2.0 the $dueOn parameter will be typehinted to a \DateTime object
@since 1.0
@throws \DomainException
|
[
"Update",
"a",
"milestone",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Milestones.php#L138-L170
|
224,726
|
joomla-framework/github-api
|
src/Package/Data/Refs.php
|
Refs.create
|
public function create($user, $repo, $ref, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/git/refs';
// Build the request data.
$data = json_encode(
array(
'ref' => $ref,
'sha' => $sha,
)
);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
php
|
public function create($user, $repo, $ref, $sha)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/git/refs';
// Build the request data.
$data = json_encode(
array(
'ref' => $ref,
'sha' => $sha,
)
);
// Send the request.
return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201);
}
|
[
"public",
"function",
"create",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"ref",
",",
"$",
"sha",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/git/refs'",
";",
"// Build the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'ref'",
"=>",
"$",
"ref",
",",
"'sha'",
"=>",
"$",
"sha",
",",
")",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
",",
"201",
")",
";",
"}"
] |
Create a Reference.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $ref The name of the fully qualified reference.
@param string $sha The SHA1 value to set this reference to.
@return object
@since 1.0
@throws \DomainException
|
[
"Create",
"a",
"Reference",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Data/Refs.php#L84-L99
|
224,727
|
joomla-framework/github-api
|
src/Package/Data/Refs.php
|
Refs.edit
|
public function edit($user, $repo, $ref, $sha, $force = false)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref;
// Create the data object.
$data = new \stdClass;
// If a title is set add it to the data object.
if ($force)
{
$data->force = true;
}
$data->sha = $sha;
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
php
|
public function edit($user, $repo, $ref, $sha, $force = false)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/git/refs/' . $ref;
// Create the data object.
$data = new \stdClass;
// If a title is set add it to the data object.
if ($force)
{
$data->force = true;
}
$data->sha = $sha;
// Encode the request data.
$data = json_encode($data);
// Send the request.
return $this->processResponse($this->client->patch($this->fetchUrl($path), $data));
}
|
[
"public",
"function",
"edit",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"ref",
",",
"$",
"sha",
",",
"$",
"force",
"=",
"false",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/git/refs/'",
".",
"$",
"ref",
";",
"// Create the data object.",
"$",
"data",
"=",
"new",
"\\",
"stdClass",
";",
"// If a title is set add it to the data object.",
"if",
"(",
"$",
"force",
")",
"{",
"$",
"data",
"->",
"force",
"=",
"true",
";",
"}",
"$",
"data",
"->",
"sha",
"=",
"$",
"sha",
";",
"// Encode the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Update a Reference.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $ref The reference to update.
@param string $sha The SHA1 value to set the reference to.
@param boolean $force Whether the update should be forced. Default to false.
@return object
@since 1.0
@throws DomainException
|
[
"Update",
"a",
"Reference",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Data/Refs.php#L115-L136
|
224,728
|
acacha/users
|
src/Observers/UserInvitationObserver.php
|
UserInvitationObserver.deleted
|
public function deleted(UserInvitation $invitation)
{
// Insert into 'revisions' (calling getTable probably not necessary, but to be safe).
\DB::table((new Revision())->getTable())->insert([
[
'revisionable_type' => $invitation->getMorphClass(),
'revisionable_id' => $invitation->id,
'key' => 'deleted_at',
'old_value' => null,
'new_value' => new \DateTime(),
'user_id' => (\Auth::check() ? \Auth::user()->id : null),
'created_at' => new \DateTime(),
'updated_at' => new \DateTime(),
]
]);
}
|
php
|
public function deleted(UserInvitation $invitation)
{
// Insert into 'revisions' (calling getTable probably not necessary, but to be safe).
\DB::table((new Revision())->getTable())->insert([
[
'revisionable_type' => $invitation->getMorphClass(),
'revisionable_id' => $invitation->id,
'key' => 'deleted_at',
'old_value' => null,
'new_value' => new \DateTime(),
'user_id' => (\Auth::check() ? \Auth::user()->id : null),
'created_at' => new \DateTime(),
'updated_at' => new \DateTime(),
]
]);
}
|
[
"public",
"function",
"deleted",
"(",
"UserInvitation",
"$",
"invitation",
")",
"{",
"// Insert into 'revisions' (calling getTable probably not necessary, but to be safe).",
"\\",
"DB",
"::",
"table",
"(",
"(",
"new",
"Revision",
"(",
")",
")",
"->",
"getTable",
"(",
")",
")",
"->",
"insert",
"(",
"[",
"[",
"'revisionable_type'",
"=>",
"$",
"invitation",
"->",
"getMorphClass",
"(",
")",
",",
"'revisionable_id'",
"=>",
"$",
"invitation",
"->",
"id",
",",
"'key'",
"=>",
"'deleted_at'",
",",
"'old_value'",
"=>",
"null",
",",
"'new_value'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"'user_id'",
"=>",
"(",
"\\",
"Auth",
"::",
"check",
"(",
")",
"?",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"id",
":",
"null",
")",
",",
"'created_at'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"'updated_at'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"]",
"]",
")",
";",
"}"
] |
Listen to the UserInvitation deleted event.
|
[
"Listen",
"to",
"the",
"UserInvitation",
"deleted",
"event",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Observers/UserInvitationObserver.php#L52-L67
|
224,729
|
php-poppler/php-poppler
|
Processor/PdfFile.php
|
PdfFile.getInfo
|
public function getInfo($inputfile)
{
if (!file_exists($inputfile)) {
throw new FileNotFoundException("File $inputfile not found.");
}
$args = array($inputfile);
$output = $this->pdfinfo->command($args);
$info = array();
foreach (explode(PHP_EOL, $output) as $line) {
if (strpos($line, ': ') === false) {
continue;
}
$parts = explode(': ', $line);
$key = trim($parts[0]);
$value = trim($parts[1]);
$info[$key] = $value;
}
return $info;
}
|
php
|
public function getInfo($inputfile)
{
if (!file_exists($inputfile)) {
throw new FileNotFoundException("File $inputfile not found.");
}
$args = array($inputfile);
$output = $this->pdfinfo->command($args);
$info = array();
foreach (explode(PHP_EOL, $output) as $line) {
if (strpos($line, ': ') === false) {
continue;
}
$parts = explode(': ', $line);
$key = trim($parts[0]);
$value = trim($parts[1]);
$info[$key] = $value;
}
return $info;
}
|
[
"public",
"function",
"getInfo",
"(",
"$",
"inputfile",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"inputfile",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"File $inputfile not found.\"",
")",
";",
"}",
"$",
"args",
"=",
"array",
"(",
"$",
"inputfile",
")",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"pdfinfo",
"->",
"command",
"(",
"$",
"args",
")",
";",
"$",
"info",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"': '",
")",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"': '",
",",
"$",
"line",
")",
";",
"$",
"key",
"=",
"trim",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"$",
"info",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"info",
";",
"}"
] |
Write to file or return content
@param string $inputfile
@return array
|
[
"Write",
"to",
"file",
"or",
"return",
"content"
] |
033427289ec4f1ff00656a0e02410a84c529ace4
|
https://github.com/php-poppler/php-poppler/blob/033427289ec4f1ff00656a0e02410a84c529ace4/Processor/PdfFile.php#L100-L122
|
224,730
|
joomla-framework/github-api
|
src/Package/Users.php
|
Users.getList
|
public function getList($since = 0)
{
// Build the request path.
$uri = new Uri($this->fetchUrl('/users'));
if ($since)
{
$uri->setVar('since', $since);
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
php
|
public function getList($since = 0)
{
// Build the request path.
$uri = new Uri($this->fetchUrl('/users'));
if ($since)
{
$uri->setVar('since', $since);
}
// Send the request.
return $this->processResponse($this->client->get($uri));
}
|
[
"public",
"function",
"getList",
"(",
"$",
"since",
"=",
"0",
")",
"{",
"// Build the request path.",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"'/users'",
")",
")",
";",
"if",
"(",
"$",
"since",
")",
"{",
"$",
"uri",
"->",
"setVar",
"(",
"'since'",
",",
"$",
"since",
")",
";",
"}",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"uri",
")",
")",
";",
"}"
] |
Get all users.
This provides a dump of every user, in the order that they signed up for GitHub.
@param integer $since The integer ID of the last User that you’ve seen.
@return object
@since 1.0
@throws \DomainException
|
[
"Get",
"all",
"users",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Users.php#L116-L128
|
224,731
|
joomla-framework/github-api
|
src/Package/Repositories/Contents.php
|
Contents.create
|
public function create($owner, $repo, $path, $message, $content, $branch = 'master', $authorName = '', $authorEmail = '', $committerName = '',
$committerEmail = ''
)
{
// Build the request path.
$route = '/repos/' . $owner . '/' . $repo . '/contents/' . $path;
$data = array(
'message' => $message,
'content' => $content,
'branch' => $branch,
);
if ($authorName)
{
if (!$authorEmail)
{
throw new \UnexpectedValueException('You must provide an author e-mail if you supply an author name');
}
$data['author'] = array(
'name' => $authorName,
'email' => $authorEmail,
);
}
if ($committerName)
{
if (!$committerEmail)
{
throw new \UnexpectedValueException('You must provide a committer e-mail if you supply a committer name');
}
$data['committer'] = array(
'name' => $committerName,
'email' => $committerEmail,
);
}
return $this->processResponse($this->client->put($this->fetchUrl($route), json_encode($data)), 201);
}
|
php
|
public function create($owner, $repo, $path, $message, $content, $branch = 'master', $authorName = '', $authorEmail = '', $committerName = '',
$committerEmail = ''
)
{
// Build the request path.
$route = '/repos/' . $owner . '/' . $repo . '/contents/' . $path;
$data = array(
'message' => $message,
'content' => $content,
'branch' => $branch,
);
if ($authorName)
{
if (!$authorEmail)
{
throw new \UnexpectedValueException('You must provide an author e-mail if you supply an author name');
}
$data['author'] = array(
'name' => $authorName,
'email' => $authorEmail,
);
}
if ($committerName)
{
if (!$committerEmail)
{
throw new \UnexpectedValueException('You must provide a committer e-mail if you supply a committer name');
}
$data['committer'] = array(
'name' => $committerName,
'email' => $committerEmail,
);
}
return $this->processResponse($this->client->put($this->fetchUrl($route), json_encode($data)), 201);
}
|
[
"public",
"function",
"create",
"(",
"$",
"owner",
",",
"$",
"repo",
",",
"$",
"path",
",",
"$",
"message",
",",
"$",
"content",
",",
"$",
"branch",
"=",
"'master'",
",",
"$",
"authorName",
"=",
"''",
",",
"$",
"authorEmail",
"=",
"''",
",",
"$",
"committerName",
"=",
"''",
",",
"$",
"committerEmail",
"=",
"''",
")",
"{",
"// Build the request path.",
"$",
"route",
"=",
"'/repos/'",
".",
"$",
"owner",
".",
"'/'",
".",
"$",
"repo",
".",
"'/contents/'",
".",
"$",
"path",
";",
"$",
"data",
"=",
"array",
"(",
"'message'",
"=>",
"$",
"message",
",",
"'content'",
"=>",
"$",
"content",
",",
"'branch'",
"=>",
"$",
"branch",
",",
")",
";",
"if",
"(",
"$",
"authorName",
")",
"{",
"if",
"(",
"!",
"$",
"authorEmail",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'You must provide an author e-mail if you supply an author name'",
")",
";",
"}",
"$",
"data",
"[",
"'author'",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"authorName",
",",
"'email'",
"=>",
"$",
"authorEmail",
",",
")",
";",
"}",
"if",
"(",
"$",
"committerName",
")",
"{",
"if",
"(",
"!",
"$",
"committerEmail",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'You must provide a committer e-mail if you supply a committer name'",
")",
";",
"}",
"$",
"data",
"[",
"'committer'",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"committerName",
",",
"'email'",
"=>",
"$",
"committerEmail",
",",
")",
";",
"}",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"put",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"route",
")",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
",",
"201",
")",
";",
"}"
] |
Create a file.
This method creates a new file in a repository.
Optional Parameters
The author section is optional and is filled in with the committer information if omitted.
If the committer information is omitted, the authenticated user’s information is used.
You must provide values for both name and email, whether you choose to use author or committer.
Otherwise, you’ll receive a 500 status code.
@param string $owner The owner of the repository.
@param string $repo The repository name.
@param string $path The content path.
@param string $message The commit message.
@param string $content The new file content, Base64 encoded.
@param string $branch The branch name. If not provided, uses the repository’s default branch (usually master).
@param string $authorName The name of the author of the commit
@param string $authorEmail The email of the author of the commit
@param string $committerName The name of the committer of the commit
@param string $committerEmail The email of the committer of the commit
@return object
@since 1.0
@throws \UnexpectedValueException
|
[
"Create",
"a",
"file",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Repositories/Contents.php#L156-L196
|
224,732
|
atorscho/membership
|
src/Assignable.php
|
Assignable.assignTo
|
public function assignTo($group): void
{
$group = $this->resolveGroup($group);
$this->groups()->attach($group);
}
|
php
|
public function assignTo($group): void
{
$group = $this->resolveGroup($group);
$this->groups()->attach($group);
}
|
[
"public",
"function",
"assignTo",
"(",
"$",
"group",
")",
":",
"void",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"resolveGroup",
"(",
"$",
"group",
")",
";",
"$",
"this",
"->",
"groups",
"(",
")",
"->",
"attach",
"(",
"$",
"group",
")",
";",
"}"
] |
Assign the model to a group.
@param int|string|Group $group
|
[
"Assign",
"the",
"model",
"to",
"a",
"group",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Assignable.php#L21-L26
|
224,733
|
atorscho/membership
|
src/Assignable.php
|
Assignable.retractFrom
|
public function retractFrom($group): void
{
$group = $this->resolveGroup($group);
$this->groups()->detach($group);
}
|
php
|
public function retractFrom($group): void
{
$group = $this->resolveGroup($group);
$this->groups()->detach($group);
}
|
[
"public",
"function",
"retractFrom",
"(",
"$",
"group",
")",
":",
"void",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"resolveGroup",
"(",
"$",
"group",
")",
";",
"$",
"this",
"->",
"groups",
"(",
")",
"->",
"detach",
"(",
"$",
"group",
")",
";",
"}"
] |
Retract the model from a group.
@param int|string|Group $group
|
[
"Retract",
"the",
"model",
"from",
"a",
"group",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Assignable.php#L33-L38
|
224,734
|
atorscho/membership
|
src/Assignable.php
|
Assignable.isAssignedTo
|
public function isAssignedTo($group): bool
{
$group = $this->resolveGroup($group);
return $this->groups()->where('group_id', is_int($group) ? $group : $group->id)->exists();
}
|
php
|
public function isAssignedTo($group): bool
{
$group = $this->resolveGroup($group);
return $this->groups()->where('group_id', is_int($group) ? $group : $group->id)->exists();
}
|
[
"public",
"function",
"isAssignedTo",
"(",
"$",
"group",
")",
":",
"bool",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"resolveGroup",
"(",
"$",
"group",
")",
";",
"return",
"$",
"this",
"->",
"groups",
"(",
")",
"->",
"where",
"(",
"'group_id'",
",",
"is_int",
"(",
"$",
"group",
")",
"?",
"$",
"group",
":",
"$",
"group",
"->",
"id",
")",
"->",
"exists",
"(",
")",
";",
"}"
] |
Check whether the model is assigned to a group.
@param int|string|Group $group
@return bool
|
[
"Check",
"whether",
"the",
"model",
"is",
"assigned",
"to",
"a",
"group",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Assignable.php#L47-L52
|
224,735
|
atorscho/membership
|
src/Assignable.php
|
Assignable.resolveGroup
|
protected function resolveGroup($group)
{
if (is_string($group)) {
$group = Group::whereHandle($group)->firstOrFail();
}
return $group;
}
|
php
|
protected function resolveGroup($group)
{
if (is_string($group)) {
$group = Group::whereHandle($group)->firstOrFail();
}
return $group;
}
|
[
"protected",
"function",
"resolveGroup",
"(",
"$",
"group",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"group",
")",
")",
"{",
"$",
"group",
"=",
"Group",
"::",
"whereHandle",
"(",
"$",
"group",
")",
"->",
"firstOrFail",
"(",
")",
";",
"}",
"return",
"$",
"group",
";",
"}"
] |
Resolve the group parameter.
@param int|string|Group $group
@return Group|int
|
[
"Resolve",
"the",
"group",
"parameter",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Assignable.php#L61-L68
|
224,736
|
atorscho/membership
|
src/Group.php
|
Group.grantPermissions
|
public function grantPermissions($permissions): void
{
if (!is_array($permissions) && !$permissions instanceof Collection) {
$permissions = func_get_args();
}
foreach ($permissions as $permission) {
$permission = $this->resolvePermission($permission);
$permission->assignTo($this);
}
}
|
php
|
public function grantPermissions($permissions): void
{
if (!is_array($permissions) && !$permissions instanceof Collection) {
$permissions = func_get_args();
}
foreach ($permissions as $permission) {
$permission = $this->resolvePermission($permission);
$permission->assignTo($this);
}
}
|
[
"public",
"function",
"grantPermissions",
"(",
"$",
"permissions",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"permissions",
")",
"&&",
"!",
"$",
"permissions",
"instanceof",
"Collection",
")",
"{",
"$",
"permissions",
"=",
"func_get_args",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"{",
"$",
"permission",
"=",
"$",
"this",
"->",
"resolvePermission",
"(",
"$",
"permission",
")",
";",
"$",
"permission",
"->",
"assignTo",
"(",
"$",
"this",
")",
";",
"}",
"}"
] |
Grant given permissions to the group.
@param array|Permission|Collection|string $permissions
|
[
"Grant",
"given",
"permissions",
"to",
"the",
"group",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Group.php#L100-L111
|
224,737
|
atorscho/membership
|
src/Group.php
|
Group.assign
|
public function assign($user, bool $primary = false): bool
{
if ($this->limitExceeded()) {
return false;
}
$this->users()->attach($user);
// Set user's primary group
if ($primary) {
// Get user's model name
$userModel = config('auth.providers.users.model');
// In case $user is an integer, find the relevant model record
if (is_int($user)) {
$user = $userModel::find($user);
}
$user->primary_group_id = $this->id;
$user->save();
}
return true;
}
|
php
|
public function assign($user, bool $primary = false): bool
{
if ($this->limitExceeded()) {
return false;
}
$this->users()->attach($user);
// Set user's primary group
if ($primary) {
// Get user's model name
$userModel = config('auth.providers.users.model');
// In case $user is an integer, find the relevant model record
if (is_int($user)) {
$user = $userModel::find($user);
}
$user->primary_group_id = $this->id;
$user->save();
}
return true;
}
|
[
"public",
"function",
"assign",
"(",
"$",
"user",
",",
"bool",
"$",
"primary",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"limitExceeded",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"users",
"(",
")",
"->",
"attach",
"(",
"$",
"user",
")",
";",
"// Set user's primary group",
"if",
"(",
"$",
"primary",
")",
"{",
"// Get user's model name",
"$",
"userModel",
"=",
"config",
"(",
"'auth.providers.users.model'",
")",
";",
"// In case $user is an integer, find the relevant model record",
"if",
"(",
"is_int",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"userModel",
"::",
"find",
"(",
"$",
"user",
")",
";",
"}",
"$",
"user",
"->",
"primary_group_id",
"=",
"$",
"this",
"->",
"id",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Assign a user to the group.
@param int|Authenticatable $user
@param bool $primary
@return bool Whether the user has been assigned.
|
[
"Assign",
"a",
"user",
"to",
"the",
"group",
"."
] |
c39ee69b5bc33702912fb16ef4f4736eaf1e6d71
|
https://github.com/atorscho/membership/blob/c39ee69b5bc33702912fb16ef4f4736eaf1e6d71/src/Group.php#L139-L162
|
224,738
|
alxmsl/AppStoreClient
|
source/AbstractClient.php
|
AbstractClient.getRequest
|
protected function getRequest($url) {
$Request = new Request();
$Request->setTransport(Request::TRANSPORT_CURL);
return $Request->setUrl($url)
->setConnectTimeout($this->getConnectTimeout())
->setTimeout($this->getRequestTimeout())
->setContentTypeCode(Request::CONTENT_TYPE_JSON);
}
|
php
|
protected function getRequest($url) {
$Request = new Request();
$Request->setTransport(Request::TRANSPORT_CURL);
return $Request->setUrl($url)
->setConnectTimeout($this->getConnectTimeout())
->setTimeout($this->getRequestTimeout())
->setContentTypeCode(Request::CONTENT_TYPE_JSON);
}
|
[
"protected",
"function",
"getRequest",
"(",
"$",
"url",
")",
"{",
"$",
"Request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"Request",
"->",
"setTransport",
"(",
"Request",
"::",
"TRANSPORT_CURL",
")",
";",
"return",
"$",
"Request",
"->",
"setUrl",
"(",
"$",
"url",
")",
"->",
"setConnectTimeout",
"(",
"$",
"this",
"->",
"getConnectTimeout",
"(",
")",
")",
"->",
"setTimeout",
"(",
"$",
"this",
"->",
"getRequestTimeout",
"(",
")",
")",
"->",
"setContentTypeCode",
"(",
"Request",
"::",
"CONTENT_TYPE_JSON",
")",
";",
"}"
] |
Getter for the request
@param string $url request url
@return Request request object
|
[
"Getter",
"for",
"the",
"request"
] |
95b6e9ea9f8b717760cf648f4a2e83d6fe3103b4
|
https://github.com/alxmsl/AppStoreClient/blob/95b6e9ea9f8b717760cf648f4a2e83d6fe3103b4/source/AbstractClient.php#L44-L51
|
224,739
|
burnbright/silverstripe-importexport
|
code/extensions/ImportAdminExtension.php
|
ImportAdminExtension.updateEditForm
|
public function updateEditForm($form)
{
if ($doadd = Config::inst()->get('ModelAdmin', 'addbetterimporters')) {
$modelclass = $this->owner->modelClass;
$grid = $form->Fields()->fieldByName($modelclass);
$config = $grid->getConfig();
//don't proceed if there is already an importer
if ($config->getComponentByType("GridFieldImporter")) {
return;
}
//don't proceed if can't create
if (!singleton($modelclass)->canCreate(Member::currentUser())) {
return;
}
//allow config to avoid adding when there are existing importers
$importerClasses = $this->owner->stat('model_importers');
if (
$doadd === "scaffolded" &&
!is_null($importerClasses) &&
isset($importerClasses[$modelclass])
) {
return;
}
//add the component
$config->addComponent(new GridFieldImporter('before'));
}
}
|
php
|
public function updateEditForm($form)
{
if ($doadd = Config::inst()->get('ModelAdmin', 'addbetterimporters')) {
$modelclass = $this->owner->modelClass;
$grid = $form->Fields()->fieldByName($modelclass);
$config = $grid->getConfig();
//don't proceed if there is already an importer
if ($config->getComponentByType("GridFieldImporter")) {
return;
}
//don't proceed if can't create
if (!singleton($modelclass)->canCreate(Member::currentUser())) {
return;
}
//allow config to avoid adding when there are existing importers
$importerClasses = $this->owner->stat('model_importers');
if (
$doadd === "scaffolded" &&
!is_null($importerClasses) &&
isset($importerClasses[$modelclass])
) {
return;
}
//add the component
$config->addComponent(new GridFieldImporter('before'));
}
}
|
[
"public",
"function",
"updateEditForm",
"(",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"doadd",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'ModelAdmin'",
",",
"'addbetterimporters'",
")",
")",
"{",
"$",
"modelclass",
"=",
"$",
"this",
"->",
"owner",
"->",
"modelClass",
";",
"$",
"grid",
"=",
"$",
"form",
"->",
"Fields",
"(",
")",
"->",
"fieldByName",
"(",
"$",
"modelclass",
")",
";",
"$",
"config",
"=",
"$",
"grid",
"->",
"getConfig",
"(",
")",
";",
"//don't proceed if there is already an importer",
"if",
"(",
"$",
"config",
"->",
"getComponentByType",
"(",
"\"GridFieldImporter\"",
")",
")",
"{",
"return",
";",
"}",
"//don't proceed if can't create",
"if",
"(",
"!",
"singleton",
"(",
"$",
"modelclass",
")",
"->",
"canCreate",
"(",
"Member",
"::",
"currentUser",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"//allow config to avoid adding when there are existing importers",
"$",
"importerClasses",
"=",
"$",
"this",
"->",
"owner",
"->",
"stat",
"(",
"'model_importers'",
")",
";",
"if",
"(",
"$",
"doadd",
"===",
"\"scaffolded\"",
"&&",
"!",
"is_null",
"(",
"$",
"importerClasses",
")",
"&&",
"isset",
"(",
"$",
"importerClasses",
"[",
"$",
"modelclass",
"]",
")",
")",
"{",
"return",
";",
"}",
"//add the component",
"$",
"config",
"->",
"addComponent",
"(",
"new",
"GridFieldImporter",
"(",
"'before'",
")",
")",
";",
"}",
"}"
] |
Add in new bulk GridFieldImporter
|
[
"Add",
"in",
"new",
"bulk",
"GridFieldImporter"
] |
673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3
|
https://github.com/burnbright/silverstripe-importexport/blob/673ca4f63ce69d2128c2cd31daac64ee5bb2ecb3/code/extensions/ImportAdminExtension.php#L21-L49
|
224,740
|
vboctor/disposable_email_checker
|
php/src/DisposableEmailChecker.php
|
DisposableEmailChecker.is_disposable_email
|
public static function is_disposable_email( $p_email ) {
$t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email );
DisposableEmailChecker::_load_domains();
return isset( DisposableEmailChecker::$domains_array[$t_domain] );
}
|
php
|
public static function is_disposable_email( $p_email ) {
$t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email );
DisposableEmailChecker::_load_domains();
return isset( DisposableEmailChecker::$domains_array[$t_domain] );
}
|
[
"public",
"static",
"function",
"is_disposable_email",
"(",
"$",
"p_email",
")",
"{",
"$",
"t_domain",
"=",
"DisposableEmailChecker",
"::",
"_get_domain_from_address",
"(",
"$",
"p_email",
")",
";",
"DisposableEmailChecker",
"::",
"_load_domains",
"(",
")",
";",
"return",
"isset",
"(",
"DisposableEmailChecker",
"::",
"$",
"domains_array",
"[",
"$",
"t_domain",
"]",
")",
";",
"}"
] |
Determines if the email address is disposable.
@param string $p_email The email address to validate.
@return boolean true: disposable, false: non-disposable.
|
[
"Determines",
"if",
"the",
"email",
"address",
"is",
"disposable",
"."
] |
e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73
|
https://github.com/vboctor/disposable_email_checker/blob/e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73/php/src/DisposableEmailChecker.php#L28-L34
|
224,741
|
vboctor/disposable_email_checker
|
php/src/DisposableEmailChecker.php
|
DisposableEmailChecker.add_domains
|
public static function add_domains( array $p_domains ) {
DisposableEmailChecker::_load_domains();
foreach( $p_domains as $t_domain ) {
$t_domain = strtolower( $t_domain );
DisposableEmailChecker::$domains_array[$t_domain] = true;
}
}
|
php
|
public static function add_domains( array $p_domains ) {
DisposableEmailChecker::_load_domains();
foreach( $p_domains as $t_domain ) {
$t_domain = strtolower( $t_domain );
DisposableEmailChecker::$domains_array[$t_domain] = true;
}
}
|
[
"public",
"static",
"function",
"add_domains",
"(",
"array",
"$",
"p_domains",
")",
"{",
"DisposableEmailChecker",
"::",
"_load_domains",
"(",
")",
";",
"foreach",
"(",
"$",
"p_domains",
"as",
"$",
"t_domain",
")",
"{",
"$",
"t_domain",
"=",
"strtolower",
"(",
"$",
"t_domain",
")",
";",
"DisposableEmailChecker",
"::",
"$",
"domains_array",
"[",
"$",
"t_domain",
"]",
"=",
"true",
";",
"}",
"}"
] |
Add a list of domains to the black list.
@param array $p_domains The list of domains to add.
|
[
"Add",
"a",
"list",
"of",
"domains",
"to",
"the",
"black",
"list",
"."
] |
e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73
|
https://github.com/vboctor/disposable_email_checker/blob/e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73/php/src/DisposableEmailChecker.php#L58-L65
|
224,742
|
vboctor/disposable_email_checker
|
php/src/DisposableEmailChecker.php
|
DisposableEmailChecker.remove_domains
|
public static function remove_domains( array $p_domains ) {
DisposableEmailChecker::_load_domains();
foreach( $p_domains as $t_domain ) {
$t_domain = strtolower( $t_domain );
unset( DisposableEmailChecker::$domains_array[$t_domain] );
}
}
|
php
|
public static function remove_domains( array $p_domains ) {
DisposableEmailChecker::_load_domains();
foreach( $p_domains as $t_domain ) {
$t_domain = strtolower( $t_domain );
unset( DisposableEmailChecker::$domains_array[$t_domain] );
}
}
|
[
"public",
"static",
"function",
"remove_domains",
"(",
"array",
"$",
"p_domains",
")",
"{",
"DisposableEmailChecker",
"::",
"_load_domains",
"(",
")",
";",
"foreach",
"(",
"$",
"p_domains",
"as",
"$",
"t_domain",
")",
"{",
"$",
"t_domain",
"=",
"strtolower",
"(",
"$",
"t_domain",
")",
";",
"unset",
"(",
"DisposableEmailChecker",
"::",
"$",
"domains_array",
"[",
"$",
"t_domain",
"]",
")",
";",
"}",
"}"
] |
Remove a list of domains from the black list.
@param array $p_domains The list of domains to remove.
|
[
"Remove",
"a",
"list",
"of",
"domains",
"from",
"the",
"black",
"list",
"."
] |
e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73
|
https://github.com/vboctor/disposable_email_checker/blob/e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73/php/src/DisposableEmailChecker.php#L72-L79
|
224,743
|
vboctor/disposable_email_checker
|
php/src/DisposableEmailChecker.php
|
DisposableEmailChecker._load_file
|
private static function _load_file() {
$t_array = file( __DIR__ . '/../../data/domains.txt' );
$t_result_array = array();
foreach ( $t_array as $t_line ) {
$t_entry = trim( $t_line );
if ( empty( $t_entry ) ) {
continue;
}
# Exclude commented lines
if ( strpos( $t_entry, '#' ) === 0 ) {
continue;
}
$t_domain = strtolower( $t_entry );
$t_result_array[$t_domain] = true;
}
return $t_result_array;
}
|
php
|
private static function _load_file() {
$t_array = file( __DIR__ . '/../../data/domains.txt' );
$t_result_array = array();
foreach ( $t_array as $t_line ) {
$t_entry = trim( $t_line );
if ( empty( $t_entry ) ) {
continue;
}
# Exclude commented lines
if ( strpos( $t_entry, '#' ) === 0 ) {
continue;
}
$t_domain = strtolower( $t_entry );
$t_result_array[$t_domain] = true;
}
return $t_result_array;
}
|
[
"private",
"static",
"function",
"_load_file",
"(",
")",
"{",
"$",
"t_array",
"=",
"file",
"(",
"__DIR__",
".",
"'/../../data/domains.txt'",
")",
";",
"$",
"t_result_array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"t_array",
"as",
"$",
"t_line",
")",
"{",
"$",
"t_entry",
"=",
"trim",
"(",
"$",
"t_line",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"t_entry",
")",
")",
"{",
"continue",
";",
"}",
"# Exclude commented lines",
"if",
"(",
"strpos",
"(",
"$",
"t_entry",
",",
"'#'",
")",
"===",
"0",
")",
"{",
"continue",
";",
"}",
"$",
"t_domain",
"=",
"strtolower",
"(",
"$",
"t_entry",
")",
";",
"$",
"t_result_array",
"[",
"$",
"t_domain",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"t_result_array",
";",
"}"
] |
Loads the domains list from disk.
@return array An array of domains matching the specified file name.
|
[
"Loads",
"the",
"domains",
"list",
"from",
"disk",
"."
] |
e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73
|
https://github.com/vboctor/disposable_email_checker/blob/e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73/php/src/DisposableEmailChecker.php#L99-L119
|
224,744
|
vboctor/disposable_email_checker
|
php/src/DisposableEmailChecker.php
|
DisposableEmailChecker._get_domain_from_address
|
private static function _get_domain_from_address( $p_email ) {
$t_domain_pos = strpos( $p_email, '@' );
// If no @ sign, assume domain was passed in and return as is.
if ( $t_domain_pos === false ) {
return $p_email;
}
return strtolower( substr( $p_email, $t_domain_pos + 1 ) );
}
|
php
|
private static function _get_domain_from_address( $p_email ) {
$t_domain_pos = strpos( $p_email, '@' );
// If no @ sign, assume domain was passed in and return as is.
if ( $t_domain_pos === false ) {
return $p_email;
}
return strtolower( substr( $p_email, $t_domain_pos + 1 ) );
}
|
[
"private",
"static",
"function",
"_get_domain_from_address",
"(",
"$",
"p_email",
")",
"{",
"$",
"t_domain_pos",
"=",
"strpos",
"(",
"$",
"p_email",
",",
"'@'",
")",
";",
"// If no @ sign, assume domain was passed in and return as is.",
"if",
"(",
"$",
"t_domain_pos",
"===",
"false",
")",
"{",
"return",
"$",
"p_email",
";",
"}",
"return",
"strtolower",
"(",
"substr",
"(",
"$",
"p_email",
",",
"$",
"t_domain_pos",
"+",
"1",
")",
")",
";",
"}"
] |
A helper function that takes in an email address and returns a lower case
domain.
@param string $p_email The email address to extra the domain from.
@return string The lower case domain or empty string if email not valid.
|
[
"A",
"helper",
"function",
"that",
"takes",
"in",
"an",
"email",
"address",
"and",
"returns",
"a",
"lower",
"case",
"domain",
"."
] |
e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73
|
https://github.com/vboctor/disposable_email_checker/blob/e73467c0fd4773bf5a7f0c1cddd6dac92b1c8f73/php/src/DisposableEmailChecker.php#L128-L137
|
224,745
|
neos/setup
|
Classes/Controller/LoginController.php
|
LoginController.initializeObject
|
public function initializeObject()
{
$settings = $this->configurationManager->getConfiguration(\Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
if (isset($settings['security']['authentication']['providers']['Neos.Setup:Login']['providerOptions']['keyName'])) {
$this->keyName = $settings['security']['authentication']['providers']['Neos.Setup:Login']['providerOptions']['keyName'];
}
}
|
php
|
public function initializeObject()
{
$settings = $this->configurationManager->getConfiguration(\Neos\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
if (isset($settings['security']['authentication']['providers']['Neos.Setup:Login']['providerOptions']['keyName'])) {
$this->keyName = $settings['security']['authentication']['providers']['Neos.Setup:Login']['providerOptions']['keyName'];
}
}
|
[
"public",
"function",
"initializeObject",
"(",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"configurationManager",
"->",
"getConfiguration",
"(",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Configuration",
"\\",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"'Neos.Flow'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"settings",
"[",
"'security'",
"]",
"[",
"'authentication'",
"]",
"[",
"'providers'",
"]",
"[",
"'Neos.Setup:Login'",
"]",
"[",
"'providerOptions'",
"]",
"[",
"'keyName'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"keyName",
"=",
"$",
"settings",
"[",
"'security'",
"]",
"[",
"'authentication'",
"]",
"[",
"'providers'",
"]",
"[",
"'Neos.Setup:Login'",
"]",
"[",
"'providerOptions'",
"]",
"[",
"'keyName'",
"]",
";",
"}",
"}"
] |
Gets the authentication provider configuration needed
@return void
|
[
"Gets",
"the",
"authentication",
"provider",
"configuration",
"needed"
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Controller/LoginController.php#L53-L59
|
224,746
|
neos/setup
|
Classes/Controller/LoginController.php
|
LoginController.generateNewPasswordAction
|
public function generateNewPasswordAction($step = 0)
{
$existingPasswordFile = Files::concatenatePaths([FLOW_PATH_DATA, 'Persistent', 'FileBasedSimpleKeyService', $this->keyName]);
if (file_exists($existingPasswordFile)) {
unlink($existingPasswordFile);
$this->addFlashMessage('A new password has been generated.', 'Password reset');
}
$this->redirect('login', null, null, ['step' => $step]);
}
|
php
|
public function generateNewPasswordAction($step = 0)
{
$existingPasswordFile = Files::concatenatePaths([FLOW_PATH_DATA, 'Persistent', 'FileBasedSimpleKeyService', $this->keyName]);
if (file_exists($existingPasswordFile)) {
unlink($existingPasswordFile);
$this->addFlashMessage('A new password has been generated.', 'Password reset');
}
$this->redirect('login', null, null, ['step' => $step]);
}
|
[
"public",
"function",
"generateNewPasswordAction",
"(",
"$",
"step",
"=",
"0",
")",
"{",
"$",
"existingPasswordFile",
"=",
"Files",
"::",
"concatenatePaths",
"(",
"[",
"FLOW_PATH_DATA",
",",
"'Persistent'",
",",
"'FileBasedSimpleKeyService'",
",",
"$",
"this",
"->",
"keyName",
"]",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"existingPasswordFile",
")",
")",
"{",
"unlink",
"(",
"$",
"existingPasswordFile",
")",
";",
"$",
"this",
"->",
"addFlashMessage",
"(",
"'A new password has been generated.'",
",",
"'Password reset'",
")",
";",
"}",
"$",
"this",
"->",
"redirect",
"(",
"'login'",
",",
"null",
",",
"null",
",",
"[",
"'step'",
"=>",
"$",
"step",
"]",
")",
";",
"}"
] |
Removes the existing password and starts over by generating a new one.
@param integer $step The requested setup step
@return void
@Flow\SkipCsrfProtection
|
[
"Removes",
"the",
"existing",
"password",
"and",
"starts",
"over",
"by",
"generating",
"a",
"new",
"one",
"."
] |
7b5437efe8113e997007be6896628aa9f5c39d2f
|
https://github.com/neos/setup/blob/7b5437efe8113e997007be6896628aa9f5c39d2f/Classes/Controller/LoginController.php#L114-L122
|
224,747
|
acacha/users
|
src/Http/Controllers/GoogleAppsUsersController.php
|
GoogleAppsUsersController.all
|
public function all(Request $request)
{
$this->authorize('list-google-apps-users');
$perPage = config('users.google_apps_users_per_page' , 15);
if ($request->has('perPage')) {
$perPage = $request->input('perPage');
}
$users = $this->service->getUsers($perPage);
return $this->paginate($users, $perPage);
}
|
php
|
public function all(Request $request)
{
$this->authorize('list-google-apps-users');
$perPage = config('users.google_apps_users_per_page' , 15);
if ($request->has('perPage')) {
$perPage = $request->input('perPage');
}
$users = $this->service->getUsers($perPage);
return $this->paginate($users, $perPage);
}
|
[
"public",
"function",
"all",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'list-google-apps-users'",
")",
";",
"$",
"perPage",
"=",
"config",
"(",
"'users.google_apps_users_per_page'",
",",
"15",
")",
";",
"if",
"(",
"$",
"request",
"->",
"has",
"(",
"'perPage'",
")",
")",
"{",
"$",
"perPage",
"=",
"$",
"request",
"->",
"input",
"(",
"'perPage'",
")",
";",
"}",
"$",
"users",
"=",
"$",
"this",
"->",
"service",
"->",
"getUsers",
"(",
"$",
"perPage",
")",
";",
"return",
"$",
"this",
"->",
"paginate",
"(",
"$",
"users",
",",
"$",
"perPage",
")",
";",
"}"
] |
List Google apps users.
|
[
"List",
"Google",
"apps",
"users",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Http/Controllers/GoogleAppsUsersController.php#L64-L76
|
224,748
|
phootwork/collection
|
src/Set.php
|
Set.add
|
public function add($element) {
if (!in_array($element, $this->collection, true)) {
$this->collection[$this->size()] = $element;
}
return $this;
}
|
php
|
public function add($element) {
if (!in_array($element, $this->collection, true)) {
$this->collection[$this->size()] = $element;
}
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"collection",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"collection",
"[",
"$",
"this",
"->",
"size",
"(",
")",
"]",
"=",
"$",
"element",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds an element to that set
@param mixed $element
@return $this
|
[
"Adds",
"an",
"element",
"to",
"that",
"set"
] |
e745fe3735a6f2099015d11ea7b917634ebf76f3
|
https://github.com/phootwork/collection/blob/e745fe3735a6f2099015d11ea7b917634ebf76f3/src/Set.php#L28-L34
|
224,749
|
codebach/PianoSoloWeatherBundle
|
Twig/WeatherExtension.php
|
WeatherExtension.weather
|
public function weather(\Twig_Environment $environment, $city)
{
$weathers = $this->weatherFactory->getWeatherObject($city);
return $environment->render('PianoSoloWeatherBundle:Weather:weather.html.twig', array(
'city' => $city,
'weathers' => $weathers,
'downloadEnabled' => $this->downloadEnabled
));
}
|
php
|
public function weather(\Twig_Environment $environment, $city)
{
$weathers = $this->weatherFactory->getWeatherObject($city);
return $environment->render('PianoSoloWeatherBundle:Weather:weather.html.twig', array(
'city' => $city,
'weathers' => $weathers,
'downloadEnabled' => $this->downloadEnabled
));
}
|
[
"public",
"function",
"weather",
"(",
"\\",
"Twig_Environment",
"$",
"environment",
",",
"$",
"city",
")",
"{",
"$",
"weathers",
"=",
"$",
"this",
"->",
"weatherFactory",
"->",
"getWeatherObject",
"(",
"$",
"city",
")",
";",
"return",
"$",
"environment",
"->",
"render",
"(",
"'PianoSoloWeatherBundle:Weather:weather.html.twig'",
",",
"array",
"(",
"'city'",
"=>",
"$",
"city",
",",
"'weathers'",
"=>",
"$",
"weathers",
",",
"'downloadEnabled'",
"=>",
"$",
"this",
"->",
"downloadEnabled",
")",
")",
";",
"}"
] |
Renders weather object of a city
@param \Twig_Environment $environment
@param mixed (integer|string) $city
@return string
|
[
"Renders",
"weather",
"object",
"of",
"a",
"city"
] |
f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269
|
https://github.com/codebach/PianoSoloWeatherBundle/blob/f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269/Twig/WeatherExtension.php#L56-L65
|
224,750
|
codebach/PianoSoloWeatherBundle
|
Twig/WeatherExtension.php
|
WeatherExtension.forecast
|
public function forecast(\Twig_Environment $environment, $city, $days = 3)
{
$weathers = $this->weatherFactory->getForecastObject($city, $days);
return $environment->render('PianoSoloWeatherBundle:Weather:weather.html.twig', array(
'city' => $city,
'weathers' => $weathers,
'downloadEnabled' => $this->downloadEnabled
));
}
|
php
|
public function forecast(\Twig_Environment $environment, $city, $days = 3)
{
$weathers = $this->weatherFactory->getForecastObject($city, $days);
return $environment->render('PianoSoloWeatherBundle:Weather:weather.html.twig', array(
'city' => $city,
'weathers' => $weathers,
'downloadEnabled' => $this->downloadEnabled
));
}
|
[
"public",
"function",
"forecast",
"(",
"\\",
"Twig_Environment",
"$",
"environment",
",",
"$",
"city",
",",
"$",
"days",
"=",
"3",
")",
"{",
"$",
"weathers",
"=",
"$",
"this",
"->",
"weatherFactory",
"->",
"getForecastObject",
"(",
"$",
"city",
",",
"$",
"days",
")",
";",
"return",
"$",
"environment",
"->",
"render",
"(",
"'PianoSoloWeatherBundle:Weather:weather.html.twig'",
",",
"array",
"(",
"'city'",
"=>",
"$",
"city",
",",
"'weathers'",
"=>",
"$",
"weathers",
",",
"'downloadEnabled'",
"=>",
"$",
"this",
"->",
"downloadEnabled",
")",
")",
";",
"}"
] |
Renders weather list of a city for days
@param \Twig_Environment $environment
@param mixed (integer|string) $city
@param int $days
@return string
|
[
"Renders",
"weather",
"list",
"of",
"a",
"city",
"for",
"days"
] |
f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269
|
https://github.com/codebach/PianoSoloWeatherBundle/blob/f6b3ce0a86dbd8ab4e23d4e2d3031e6d4af0e269/Twig/WeatherExtension.php#L76-L85
|
224,751
|
joomla-framework/github-api
|
src/Package/Users/Followers.php
|
Followers.checkUserFollowing
|
public function checkUserFollowing($user, $target)
{
// Build the request path.
$path = "/user/$user/following/$target";
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204' :
// User is following the target
return true;
case '404' :
// User is not following the target
return false;
default :
throw new \UnexpectedValueException('Unexpected response code: ' . $response->code);
}
}
|
php
|
public function checkUserFollowing($user, $target)
{
// Build the request path.
$path = "/user/$user/following/$target";
$response = $this->client->get($this->fetchUrl($path));
switch ($response->code)
{
case '204' :
// User is following the target
return true;
case '404' :
// User is not following the target
return false;
default :
throw new \UnexpectedValueException('Unexpected response code: ' . $response->code);
}
}
|
[
"public",
"function",
"checkUserFollowing",
"(",
"$",
"user",
",",
"$",
"target",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"\"/user/$user/following/$target\"",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
";",
"switch",
"(",
"$",
"response",
"->",
"code",
")",
"{",
"case",
"'204'",
":",
"// User is following the target",
"return",
"true",
";",
"case",
"'404'",
":",
"// User is not following the target",
"return",
"false",
";",
"default",
":",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Unexpected response code: '",
".",
"$",
"response",
"->",
"code",
")",
";",
"}",
"}"
] |
Check if one user follows another.
@param string $user The name of the user.
@param string $target The name of the user to check is being followed.
@return boolean
@since 1.4.0
@throws \UnexpectedValueException
|
[
"Check",
"if",
"one",
"user",
"follows",
"another",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Users/Followers.php#L107-L127
|
224,752
|
acacha/users
|
src/Traits/HasPaginator.php
|
HasPaginator.paginate
|
protected function paginate($items, $perPage = 15)
{
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$currentPageItems = collect($items)->slice(($currentPage - 1) * $perPage, $perPage);
return new LengthAwarePaginator($currentPageItems, count($items), $perPage);
}
|
php
|
protected function paginate($items, $perPage = 15)
{
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$currentPageItems = collect($items)->slice(($currentPage - 1) * $perPage, $perPage);
return new LengthAwarePaginator($currentPageItems, count($items), $perPage);
}
|
[
"protected",
"function",
"paginate",
"(",
"$",
"items",
",",
"$",
"perPage",
"=",
"15",
")",
"{",
"$",
"currentPage",
"=",
"LengthAwarePaginator",
"::",
"resolveCurrentPage",
"(",
")",
";",
"$",
"currentPageItems",
"=",
"collect",
"(",
"$",
"items",
")",
"->",
"slice",
"(",
"(",
"$",
"currentPage",
"-",
"1",
")",
"*",
"$",
"perPage",
",",
"$",
"perPage",
")",
";",
"return",
"new",
"LengthAwarePaginator",
"(",
"$",
"currentPageItems",
",",
"count",
"(",
"$",
"items",
")",
",",
"$",
"perPage",
")",
";",
"}"
] |
Create a length aware custom paginator instance.
@param Collection $items
@param int $perPage
@return \Illuminate\Pagination\LengthAwarePaginator
|
[
"Create",
"a",
"length",
"aware",
"custom",
"paginator",
"instance",
"."
] |
af74be23d225bc9a23ee049579abb1596ae683c0
|
https://github.com/acacha/users/blob/af74be23d225bc9a23ee049579abb1596ae683c0/src/Traits/HasPaginator.php#L23-L30
|
224,753
|
netz98/n98-deployer
|
src/Deployer/Registry.php
|
Registry.registerTasks
|
public static function registerTasks(array $tasks)
{
// Register Tasks
foreach ($tasks as $key => $task) {
$roles = array_key_exists('roles', $task) ? $task['roles'] : null;
self::registerTask($key, $task['desc'], $task['callback'], $roles);
}
}
|
php
|
public static function registerTasks(array $tasks)
{
// Register Tasks
foreach ($tasks as $key => $task) {
$roles = array_key_exists('roles', $task) ? $task['roles'] : null;
self::registerTask($key, $task['desc'], $task['callback'], $roles);
}
}
|
[
"public",
"static",
"function",
"registerTasks",
"(",
"array",
"$",
"tasks",
")",
"{",
"// Register Tasks",
"foreach",
"(",
"$",
"tasks",
"as",
"$",
"key",
"=>",
"$",
"task",
")",
"{",
"$",
"roles",
"=",
"array_key_exists",
"(",
"'roles'",
",",
"$",
"task",
")",
"?",
"$",
"task",
"[",
"'roles'",
"]",
":",
"null",
";",
"self",
"::",
"registerTask",
"(",
"$",
"key",
",",
"$",
"task",
"[",
"'desc'",
"]",
",",
"$",
"task",
"[",
"'callback'",
"]",
",",
"$",
"roles",
")",
";",
"}",
"}"
] |
Register All N98 Tasks
@param array $tasks
|
[
"Register",
"All",
"N98",
"Tasks"
] |
cf7b7c790f45c41ed338b8a33b498eeaaaa765e9
|
https://github.com/netz98/n98-deployer/blob/cf7b7c790f45c41ed338b8a33b498eeaaaa765e9/src/Deployer/Registry.php#L20-L27
|
224,754
|
joomla-framework/github-api
|
src/Package/Issues/Labels.php
|
Labels.update
|
public function update($user, $repo, $label, $name, $color)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/labels/' . $label;
// Build the request data.
$data = json_encode(
array(
'name' => $name,
'color' => $color,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
php
|
public function update($user, $repo, $label, $name, $color)
{
// Build the request path.
$path = '/repos/' . $user . '/' . $repo . '/labels/' . $label;
// Build the request data.
$data = json_encode(
array(
'name' => $name,
'color' => $color,
)
);
// Send the request.
return $this->processResponse(
$this->client->patch($this->fetchUrl($path), $data)
);
}
|
[
"public",
"function",
"update",
"(",
"$",
"user",
",",
"$",
"repo",
",",
"$",
"label",
",",
"$",
"name",
",",
"$",
"color",
")",
"{",
"// Build the request path.",
"$",
"path",
"=",
"'/repos/'",
".",
"$",
"user",
".",
"'/'",
".",
"$",
"repo",
".",
"'/labels/'",
".",
"$",
"label",
";",
"// Build the request data.",
"$",
"data",
"=",
"json_encode",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'color'",
"=>",
"$",
"color",
",",
")",
")",
";",
"// Send the request.",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"client",
"->",
"patch",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
",",
"$",
"data",
")",
")",
";",
"}"
] |
Update a label.
@param string $user The name of the owner of the GitHub repository.
@param string $repo The name of the GitHub repository.
@param string $label The label name.
@param string $name The new label name.
@param string $color The new label color.
@return object
@since 1.0
|
[
"Update",
"a",
"label",
"."
] |
27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04
|
https://github.com/joomla-framework/github-api/blob/27dcf6ab6389f68cf01903fcec6ab7b5cdc30e04/src/Package/Issues/Labels.php#L131-L148
|
224,755
|
jonathantorres/laravel-medium-sdk
|
src/LaravelMediumSdkServiceProvider.php
|
LaravelMediumSdkServiceProvider.register
|
public function register()
{
$this->app->bind('JonathanTorres\LaravelMediumSdk\LaravelMediumSdk', function ($app) {
return new Medium([
'client-id' => config('laravel-medium-sdk.client-id'),
'client-secret' => config('laravel-medium-sdk.client-secret'),
'redirect-url' => config('laravel-medium-sdk.redirect-url'),
'state' => config('laravel-medium-sdk.state'),
'scopes' => config('laravel-medium-sdk.scopes'),
]);
});
}
|
php
|
public function register()
{
$this->app->bind('JonathanTorres\LaravelMediumSdk\LaravelMediumSdk', function ($app) {
return new Medium([
'client-id' => config('laravel-medium-sdk.client-id'),
'client-secret' => config('laravel-medium-sdk.client-secret'),
'redirect-url' => config('laravel-medium-sdk.redirect-url'),
'state' => config('laravel-medium-sdk.state'),
'scopes' => config('laravel-medium-sdk.scopes'),
]);
});
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'JonathanTorres\\LaravelMediumSdk\\LaravelMediumSdk'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Medium",
"(",
"[",
"'client-id'",
"=>",
"config",
"(",
"'laravel-medium-sdk.client-id'",
")",
",",
"'client-secret'",
"=>",
"config",
"(",
"'laravel-medium-sdk.client-secret'",
")",
",",
"'redirect-url'",
"=>",
"config",
"(",
"'laravel-medium-sdk.redirect-url'",
")",
",",
"'state'",
"=>",
"config",
"(",
"'laravel-medium-sdk.state'",
")",
",",
"'scopes'",
"=>",
"config",
"(",
"'laravel-medium-sdk.scopes'",
")",
",",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Register Medium class instance in the container.
@return void
|
[
"Register",
"Medium",
"class",
"instance",
"in",
"the",
"container",
"."
] |
8f9c7a2c86ad6f2b4cda56a7f582d8be123845be
|
https://github.com/jonathantorres/laravel-medium-sdk/blob/8f9c7a2c86ad6f2b4cda56a7f582d8be123845be/src/LaravelMediumSdkServiceProvider.php#L27-L38
|
224,756
|
Influendo/laravel-survivor
|
src/Survivor.php
|
Survivor.getScript
|
public function getScript()
{
$script = view('survivor::script')->with([
'token' => csrf_token(),
'url' => route('survivor.ping'),
'interval' => config('survivor.interval', 300000),
'input_elements' => config('survivor.input_elements', 'input[name=_token]'),
])->render();
return preg_replace('!\s+!', ' ', $script);
}
|
php
|
public function getScript()
{
$script = view('survivor::script')->with([
'token' => csrf_token(),
'url' => route('survivor.ping'),
'interval' => config('survivor.interval', 300000),
'input_elements' => config('survivor.input_elements', 'input[name=_token]'),
])->render();
return preg_replace('!\s+!', ' ', $script);
}
|
[
"public",
"function",
"getScript",
"(",
")",
"{",
"$",
"script",
"=",
"view",
"(",
"'survivor::script'",
")",
"->",
"with",
"(",
"[",
"'token'",
"=>",
"csrf_token",
"(",
")",
",",
"'url'",
"=>",
"route",
"(",
"'survivor.ping'",
")",
",",
"'interval'",
"=>",
"config",
"(",
"'survivor.interval'",
",",
"300000",
")",
",",
"'input_elements'",
"=>",
"config",
"(",
"'survivor.input_elements'",
",",
"'input[name=_token]'",
")",
",",
"]",
")",
"->",
"render",
"(",
")",
";",
"return",
"preg_replace",
"(",
"'!\\s+!'",
",",
"' '",
",",
"$",
"script",
")",
";",
"}"
] |
Return the script tag for the survivor lib
@return string
|
[
"Return",
"the",
"script",
"tag",
"for",
"the",
"survivor",
"lib"
] |
422aa0727110a86b8b0557bc48c68a94f0de6fba
|
https://github.com/Influendo/laravel-survivor/blob/422aa0727110a86b8b0557bc48c68a94f0de6fba/src/Survivor.php#L12-L22
|
224,757
|
rambler-digital-solutions/hydrogen
|
src/Query.php
|
Query.has
|
public function has(string $criterion): bool
{
foreach ($this->criteria as $haystack) {
if (\get_class($haystack) === $criterion) {
return true;
}
}
return false;
}
|
php
|
public function has(string $criterion): bool
{
foreach ($this->criteria as $haystack) {
if (\get_class($haystack) === $criterion) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"has",
"(",
"string",
"$",
"criterion",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"criteria",
"as",
"$",
"haystack",
")",
"{",
"if",
"(",
"\\",
"get_class",
"(",
"$",
"haystack",
")",
"===",
"$",
"criterion",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
The method checks for the presence of the required criterion inside the query.
TODO Add callable argument support (like filter).
@param string $criterion
@return bool
|
[
"The",
"method",
"checks",
"for",
"the",
"presence",
"of",
"the",
"required",
"criterion",
"inside",
"the",
"query",
"."
] |
997f37ede0b88f345f049ead61862ae20b1fe5e2
|
https://github.com/rambler-digital-solutions/hydrogen/blob/997f37ede0b88f345f049ead61862ae20b1fe5e2/src/Query.php#L110-L119
|
224,758
|
rambler-digital-solutions/hydrogen
|
src/Query.php
|
Query.column
|
public function column(string $name): string
{
$name = \addcslashes($name, "'");
$table = $this->getMetadata()->getTableName();
return \sprintf("FIELD('%s', '%s', '%s')", $table, $this->getAlias(), $name);
}
|
php
|
public function column(string $name): string
{
$name = \addcslashes($name, "'");
$table = $this->getMetadata()->getTableName();
return \sprintf("FIELD('%s', '%s', '%s')", $table, $this->getAlias(), $name);
}
|
[
"public",
"function",
"column",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"name",
"=",
"\\",
"addcslashes",
"(",
"$",
"name",
",",
"\"'\"",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
")",
"->",
"getTableName",
"(",
")",
";",
"return",
"\\",
"sprintf",
"(",
"\"FIELD('%s', '%s', '%s')\"",
",",
"$",
"table",
",",
"$",
"this",
"->",
"getAlias",
"(",
")",
",",
"$",
"name",
")",
";",
"}"
] |
Creates the ability to directly access the table's column.
@param string $name
@return string
|
[
"Creates",
"the",
"ability",
"to",
"directly",
"access",
"the",
"table",
"s",
"column",
"."
] |
997f37ede0b88f345f049ead61862ae20b1fe5e2
|
https://github.com/rambler-digital-solutions/hydrogen/blob/997f37ede0b88f345f049ead61862ae20b1fe5e2/src/Query.php#L145-L151
|
224,759
|
rambler-digital-solutions/hydrogen
|
src/Query.php
|
Query.merge
|
public function merge(Query $query): Query
{
foreach ($query->getCriteria() as $criterion) {
$criterion->attach($this);
}
return $this->attach($query);
}
|
php
|
public function merge(Query $query): Query
{
foreach ($query->getCriteria() as $criterion) {
$criterion->attach($this);
}
return $this->attach($query);
}
|
[
"public",
"function",
"merge",
"(",
"Query",
"$",
"query",
")",
":",
"Query",
"{",
"foreach",
"(",
"$",
"query",
"->",
"getCriteria",
"(",
")",
"as",
"$",
"criterion",
")",
"{",
"$",
"criterion",
"->",
"attach",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"attach",
"(",
"$",
"query",
")",
";",
"}"
] |
Copies a set of Criteria from the child query to the parent.
@param Query $query
@return Query
|
[
"Copies",
"a",
"set",
"of",
"Criteria",
"from",
"the",
"child",
"query",
"to",
"the",
"parent",
"."
] |
997f37ede0b88f345f049ead61862ae20b1fe5e2
|
https://github.com/rambler-digital-solutions/hydrogen/blob/997f37ede0b88f345f049ead61862ae20b1fe5e2/src/Query.php#L223-L230
|
224,760
|
rambler-digital-solutions/hydrogen
|
src/Query.php
|
Query.create
|
public function create(): Query
{
$query = static::new()->scope(...$this->getScopes());
if ($this->repository) {
return $query->from($this->repository);
}
return $query;
}
|
php
|
public function create(): Query
{
$query = static::new()->scope(...$this->getScopes());
if ($this->repository) {
return $query->from($this->repository);
}
return $query;
}
|
[
"public",
"function",
"create",
"(",
")",
":",
"Query",
"{",
"$",
"query",
"=",
"static",
"::",
"new",
"(",
")",
"->",
"scope",
"(",
"...",
"$",
"this",
"->",
"getScopes",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"repository",
")",
"{",
"return",
"$",
"query",
"->",
"from",
"(",
"$",
"this",
"->",
"repository",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Creates a new query using the current set of scopes.
@return Query
|
[
"Creates",
"a",
"new",
"query",
"using",
"the",
"current",
"set",
"of",
"scopes",
"."
] |
997f37ede0b88f345f049ead61862ae20b1fe5e2
|
https://github.com/rambler-digital-solutions/hydrogen/blob/997f37ede0b88f345f049ead61862ae20b1fe5e2/src/Query.php#L297-L306
|
224,761
|
dereuromark/cakephp-data
|
src/Model/Table/LocationsTable.php
|
LocationsTable.findIp
|
public static function findIp() {
if ((int)Configure::read('debug') > 1) {
$ip = Configure::read('App.defaultIp');
if ($ip) {
return $ip;
}
return '127.0.0.1';
}
$ip = Utility::getClientIp();
# usually getClientIp already removes multiple ips in favor of one single ip. but seems to fail sometimes
if (strpos($ip, ',') !== false) {
return false;
//$ips = explode(',', $ip);
//$ip = trim($ips[0]); # first
//$ip = trim($ips[count($ips)-1]); # last
}
return $ip;
}
|
php
|
public static function findIp() {
if ((int)Configure::read('debug') > 1) {
$ip = Configure::read('App.defaultIp');
if ($ip) {
return $ip;
}
return '127.0.0.1';
}
$ip = Utility::getClientIp();
# usually getClientIp already removes multiple ips in favor of one single ip. but seems to fail sometimes
if (strpos($ip, ',') !== false) {
return false;
//$ips = explode(',', $ip);
//$ip = trim($ips[0]); # first
//$ip = trim($ips[count($ips)-1]); # last
}
return $ip;
}
|
[
"public",
"static",
"function",
"findIp",
"(",
")",
"{",
"if",
"(",
"(",
"int",
")",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
">",
"1",
")",
"{",
"$",
"ip",
"=",
"Configure",
"::",
"read",
"(",
"'App.defaultIp'",
")",
";",
"if",
"(",
"$",
"ip",
")",
"{",
"return",
"$",
"ip",
";",
"}",
"return",
"'127.0.0.1'",
";",
"}",
"$",
"ip",
"=",
"Utility",
"::",
"getClientIp",
"(",
")",
";",
"# usually getClientIp already removes multiple ips in favor of one single ip. but seems to fail sometimes",
"if",
"(",
"strpos",
"(",
"$",
"ip",
",",
"','",
")",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"//$ips = explode(',', $ip);",
"//$ip = trim($ips[0]); # first",
"//$ip = trim($ips[count($ips)-1]); # last",
"}",
"return",
"$",
"ip",
";",
"}"
] |
Returns current IP address.
Note that in debug mode it will emulate it - and retrieve the preconfigured one.
NEW: if many ips in row (ip1, ip2, ip3), use last (or first???) one!
@return string IP
|
[
"Returns",
"current",
"IP",
"address",
".",
"Note",
"that",
"in",
"debug",
"mode",
"it",
"will",
"emulate",
"it",
"-",
"and",
"retrieve",
"the",
"preconfigured",
"one",
"."
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/LocationsTable.php#L151-L168
|
224,762
|
dereuromark/cakephp-data
|
src/Model/Table/DistrictsTable.php
|
DistrictsTable.getDistrictsByCity
|
public function getDistrictsByCity($citySlug, $type = 'all') {
$options = [
'contain' => ['Cities'],
'conditions' => [
//$this->alias.'.lat <>' => 0,
//$this->alias.'.lng <>' => 0,
$this->Cities->getAlias() . '.slug' => $citySlug,
],
'fields' => [$this->getAlias() . '.slug', $this->getAlias() . '.name'],
];
return $this->find($type, $options);
}
|
php
|
public function getDistrictsByCity($citySlug, $type = 'all') {
$options = [
'contain' => ['Cities'],
'conditions' => [
//$this->alias.'.lat <>' => 0,
//$this->alias.'.lng <>' => 0,
$this->Cities->getAlias() . '.slug' => $citySlug,
],
'fields' => [$this->getAlias() . '.slug', $this->getAlias() . '.name'],
];
return $this->find($type, $options);
}
|
[
"public",
"function",
"getDistrictsByCity",
"(",
"$",
"citySlug",
",",
"$",
"type",
"=",
"'all'",
")",
"{",
"$",
"options",
"=",
"[",
"'contain'",
"=>",
"[",
"'Cities'",
"]",
",",
"'conditions'",
"=>",
"[",
"//$this->alias.'.lat <>' => 0,",
"//$this->alias.'.lng <>' => 0,",
"$",
"this",
"->",
"Cities",
"->",
"getAlias",
"(",
")",
".",
"'.slug'",
"=>",
"$",
"citySlug",
",",
"]",
",",
"'fields'",
"=>",
"[",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.slug'",
",",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.name'",
"]",
",",
"]",
";",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"type",
",",
"$",
"options",
")",
";",
"}"
] |
For start page
@param string $citySlug
@param string $type
@return \Cake\ORM\Query
|
[
"For",
"start",
"page"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/DistrictsTable.php#L76-L87
|
224,763
|
sulu/SuluRedirectBundle
|
Controller/RedirectRouteImportController.php
|
RedirectRouteImportController.importAction
|
public function importAction(Request $request)
{
if (!$request->files->has('redirectRoutes')) {
return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
}
/** @var UploadedFile $uploadedFile */
$uploadedFile = $request->files->get('redirectRoutes');
$file = $uploadedFile->move(
$this->importPath,
$uploadedFile->getClientOriginalName()
);
try {
return new JsonResponse($this->importFile($file));
} catch (ReaderNotFoundException $exception) {
return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
} catch (ConverterNotFoundException $exception) {
return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
}
}
|
php
|
public function importAction(Request $request)
{
if (!$request->files->has('redirectRoutes')) {
return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
}
/** @var UploadedFile $uploadedFile */
$uploadedFile = $request->files->get('redirectRoutes');
$file = $uploadedFile->move(
$this->importPath,
$uploadedFile->getClientOriginalName()
);
try {
return new JsonResponse($this->importFile($file));
} catch (ReaderNotFoundException $exception) {
return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
} catch (ConverterNotFoundException $exception) {
return new JsonResponse(null, Response::HTTP_BAD_REQUEST);
}
}
|
[
"public",
"function",
"importAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"request",
"->",
"files",
"->",
"has",
"(",
"'redirectRoutes'",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"null",
",",
"Response",
"::",
"HTTP_BAD_REQUEST",
")",
";",
"}",
"/** @var UploadedFile $uploadedFile */",
"$",
"uploadedFile",
"=",
"$",
"request",
"->",
"files",
"->",
"get",
"(",
"'redirectRoutes'",
")",
";",
"$",
"file",
"=",
"$",
"uploadedFile",
"->",
"move",
"(",
"$",
"this",
"->",
"importPath",
",",
"$",
"uploadedFile",
"->",
"getClientOriginalName",
"(",
")",
")",
";",
"try",
"{",
"return",
"new",
"JsonResponse",
"(",
"$",
"this",
"->",
"importFile",
"(",
"$",
"file",
")",
")",
";",
"}",
"catch",
"(",
"ReaderNotFoundException",
"$",
"exception",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"null",
",",
"Response",
"::",
"HTTP_BAD_REQUEST",
")",
";",
"}",
"catch",
"(",
"ConverterNotFoundException",
"$",
"exception",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"null",
",",
"Response",
"::",
"HTTP_BAD_REQUEST",
")",
";",
"}",
"}"
] |
Import file which was uploaded.
@param Request $request
@return Response
|
[
"Import",
"file",
"which",
"was",
"uploaded",
"."
] |
913c501cced6c7db5fb96d4baf6cce4b884c65c6
|
https://github.com/sulu/SuluRedirectBundle/blob/913c501cced6c7db5fb96d4baf6cce4b884c65c6/Controller/RedirectRouteImportController.php#L56-L76
|
224,764
|
sulu/SuluRedirectBundle
|
Controller/RedirectRouteImportController.php
|
RedirectRouteImportController.importFile
|
private function importFile(File $file)
{
$response = [
'fileName' => $file->getFilename(),
'total' => 0,
'exceptions' => [],
];
/** @var Item $item */
foreach ($this->import->import($file->getRealPath()) as $item) {
++$response['total'];
if (!$item->getException()) {
continue;
}
$response['exceptions'][] = [
'exception' => $item->getException(),
'lineNumber' => $item->getLineNumber(),
'lineContent' => $item->getLineContent(),
];
}
return $response;
}
|
php
|
private function importFile(File $file)
{
$response = [
'fileName' => $file->getFilename(),
'total' => 0,
'exceptions' => [],
];
/** @var Item $item */
foreach ($this->import->import($file->getRealPath()) as $item) {
++$response['total'];
if (!$item->getException()) {
continue;
}
$response['exceptions'][] = [
'exception' => $item->getException(),
'lineNumber' => $item->getLineNumber(),
'lineContent' => $item->getLineContent(),
];
}
return $response;
}
|
[
"private",
"function",
"importFile",
"(",
"File",
"$",
"file",
")",
"{",
"$",
"response",
"=",
"[",
"'fileName'",
"=>",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'total'",
"=>",
"0",
",",
"'exceptions'",
"=>",
"[",
"]",
",",
"]",
";",
"/** @var Item $item */",
"foreach",
"(",
"$",
"this",
"->",
"import",
"->",
"import",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
"as",
"$",
"item",
")",
"{",
"++",
"$",
"response",
"[",
"'total'",
"]",
";",
"if",
"(",
"!",
"$",
"item",
"->",
"getException",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"response",
"[",
"'exceptions'",
"]",
"[",
"]",
"=",
"[",
"'exception'",
"=>",
"$",
"item",
"->",
"getException",
"(",
")",
",",
"'lineNumber'",
"=>",
"$",
"item",
"->",
"getLineNumber",
"(",
")",
",",
"'lineContent'",
"=>",
"$",
"item",
"->",
"getLineContent",
"(",
")",
",",
"]",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Import given file and returns serializable response.
@param File $file
@return array
|
[
"Import",
"given",
"file",
"and",
"returns",
"serializable",
"response",
"."
] |
913c501cced6c7db5fb96d4baf6cce4b884c65c6
|
https://github.com/sulu/SuluRedirectBundle/blob/913c501cced6c7db5fb96d4baf6cce4b884c65c6/Controller/RedirectRouteImportController.php#L85-L109
|
224,765
|
sulu/SuluRedirectBundle
|
Import/Reader/CsvReader.php
|
CsvReader.interpret
|
private function interpret(array $line, array $header)
{
$item = [];
foreach ($header as $index => $key) {
$item[$key] = array_key_exists($index, $line) ? $line[$index] : null;
}
return $item;
}
|
php
|
private function interpret(array $line, array $header)
{
$item = [];
foreach ($header as $index => $key) {
$item[$key] = array_key_exists($index, $line) ? $line[$index] : null;
}
return $item;
}
|
[
"private",
"function",
"interpret",
"(",
"array",
"$",
"line",
",",
"array",
"$",
"header",
")",
"{",
"$",
"item",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"header",
"as",
"$",
"index",
"=>",
"$",
"key",
")",
"{",
"$",
"item",
"[",
"$",
"key",
"]",
"=",
"array_key_exists",
"(",
"$",
"index",
",",
"$",
"line",
")",
"?",
"$",
"line",
"[",
"$",
"index",
"]",
":",
"null",
";",
"}",
"return",
"$",
"item",
";",
"}"
] |
Interpret given line.
@param array $line
@param array $header
@return array
|
[
"Interpret",
"given",
"line",
"."
] |
913c501cced6c7db5fb96d4baf6cce4b884c65c6
|
https://github.com/sulu/SuluRedirectBundle/blob/913c501cced6c7db5fb96d4baf6cce4b884c65c6/Import/Reader/CsvReader.php#L64-L72
|
224,766
|
addwiki/wikibase-api
|
src/Api/GenericOptions.php
|
GenericOptions.setOption
|
public function setOption( $option, $value ) {
if ( !is_string( $option ) ) {
throw new InvalidArgumentException( 'Option name needs to be a string' );
}
$this->options[$option] = $value;
}
|
php
|
public function setOption( $option, $value ) {
if ( !is_string( $option ) ) {
throw new InvalidArgumentException( 'Option name needs to be a string' );
}
$this->options[$option] = $value;
}
|
[
"public",
"function",
"setOption",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"option",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Option name needs to be a string'",
")",
";",
"}",
"$",
"this",
"->",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets the value of the specified option.
@since 0.2
@param string $option
@param mixed $value
@throws InvalidArgumentException
|
[
"Sets",
"the",
"value",
"of",
"the",
"specified",
"option",
"."
] |
86d397451692bd5984cad83e9d4f76c78a844fa1
|
https://github.com/addwiki/wikibase-api/blob/86d397451692bd5984cad83e9d4f76c78a844fa1/src/Api/GenericOptions.php#L50-L56
|
224,767
|
addwiki/wikibase-api
|
src/Api/GenericOptions.php
|
GenericOptions.getOption
|
public function getOption( $option ) {
if ( !array_key_exists( $option, $this->options ) ) {
throw new OutOfBoundsException( "Option '$option' has not been set so cannot be obtained" );
}
return $this->options[$option];
}
|
php
|
public function getOption( $option ) {
if ( !array_key_exists( $option, $this->options ) ) {
throw new OutOfBoundsException( "Option '$option' has not been set so cannot be obtained" );
}
return $this->options[$option];
}
|
[
"public",
"function",
"getOption",
"(",
"$",
"option",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"\"Option '$option' has not been set so cannot be obtained\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"options",
"[",
"$",
"option",
"]",
";",
"}"
] |
Returns the value of the specified option. If the option is not set,
an InvalidArgumentException is thrown.
@since 0.2
@param string $option
@throws OutOfBoundsException
|
[
"Returns",
"the",
"value",
"of",
"the",
"specified",
"option",
".",
"If",
"the",
"option",
"is",
"not",
"set",
"an",
"InvalidArgumentException",
"is",
"thrown",
"."
] |
86d397451692bd5984cad83e9d4f76c78a844fa1
|
https://github.com/addwiki/wikibase-api/blob/86d397451692bd5984cad83e9d4f76c78a844fa1/src/Api/GenericOptions.php#L68-L74
|
224,768
|
dereuromark/cakephp-data
|
src/Model/Table/LanguagesTable.php
|
LanguagesTable.codeList
|
public function codeList($conditions = []) {
$conditions += ['status' => 1];
$res = $this->find('all', ['conditions' => $conditions, 'fields' => ['code', 'name']]);
$ret = [];
foreach ($res as $language) {
$ret[$language['code']] = $language['name'];
}
return $ret;
}
|
php
|
public function codeList($conditions = []) {
$conditions += ['status' => 1];
$res = $this->find('all', ['conditions' => $conditions, 'fields' => ['code', 'name']]);
$ret = [];
foreach ($res as $language) {
$ret[$language['code']] = $language['name'];
}
return $ret;
}
|
[
"public",
"function",
"codeList",
"(",
"$",
"conditions",
"=",
"[",
"]",
")",
"{",
"$",
"conditions",
"+=",
"[",
"'status'",
"=>",
"1",
"]",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"find",
"(",
"'all'",
",",
"[",
"'conditions'",
"=>",
"$",
"conditions",
",",
"'fields'",
"=>",
"[",
"'code'",
",",
"'name'",
"]",
"]",
")",
";",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"res",
"as",
"$",
"language",
")",
"{",
"$",
"ret",
"[",
"$",
"language",
"[",
"'code'",
"]",
"]",
"=",
"$",
"language",
"[",
"'name'",
"]",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
DE => Deutsch, ...
@param array $conditions
@return array
|
[
"DE",
"=",
">",
"Deutsch",
"..."
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/LanguagesTable.php#L154-L162
|
224,769
|
opensky/OpenSkyRuntimeConfigBundle
|
Service/RuntimeParameterBag.php
|
RuntimeParameterBag.get
|
public function get($name)
{
$this->initialize();
if (!isset($this->parameters[$name]) && !array_key_exists($name, $this->parameters)) {
if ($this->container) {
return $this->container->getParameter($name);
}
return null;
}
return $this->parameters[$name];
}
|
php
|
public function get($name)
{
$this->initialize();
if (!isset($this->parameters[$name]) && !array_key_exists($name, $this->parameters)) {
if ($this->container) {
return $this->container->getParameter($name);
}
return null;
}
return $this->parameters[$name];
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"parameters",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"$",
"name",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"parameters",
"[",
"$",
"name",
"]",
";",
"}"
] |
Gets a parameter by name. If the parameter is undefined, this method will
defer to the service container if available.
{@inheritdoc}
|
[
"Gets",
"a",
"parameter",
"by",
"name",
".",
"If",
"the",
"parameter",
"is",
"undefined",
"this",
"method",
"will",
"defer",
"to",
"the",
"service",
"container",
"if",
"available",
"."
] |
bcd76223b6582d34ffcc3962802760bc98df8a6f
|
https://github.com/opensky/OpenSkyRuntimeConfigBundle/blob/bcd76223b6582d34ffcc3962802760bc98df8a6f/Service/RuntimeParameterBag.php#L59-L72
|
224,770
|
opensky/OpenSkyRuntimeConfigBundle
|
Service/RuntimeParameterBag.php
|
RuntimeParameterBag.has
|
public function has($name)
{
$this->initialize();
if (parent::has($name)) {
return true;
}
if ($this->container !== null) {
return $this->container->hasParameter($name);
}
return false;
}
|
php
|
public function has($name)
{
$this->initialize();
if (parent::has($name)) {
return true;
}
if ($this->container !== null) {
return $this->container->hasParameter($name);
}
return false;
}
|
[
"public",
"function",
"has",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"parent",
"::",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"container",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"->",
"hasParameter",
"(",
"$",
"name",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns whether a parameter is defined. This method does not consider
parameters from the service container, regardless of its availability.
{@inheritdoc}
|
[
"Returns",
"whether",
"a",
"parameter",
"is",
"defined",
".",
"This",
"method",
"does",
"not",
"consider",
"parameters",
"from",
"the",
"service",
"container",
"regardless",
"of",
"its",
"availability",
"."
] |
bcd76223b6582d34ffcc3962802760bc98df8a6f
|
https://github.com/opensky/OpenSkyRuntimeConfigBundle/blob/bcd76223b6582d34ffcc3962802760bc98df8a6f/Service/RuntimeParameterBag.php#L80-L93
|
224,771
|
tooleks/laravel-asset-version
|
src/Services/AssetService.php
|
AssetService.appendVersionToPath
|
protected function appendVersionToPath(string $path) : string
{
return ($this->version) ? ($path . '?v=' . $this->version) : ($path);
}
|
php
|
protected function appendVersionToPath(string $path) : string
{
return ($this->version) ? ($path . '?v=' . $this->version) : ($path);
}
|
[
"protected",
"function",
"appendVersionToPath",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"return",
"(",
"$",
"this",
"->",
"version",
")",
"?",
"(",
"$",
"path",
".",
"'?v='",
".",
"$",
"this",
"->",
"version",
")",
":",
"(",
"$",
"path",
")",
";",
"}"
] |
Append version parameter to the asset path.
@param string $path
@return string
|
[
"Append",
"version",
"parameter",
"to",
"the",
"asset",
"path",
"."
] |
0eae13d91002c3c29e1ae7c5809b540150d797fe
|
https://github.com/tooleks/laravel-asset-version/blob/0eae13d91002c3c29e1ae7c5809b540150d797fe/src/Services/AssetService.php#L88-L91
|
224,772
|
flipboxstudio/image-controller
|
src/Flipbox/ImageController/ImageUploader.php
|
ImageUploader.createUploadedFile
|
protected function createUploadedFile($file)
{
try {
$imageManager = new ImageManager;
$image = $imageManager->make($file);
$extension = $this->getExtensionFromMime($image->mime());
$fileName = $this->generateFileName($extension);
$temporaryPath = $this->getTemporaryImageBasePath();
$this->temporaryImage = $temporaryPath.'/'.$fileName;
$image->save($this->temporaryImage);
return new UploadedFile(
$this->temporaryImage,
$fileName,
$image->mime(),
$image->filesize(),
null,
TRUE
);
} catch (Exception $e) {
throw new ImageUploaderException("Error create uploaded file");
}
}
|
php
|
protected function createUploadedFile($file)
{
try {
$imageManager = new ImageManager;
$image = $imageManager->make($file);
$extension = $this->getExtensionFromMime($image->mime());
$fileName = $this->generateFileName($extension);
$temporaryPath = $this->getTemporaryImageBasePath();
$this->temporaryImage = $temporaryPath.'/'.$fileName;
$image->save($this->temporaryImage);
return new UploadedFile(
$this->temporaryImage,
$fileName,
$image->mime(),
$image->filesize(),
null,
TRUE
);
} catch (Exception $e) {
throw new ImageUploaderException("Error create uploaded file");
}
}
|
[
"protected",
"function",
"createUploadedFile",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"$",
"imageManager",
"=",
"new",
"ImageManager",
";",
"$",
"image",
"=",
"$",
"imageManager",
"->",
"make",
"(",
"$",
"file",
")",
";",
"$",
"extension",
"=",
"$",
"this",
"->",
"getExtensionFromMime",
"(",
"$",
"image",
"->",
"mime",
"(",
")",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"generateFileName",
"(",
"$",
"extension",
")",
";",
"$",
"temporaryPath",
"=",
"$",
"this",
"->",
"getTemporaryImageBasePath",
"(",
")",
";",
"$",
"this",
"->",
"temporaryImage",
"=",
"$",
"temporaryPath",
".",
"'/'",
".",
"$",
"fileName",
";",
"$",
"image",
"->",
"save",
"(",
"$",
"this",
"->",
"temporaryImage",
")",
";",
"return",
"new",
"UploadedFile",
"(",
"$",
"this",
"->",
"temporaryImage",
",",
"$",
"fileName",
",",
"$",
"image",
"->",
"mime",
"(",
")",
",",
"$",
"image",
"->",
"filesize",
"(",
")",
",",
"null",
",",
"TRUE",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ImageUploaderException",
"(",
"\"Error create uploaded file\"",
")",
";",
"}",
"}"
] |
create uploaded file
@param string $file
@return UploadedFile
|
[
"create",
"uploaded",
"file"
] |
a32649839adaec40929c14dce39fdaf764f07599
|
https://github.com/flipboxstudio/image-controller/blob/a32649839adaec40929c14dce39fdaf764f07599/src/Flipbox/ImageController/ImageUploader.php#L94-L116
|
224,773
|
flipboxstudio/image-controller
|
src/Flipbox/ImageController/ImageUploader.php
|
ImageUploader.getTemporaryImageBasePath
|
protected function getTemporaryImageBasePath()
{
$basePath = $this->getImageBasePath();
$temporaryPath = $basePath . '/'. $this->temporaryPath;
if (!File::exists($temporaryPath)) {
File::makeDirectory($temporaryPath, 0755, true);
}
return $temporaryPath;
}
|
php
|
protected function getTemporaryImageBasePath()
{
$basePath = $this->getImageBasePath();
$temporaryPath = $basePath . '/'. $this->temporaryPath;
if (!File::exists($temporaryPath)) {
File::makeDirectory($temporaryPath, 0755, true);
}
return $temporaryPath;
}
|
[
"protected",
"function",
"getTemporaryImageBasePath",
"(",
")",
"{",
"$",
"basePath",
"=",
"$",
"this",
"->",
"getImageBasePath",
"(",
")",
";",
"$",
"temporaryPath",
"=",
"$",
"basePath",
".",
"'/'",
".",
"$",
"this",
"->",
"temporaryPath",
";",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"$",
"temporaryPath",
")",
")",
"{",
"File",
"::",
"makeDirectory",
"(",
"$",
"temporaryPath",
",",
"0755",
",",
"true",
")",
";",
"}",
"return",
"$",
"temporaryPath",
";",
"}"
] |
get temporary image base path
@return string
|
[
"get",
"temporary",
"image",
"base",
"path"
] |
a32649839adaec40929c14dce39fdaf764f07599
|
https://github.com/flipboxstudio/image-controller/blob/a32649839adaec40929c14dce39fdaf764f07599/src/Flipbox/ImageController/ImageUploader.php#L167-L178
|
224,774
|
flipboxstudio/image-controller
|
src/Flipbox/ImageController/ImageUploader.php
|
ImageUploader.generateImageUrl
|
public function generateImageUrl($file, $size=null)
{
$url = $this->config->get('prefix').'/'.$file;
if (!is_null($size)) {
$url .= '?size='.$size;
}
return URL::to($url);
}
|
php
|
public function generateImageUrl($file, $size=null)
{
$url = $this->config->get('prefix').'/'.$file;
if (!is_null($size)) {
$url .= '?size='.$size;
}
return URL::to($url);
}
|
[
"public",
"function",
"generateImageUrl",
"(",
"$",
"file",
",",
"$",
"size",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'prefix'",
")",
".",
"'/'",
".",
"$",
"file",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"size",
")",
")",
"{",
"$",
"url",
".=",
"'?size='",
".",
"$",
"size",
";",
"}",
"return",
"URL",
"::",
"to",
"(",
"$",
"url",
")",
";",
"}"
] |
generate image file url
@param string $file, $size
@return string
|
[
"generate",
"image",
"file",
"url"
] |
a32649839adaec40929c14dce39fdaf764f07599
|
https://github.com/flipboxstudio/image-controller/blob/a32649839adaec40929c14dce39fdaf764f07599/src/Flipbox/ImageController/ImageUploader.php#L186-L195
|
224,775
|
rambler-digital-solutions/hydrogen
|
src/Collection.php
|
Collection.wrap
|
public static function wrap($value): self
{
switch (true) {
case $value instanceof self:
return new static($value);
case $value instanceof BaseCollection:
return new static($value);
default:
return new static(Arr::wrap($value));
}
}
|
php
|
public static function wrap($value): self
{
switch (true) {
case $value instanceof self:
return new static($value);
case $value instanceof BaseCollection:
return new static($value);
default:
return new static(Arr::wrap($value));
}
}
|
[
"public",
"static",
"function",
"wrap",
"(",
"$",
"value",
")",
":",
"self",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"value",
"instanceof",
"self",
":",
"return",
"new",
"static",
"(",
"$",
"value",
")",
";",
"case",
"$",
"value",
"instanceof",
"BaseCollection",
":",
"return",
"new",
"static",
"(",
"$",
"value",
")",
";",
"default",
":",
"return",
"new",
"static",
"(",
"Arr",
"::",
"wrap",
"(",
"$",
"value",
")",
")",
";",
"}",
"}"
] |
Wrap the given value in a collection if applicable.
@param mixed $value
@return static
|
[
"Wrap",
"the",
"given",
"value",
"in",
"a",
"collection",
"if",
"applicable",
"."
] |
997f37ede0b88f345f049ead61862ae20b1fe5e2
|
https://github.com/rambler-digital-solutions/hydrogen/blob/997f37ede0b88f345f049ead61862ae20b1fe5e2/src/Collection.php#L88-L100
|
224,776
|
Influendo/laravel-survivor
|
src/SurvivorServiceProvider.php
|
SurvivorServiceProvider.boot
|
public function boot()
{
// Setup config file
$this->publishes([__DIR__ . '/../config/config.php' => config_path('survivor.php')], 'survivor');
// Also setup views
$this->loadViewsFrom(__DIR__.'/../views', 'survivor');
// Load the routes if not cached already
if ( ! $this->app->routesAreCached()) {
require __DIR__ . '/routes.php';
}
// Also load the helper file
require __DIR__ . '/helpers.php';
// Setup a blade directive for the ping script
Blade::directive('survivor', function($expression) {
app('Influendo\LaravelSurvivor\Survivor')->getScript();
});
}
|
php
|
public function boot()
{
// Setup config file
$this->publishes([__DIR__ . '/../config/config.php' => config_path('survivor.php')], 'survivor');
// Also setup views
$this->loadViewsFrom(__DIR__.'/../views', 'survivor');
// Load the routes if not cached already
if ( ! $this->app->routesAreCached()) {
require __DIR__ . '/routes.php';
}
// Also load the helper file
require __DIR__ . '/helpers.php';
// Setup a blade directive for the ping script
Blade::directive('survivor', function($expression) {
app('Influendo\LaravelSurvivor\Survivor')->getScript();
});
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"// Setup config file",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../config/config.php'",
"=>",
"config_path",
"(",
"'survivor.php'",
")",
"]",
",",
"'survivor'",
")",
";",
"// Also setup views",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"__DIR__",
".",
"'/../views'",
",",
"'survivor'",
")",
";",
"// Load the routes if not cached already",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"routesAreCached",
"(",
")",
")",
"{",
"require",
"__DIR__",
".",
"'/routes.php'",
";",
"}",
"// Also load the helper file",
"require",
"__DIR__",
".",
"'/helpers.php'",
";",
"// Setup a blade directive for the ping script",
"Blade",
"::",
"directive",
"(",
"'survivor'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"app",
"(",
"'Influendo\\LaravelSurvivor\\Survivor'",
")",
"->",
"getScript",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Boot up the provider and load routes
@return void
|
[
"Boot",
"up",
"the",
"provider",
"and",
"load",
"routes"
] |
422aa0727110a86b8b0557bc48c68a94f0de6fba
|
https://github.com/Influendo/laravel-survivor/blob/422aa0727110a86b8b0557bc48c68a94f0de6fba/src/SurvivorServiceProvider.php#L22-L42
|
224,777
|
addwiki/wikibase-api
|
src/Api/Service/RevisionsGetter.php
|
RevisionsGetter.getRevisions
|
public function getRevisions( array $identifyingInfoArray ) {
$entityIdStrings = array();
$siteLinksStringMapping = array();
foreach( $identifyingInfoArray as $someInfo ) {
if( $someInfo instanceof EntityId ) {
$entityIdStrings[] = $someInfo->getSerialization();
} elseif ( $someInfo instanceof SiteLink ) {
$siteLinksStringMapping[ $someInfo->getSiteId() ][] = $someInfo->getPageName();
} elseif( is_string( $someInfo ) ) {
$entityIdStrings[] = $someInfo;
} else {
throw new InvalidArgumentException( 'Unexpected $identifyingInfoArray in RevisionsGetter::getRevisions' );
}
}
// The below makes as few requests as possible to get the Revisions required!
$gotRevisionsFromIds = false;
$revisions = new Revisions();
if( !empty( $siteLinksStringMapping ) ) {
foreach( $siteLinksStringMapping as $site => $siteLinkStrings ) {
$params = array( 'sites' => $site );
if( !$gotRevisionsFromIds && !empty( $entityIdStrings ) ) {
$params['ids'] = implode( '|', $entityIdStrings );
$gotRevisionsFromIds = true;
}
$params['titles'] = implode( '|', $siteLinkStrings );
$result = $this->api->getRequest( new SimpleRequest( 'wbgetentities', $params ) );
$resultRevisions = $this->newRevisionsFromResult( $result['entities'] );
$revisions->addRevisions( $resultRevisions );
}
} else {
$params = array( 'ids' => implode( '|', $entityIdStrings ) );
$result = $this->api->getRequest( new SimpleRequest( 'wbgetentities', $params ) );
$resultRevisions = $this->newRevisionsFromResult( $result['entities'] );
$revisions->addRevisions( $resultRevisions );
}
return $revisions;
}
|
php
|
public function getRevisions( array $identifyingInfoArray ) {
$entityIdStrings = array();
$siteLinksStringMapping = array();
foreach( $identifyingInfoArray as $someInfo ) {
if( $someInfo instanceof EntityId ) {
$entityIdStrings[] = $someInfo->getSerialization();
} elseif ( $someInfo instanceof SiteLink ) {
$siteLinksStringMapping[ $someInfo->getSiteId() ][] = $someInfo->getPageName();
} elseif( is_string( $someInfo ) ) {
$entityIdStrings[] = $someInfo;
} else {
throw new InvalidArgumentException( 'Unexpected $identifyingInfoArray in RevisionsGetter::getRevisions' );
}
}
// The below makes as few requests as possible to get the Revisions required!
$gotRevisionsFromIds = false;
$revisions = new Revisions();
if( !empty( $siteLinksStringMapping ) ) {
foreach( $siteLinksStringMapping as $site => $siteLinkStrings ) {
$params = array( 'sites' => $site );
if( !$gotRevisionsFromIds && !empty( $entityIdStrings ) ) {
$params['ids'] = implode( '|', $entityIdStrings );
$gotRevisionsFromIds = true;
}
$params['titles'] = implode( '|', $siteLinkStrings );
$result = $this->api->getRequest( new SimpleRequest( 'wbgetentities', $params ) );
$resultRevisions = $this->newRevisionsFromResult( $result['entities'] );
$revisions->addRevisions( $resultRevisions );
}
} else {
$params = array( 'ids' => implode( '|', $entityIdStrings ) );
$result = $this->api->getRequest( new SimpleRequest( 'wbgetentities', $params ) );
$resultRevisions = $this->newRevisionsFromResult( $result['entities'] );
$revisions->addRevisions( $resultRevisions );
}
return $revisions;
}
|
[
"public",
"function",
"getRevisions",
"(",
"array",
"$",
"identifyingInfoArray",
")",
"{",
"$",
"entityIdStrings",
"=",
"array",
"(",
")",
";",
"$",
"siteLinksStringMapping",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"identifyingInfoArray",
"as",
"$",
"someInfo",
")",
"{",
"if",
"(",
"$",
"someInfo",
"instanceof",
"EntityId",
")",
"{",
"$",
"entityIdStrings",
"[",
"]",
"=",
"$",
"someInfo",
"->",
"getSerialization",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"someInfo",
"instanceof",
"SiteLink",
")",
"{",
"$",
"siteLinksStringMapping",
"[",
"$",
"someInfo",
"->",
"getSiteId",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"someInfo",
"->",
"getPageName",
"(",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"someInfo",
")",
")",
"{",
"$",
"entityIdStrings",
"[",
"]",
"=",
"$",
"someInfo",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unexpected $identifyingInfoArray in RevisionsGetter::getRevisions'",
")",
";",
"}",
"}",
"// The below makes as few requests as possible to get the Revisions required!",
"$",
"gotRevisionsFromIds",
"=",
"false",
";",
"$",
"revisions",
"=",
"new",
"Revisions",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"siteLinksStringMapping",
")",
")",
"{",
"foreach",
"(",
"$",
"siteLinksStringMapping",
"as",
"$",
"site",
"=>",
"$",
"siteLinkStrings",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'sites'",
"=>",
"$",
"site",
")",
";",
"if",
"(",
"!",
"$",
"gotRevisionsFromIds",
"&&",
"!",
"empty",
"(",
"$",
"entityIdStrings",
")",
")",
"{",
"$",
"params",
"[",
"'ids'",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"entityIdStrings",
")",
";",
"$",
"gotRevisionsFromIds",
"=",
"true",
";",
"}",
"$",
"params",
"[",
"'titles'",
"]",
"=",
"implode",
"(",
"'|'",
",",
"$",
"siteLinkStrings",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"getRequest",
"(",
"new",
"SimpleRequest",
"(",
"'wbgetentities'",
",",
"$",
"params",
")",
")",
";",
"$",
"resultRevisions",
"=",
"$",
"this",
"->",
"newRevisionsFromResult",
"(",
"$",
"result",
"[",
"'entities'",
"]",
")",
";",
"$",
"revisions",
"->",
"addRevisions",
"(",
"$",
"resultRevisions",
")",
";",
"}",
"}",
"else",
"{",
"$",
"params",
"=",
"array",
"(",
"'ids'",
"=>",
"implode",
"(",
"'|'",
",",
"$",
"entityIdStrings",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"api",
"->",
"getRequest",
"(",
"new",
"SimpleRequest",
"(",
"'wbgetentities'",
",",
"$",
"params",
")",
")",
";",
"$",
"resultRevisions",
"=",
"$",
"this",
"->",
"newRevisionsFromResult",
"(",
"$",
"result",
"[",
"'entities'",
"]",
")",
";",
"$",
"revisions",
"->",
"addRevisions",
"(",
"$",
"resultRevisions",
")",
";",
"}",
"return",
"$",
"revisions",
";",
"}"
] |
Get revisions for the entities identified using as few requests as possible.
@param array $identifyingInfoArray Can include the following:
EntityId EntityId objects
SiteLink SiteLink objects
string Serialized entity ids (these are not validated before passing to the api)
@since 0.4
@return Revisions
|
[
"Get",
"revisions",
"for",
"the",
"entities",
"identified",
"using",
"as",
"few",
"requests",
"as",
"possible",
"."
] |
86d397451692bd5984cad83e9d4f76c78a844fa1
|
https://github.com/addwiki/wikibase-api/blob/86d397451692bd5984cad83e9d4f76c78a844fa1/src/Api/Service/RevisionsGetter.php#L58-L98
|
224,778
|
dereuromark/cakephp-data
|
src/Model/Table/PostalCodesTable.php
|
PostalCodesTable.stats
|
public function stats() {
$res = [];
$query = $this->find();
$list = $query
->select(['count' => $query->count(), 'country_id'])
->group('country_id')
->hydrate(false)
->all();
foreach ($list as $x) {
$res[$x['country_id']] = (int)$x['count'];
}
return $res;
}
|
php
|
public function stats() {
$res = [];
$query = $this->find();
$list = $query
->select(['count' => $query->count(), 'country_id'])
->group('country_id')
->hydrate(false)
->all();
foreach ($list as $x) {
$res[$x['country_id']] = (int)$x['count'];
}
return $res;
}
|
[
"public",
"function",
"stats",
"(",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
";",
"$",
"list",
"=",
"$",
"query",
"->",
"select",
"(",
"[",
"'count'",
"=>",
"$",
"query",
"->",
"count",
"(",
")",
",",
"'country_id'",
"]",
")",
"->",
"group",
"(",
"'country_id'",
")",
"->",
"hydrate",
"(",
"false",
")",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"x",
")",
"{",
"$",
"res",
"[",
"$",
"x",
"[",
"'country_id'",
"]",
"]",
"=",
"(",
"int",
")",
"$",
"x",
"[",
"'count'",
"]",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Postal codes per country
@return array
|
[
"Postal",
"codes",
"per",
"country"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/PostalCodesTable.php#L118-L133
|
224,779
|
sulu/SuluRedirectBundle
|
Controller/WebsiteRedirectController.php
|
WebsiteRedirectController.redirect
|
public function redirect(Request $request, RedirectRouteInterface $redirectRoute)
{
if (410 === $redirectRoute->getStatusCode()) {
throw new HttpException(410);
}
$queryString = http_build_query($request->query->all());
$url = [
$redirectRoute->getTarget(),
false === strpos($redirectRoute->getTarget(), '?') ? '?' : '&',
$queryString,
];
$url = trim(implode($url), '&? ');
return new RedirectResponse($url, $redirectRoute->getStatusCode());
}
|
php
|
public function redirect(Request $request, RedirectRouteInterface $redirectRoute)
{
if (410 === $redirectRoute->getStatusCode()) {
throw new HttpException(410);
}
$queryString = http_build_query($request->query->all());
$url = [
$redirectRoute->getTarget(),
false === strpos($redirectRoute->getTarget(), '?') ? '?' : '&',
$queryString,
];
$url = trim(implode($url), '&? ');
return new RedirectResponse($url, $redirectRoute->getStatusCode());
}
|
[
"public",
"function",
"redirect",
"(",
"Request",
"$",
"request",
",",
"RedirectRouteInterface",
"$",
"redirectRoute",
")",
"{",
"if",
"(",
"410",
"===",
"$",
"redirectRoute",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"HttpException",
"(",
"410",
")",
";",
"}",
"$",
"queryString",
"=",
"http_build_query",
"(",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"$",
"url",
"=",
"[",
"$",
"redirectRoute",
"->",
"getTarget",
"(",
")",
",",
"false",
"===",
"strpos",
"(",
"$",
"redirectRoute",
"->",
"getTarget",
"(",
")",
",",
"'?'",
")",
"?",
"'?'",
":",
"'&'",
",",
"$",
"queryString",
",",
"]",
";",
"$",
"url",
"=",
"trim",
"(",
"implode",
"(",
"$",
"url",
")",
",",
"'&? '",
")",
";",
"return",
"new",
"RedirectResponse",
"(",
"$",
"url",
",",
"$",
"redirectRoute",
"->",
"getStatusCode",
"(",
")",
")",
";",
"}"
] |
Handles redirect for given redirect-route.
@param Request $request
@param RedirectRouteInterface $redirectRoute
@return RedirectResponse
|
[
"Handles",
"redirect",
"for",
"given",
"redirect",
"-",
"route",
"."
] |
913c501cced6c7db5fb96d4baf6cce4b884c65c6
|
https://github.com/sulu/SuluRedirectBundle/blob/913c501cced6c7db5fb96d4baf6cce4b884c65c6/Controller/WebsiteRedirectController.php#L32-L49
|
224,780
|
opensky/OpenSkyRuntimeConfigBundle
|
Service/RuntimeParameterBagLogger.php
|
RuntimeParameterBagLogger.log
|
public function log($message)
{
if (null !== $this->logger) {
call_user_func(array($this->logger, $this->level), $message);
}
}
|
php
|
public function log($message)
{
if (null !== $this->logger) {
call_user_func(array($this->logger, $this->level), $message);
}
}
|
[
"public",
"function",
"log",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"logger",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"logger",
",",
"$",
"this",
"->",
"level",
")",
",",
"$",
"message",
")",
";",
"}",
"}"
] |
Log a message at the specified level.
@param string $message
|
[
"Log",
"a",
"message",
"at",
"the",
"specified",
"level",
"."
] |
bcd76223b6582d34ffcc3962802760bc98df8a6f
|
https://github.com/opensky/OpenSkyRuntimeConfigBundle/blob/bcd76223b6582d34ffcc3962802760bc98df8a6f/Service/RuntimeParameterBagLogger.php#L35-L40
|
224,781
|
dereuromark/cakephp-data
|
src/Controller/Admin/StatesController.php
|
StatesController._processCountry
|
protected function _processCountry($cid) {
$saveCid = true;
if (empty($cid)) {
$saveCid = false;
$cid = $this->request->getSession()->read('State.cid');
}
if (!empty($cid) && $cid < 0) {
$this->request->getSession()->delete('State.cid');
$cid = null;
} elseif (!empty($cid) && $saveCid) {
$this->request->getSession()->write('State.cid', $cid);
}
if (!empty($cid)) {
$this->paginate = ['conditions' => ['country_id' => $cid]] + $this->paginate;
$this->request->data['Filter']['id'] = $cid;
}
}
|
php
|
protected function _processCountry($cid) {
$saveCid = true;
if (empty($cid)) {
$saveCid = false;
$cid = $this->request->getSession()->read('State.cid');
}
if (!empty($cid) && $cid < 0) {
$this->request->getSession()->delete('State.cid');
$cid = null;
} elseif (!empty($cid) && $saveCid) {
$this->request->getSession()->write('State.cid', $cid);
}
if (!empty($cid)) {
$this->paginate = ['conditions' => ['country_id' => $cid]] + $this->paginate;
$this->request->data['Filter']['id'] = $cid;
}
}
|
[
"protected",
"function",
"_processCountry",
"(",
"$",
"cid",
")",
"{",
"$",
"saveCid",
"=",
"true",
";",
"if",
"(",
"empty",
"(",
"$",
"cid",
")",
")",
"{",
"$",
"saveCid",
"=",
"false",
";",
"$",
"cid",
"=",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"read",
"(",
"'State.cid'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"cid",
")",
"&&",
"$",
"cid",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"delete",
"(",
"'State.cid'",
")",
";",
"$",
"cid",
"=",
"null",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"cid",
")",
"&&",
"$",
"saveCid",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"write",
"(",
"'State.cid'",
",",
"$",
"cid",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"cid",
")",
")",
"{",
"$",
"this",
"->",
"paginate",
"=",
"[",
"'conditions'",
"=>",
"[",
"'country_id'",
"=>",
"$",
"cid",
"]",
"]",
"+",
"$",
"this",
"->",
"paginate",
";",
"$",
"this",
"->",
"request",
"->",
"data",
"[",
"'Filter'",
"]",
"[",
"'id'",
"]",
"=",
"$",
"cid",
";",
"}",
"}"
] |
For both index views
@deprecated
@param int $cid
@return \Cake\Http\Response|null
|
[
"For",
"both",
"index",
"views"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Controller/Admin/StatesController.php#L193-L210
|
224,782
|
dereuromark/cakephp-data
|
src/Controller/Admin/CurrenciesController.php
|
CurrenciesController.toggle
|
public function toggle($field = null, $id = null) {
$fields = ['active'];
if (!empty($field) && in_array($field, $fields) && !empty($id)) {
$value = $this->{$this->modelClass}->toggleField($field, $id);
}
# http get request + redirect
if (!$this->request->is('ajax')) {
$this->Flash->success(__('Saved'));
return $this->Common->autoRedirect(['action' => 'index']);
}
# ajax
$model = $this->{$this->modelClass}->alias;
$this->autoRender = false;
if (isset($value)) {
$this->set('ajaxToggle', $value);
$this->set(compact('field', 'model'));
//FIXME
$this->render('admin_toggle', 'ajax');
}
}
|
php
|
public function toggle($field = null, $id = null) {
$fields = ['active'];
if (!empty($field) && in_array($field, $fields) && !empty($id)) {
$value = $this->{$this->modelClass}->toggleField($field, $id);
}
# http get request + redirect
if (!$this->request->is('ajax')) {
$this->Flash->success(__('Saved'));
return $this->Common->autoRedirect(['action' => 'index']);
}
# ajax
$model = $this->{$this->modelClass}->alias;
$this->autoRender = false;
if (isset($value)) {
$this->set('ajaxToggle', $value);
$this->set(compact('field', 'model'));
//FIXME
$this->render('admin_toggle', 'ajax');
}
}
|
[
"public",
"function",
"toggle",
"(",
"$",
"field",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"'active'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
")",
"&&",
"in_array",
"(",
"$",
"field",
",",
"$",
"fields",
")",
"&&",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"modelClass",
"}",
"->",
"toggleField",
"(",
"$",
"field",
",",
"$",
"id",
")",
";",
"}",
"# http get request + redirect",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"__",
"(",
"'Saved'",
")",
")",
";",
"return",
"$",
"this",
"->",
"Common",
"->",
"autoRedirect",
"(",
"[",
"'action'",
"=>",
"'index'",
"]",
")",
";",
"}",
"# ajax",
"$",
"model",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"modelClass",
"}",
"->",
"alias",
";",
"$",
"this",
"->",
"autoRender",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"'ajaxToggle'",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'field'",
",",
"'model'",
")",
")",
";",
"//FIXME",
"$",
"this",
"->",
"render",
"(",
"'admin_toggle'",
",",
"'ajax'",
")",
";",
"}",
"}"
] |
Toggle - ajax
@param string|null $field
@param int|null $id
@return \Cake\Http\Response|null
|
[
"Toggle",
"-",
"ajax"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Controller/Admin/CurrenciesController.php#L152-L176
|
224,783
|
mcustiel/php-simple-cache
|
src/Drivers/memcache/Cache.php
|
Cache.openConnection
|
private function openConnection(\stdClass $initData)
{
$connectionOptions = $this->parseConnectionData($initData);
if (isset($this->persistent) && (boolean) $this->persistent) {
$this->persistentConnect($connectionOptions);
} else {
$this->notPersistentConnect($connectionOptions);
}
}
|
php
|
private function openConnection(\stdClass $initData)
{
$connectionOptions = $this->parseConnectionData($initData);
if (isset($this->persistent) && (boolean) $this->persistent) {
$this->persistentConnect($connectionOptions);
} else {
$this->notPersistentConnect($connectionOptions);
}
}
|
[
"private",
"function",
"openConnection",
"(",
"\\",
"stdClass",
"$",
"initData",
")",
"{",
"$",
"connectionOptions",
"=",
"$",
"this",
"->",
"parseConnectionData",
"(",
"$",
"initData",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"persistent",
")",
"&&",
"(",
"boolean",
")",
"$",
"this",
"->",
"persistent",
")",
"{",
"$",
"this",
"->",
"persistentConnect",
"(",
"$",
"connectionOptions",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"notPersistentConnect",
"(",
"$",
"connectionOptions",
")",
";",
"}",
"}"
] |
Opens a connection to memcached server.
@param \stdClass $initData
|
[
"Opens",
"a",
"connection",
"to",
"memcached",
"server",
"."
] |
ceb3856b5e672a7ab5196277e3e61dc697482a0b
|
https://github.com/mcustiel/php-simple-cache/blob/ceb3856b5e672a7ab5196277e3e61dc697482a0b/src/Drivers/memcache/Cache.php#L115-L123
|
224,784
|
mcustiel/php-simple-cache
|
src/Drivers/memcache/Cache.php
|
Cache.parseConnectionData
|
private function parseConnectionData(\stdClass $initData)
{
$return = new \stdClass;
$return->host = isset($initData->host) ? $initData->host : self::DEFAULT_HOST;
$return->port = isset($initData->port) ? $initData->port : null;
$return->timeout = isset($initData->timeoutInSeconds) ? $initData->timeoutInSeconds : null;
return $return;
}
|
php
|
private function parseConnectionData(\stdClass $initData)
{
$return = new \stdClass;
$return->host = isset($initData->host) ? $initData->host : self::DEFAULT_HOST;
$return->port = isset($initData->port) ? $initData->port : null;
$return->timeout = isset($initData->timeoutInSeconds) ? $initData->timeoutInSeconds : null;
return $return;
}
|
[
"private",
"function",
"parseConnectionData",
"(",
"\\",
"stdClass",
"$",
"initData",
")",
"{",
"$",
"return",
"=",
"new",
"\\",
"stdClass",
";",
"$",
"return",
"->",
"host",
"=",
"isset",
"(",
"$",
"initData",
"->",
"host",
")",
"?",
"$",
"initData",
"->",
"host",
":",
"self",
"::",
"DEFAULT_HOST",
";",
"$",
"return",
"->",
"port",
"=",
"isset",
"(",
"$",
"initData",
"->",
"port",
")",
"?",
"$",
"initData",
"->",
"port",
":",
"null",
";",
"$",
"return",
"->",
"timeout",
"=",
"isset",
"(",
"$",
"initData",
"->",
"timeoutInSeconds",
")",
"?",
"$",
"initData",
"->",
"timeoutInSeconds",
":",
"null",
";",
"return",
"$",
"return",
";",
"}"
] |
Fixes memcached configuration.
@param \stdClass $initData
@return \stdClass
|
[
"Fixes",
"memcached",
"configuration",
"."
] |
ceb3856b5e672a7ab5196277e3e61dc697482a0b
|
https://github.com/mcustiel/php-simple-cache/blob/ceb3856b5e672a7ab5196277e3e61dc697482a0b/src/Drivers/memcache/Cache.php#L170-L178
|
224,785
|
yii2mod/yii2-toggle-column
|
actions/ToggleAction.php
|
ToggleAction.run
|
public function run($id, $attribute)
{
$model = $this->findModel($this->modelClass, $id);
if (!$model->hasAttribute($attribute)) {
throw new InvalidConfigException("Attribute doesn't exist.");
}
if ($model->$attribute == $this->onValue) {
$model->$attribute = $this->offValue;
} else {
$model->$attribute = $this->onValue;
}
if ($this->preProcess && is_callable($this->preProcess, true)) {
call_user_func($this->preProcess, $model);
}
if ($model->save(true, [$attribute])) {
if ($this->setFlash) {
Yii::$app->session->setFlash('success', $this->flashSuccess);
}
} else {
if ($this->setFlash) {
Yii::$app->session->setFlash('error', $this->flashError);
}
}
if (Yii::$app->request->getIsAjax()) {
Yii::$app->end();
}
if (!empty($this->redirect)) {
return $this->controller->redirect($this->redirect);
}
return $this->controller->redirect(Yii::$app->request->getReferrer());
}
|
php
|
public function run($id, $attribute)
{
$model = $this->findModel($this->modelClass, $id);
if (!$model->hasAttribute($attribute)) {
throw new InvalidConfigException("Attribute doesn't exist.");
}
if ($model->$attribute == $this->onValue) {
$model->$attribute = $this->offValue;
} else {
$model->$attribute = $this->onValue;
}
if ($this->preProcess && is_callable($this->preProcess, true)) {
call_user_func($this->preProcess, $model);
}
if ($model->save(true, [$attribute])) {
if ($this->setFlash) {
Yii::$app->session->setFlash('success', $this->flashSuccess);
}
} else {
if ($this->setFlash) {
Yii::$app->session->setFlash('error', $this->flashError);
}
}
if (Yii::$app->request->getIsAjax()) {
Yii::$app->end();
}
if (!empty($this->redirect)) {
return $this->controller->redirect($this->redirect);
}
return $this->controller->redirect(Yii::$app->request->getReferrer());
}
|
[
"public",
"function",
"run",
"(",
"$",
"id",
",",
"$",
"attribute",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"this",
"->",
"modelClass",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"model",
"->",
"hasAttribute",
"(",
"$",
"attribute",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"Attribute doesn't exist.\"",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"$",
"attribute",
"==",
"$",
"this",
"->",
"onValue",
")",
"{",
"$",
"model",
"->",
"$",
"attribute",
"=",
"$",
"this",
"->",
"offValue",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"$",
"attribute",
"=",
"$",
"this",
"->",
"onValue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"preProcess",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"preProcess",
",",
"true",
")",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"preProcess",
",",
"$",
"model",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
"true",
",",
"[",
"$",
"attribute",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"setFlash",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"$",
"this",
"->",
"flashSuccess",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"setFlash",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'error'",
",",
"$",
"this",
"->",
"flashError",
")",
";",
"}",
"}",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getIsAjax",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"end",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"redirect",
")",
")",
"{",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirect",
"(",
"$",
"this",
"->",
"redirect",
")",
";",
"}",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirect",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"getReferrer",
"(",
")",
")",
";",
"}"
] |
Change column value
@param $id
@param $attribute
@return \yii\web\Response
@throws InvalidConfigException
|
[
"Change",
"column",
"value"
] |
f9251136728c70830a2b8fc138bf27c9638c8602
|
https://github.com/yii2mod/yii2-toggle-column/blob/f9251136728c70830a2b8fc138bf27c9638c8602/actions/ToggleAction.php#L86-L123
|
224,786
|
sulu/SuluRedirectBundle
|
Import/Writer/Writer.php
|
Writer.save
|
private function save(RedirectRouteInterface $entity)
{
$this->manager->save($entity);
if (0 === count($this->sources) % $this->batchSize) {
$this->entityManager->flush();
}
}
|
php
|
private function save(RedirectRouteInterface $entity)
{
$this->manager->save($entity);
if (0 === count($this->sources) % $this->batchSize) {
$this->entityManager->flush();
}
}
|
[
"private",
"function",
"save",
"(",
"RedirectRouteInterface",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"manager",
"->",
"save",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"this",
"->",
"sources",
")",
"%",
"$",
"this",
"->",
"batchSize",
")",
"{",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] |
Save entity by using manager.
@param RedirectRouteInterface $entity
|
[
"Save",
"entity",
"by",
"using",
"manager",
"."
] |
913c501cced6c7db5fb96d4baf6cce4b884c65c6
|
https://github.com/sulu/SuluRedirectBundle/blob/913c501cced6c7db5fb96d4baf6cce4b884c65c6/Import/Writer/Writer.php#L97-L104
|
224,787
|
sulu/SuluRedirectBundle
|
Import/Writer/Writer.php
|
Writer.validate
|
private function validate(RedirectRouteInterface $entity)
{
if ('' === $entity->getTarget() && Response::HTTP_GONE !== (int)$entity->getStatusCode()) {
throw new TargetIsEmptyException($entity);
}
if (in_array(strtolower($entity->getSource()), $this->sources)) {
throw new DuplicatedSourceException($entity);
}
}
|
php
|
private function validate(RedirectRouteInterface $entity)
{
if ('' === $entity->getTarget() && Response::HTTP_GONE !== (int)$entity->getStatusCode()) {
throw new TargetIsEmptyException($entity);
}
if (in_array(strtolower($entity->getSource()), $this->sources)) {
throw new DuplicatedSourceException($entity);
}
}
|
[
"private",
"function",
"validate",
"(",
"RedirectRouteInterface",
"$",
"entity",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"entity",
"->",
"getTarget",
"(",
")",
"&&",
"Response",
"::",
"HTTP_GONE",
"!==",
"(",
"int",
")",
"$",
"entity",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"TargetIsEmptyException",
"(",
"$",
"entity",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"$",
"entity",
"->",
"getSource",
"(",
")",
")",
",",
"$",
"this",
"->",
"sources",
")",
")",
"{",
"throw",
"new",
"DuplicatedSourceException",
"(",
"$",
"entity",
")",
";",
"}",
"}"
] |
Validate given redirect-route.
@param RedirectRouteInterface $entity
@throws DuplicatedSourceException
@throws TargetIsEmptyException
|
[
"Validate",
"given",
"redirect",
"-",
"route",
"."
] |
913c501cced6c7db5fb96d4baf6cce4b884c65c6
|
https://github.com/sulu/SuluRedirectBundle/blob/913c501cced6c7db5fb96d4baf6cce4b884c65c6/Import/Writer/Writer.php#L114-L123
|
224,788
|
dereuromark/cakephp-data
|
src/Controller/Admin/LanguagesController.php
|
LanguagesController.importFromCore
|
public function importFromCore() {
if (!empty($this->request->query['reset'])) {
$this->Languages->truncate();
}
//$languages = $this->Languages->iso3ToIso2();
$languages = $this->Languages->catalog();
$count = 0;
$errors = [];
foreach ($languages as $language) {
if (!($code = $this->Languages->iso3ToIso2($language['localeFallback']))) {
$code = '';
}
$data = [
'name' => $language,
'ori_name' => $language,
'code' => $code,
'locale' => $language['locale'],
'locale_fallback' => $language['localeFallback'],
'direction' => $language['direction']
];
$language = $this->Languages->newEntity($data);
if ($this->Languages->save($language)) {
$count++;
} else {
$errors[] = ['data' => $language, 'errors' => $this->Languages->validationErrors];
}
}
$this->Flash->success($count . ' of ' . count($languages) . ' ' . __('languages added'));
$errorMessage = [];
foreach ($errors as $error) {
$errorMessage[] = $error['data'] . ' (' . returns($error['errors']) . ')';
}
$this->Flash->warning(__('not added') . ' ' . implode(', ', $errorMessage));
return $this->redirect(['action' => 'index']);
}
|
php
|
public function importFromCore() {
if (!empty($this->request->query['reset'])) {
$this->Languages->truncate();
}
//$languages = $this->Languages->iso3ToIso2();
$languages = $this->Languages->catalog();
$count = 0;
$errors = [];
foreach ($languages as $language) {
if (!($code = $this->Languages->iso3ToIso2($language['localeFallback']))) {
$code = '';
}
$data = [
'name' => $language,
'ori_name' => $language,
'code' => $code,
'locale' => $language['locale'],
'locale_fallback' => $language['localeFallback'],
'direction' => $language['direction']
];
$language = $this->Languages->newEntity($data);
if ($this->Languages->save($language)) {
$count++;
} else {
$errors[] = ['data' => $language, 'errors' => $this->Languages->validationErrors];
}
}
$this->Flash->success($count . ' of ' . count($languages) . ' ' . __('languages added'));
$errorMessage = [];
foreach ($errors as $error) {
$errorMessage[] = $error['data'] . ' (' . returns($error['errors']) . ')';
}
$this->Flash->warning(__('not added') . ' ' . implode(', ', $errorMessage));
return $this->redirect(['action' => 'index']);
}
|
[
"public",
"function",
"importFromCore",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"query",
"[",
"'reset'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"Languages",
"->",
"truncate",
"(",
")",
";",
"}",
"//$languages = $this->Languages->iso3ToIso2();",
"$",
"languages",
"=",
"$",
"this",
"->",
"Languages",
"->",
"catalog",
"(",
")",
";",
"$",
"count",
"=",
"0",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"code",
"=",
"$",
"this",
"->",
"Languages",
"->",
"iso3ToIso2",
"(",
"$",
"language",
"[",
"'localeFallback'",
"]",
")",
")",
")",
"{",
"$",
"code",
"=",
"''",
";",
"}",
"$",
"data",
"=",
"[",
"'name'",
"=>",
"$",
"language",
",",
"'ori_name'",
"=>",
"$",
"language",
",",
"'code'",
"=>",
"$",
"code",
",",
"'locale'",
"=>",
"$",
"language",
"[",
"'locale'",
"]",
",",
"'locale_fallback'",
"=>",
"$",
"language",
"[",
"'localeFallback'",
"]",
",",
"'direction'",
"=>",
"$",
"language",
"[",
"'direction'",
"]",
"]",
";",
"$",
"language",
"=",
"$",
"this",
"->",
"Languages",
"->",
"newEntity",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Languages",
"->",
"save",
"(",
"$",
"language",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"else",
"{",
"$",
"errors",
"[",
"]",
"=",
"[",
"'data'",
"=>",
"$",
"language",
",",
"'errors'",
"=>",
"$",
"this",
"->",
"Languages",
"->",
"validationErrors",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"$",
"count",
".",
"' of '",
".",
"count",
"(",
"$",
"languages",
")",
".",
"' '",
".",
"__",
"(",
"'languages added'",
")",
")",
";",
"$",
"errorMessage",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"errorMessage",
"[",
"]",
"=",
"$",
"error",
"[",
"'data'",
"]",
".",
"' ('",
".",
"returns",
"(",
"$",
"error",
"[",
"'errors'",
"]",
")",
".",
"')'",
";",
"}",
"$",
"this",
"->",
"Flash",
"->",
"warning",
"(",
"__",
"(",
"'not added'",
")",
".",
"' '",
".",
"implode",
"(",
"', '",
",",
"$",
"errorMessage",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'index'",
"]",
")",
";",
"}"
] |
Should only be done once at the very beginning
@return \Cake\Http\Response|null
|
[
"Should",
"only",
"be",
"done",
"once",
"at",
"the",
"very",
"beginning"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Controller/Admin/LanguagesController.php#L119-L155
|
224,789
|
mediumart/orange-sms
|
src/SMS.php
|
SMS.from
|
public function from($number, $name = null)
{
$this->senderNumber = $number;
$this->senderName = $name;
return $this;
}
|
php
|
public function from($number, $name = null)
{
$this->senderNumber = $number;
$this->senderName = $name;
return $this;
}
|
[
"public",
"function",
"from",
"(",
"$",
"number",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"senderNumber",
"=",
"$",
"number",
";",
"$",
"this",
"->",
"senderName",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] |
set SMS sender details.
@param string $number
@param string|null $name
@return $this
|
[
"set",
"SMS",
"sender",
"details",
"."
] |
62aff9d24c326663fa8b9e742fa3f15c9df20945
|
https://github.com/mediumart/orange-sms/blob/62aff9d24c326663fa8b9e742fa3f15c9df20945/src/SMS.php#L83-L90
|
224,790
|
mediumart/orange-sms
|
src/SMS.php
|
SMS.send
|
public function send()
{
return $this->client->executeRequest(
new OutboundSMSRequest(
$this->message,
$this->recipientNumber,
$this->senderNumber,
$this->senderName
)
);
}
|
php
|
public function send()
{
return $this->client->executeRequest(
new OutboundSMSRequest(
$this->message,
$this->recipientNumber,
$this->senderNumber,
$this->senderName
)
);
}
|
[
"public",
"function",
"send",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"executeRequest",
"(",
"new",
"OutboundSMSRequest",
"(",
"$",
"this",
"->",
"message",
",",
"$",
"this",
"->",
"recipientNumber",
",",
"$",
"this",
"->",
"senderNumber",
",",
"$",
"this",
"->",
"senderName",
")",
")",
";",
"}"
] |
Send SMS.
@return array
|
[
"Send",
"SMS",
"."
] |
62aff9d24c326663fa8b9e742fa3f15c9df20945
|
https://github.com/mediumart/orange-sms/blob/62aff9d24c326663fa8b9e742fa3f15c9df20945/src/SMS.php#L110-L120
|
224,791
|
mediumart/orange-sms
|
src/SMS.php
|
SMS.statistics
|
public function statistics($country = null, $appID = null)
{
return $this->client->executeRequest(
new StatisticsRequest($country, $appID)
);
}
|
php
|
public function statistics($country = null, $appID = null)
{
return $this->client->executeRequest(
new StatisticsRequest($country, $appID)
);
}
|
[
"public",
"function",
"statistics",
"(",
"$",
"country",
"=",
"null",
",",
"$",
"appID",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"executeRequest",
"(",
"new",
"StatisticsRequest",
"(",
"$",
"country",
",",
"$",
"appID",
")",
")",
";",
"}"
] |
Get SMS statistics.
@param string|null $country
@param string|null $appID
@return array
|
[
"Get",
"SMS",
"statistics",
"."
] |
62aff9d24c326663fa8b9e742fa3f15c9df20945
|
https://github.com/mediumart/orange-sms/blob/62aff9d24c326663fa8b9e742fa3f15c9df20945/src/SMS.php#L155-L160
|
224,792
|
mediumart/orange-sms
|
src/SMS.php
|
SMS.setDeliveryReceiptNotificationUrl
|
public function setDeliveryReceiptNotificationUrl($url, $sender = null)
{
return $this->client->executeRequest(
new SMSDRRegisterCallbackRequest($url, $sender ?: $this->senderNumber)
);
}
|
php
|
public function setDeliveryReceiptNotificationUrl($url, $sender = null)
{
return $this->client->executeRequest(
new SMSDRRegisterCallbackRequest($url, $sender ?: $this->senderNumber)
);
}
|
[
"public",
"function",
"setDeliveryReceiptNotificationUrl",
"(",
"$",
"url",
",",
"$",
"sender",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"executeRequest",
"(",
"new",
"SMSDRRegisterCallbackRequest",
"(",
"$",
"url",
",",
"$",
"sender",
"?",
":",
"$",
"this",
"->",
"senderNumber",
")",
")",
";",
"}"
] |
Set the SMS DR notification endpoint.
@param $url
@param $sender
@return array
|
[
"Set",
"the",
"SMS",
"DR",
"notification",
"endpoint",
"."
] |
62aff9d24c326663fa8b9e742fa3f15c9df20945
|
https://github.com/mediumart/orange-sms/blob/62aff9d24c326663fa8b9e742fa3f15c9df20945/src/SMS.php#L169-L174
|
224,793
|
mediumart/orange-sms
|
src/SMS.php
|
SMS.deleteDeliveryReceiptNotificationUrl
|
public function deleteDeliveryReceiptNotificationUrl($id, $sender = null)
{
return $this->client->executeRequest(
new SMSDRDeleteCallbackRequest($id, $sender ?: $this->senderNumber)
);
}
|
php
|
public function deleteDeliveryReceiptNotificationUrl($id, $sender = null)
{
return $this->client->executeRequest(
new SMSDRDeleteCallbackRequest($id, $sender ?: $this->senderNumber)
);
}
|
[
"public",
"function",
"deleteDeliveryReceiptNotificationUrl",
"(",
"$",
"id",
",",
"$",
"sender",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"executeRequest",
"(",
"new",
"SMSDRDeleteCallbackRequest",
"(",
"$",
"id",
",",
"$",
"sender",
"?",
":",
"$",
"this",
"->",
"senderNumber",
")",
")",
";",
"}"
] |
Delete the SMS DR notification endpoint.
@param $id
@param $sender
@return array
|
[
"Delete",
"the",
"SMS",
"DR",
"notification",
"endpoint",
"."
] |
62aff9d24c326663fa8b9e742fa3f15c9df20945
|
https://github.com/mediumart/orange-sms/blob/62aff9d24c326663fa8b9e742fa3f15c9df20945/src/SMS.php#L196-L201
|
224,794
|
dereuromark/cakephp-data
|
src/Model/Table/CurrenciesTable.php
|
CurrenciesTable.foreignCurrencies
|
public function foreignCurrencies($options = []) {
$defaults = ['conditions' => [$this->getAlias() . '.base' => 0]];
$options = Hash::merge($defaults, $options);
return $this->find('all', $options);
}
|
php
|
public function foreignCurrencies($options = []) {
$defaults = ['conditions' => [$this->getAlias() . '.base' => 0]];
$options = Hash::merge($defaults, $options);
return $this->find('all', $options);
}
|
[
"public",
"function",
"foreignCurrencies",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'conditions'",
"=>",
"[",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.base'",
"=>",
"0",
"]",
"]",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"defaults",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"find",
"(",
"'all'",
",",
"$",
"options",
")",
";",
"}"
] |
All except base one
@param array $options
@return \Cake\ORM\Query
|
[
"All",
"except",
"base",
"one"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/CurrenciesTable.php#L194-L198
|
224,795
|
dereuromark/cakephp-data
|
src/Model/Table/CurrenciesTable.php
|
CurrenciesTable.availableCurrencies
|
public function availableCurrencies() {
if (!isset($this->CurrencyLib)) {
$this->CurrencyLib = new CurrencyLib();
}
$base = $this->baseCurrency();
$res = $this->CurrencyLib->table($base['code'], 4);
if ($res) {
return $res;
}
return [];
}
|
php
|
public function availableCurrencies() {
if (!isset($this->CurrencyLib)) {
$this->CurrencyLib = new CurrencyLib();
}
$base = $this->baseCurrency();
$res = $this->CurrencyLib->table($base['code'], 4);
if ($res) {
return $res;
}
return [];
}
|
[
"public",
"function",
"availableCurrencies",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"CurrencyLib",
")",
")",
"{",
"$",
"this",
"->",
"CurrencyLib",
"=",
"new",
"CurrencyLib",
"(",
")",
";",
"}",
"$",
"base",
"=",
"$",
"this",
"->",
"baseCurrency",
"(",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"CurrencyLib",
"->",
"table",
"(",
"$",
"base",
"[",
"'code'",
"]",
",",
"4",
")",
";",
"if",
"(",
"$",
"res",
")",
"{",
"return",
"$",
"res",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
For calculation etc
@return array
|
[
"For",
"calculation",
"etc"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/CurrenciesTable.php#L216-L226
|
224,796
|
dereuromark/cakephp-data
|
src/Model/Table/CurrenciesTable.php
|
CurrenciesTable.currencyList
|
public function currencyList() {
$res = $this->availableCurrencies();
foreach ($res as $key => $val) {
$val = $key;
$valExt = $this->CurrencyLib->getName($key);
if ($valExt) {
$val .= ' - ' . $valExt;
}
$res[$key] = $val;
}
return $res;
}
|
php
|
public function currencyList() {
$res = $this->availableCurrencies();
foreach ($res as $key => $val) {
$val = $key;
$valExt = $this->CurrencyLib->getName($key);
if ($valExt) {
$val .= ' - ' . $valExt;
}
$res[$key] = $val;
}
return $res;
}
|
[
"public",
"function",
"currencyList",
"(",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"availableCurrencies",
"(",
")",
";",
"foreach",
"(",
"$",
"res",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"$",
"key",
";",
"$",
"valExt",
"=",
"$",
"this",
"->",
"CurrencyLib",
"->",
"getName",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"valExt",
")",
"{",
"$",
"val",
".=",
"' - '",
".",
"$",
"valExt",
";",
"}",
"$",
"res",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
For user selection
@return array
|
[
"For",
"user",
"selection"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/CurrenciesTable.php#L233-L246
|
224,797
|
enlitepro/enlite-monolog
|
src/EnliteMonolog/Service/MonologServiceFactory.php
|
MonologServiceFactory.createInstanceFromArguments
|
private function createInstanceFromArguments($className, array $arguments)
{
$reflection = new \ReflectionClass($className);
$constructor = $reflection->getConstructor();
// There is no or at least a non-accessible constructor for provided class name,
// therefore there is no need to handle arguments anyway
if ($constructor === null) {
return $reflection->newInstanceArgs($arguments);
}
if (!$constructor->isPublic()) {
throw new \InvalidArgumentException(sprintf(
'%s::__construct is not accessible',
$className
));
}
$requiredArgsCount = $constructor->getNumberOfRequiredParameters();
$argumentCount = count($arguments);
if ($requiredArgsCount > $argumentCount) {
throw new \InvalidArgumentException(sprintf(
'%s::__construct() requires at least %d arguments; %d given',
$className,
$requiredArgsCount,
$argumentCount
));
}
// Arguments supposed to be ordered
if (isset($arguments[0])) {
return $reflection->newInstanceArgs($arguments);
}
$parameters = array();
foreach ($constructor->getParameters() as $parameter) {
$parameterName = $parameter->getName();
if (array_key_exists($parameterName, $arguments)) {
$parameters[$parameter->getPosition()] = $arguments[$parameterName];
continue;
}
if (!$parameter->isOptional()) {
throw new \InvalidArgumentException(sprintf(
'Missing at least one required parameters `%s`',
$parameterName
));
}
$parameters[$parameter->getPosition()] = $parameter->getDefaultValue();
}
return $reflection->newInstanceArgs($parameters);
}
|
php
|
private function createInstanceFromArguments($className, array $arguments)
{
$reflection = new \ReflectionClass($className);
$constructor = $reflection->getConstructor();
// There is no or at least a non-accessible constructor for provided class name,
// therefore there is no need to handle arguments anyway
if ($constructor === null) {
return $reflection->newInstanceArgs($arguments);
}
if (!$constructor->isPublic()) {
throw new \InvalidArgumentException(sprintf(
'%s::__construct is not accessible',
$className
));
}
$requiredArgsCount = $constructor->getNumberOfRequiredParameters();
$argumentCount = count($arguments);
if ($requiredArgsCount > $argumentCount) {
throw new \InvalidArgumentException(sprintf(
'%s::__construct() requires at least %d arguments; %d given',
$className,
$requiredArgsCount,
$argumentCount
));
}
// Arguments supposed to be ordered
if (isset($arguments[0])) {
return $reflection->newInstanceArgs($arguments);
}
$parameters = array();
foreach ($constructor->getParameters() as $parameter) {
$parameterName = $parameter->getName();
if (array_key_exists($parameterName, $arguments)) {
$parameters[$parameter->getPosition()] = $arguments[$parameterName];
continue;
}
if (!$parameter->isOptional()) {
throw new \InvalidArgumentException(sprintf(
'Missing at least one required parameters `%s`',
$parameterName
));
}
$parameters[$parameter->getPosition()] = $parameter->getDefaultValue();
}
return $reflection->newInstanceArgs($parameters);
}
|
[
"private",
"function",
"createInstanceFromArguments",
"(",
"$",
"className",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"constructor",
"=",
"$",
"reflection",
"->",
"getConstructor",
"(",
")",
";",
"// There is no or at least a non-accessible constructor for provided class name,",
"// therefore there is no need to handle arguments anyway",
"if",
"(",
"$",
"constructor",
"===",
"null",
")",
"{",
"return",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"arguments",
")",
";",
"}",
"if",
"(",
"!",
"$",
"constructor",
"->",
"isPublic",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s::__construct is not accessible'",
",",
"$",
"className",
")",
")",
";",
"}",
"$",
"requiredArgsCount",
"=",
"$",
"constructor",
"->",
"getNumberOfRequiredParameters",
"(",
")",
";",
"$",
"argumentCount",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"$",
"requiredArgsCount",
">",
"$",
"argumentCount",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s::__construct() requires at least %d arguments; %d given'",
",",
"$",
"className",
",",
"$",
"requiredArgsCount",
",",
"$",
"argumentCount",
")",
")",
";",
"}",
"// Arguments supposed to be ordered",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"arguments",
")",
";",
"}",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"constructor",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"$",
"parameterName",
"=",
"$",
"parameter",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"parameterName",
",",
"$",
"arguments",
")",
")",
"{",
"$",
"parameters",
"[",
"$",
"parameter",
"->",
"getPosition",
"(",
")",
"]",
"=",
"$",
"arguments",
"[",
"$",
"parameterName",
"]",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"parameter",
"->",
"isOptional",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Missing at least one required parameters `%s`'",
",",
"$",
"parameterName",
")",
")",
";",
"}",
"$",
"parameters",
"[",
"$",
"parameter",
"->",
"getPosition",
"(",
")",
"]",
"=",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"return",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"parameters",
")",
";",
"}"
] |
Handles the constructor arguments and if they're named, just sort them to fit constructor ordering.
@param string $className
@param array $arguments
@return object
@throws \InvalidArgumentException If given arguments are not valid for provided className constructor.
|
[
"Handles",
"the",
"constructor",
"arguments",
"and",
"if",
"they",
"re",
"named",
"just",
"sort",
"them",
"to",
"fit",
"constructor",
"ordering",
"."
] |
4c3064f25499ee78b26e4706852acae3e228e81f
|
https://github.com/enlitepro/enlite-monolog/blob/4c3064f25499ee78b26e4706852acae3e228e81f/src/EnliteMonolog/Service/MonologServiceFactory.php#L250-L306
|
224,798
|
schmittjoh/composer-deps-analyzer
|
src/JMS/Composer/Graph/DependencyGraph.php
|
DependencyGraph.getAggregatePackageContaining
|
public function getAggregatePackageContaining($packageName)
{
foreach ($this->packages as $packageNode) {
if ($packageNode->replaces($packageName)) {
return $packageNode;
}
}
return null;
}
|
php
|
public function getAggregatePackageContaining($packageName)
{
foreach ($this->packages as $packageNode) {
if ($packageNode->replaces($packageName)) {
return $packageNode;
}
}
return null;
}
|
[
"public",
"function",
"getAggregatePackageContaining",
"(",
"$",
"packageName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"packages",
"as",
"$",
"packageNode",
")",
"{",
"if",
"(",
"$",
"packageNode",
"->",
"replaces",
"(",
"$",
"packageName",
")",
")",
"{",
"return",
"$",
"packageNode",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Searches the graph for an aggregate package that contains the given package.
@param string $packageName the name of the contained package
@return PackageNode|null the aggregate package
|
[
"Searches",
"the",
"graph",
"for",
"an",
"aggregate",
"package",
"that",
"contains",
"the",
"given",
"package",
"."
] |
6e72a866c40a98e63efb6bb059a2bbaadcb8aa15
|
https://github.com/schmittjoh/composer-deps-analyzer/blob/6e72a866c40a98e63efb6bb059a2bbaadcb8aa15/src/JMS/Composer/Graph/DependencyGraph.php#L156-L165
|
224,799
|
dereuromark/cakephp-data
|
src/Model/Table/AddressesTable.php
|
AddressesTable.fitsToCountry
|
public function fitsToCountry($data) {
if (!isset($data['country_id']) || !isset($data['country_province_id'])) {
return true;
}
$res = $this->Countries->States->find('list', [
'conditions' => ['country_id' => $data['country_id']]
])->toArray();
if (empty($res) || array_shift($data) == 0) {
$data['country_province_id'] = 0;
} elseif (empty($data['country_province_id']) || !array_key_exists($data['country_province_id'], $res)) {
return false;
}
return true;
}
|
php
|
public function fitsToCountry($data) {
if (!isset($data['country_id']) || !isset($data['country_province_id'])) {
return true;
}
$res = $this->Countries->States->find('list', [
'conditions' => ['country_id' => $data['country_id']]
])->toArray();
if (empty($res) || array_shift($data) == 0) {
$data['country_province_id'] = 0;
} elseif (empty($data['country_province_id']) || !array_key_exists($data['country_province_id'], $res)) {
return false;
}
return true;
}
|
[
"public",
"function",
"fitsToCountry",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'country_id'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"data",
"[",
"'country_province_id'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"res",
"=",
"$",
"this",
"->",
"Countries",
"->",
"States",
"->",
"find",
"(",
"'list'",
",",
"[",
"'conditions'",
"=>",
"[",
"'country_id'",
"=>",
"$",
"data",
"[",
"'country_id'",
"]",
"]",
"]",
")",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"res",
")",
"||",
"array_shift",
"(",
"$",
"data",
")",
"==",
"0",
")",
"{",
"$",
"data",
"[",
"'country_province_id'",
"]",
"=",
"0",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"data",
"[",
"'country_province_id'",
"]",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"data",
"[",
"'country_province_id'",
"]",
",",
"$",
"res",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validation of country_province_id
@param string $data
@return bool
|
[
"Validation",
"of",
"country_province_id"
] |
362f8db270fc994ac3665c33682cefba7d73bb44
|
https://github.com/dereuromark/cakephp-data/blob/362f8db270fc994ac3665c33682cefba7d73bb44/src/Model/Table/AddressesTable.php#L231-L244
|
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.