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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
27,500
|
Litepie/Message
|
src/Http/Controllers/MessageResourceController.php
|
MessageResourceController.show
|
public function show(MessageRequest $request, Message $message)
{
if ($message->exists) {
$view = 'message::message.show';
} else {
$view = 'message::message.new';
}
return $this->response->title(trans('app.view') . ' ' . trans('message::message.name'))
->data(compact('message'))
->view($view, true)
->output();
}
|
php
|
public function show(MessageRequest $request, Message $message)
{
if ($message->exists) {
$view = 'message::message.show';
} else {
$view = 'message::message.new';
}
return $this->response->title(trans('app.view') . ' ' . trans('message::message.name'))
->data(compact('message'))
->view($view, true)
->output();
}
|
[
"public",
"function",
"show",
"(",
"MessageRequest",
"$",
"request",
",",
"Message",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"exists",
")",
"{",
"$",
"view",
"=",
"'message::message.show'",
";",
"}",
"else",
"{",
"$",
"view",
"=",
"'message::message.new'",
";",
"}",
"return",
"$",
"this",
"->",
"response",
"->",
"title",
"(",
"trans",
"(",
"'app.view'",
")",
".",
"' '",
".",
"trans",
"(",
"'message::message.name'",
")",
")",
"->",
"data",
"(",
"compact",
"(",
"'message'",
")",
")",
"->",
"view",
"(",
"$",
"view",
",",
"true",
")",
"->",
"output",
"(",
")",
";",
"}"
] |
Display message.
@param Request $request
@param Model $message
@return Response
|
[
"Display",
"message",
"."
] |
6c123f0feea627d572141fd71935250f3ba3cad0
|
https://github.com/Litepie/Message/blob/6c123f0feea627d572141fd71935250f3ba3cad0/src/Http/Controllers/MessageResourceController.php#L66-L79
|
27,501
|
Litepie/Message
|
src/Http/Controllers/MessageResourceController.php
|
MessageResourceController.store
|
public function store(MessageRequest $request)
{
try {
$mail_to = $request->get('mails');
$status = $request->get('status');
$sent = $request->all();
$inbox = $request->all();
$draft = $request->all();
if (empty($mail_to)) {
return response()->json([
'message' => trans('messages.success.updated', ['Module' => trans('message::message.name')]),
'code' => 204,
'redirect' => trans_url('/admin/message/message/0'),
], 201);
}
foreach ($mail_to as $user_id) {
if ($status == 'Draft') {
//draft
$draft['user_id'] = user_id('admin.web');
$draft['user_type'] = user_type('admin.web');
$draft['to'] = $user_id;
$draft['status'] = "Draft";
$message1 = $this->repository->create($draft);
} else {
//sent
$sent['user_id'] = user_id('admin.web');
$sent['user_type'] = user_type('admin.web');
$sent['to'] = $user_id;
$message = $this->repository->create($sent);
//inbox
$inbox['user_id'] = user_id('admin.web');
$inbox['user_type'] = user_type('admin.web');
$inbox['to'] = $user_id;
$inbox['status'] = "Inbox";
$message1 = $this->repository->create($inbox);
}
}
$inbox_count = $this->repository->msgCount('Inbox');
$draft_count = $this->repository->msgCount('Draft');
$sent_count = $this->repository->msgCount('Sent');
return response()->json([
'message' => trans('messages.success.updated', ['Module' => trans('message::message.name')]),
'code' => 204,
'redirect' => trans_url('/admin/message/message/status/Inbox'),
'inbox_count' => $inbox_count,
'draft_count' => $draft_count,
'sent_count' => $sent_count,
], 201);
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'code' => 400,
], 400);
}
}
|
php
|
public function store(MessageRequest $request)
{
try {
$mail_to = $request->get('mails');
$status = $request->get('status');
$sent = $request->all();
$inbox = $request->all();
$draft = $request->all();
if (empty($mail_to)) {
return response()->json([
'message' => trans('messages.success.updated', ['Module' => trans('message::message.name')]),
'code' => 204,
'redirect' => trans_url('/admin/message/message/0'),
], 201);
}
foreach ($mail_to as $user_id) {
if ($status == 'Draft') {
//draft
$draft['user_id'] = user_id('admin.web');
$draft['user_type'] = user_type('admin.web');
$draft['to'] = $user_id;
$draft['status'] = "Draft";
$message1 = $this->repository->create($draft);
} else {
//sent
$sent['user_id'] = user_id('admin.web');
$sent['user_type'] = user_type('admin.web');
$sent['to'] = $user_id;
$message = $this->repository->create($sent);
//inbox
$inbox['user_id'] = user_id('admin.web');
$inbox['user_type'] = user_type('admin.web');
$inbox['to'] = $user_id;
$inbox['status'] = "Inbox";
$message1 = $this->repository->create($inbox);
}
}
$inbox_count = $this->repository->msgCount('Inbox');
$draft_count = $this->repository->msgCount('Draft');
$sent_count = $this->repository->msgCount('Sent');
return response()->json([
'message' => trans('messages.success.updated', ['Module' => trans('message::message.name')]),
'code' => 204,
'redirect' => trans_url('/admin/message/message/status/Inbox'),
'inbox_count' => $inbox_count,
'draft_count' => $draft_count,
'sent_count' => $sent_count,
], 201);
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'code' => 400,
], 400);
}
}
|
[
"public",
"function",
"store",
"(",
"MessageRequest",
"$",
"request",
")",
"{",
"try",
"{",
"$",
"mail_to",
"=",
"$",
"request",
"->",
"get",
"(",
"'mails'",
")",
";",
"$",
"status",
"=",
"$",
"request",
"->",
"get",
"(",
"'status'",
")",
";",
"$",
"sent",
"=",
"$",
"request",
"->",
"all",
"(",
")",
";",
"$",
"inbox",
"=",
"$",
"request",
"->",
"all",
"(",
")",
";",
"$",
"draft",
"=",
"$",
"request",
"->",
"all",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"mail_to",
")",
")",
"{",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'message'",
"=>",
"trans",
"(",
"'messages.success.updated'",
",",
"[",
"'Module'",
"=>",
"trans",
"(",
"'message::message.name'",
")",
"]",
")",
",",
"'code'",
"=>",
"204",
",",
"'redirect'",
"=>",
"trans_url",
"(",
"'/admin/message/message/0'",
")",
",",
"]",
",",
"201",
")",
";",
"}",
"foreach",
"(",
"$",
"mail_to",
"as",
"$",
"user_id",
")",
"{",
"if",
"(",
"$",
"status",
"==",
"'Draft'",
")",
"{",
"//draft",
"$",
"draft",
"[",
"'user_id'",
"]",
"=",
"user_id",
"(",
"'admin.web'",
")",
";",
"$",
"draft",
"[",
"'user_type'",
"]",
"=",
"user_type",
"(",
"'admin.web'",
")",
";",
"$",
"draft",
"[",
"'to'",
"]",
"=",
"$",
"user_id",
";",
"$",
"draft",
"[",
"'status'",
"]",
"=",
"\"Draft\"",
";",
"$",
"message1",
"=",
"$",
"this",
"->",
"repository",
"->",
"create",
"(",
"$",
"draft",
")",
";",
"}",
"else",
"{",
"//sent",
"$",
"sent",
"[",
"'user_id'",
"]",
"=",
"user_id",
"(",
"'admin.web'",
")",
";",
"$",
"sent",
"[",
"'user_type'",
"]",
"=",
"user_type",
"(",
"'admin.web'",
")",
";",
"$",
"sent",
"[",
"'to'",
"]",
"=",
"$",
"user_id",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"repository",
"->",
"create",
"(",
"$",
"sent",
")",
";",
"//inbox",
"$",
"inbox",
"[",
"'user_id'",
"]",
"=",
"user_id",
"(",
"'admin.web'",
")",
";",
"$",
"inbox",
"[",
"'user_type'",
"]",
"=",
"user_type",
"(",
"'admin.web'",
")",
";",
"$",
"inbox",
"[",
"'to'",
"]",
"=",
"$",
"user_id",
";",
"$",
"inbox",
"[",
"'status'",
"]",
"=",
"\"Inbox\"",
";",
"$",
"message1",
"=",
"$",
"this",
"->",
"repository",
"->",
"create",
"(",
"$",
"inbox",
")",
";",
"}",
"}",
"$",
"inbox_count",
"=",
"$",
"this",
"->",
"repository",
"->",
"msgCount",
"(",
"'Inbox'",
")",
";",
"$",
"draft_count",
"=",
"$",
"this",
"->",
"repository",
"->",
"msgCount",
"(",
"'Draft'",
")",
";",
"$",
"sent_count",
"=",
"$",
"this",
"->",
"repository",
"->",
"msgCount",
"(",
"'Sent'",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'message'",
"=>",
"trans",
"(",
"'messages.success.updated'",
",",
"[",
"'Module'",
"=>",
"trans",
"(",
"'message::message.name'",
")",
"]",
")",
",",
"'code'",
"=>",
"204",
",",
"'redirect'",
"=>",
"trans_url",
"(",
"'/admin/message/message/status/Inbox'",
")",
",",
"'inbox_count'",
"=>",
"$",
"inbox_count",
",",
"'draft_count'",
"=>",
"$",
"draft_count",
",",
"'sent_count'",
"=>",
"$",
"sent_count",
",",
"]",
",",
"201",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"400",
",",
"]",
",",
"400",
")",
";",
"}",
"}"
] |
Create new message.
@param Request $request
@return Response
|
[
"Create",
"new",
"message",
"."
] |
6c123f0feea627d572141fd71935250f3ba3cad0
|
https://github.com/Litepie/Message/blob/6c123f0feea627d572141fd71935250f3ba3cad0/src/Http/Controllers/MessageResourceController.php#L105-L169
|
27,502
|
Litepie/Message
|
src/Http/Controllers/MessageResourceController.php
|
MessageResourceController.edit
|
public function edit(MessageRequest $request, Message $message)
{
Form::populate($message);
return response()->view('message::message.edit', compact('message'));
}
|
php
|
public function edit(MessageRequest $request, Message $message)
{
Form::populate($message);
return response()->view('message::message.edit', compact('message'));
}
|
[
"public",
"function",
"edit",
"(",
"MessageRequest",
"$",
"request",
",",
"Message",
"$",
"message",
")",
"{",
"Form",
"::",
"populate",
"(",
"$",
"message",
")",
";",
"return",
"response",
"(",
")",
"->",
"view",
"(",
"'message::message.edit'",
",",
"compact",
"(",
"'message'",
")",
")",
";",
"}"
] |
Show message for editing.
@param Request $request
@param Model $message
@return Response
|
[
"Show",
"message",
"for",
"editing",
"."
] |
6c123f0feea627d572141fd71935250f3ba3cad0
|
https://github.com/Litepie/Message/blob/6c123f0feea627d572141fd71935250f3ba3cad0/src/Http/Controllers/MessageResourceController.php#L179-L183
|
27,503
|
Litepie/Message
|
src/Http/Controllers/MessageResourceController.php
|
MessageResourceController.destroy
|
public function destroy(MessageRequest $request, Message $message)
{
try {
if (!empty($request->get('arrayIds'))) {
$ids = $request->get('arrayIds');
$t = $this->repository->deleteMultiple($ids);
return $t;
} else {
$t = $message->delete();
}
$this->repository->pushCriteria(new \Litepie\Message\Repositories\Criteria\MessageAdminCriteria());
$inbox_count = $this->repository->msgCount('Inbox');
$trash_count = $this->repository->msgCount('Trash');
return response()->json([
'message' => trans('messages.success.deleted', ['Module' => trans('message::message.name')]),
'code' => 202,
'redirect' => trans_url('/admin/message/message/0'),
'inbox_count' => $inbox_count,
'trash_count' => $trash_count,
], 202);
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'code' => 400,
'redirect' => trans_url('/admin/message/message/' . $message->getRouteKey()),
], 400);
}
}
|
php
|
public function destroy(MessageRequest $request, Message $message)
{
try {
if (!empty($request->get('arrayIds'))) {
$ids = $request->get('arrayIds');
$t = $this->repository->deleteMultiple($ids);
return $t;
} else {
$t = $message->delete();
}
$this->repository->pushCriteria(new \Litepie\Message\Repositories\Criteria\MessageAdminCriteria());
$inbox_count = $this->repository->msgCount('Inbox');
$trash_count = $this->repository->msgCount('Trash');
return response()->json([
'message' => trans('messages.success.deleted', ['Module' => trans('message::message.name')]),
'code' => 202,
'redirect' => trans_url('/admin/message/message/0'),
'inbox_count' => $inbox_count,
'trash_count' => $trash_count,
], 202);
} catch (Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'code' => 400,
'redirect' => trans_url('/admin/message/message/' . $message->getRouteKey()),
], 400);
}
}
|
[
"public",
"function",
"destroy",
"(",
"MessageRequest",
"$",
"request",
",",
"Message",
"$",
"message",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"request",
"->",
"get",
"(",
"'arrayIds'",
")",
")",
")",
"{",
"$",
"ids",
"=",
"$",
"request",
"->",
"get",
"(",
"'arrayIds'",
")",
";",
"$",
"t",
"=",
"$",
"this",
"->",
"repository",
"->",
"deleteMultiple",
"(",
"$",
"ids",
")",
";",
"return",
"$",
"t",
";",
"}",
"else",
"{",
"$",
"t",
"=",
"$",
"message",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"this",
"->",
"repository",
"->",
"pushCriteria",
"(",
"new",
"\\",
"Litepie",
"\\",
"Message",
"\\",
"Repositories",
"\\",
"Criteria",
"\\",
"MessageAdminCriteria",
"(",
")",
")",
";",
"$",
"inbox_count",
"=",
"$",
"this",
"->",
"repository",
"->",
"msgCount",
"(",
"'Inbox'",
")",
";",
"$",
"trash_count",
"=",
"$",
"this",
"->",
"repository",
"->",
"msgCount",
"(",
"'Trash'",
")",
";",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'message'",
"=>",
"trans",
"(",
"'messages.success.deleted'",
",",
"[",
"'Module'",
"=>",
"trans",
"(",
"'message::message.name'",
")",
"]",
")",
",",
"'code'",
"=>",
"202",
",",
"'redirect'",
"=>",
"trans_url",
"(",
"'/admin/message/message/0'",
")",
",",
"'inbox_count'",
"=>",
"$",
"inbox_count",
",",
"'trash_count'",
"=>",
"$",
"trash_count",
",",
"]",
",",
"202",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"response",
"(",
")",
"->",
"json",
"(",
"[",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"400",
",",
"'redirect'",
"=>",
"trans_url",
"(",
"'/admin/message/message/'",
".",
"$",
"message",
"->",
"getRouteKey",
"(",
")",
")",
",",
"]",
",",
"400",
")",
";",
"}",
"}"
] |
Remove the message.
@param Model $message
@return Response
|
[
"Remove",
"the",
"message",
"."
] |
6c123f0feea627d572141fd71935250f3ba3cad0
|
https://github.com/Litepie/Message/blob/6c123f0feea627d572141fd71935250f3ba3cad0/src/Http/Controllers/MessageResourceController.php#L227-L260
|
27,504
|
kherge-abandoned/php-phar-update
|
src/lib/Herrera/Phar/Update/Manifest.php
|
Manifest.load
|
public static function load($json)
{
$j = new Json();
return self::create($j->decode($json), $j);
}
|
php
|
public static function load($json)
{
$j = new Json();
return self::create($j->decode($json), $j);
}
|
[
"public",
"static",
"function",
"load",
"(",
"$",
"json",
")",
"{",
"$",
"j",
"=",
"new",
"Json",
"(",
")",
";",
"return",
"self",
"::",
"create",
"(",
"$",
"j",
"->",
"decode",
"(",
"$",
"json",
")",
",",
"$",
"j",
")",
";",
"}"
] |
Loads the manifest from a JSON encoded string.
@param string $json The JSON encoded string.
@return Manifest The manifest.
|
[
"Loads",
"the",
"manifest",
"from",
"a",
"JSON",
"encoded",
"string",
"."
] |
15643c90d3d43620a4f45c910e6afb7a0ad4b488
|
https://github.com/kherge-abandoned/php-phar-update/blob/15643c90d3d43620a4f45c910e6afb7a0ad4b488/src/lib/Herrera/Phar/Update/Manifest.php#L88-L93
|
27,505
|
kherge-abandoned/php-phar-update
|
src/lib/Herrera/Phar/Update/Manifest.php
|
Manifest.loadFile
|
public static function loadFile($file)
{
$json = new Json();
return self::create($json->decodeFile($file), $json);
}
|
php
|
public static function loadFile($file)
{
$json = new Json();
return self::create($json->decodeFile($file), $json);
}
|
[
"public",
"static",
"function",
"loadFile",
"(",
"$",
"file",
")",
"{",
"$",
"json",
"=",
"new",
"Json",
"(",
")",
";",
"return",
"self",
"::",
"create",
"(",
"$",
"json",
"->",
"decodeFile",
"(",
"$",
"file",
")",
",",
"$",
"json",
")",
";",
"}"
] |
Loads the manifest from a JSON encoded file.
@param string $file The JSON encoded file.
@return Manifest The manifest.
|
[
"Loads",
"the",
"manifest",
"from",
"a",
"JSON",
"encoded",
"file",
"."
] |
15643c90d3d43620a4f45c910e6afb7a0ad4b488
|
https://github.com/kherge-abandoned/php-phar-update/blob/15643c90d3d43620a4f45c910e6afb7a0ad4b488/src/lib/Herrera/Phar/Update/Manifest.php#L102-L107
|
27,506
|
kherge-abandoned/php-phar-update
|
src/lib/Herrera/Phar/Update/Manifest.php
|
Manifest.create
|
private static function create($decoded, Json $json)
{
$json->validate(
$json->decodeFile(PHAR_UPDATE_MANIFEST_SCHEMA),
$decoded
);
$updates = array();
foreach ($decoded as $update) {
$updates[] = new Update(
$update->name,
$update->sha1,
$update->url,
Parser::toVersion($update->version),
isset($update->publicKey) ? $update->publicKey : null
);
}
usort(
$updates,
function (Update $a, Update $b) {
return Comparator::isGreaterThan(
$a->getVersion(),
$b->getVersion()
);
}
);
return new static($updates);
}
|
php
|
private static function create($decoded, Json $json)
{
$json->validate(
$json->decodeFile(PHAR_UPDATE_MANIFEST_SCHEMA),
$decoded
);
$updates = array();
foreach ($decoded as $update) {
$updates[] = new Update(
$update->name,
$update->sha1,
$update->url,
Parser::toVersion($update->version),
isset($update->publicKey) ? $update->publicKey : null
);
}
usort(
$updates,
function (Update $a, Update $b) {
return Comparator::isGreaterThan(
$a->getVersion(),
$b->getVersion()
);
}
);
return new static($updates);
}
|
[
"private",
"static",
"function",
"create",
"(",
"$",
"decoded",
",",
"Json",
"$",
"json",
")",
"{",
"$",
"json",
"->",
"validate",
"(",
"$",
"json",
"->",
"decodeFile",
"(",
"PHAR_UPDATE_MANIFEST_SCHEMA",
")",
",",
"$",
"decoded",
")",
";",
"$",
"updates",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"decoded",
"as",
"$",
"update",
")",
"{",
"$",
"updates",
"[",
"]",
"=",
"new",
"Update",
"(",
"$",
"update",
"->",
"name",
",",
"$",
"update",
"->",
"sha1",
",",
"$",
"update",
"->",
"url",
",",
"Parser",
"::",
"toVersion",
"(",
"$",
"update",
"->",
"version",
")",
",",
"isset",
"(",
"$",
"update",
"->",
"publicKey",
")",
"?",
"$",
"update",
"->",
"publicKey",
":",
"null",
")",
";",
"}",
"usort",
"(",
"$",
"updates",
",",
"function",
"(",
"Update",
"$",
"a",
",",
"Update",
"$",
"b",
")",
"{",
"return",
"Comparator",
"::",
"isGreaterThan",
"(",
"$",
"a",
"->",
"getVersion",
"(",
")",
",",
"$",
"b",
"->",
"getVersion",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"new",
"static",
"(",
"$",
"updates",
")",
";",
"}"
] |
Validates the data, processes it, and returns a new instance of Manifest.
@param array $decoded The decoded JSON data.
@param Json $json The Json instance used to decode the data.
@return Manifest The new instance.
|
[
"Validates",
"the",
"data",
"processes",
"it",
"and",
"returns",
"a",
"new",
"instance",
"of",
"Manifest",
"."
] |
15643c90d3d43620a4f45c910e6afb7a0ad4b488
|
https://github.com/kherge-abandoned/php-phar-update/blob/15643c90d3d43620a4f45c910e6afb7a0ad4b488/src/lib/Herrera/Phar/Update/Manifest.php#L117-L147
|
27,507
|
prooph/laravel-package
|
src/Migration/Schema/SnapshotSchema.php
|
SnapshotSchema.create
|
public static function create($snapshotName = 'snapshot')
{
Schema::create($snapshotName, function (Blueprint $snapshot) use ($snapshotName) {
// UUID4 of linked aggregate
$snapshot->char('aggregate_id', 36);
// Class of the linked aggregate
$snapshot->string('aggregate_type', 150);
// Version of the aggregate after event was recorded
$snapshot->integer('last_version', false, true);
// DateTime ISO8601 + microseconds UTC stored as a string e.g. 2016-02-02T11:45:39.000000
$snapshot->char('created_at', 26);
$snapshot->binary('aggregate_root');
$snapshot->index(['aggregate_id', 'aggregate_type'], $snapshotName . '_m_v_uix');
});
}
|
php
|
public static function create($snapshotName = 'snapshot')
{
Schema::create($snapshotName, function (Blueprint $snapshot) use ($snapshotName) {
// UUID4 of linked aggregate
$snapshot->char('aggregate_id', 36);
// Class of the linked aggregate
$snapshot->string('aggregate_type', 150);
// Version of the aggregate after event was recorded
$snapshot->integer('last_version', false, true);
// DateTime ISO8601 + microseconds UTC stored as a string e.g. 2016-02-02T11:45:39.000000
$snapshot->char('created_at', 26);
$snapshot->binary('aggregate_root');
$snapshot->index(['aggregate_id', 'aggregate_type'], $snapshotName . '_m_v_uix');
});
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"snapshotName",
"=",
"'snapshot'",
")",
"{",
"Schema",
"::",
"create",
"(",
"$",
"snapshotName",
",",
"function",
"(",
"Blueprint",
"$",
"snapshot",
")",
"use",
"(",
"$",
"snapshotName",
")",
"{",
"// UUID4 of linked aggregate",
"$",
"snapshot",
"->",
"char",
"(",
"'aggregate_id'",
",",
"36",
")",
";",
"// Class of the linked aggregate",
"$",
"snapshot",
"->",
"string",
"(",
"'aggregate_type'",
",",
"150",
")",
";",
"// Version of the aggregate after event was recorded",
"$",
"snapshot",
"->",
"integer",
"(",
"'last_version'",
",",
"false",
",",
"true",
")",
";",
"// DateTime ISO8601 + microseconds UTC stored as a string e.g. 2016-02-02T11:45:39.000000",
"$",
"snapshot",
"->",
"char",
"(",
"'created_at'",
",",
"26",
")",
";",
"$",
"snapshot",
"->",
"binary",
"(",
"'aggregate_root'",
")",
";",
"$",
"snapshot",
"->",
"index",
"(",
"[",
"'aggregate_id'",
",",
"'aggregate_type'",
"]",
",",
"$",
"snapshotName",
".",
"'_m_v_uix'",
")",
";",
"}",
")",
";",
"}"
] |
Creates a snapshot schema
@param Schema $schema
@param string $snapshotName Defaults to 'snapshot'
|
[
"Creates",
"a",
"snapshot",
"schema"
] |
e9647921ad1dc7b9753010e4648933555d89cddc
|
https://github.com/prooph/laravel-package/blob/e9647921ad1dc7b9753010e4648933555d89cddc/src/Migration/Schema/SnapshotSchema.php#L30-L45
|
27,508
|
prooph/laravel-package
|
src/Facades/QueryBus.php
|
QueryBus.resultFrom
|
public static function resultFrom($aQuery)
{
/** @var \Prooph\ServiceBus\QueryBus $instance */
$instance = self::getFacadeRoot();
$ret = null;
$instance
->dispatch($aQuery)
->done(function ($result) use (&$ret) {
$ret = $result;
}, function () use ($aQuery) {
throw QueryResultFailed::fromQuery($aQuery, func_get_args());
});
return $ret;
}
|
php
|
public static function resultFrom($aQuery)
{
/** @var \Prooph\ServiceBus\QueryBus $instance */
$instance = self::getFacadeRoot();
$ret = null;
$instance
->dispatch($aQuery)
->done(function ($result) use (&$ret) {
$ret = $result;
}, function () use ($aQuery) {
throw QueryResultFailed::fromQuery($aQuery, func_get_args());
});
return $ret;
}
|
[
"public",
"static",
"function",
"resultFrom",
"(",
"$",
"aQuery",
")",
"{",
"/** @var \\Prooph\\ServiceBus\\QueryBus $instance */",
"$",
"instance",
"=",
"self",
"::",
"getFacadeRoot",
"(",
")",
";",
"$",
"ret",
"=",
"null",
";",
"$",
"instance",
"->",
"dispatch",
"(",
"$",
"aQuery",
")",
"->",
"done",
"(",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"&",
"$",
"ret",
")",
"{",
"$",
"ret",
"=",
"$",
"result",
";",
"}",
",",
"function",
"(",
")",
"use",
"(",
"$",
"aQuery",
")",
"{",
"throw",
"QueryResultFailed",
"::",
"fromQuery",
"(",
"$",
"aQuery",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
The default dispatch method will return you a promise
sometimes you might want to just get the result instead
this method will return you the result on a successful
query, and throw an exception instead if the query
fails.
@throws QueryResultFailed
@param Query|mixed $aQuery
@return mixed
|
[
"The",
"default",
"dispatch",
"method",
"will",
"return",
"you",
"a",
"promise",
"sometimes",
"you",
"might",
"want",
"to",
"just",
"get",
"the",
"result",
"instead",
"this",
"method",
"will",
"return",
"you",
"the",
"result",
"on",
"a",
"successful",
"query",
"and",
"throw",
"an",
"exception",
"instead",
"if",
"the",
"query",
"fails",
"."
] |
e9647921ad1dc7b9753010e4648933555d89cddc
|
https://github.com/prooph/laravel-package/blob/e9647921ad1dc7b9753010e4648933555d89cddc/src/Facades/QueryBus.php#L39-L54
|
27,509
|
DivineOmega/array_undot
|
src/ArrayHelpers.php
|
ArrayHelpers.undot
|
public function undot(array $dotNotationArray)
{
$array = [];
foreach ($dotNotationArray as $key => $value) {
$this->set($array, $key, $value);
}
return $array;
}
|
php
|
public function undot(array $dotNotationArray)
{
$array = [];
foreach ($dotNotationArray as $key => $value) {
$this->set($array, $key, $value);
}
return $array;
}
|
[
"public",
"function",
"undot",
"(",
"array",
"$",
"dotNotationArray",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"dotNotationArray",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Expands a dot notation array into a full multi-dimensional array
@param array $dotNotationArray
@return array
|
[
"Expands",
"a",
"dot",
"notation",
"array",
"into",
"a",
"full",
"multi",
"-",
"dimensional",
"array"
] |
44aed525e775718e3821d670b08046fd84914d10
|
https://github.com/DivineOmega/array_undot/blob/44aed525e775718e3821d670b08046fd84914d10/src/ArrayHelpers.php#L14-L22
|
27,510
|
dreamfactorysoftware/df-sqldb
|
src/Database/Schema/SqlSchema.php
|
SqlSchema.getSupportedResourceTypes
|
public function getSupportedResourceTypes()
{
return [
DbResourceTypes::TYPE_SCHEMA,
DbResourceTypes::TYPE_TABLE,
DbResourceTypes::TYPE_TABLE_FIELD,
DbResourceTypes::TYPE_TABLE_CONSTRAINT,
DbResourceTypes::TYPE_TABLE_RELATIONSHIP,
DbResourceTypes::TYPE_VIEW,
DbResourceTypes::TYPE_FUNCTION,
DbResourceTypes::TYPE_PROCEDURE,
];
}
|
php
|
public function getSupportedResourceTypes()
{
return [
DbResourceTypes::TYPE_SCHEMA,
DbResourceTypes::TYPE_TABLE,
DbResourceTypes::TYPE_TABLE_FIELD,
DbResourceTypes::TYPE_TABLE_CONSTRAINT,
DbResourceTypes::TYPE_TABLE_RELATIONSHIP,
DbResourceTypes::TYPE_VIEW,
DbResourceTypes::TYPE_FUNCTION,
DbResourceTypes::TYPE_PROCEDURE,
];
}
|
[
"public",
"function",
"getSupportedResourceTypes",
"(",
")",
"{",
"return",
"[",
"DbResourceTypes",
"::",
"TYPE_SCHEMA",
",",
"DbResourceTypes",
"::",
"TYPE_TABLE",
",",
"DbResourceTypes",
"::",
"TYPE_TABLE_FIELD",
",",
"DbResourceTypes",
"::",
"TYPE_TABLE_CONSTRAINT",
",",
"DbResourceTypes",
"::",
"TYPE_TABLE_RELATIONSHIP",
",",
"DbResourceTypes",
"::",
"TYPE_VIEW",
",",
"DbResourceTypes",
"::",
"TYPE_FUNCTION",
",",
"DbResourceTypes",
"::",
"TYPE_PROCEDURE",
",",
"]",
";",
"}"
] |
Return an array of supported schema resource types.
@return array
|
[
"Return",
"an",
"array",
"of",
"supported",
"schema",
"resource",
"types",
"."
] |
f5b6c45fae068db5043419405299bfbc928fa90b
|
https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Database/Schema/SqlSchema.php#L33-L45
|
27,511
|
dreamfactorysoftware/df-sqldb
|
src/Resources/StoredProcedure.php
|
StoredProcedure.describeProcedures
|
protected function describeProcedures($names, $refresh = false)
{
$names = static::validateAsArray(
$names,
',',
true,
'The request contains no valid procedure names or properties.'
);
$out = [];
foreach ($names as $name) {
$out[] = $this->describeProcedure($name, $refresh);
}
return $out;
}
|
php
|
protected function describeProcedures($names, $refresh = false)
{
$names = static::validateAsArray(
$names,
',',
true,
'The request contains no valid procedure names or properties.'
);
$out = [];
foreach ($names as $name) {
$out[] = $this->describeProcedure($name, $refresh);
}
return $out;
}
|
[
"protected",
"function",
"describeProcedures",
"(",
"$",
"names",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"names",
"=",
"static",
"::",
"validateAsArray",
"(",
"$",
"names",
",",
"','",
",",
"true",
",",
"'The request contains no valid procedure names or properties.'",
")",
";",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"this",
"->",
"describeProcedure",
"(",
"$",
"name",
",",
"$",
"refresh",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Get multiple procedures and their properties
@param string | array $names Procedure names comma-delimited string or array
@param bool $refresh Force a refresh of the schema from the database
@return array
@throws \Exception
|
[
"Get",
"multiple",
"procedures",
"and",
"their",
"properties"
] |
f5b6c45fae068db5043419405299bfbc928fa90b
|
https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Resources/StoredProcedure.php#L273-L288
|
27,512
|
dreamfactorysoftware/df-sqldb
|
src/Resources/StoredProcedure.php
|
StoredProcedure.describeProcedure
|
protected function describeProcedure($name, $refresh = false)
{
$name = (is_array($name) ? array_get($name, 'name') : $name);
if (empty($name)) {
throw new BadRequestException('Procedure name can not be empty.');
}
$this->checkPermission(Verbs::GET, $name);
try {
$procedure = $this->getProcedure($name, $refresh);
$result = $procedure->toArray();
$result['access'] = $this->getPermissions($name);
return $result;
} catch (RestException $ex) {
throw $ex;
} catch (\Exception $ex) {
throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
}
}
|
php
|
protected function describeProcedure($name, $refresh = false)
{
$name = (is_array($name) ? array_get($name, 'name') : $name);
if (empty($name)) {
throw new BadRequestException('Procedure name can not be empty.');
}
$this->checkPermission(Verbs::GET, $name);
try {
$procedure = $this->getProcedure($name, $refresh);
$result = $procedure->toArray();
$result['access'] = $this->getPermissions($name);
return $result;
} catch (RestException $ex) {
throw $ex;
} catch (\Exception $ex) {
throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
}
}
|
[
"protected",
"function",
"describeProcedure",
"(",
"$",
"name",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"(",
"is_array",
"(",
"$",
"name",
")",
"?",
"array_get",
"(",
"$",
"name",
",",
"'name'",
")",
":",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"'Procedure name can not be empty.'",
")",
";",
"}",
"$",
"this",
"->",
"checkPermission",
"(",
"Verbs",
"::",
"GET",
",",
"$",
"name",
")",
";",
"try",
"{",
"$",
"procedure",
"=",
"$",
"this",
"->",
"getProcedure",
"(",
"$",
"name",
",",
"$",
"refresh",
")",
";",
"$",
"result",
"=",
"$",
"procedure",
"->",
"toArray",
"(",
")",
";",
"$",
"result",
"[",
"'access'",
"]",
"=",
"$",
"this",
"->",
"getPermissions",
"(",
"$",
"name",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"RestException",
"$",
"ex",
")",
"{",
"throw",
"$",
"ex",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"InternalServerErrorException",
"(",
"\"Failed to query database schema.\\n{$ex->getMessage()}\"",
")",
";",
"}",
"}"
] |
Get any properties related to the procedure
@param string | array $name Procedure name or defining properties
@param bool $refresh Force a refresh of the schema from the database
@return array
@throws \Exception
|
[
"Get",
"any",
"properties",
"related",
"to",
"the",
"procedure"
] |
f5b6c45fae068db5043419405299bfbc928fa90b
|
https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Resources/StoredProcedure.php#L299-L319
|
27,513
|
nglasl/silverstripe-mediawesome
|
src/pages/MediaPage.php
|
MediaPage.validate
|
public function validate() {
$parent = $this->getParent();
// The URL segment will conflict with a year/month/day/media format when numeric.
if(is_numeric($this->URLSegment) || !($parent instanceof MediaHolder) || ($this->MediaTypeID && ($parent->MediaTypeID != $this->MediaTypeID))) {
// Customise a validation error message.
if(is_numeric($this->URLSegment)) {
$message = '"URL Segment" must not be numeric!';
}
else if(!($parent instanceof MediaHolder)) {
$message = 'The parent needs to be a published media holder!';
}
else {
$message = "The media holder type doesn't match this!";
}
$error = new HTTPResponse_Exception($message, 403);
$error->getResponse()->addHeader('X-Status', rawurlencode($message));
// Allow extension customisation.
$this->extend('validateMediaPage', $error);
throw $error;
}
return parent::validate();
}
|
php
|
public function validate() {
$parent = $this->getParent();
// The URL segment will conflict with a year/month/day/media format when numeric.
if(is_numeric($this->URLSegment) || !($parent instanceof MediaHolder) || ($this->MediaTypeID && ($parent->MediaTypeID != $this->MediaTypeID))) {
// Customise a validation error message.
if(is_numeric($this->URLSegment)) {
$message = '"URL Segment" must not be numeric!';
}
else if(!($parent instanceof MediaHolder)) {
$message = 'The parent needs to be a published media holder!';
}
else {
$message = "The media holder type doesn't match this!";
}
$error = new HTTPResponse_Exception($message, 403);
$error->getResponse()->addHeader('X-Status', rawurlencode($message));
// Allow extension customisation.
$this->extend('validateMediaPage', $error);
throw $error;
}
return parent::validate();
}
|
[
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"// The URL segment will conflict with a year/month/day/media format when numeric.",
"if",
"(",
"is_numeric",
"(",
"$",
"this",
"->",
"URLSegment",
")",
"||",
"!",
"(",
"$",
"parent",
"instanceof",
"MediaHolder",
")",
"||",
"(",
"$",
"this",
"->",
"MediaTypeID",
"&&",
"(",
"$",
"parent",
"->",
"MediaTypeID",
"!=",
"$",
"this",
"->",
"MediaTypeID",
")",
")",
")",
"{",
"// Customise a validation error message.",
"if",
"(",
"is_numeric",
"(",
"$",
"this",
"->",
"URLSegment",
")",
")",
"{",
"$",
"message",
"=",
"'\"URL Segment\" must not be numeric!'",
";",
"}",
"else",
"if",
"(",
"!",
"(",
"$",
"parent",
"instanceof",
"MediaHolder",
")",
")",
"{",
"$",
"message",
"=",
"'The parent needs to be a published media holder!'",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"\"The media holder type doesn't match this!\"",
";",
"}",
"$",
"error",
"=",
"new",
"HTTPResponse_Exception",
"(",
"$",
"message",
",",
"403",
")",
";",
"$",
"error",
"->",
"getResponse",
"(",
")",
"->",
"addHeader",
"(",
"'X-Status'",
",",
"rawurlencode",
"(",
"$",
"message",
")",
")",
";",
"// Allow extension customisation.",
"$",
"this",
"->",
"extend",
"(",
"'validateMediaPage'",
",",
"$",
"error",
")",
";",
"throw",
"$",
"error",
";",
"}",
"return",
"parent",
"::",
"validate",
"(",
")",
";",
"}"
] |
Confirm that the current page is valid.
|
[
"Confirm",
"that",
"the",
"current",
"page",
"is",
"valid",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/pages/MediaPage.php#L322-L350
|
27,514
|
nglasl/silverstripe-mediawesome
|
src/pages/MediaPage.php
|
MediaPage.Link
|
public function Link($action = null) {
$parent = $this->getParent();
if(!$parent) {
return null;
}
$date = ($parent->URLFormatting !== '-') ? $this->dbObject('Date')->Format($parent->URLFormatting ?: 'y/MM/dd/') : '';
$join = array(
$parent->Link(),
"{$date}{$this->URLSegment}/"
);
if($action) {
$join[] = "{$action}/";
}
$link = Controller::join_links($join);
return $link;
}
|
php
|
public function Link($action = null) {
$parent = $this->getParent();
if(!$parent) {
return null;
}
$date = ($parent->URLFormatting !== '-') ? $this->dbObject('Date')->Format($parent->URLFormatting ?: 'y/MM/dd/') : '';
$join = array(
$parent->Link(),
"{$date}{$this->URLSegment}/"
);
if($action) {
$join[] = "{$action}/";
}
$link = Controller::join_links($join);
return $link;
}
|
[
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parent",
")",
"{",
"return",
"null",
";",
"}",
"$",
"date",
"=",
"(",
"$",
"parent",
"->",
"URLFormatting",
"!==",
"'-'",
")",
"?",
"$",
"this",
"->",
"dbObject",
"(",
"'Date'",
")",
"->",
"Format",
"(",
"$",
"parent",
"->",
"URLFormatting",
"?",
":",
"'y/MM/dd/'",
")",
":",
"''",
";",
"$",
"join",
"=",
"array",
"(",
"$",
"parent",
"->",
"Link",
"(",
")",
",",
"\"{$date}{$this->URLSegment}/\"",
")",
";",
"if",
"(",
"$",
"action",
")",
"{",
"$",
"join",
"[",
"]",
"=",
"\"{$action}/\"",
";",
"}",
"$",
"link",
"=",
"Controller",
"::",
"join_links",
"(",
"$",
"join",
")",
";",
"return",
"$",
"link",
";",
"}"
] |
Determine the URL by using the media holder's defined URL format.
|
[
"Determine",
"the",
"URL",
"by",
"using",
"the",
"media",
"holder",
"s",
"defined",
"URL",
"format",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/pages/MediaPage.php#L405-L421
|
27,515
|
nglasl/silverstripe-mediawesome
|
src/pages/MediaPage.php
|
MediaPage.AbsoluteLink
|
public function AbsoluteLink($action = null) {
$parent = $this->getParent();
if(!$parent) {
return null;
}
$date = ($parent->URLFormatting !== '-') ? $this->dbObject('Date')->Format($parent->URLFormatting ?: 'y/MM/dd/') : '';
$link = $parent->AbsoluteLink() . "{$date}{$this->URLSegment}/";
if($action) {
$link .= "{$action}/";
}
return $link;
}
|
php
|
public function AbsoluteLink($action = null) {
$parent = $this->getParent();
if(!$parent) {
return null;
}
$date = ($parent->URLFormatting !== '-') ? $this->dbObject('Date')->Format($parent->URLFormatting ?: 'y/MM/dd/') : '';
$link = $parent->AbsoluteLink() . "{$date}{$this->URLSegment}/";
if($action) {
$link .= "{$action}/";
}
return $link;
}
|
[
"public",
"function",
"AbsoluteLink",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parent",
")",
"{",
"return",
"null",
";",
"}",
"$",
"date",
"=",
"(",
"$",
"parent",
"->",
"URLFormatting",
"!==",
"'-'",
")",
"?",
"$",
"this",
"->",
"dbObject",
"(",
"'Date'",
")",
"->",
"Format",
"(",
"$",
"parent",
"->",
"URLFormatting",
"?",
":",
"'y/MM/dd/'",
")",
":",
"''",
";",
"$",
"link",
"=",
"$",
"parent",
"->",
"AbsoluteLink",
"(",
")",
".",
"\"{$date}{$this->URLSegment}/\"",
";",
"if",
"(",
"$",
"action",
")",
"{",
"$",
"link",
".=",
"\"{$action}/\"",
";",
"}",
"return",
"$",
"link",
";",
"}"
] |
Determine the absolute URL by using the media holder's defined URL format.
|
[
"Determine",
"the",
"absolute",
"URL",
"by",
"using",
"the",
"media",
"holder",
"s",
"defined",
"URL",
"format",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/pages/MediaPage.php#L427-L439
|
27,516
|
dreamfactorysoftware/df-sqldb
|
src/Database/Schema/SqliteSchema.php
|
SqliteSchema.addForeignKey
|
public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
{
throw new \Exception('Adding a foreign key constraint to an existing table is not supported by SQLite.');
}
|
php
|
public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
{
throw new \Exception('Adding a foreign key constraint to an existing table is not supported by SQLite.');
}
|
[
"public",
"function",
"addForeignKey",
"(",
"$",
"name",
",",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"refTable",
",",
"$",
"refColumns",
",",
"$",
"delete",
"=",
"null",
",",
"$",
"update",
"=",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Adding a foreign key constraint to an existing table is not supported by SQLite.'",
")",
";",
"}"
] |
Builds a SQL statement for adding a foreign key constraint to an existing table.
Because SQLite does not support adding foreign key to an existing table, calling this method will throw an
exception.
@param string $name the name of the foreign key constraint.
@param string $table the table that the foreign key constraint will be added to.
@param string $columns the name of the column to that the constraint will be added on. If there are multiple
columns, separate them with commas.
@param string $refTable the table that the foreign key references to.
@param string $refColumns the name of the column that the foreign key references to. If there are multiple
columns, separate them with commas.
@param string $delete the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION,
SET DEFAULT, SET NULL
@param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION,
SET DEFAULT, SET NULL
@throws \Exception
@return string the SQL statement for adding a foreign key constraint to an existing table.
|
[
"Builds",
"a",
"SQL",
"statement",
"for",
"adding",
"a",
"foreign",
"key",
"constraint",
"to",
"an",
"existing",
"table",
".",
"Because",
"SQLite",
"does",
"not",
"support",
"adding",
"foreign",
"key",
"to",
"an",
"existing",
"table",
"calling",
"this",
"method",
"will",
"throw",
"an",
"exception",
"."
] |
f5b6c45fae068db5043419405299bfbc928fa90b
|
https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Database/Schema/SqliteSchema.php#L472-L475
|
27,517
|
nglasl/silverstripe-mediawesome
|
src/objects/MediaTag.php
|
MediaTag.validate
|
public function validate() {
$result = parent::validate();
// Confirm that the current tag has been given a title and doesn't already exist.
$this->Title = strtolower($this->Title);
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
else if($result->isValid() && MediaTag::get_one(MediaTag::class, array(
'ID != ?' => $this->ID,
'Title = ?' => $this->Title
))) {
$result->addError('Tag already exists!');
}
// Allow extension customisation.
$this->extend('validateMediaTag', $result);
return $result;
}
|
php
|
public function validate() {
$result = parent::validate();
// Confirm that the current tag has been given a title and doesn't already exist.
$this->Title = strtolower($this->Title);
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
else if($result->isValid() && MediaTag::get_one(MediaTag::class, array(
'ID != ?' => $this->ID,
'Title = ?' => $this->Title
))) {
$result->addError('Tag already exists!');
}
// Allow extension customisation.
$this->extend('validateMediaTag', $result);
return $result;
}
|
[
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"validate",
"(",
")",
";",
"// Confirm that the current tag has been given a title and doesn't already exist.",
"$",
"this",
"->",
"Title",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"Title",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isValid",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"Title",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"'\"Title\" required!'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"result",
"->",
"isValid",
"(",
")",
"&&",
"MediaTag",
"::",
"get_one",
"(",
"MediaTag",
"::",
"class",
",",
"array",
"(",
"'ID != ?'",
"=>",
"$",
"this",
"->",
"ID",
",",
"'Title = ?'",
"=>",
"$",
"this",
"->",
"Title",
")",
")",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"'Tag already exists!'",
")",
";",
"}",
"// Allow extension customisation.",
"$",
"this",
"->",
"extend",
"(",
"'validateMediaTag'",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Confirm that the current tag is valid.
|
[
"Confirm",
"that",
"the",
"current",
"tag",
"is",
"valid",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/objects/MediaTag.php#L46-L67
|
27,518
|
MetaModels/filter_fromto
|
src/FilterRule/FromTo.php
|
FromTo.setLowerBound
|
public function setLowerBound($value, $inclusive)
{
$this->lowerBound = $value;
$this->lowerInclusive = (bool) $inclusive;
return $this;
}
|
php
|
public function setLowerBound($value, $inclusive)
{
$this->lowerBound = $value;
$this->lowerInclusive = (bool) $inclusive;
return $this;
}
|
[
"public",
"function",
"setLowerBound",
"(",
"$",
"value",
",",
"$",
"inclusive",
")",
"{",
"$",
"this",
"->",
"lowerBound",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"lowerInclusive",
"=",
"(",
"bool",
")",
"$",
"inclusive",
";",
"return",
"$",
"this",
";",
"}"
] |
Mark the lower bound of the range to search.
@param mixed $value The value to use for the lower bound.
@param bool $inclusive Flag if the value shall also be included in the result.
@return FromTo
|
[
"Mark",
"the",
"lower",
"bound",
"of",
"the",
"range",
"to",
"search",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterRule/FromTo.php#L90-L96
|
27,519
|
MetaModels/filter_fromto
|
src/FilterRule/FromTo.php
|
FromTo.setUpperBound
|
public function setUpperBound($value, $inclusive)
{
$this->upperBound = $value;
$this->upperInclusive = (bool) $inclusive;
return $this;
}
|
php
|
public function setUpperBound($value, $inclusive)
{
$this->upperBound = $value;
$this->upperInclusive = (bool) $inclusive;
return $this;
}
|
[
"public",
"function",
"setUpperBound",
"(",
"$",
"value",
",",
"$",
"inclusive",
")",
"{",
"$",
"this",
"->",
"upperBound",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"upperInclusive",
"=",
"(",
"bool",
")",
"$",
"inclusive",
";",
"return",
"$",
"this",
";",
"}"
] |
Mark the upper bound of the range to search.
@param mixed $value The value to use for the upper bound.
@param bool $inclusive Flag if the value shall also be included in the result.
@return FromTo
|
[
"Mark",
"the",
"upper",
"bound",
"of",
"the",
"range",
"to",
"search",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterRule/FromTo.php#L127-L133
|
27,520
|
MetaModels/filter_fromto
|
src/FilterRule/FromTo.php
|
FromTo.evaluateLowerBound
|
protected function evaluateLowerBound()
{
if (empty($this->lowerBound)) {
return null;
}
return $this->executeRule(
new GreaterThan($this->getAttribute(), $this->getLowerBound(), $this->isLowerInclusive())
);
}
|
php
|
protected function evaluateLowerBound()
{
if (empty($this->lowerBound)) {
return null;
}
return $this->executeRule(
new GreaterThan($this->getAttribute(), $this->getLowerBound(), $this->isLowerInclusive())
);
}
|
[
"protected",
"function",
"evaluateLowerBound",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"lowerBound",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"executeRule",
"(",
"new",
"GreaterThan",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
")",
",",
"$",
"this",
"->",
"getLowerBound",
"(",
")",
",",
"$",
"this",
"->",
"isLowerInclusive",
"(",
")",
")",
")",
";",
"}"
] |
Evaluate the lower bounding of the range.
@return null|\string[]
|
[
"Evaluate",
"the",
"lower",
"bounding",
"of",
"the",
"range",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterRule/FromTo.php#L182-L191
|
27,521
|
MetaModels/filter_fromto
|
src/FilterRule/FromTo.php
|
FromTo.evaluateUpperBound
|
protected function evaluateUpperBound()
{
if (empty($this->upperBound)) {
return null;
}
return $this->executeRule(
new LessThan($this->getAttribute(), $this->getUpperBound(), $this->isUpperInclusive())
);
}
|
php
|
protected function evaluateUpperBound()
{
if (empty($this->upperBound)) {
return null;
}
return $this->executeRule(
new LessThan($this->getAttribute(), $this->getUpperBound(), $this->isUpperInclusive())
);
}
|
[
"protected",
"function",
"evaluateUpperBound",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"upperBound",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"executeRule",
"(",
"new",
"LessThan",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
")",
",",
"$",
"this",
"->",
"getUpperBound",
"(",
")",
",",
"$",
"this",
"->",
"isUpperInclusive",
"(",
")",
")",
")",
";",
"}"
] |
Evaluate the upper bounding of the range.
@return null|\string[]
|
[
"Evaluate",
"the",
"upper",
"bounding",
"of",
"the",
"range",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterRule/FromTo.php#L198-L207
|
27,522
|
MetaModels/filter_fromto
|
src/EventListener/FilterRangeDateRegexpListener.php
|
FilterRangeDateRegexpListener.onAddCustomRegexp
|
public static function onAddCustomRegexp($rgxp, $value, $widget)
{
if ('MetaModelsFilterRangeDateRgXp' !== $rgxp) {
return;
}
$format = $widget->dateformat;
if (!\preg_match('~^'. Date::getRegexp($format) .'$~i', $value)) {
$widget->addError(\sprintf($GLOBALS['TL_LANG']['ERR']['date'], Date::getInputFormat($format)));
} else {
// Validate the date (see https://github.com/contao/core/issues/5086)
try {
new Date($value, $format);
} catch (\OutOfBoundsException $e) {
$widget->addError(\sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $value));
}
}
}
|
php
|
public static function onAddCustomRegexp($rgxp, $value, $widget)
{
if ('MetaModelsFilterRangeDateRgXp' !== $rgxp) {
return;
}
$format = $widget->dateformat;
if (!\preg_match('~^'. Date::getRegexp($format) .'$~i', $value)) {
$widget->addError(\sprintf($GLOBALS['TL_LANG']['ERR']['date'], Date::getInputFormat($format)));
} else {
// Validate the date (see https://github.com/contao/core/issues/5086)
try {
new Date($value, $format);
} catch (\OutOfBoundsException $e) {
$widget->addError(\sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $value));
}
}
}
|
[
"public",
"static",
"function",
"onAddCustomRegexp",
"(",
"$",
"rgxp",
",",
"$",
"value",
",",
"$",
"widget",
")",
"{",
"if",
"(",
"'MetaModelsFilterRangeDateRgXp'",
"!==",
"$",
"rgxp",
")",
"{",
"return",
";",
"}",
"$",
"format",
"=",
"$",
"widget",
"->",
"dateformat",
";",
"if",
"(",
"!",
"\\",
"preg_match",
"(",
"'~^'",
".",
"Date",
"::",
"getRegexp",
"(",
"$",
"format",
")",
".",
"'$~i'",
",",
"$",
"value",
")",
")",
"{",
"$",
"widget",
"->",
"addError",
"(",
"\\",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'ERR'",
"]",
"[",
"'date'",
"]",
",",
"Date",
"::",
"getInputFormat",
"(",
"$",
"format",
")",
")",
")",
";",
"}",
"else",
"{",
"// Validate the date (see https://github.com/contao/core/issues/5086)",
"try",
"{",
"new",
"Date",
"(",
"$",
"value",
",",
"$",
"format",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"$",
"widget",
"->",
"addError",
"(",
"\\",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'ERR'",
"]",
"[",
"'invalidDate'",
"]",
",",
"$",
"value",
")",
")",
";",
"}",
"}",
"}"
] |
Process a custom date regexp on a widget.
@param string $rgxp The rgxp being evaluated.
@param string $value The value to check.
@param Widget $widget The widget to process.
@return void
@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
|
[
"Process",
"a",
"custom",
"date",
"regexp",
"on",
"a",
"widget",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/EventListener/FilterRangeDateRegexpListener.php#L47-L64
|
27,523
|
MetaModels/filter_fromto
|
src/FilterSetting/AbstractFromTo.php
|
AbstractFromTo.getParameterValue
|
protected function getParameterValue($filterUrl)
{
$parameterName = $this->getParamName();
if (isset($filterUrl[$parameterName]) && !empty($filterUrl[$parameterName])) {
if (\is_array($filterUrl[$parameterName])) {
return \array_values($filterUrl[$parameterName]);
}
return \array_values(\explode(',', $filterUrl[$parameterName]));
}
return null;
}
|
php
|
protected function getParameterValue($filterUrl)
{
$parameterName = $this->getParamName();
if (isset($filterUrl[$parameterName]) && !empty($filterUrl[$parameterName])) {
if (\is_array($filterUrl[$parameterName])) {
return \array_values($filterUrl[$parameterName]);
}
return \array_values(\explode(',', $filterUrl[$parameterName]));
}
return null;
}
|
[
"protected",
"function",
"getParameterValue",
"(",
"$",
"filterUrl",
")",
"{",
"$",
"parameterName",
"=",
"$",
"this",
"->",
"getParamName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"filterUrl",
"[",
"$",
"parameterName",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"filterUrl",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"filterUrl",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"return",
"\\",
"array_values",
"(",
"$",
"filterUrl",
"[",
"$",
"parameterName",
"]",
")",
";",
"}",
"return",
"\\",
"array_values",
"(",
"\\",
"explode",
"(",
"','",
",",
"$",
"filterUrl",
"[",
"$",
"parameterName",
"]",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Retrieve the parameter value from the filter url.
@param array $filterUrl The filter url from which to extract the parameter.
@return null|string|array
|
[
"Retrieve",
"the",
"parameter",
"value",
"from",
"the",
"filter",
"url",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterSetting/AbstractFromTo.php#L84-L96
|
27,524
|
MetaModels/filter_fromto
|
src/FilterSetting/AbstractFromTo.php
|
AbstractFromTo.getReferencedAttributes
|
public function getReferencedAttributes()
{
$objAttribute = null;
if (!($this->get('attr_id')
&& ($objAttribute = $this->getMetaModel()->getAttributeById($this->get('attr_id'))))) {
return [];
}
return $objAttribute ? [$objAttribute->getColName()] : [];
}
|
php
|
public function getReferencedAttributes()
{
$objAttribute = null;
if (!($this->get('attr_id')
&& ($objAttribute = $this->getMetaModel()->getAttributeById($this->get('attr_id'))))) {
return [];
}
return $objAttribute ? [$objAttribute->getColName()] : [];
}
|
[
"public",
"function",
"getReferencedAttributes",
"(",
")",
"{",
"$",
"objAttribute",
"=",
"null",
";",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"get",
"(",
"'attr_id'",
")",
"&&",
"(",
"$",
"objAttribute",
"=",
"$",
"this",
"->",
"getMetaModel",
"(",
")",
"->",
"getAttributeById",
"(",
"$",
"this",
"->",
"get",
"(",
"'attr_id'",
")",
")",
")",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"objAttribute",
"?",
"[",
"$",
"objAttribute",
"->",
"getColName",
"(",
")",
"]",
":",
"[",
"]",
";",
"}"
] |
Retrieve the attribute name that is referenced in this filter setting.
@return array
|
[
"Retrieve",
"the",
"attribute",
"name",
"that",
"is",
"referenced",
"in",
"this",
"filter",
"setting",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterSetting/AbstractFromTo.php#L103-L112
|
27,525
|
MetaModels/filter_fromto
|
src/FilterSetting/AbstractFromTo.php
|
AbstractFromTo.prepareWidgetOptions
|
protected function prepareWidgetOptions($arrIds, $objAttribute)
{
$arrOptions = $objAttribute->getFilterOptions(
($this->get('onlypossible') ? $arrIds : null),
(bool) $this->get('onlyused')
);
// Remove empty values from list.
foreach ($arrOptions as $mixKeyOption => $mixOption) {
// Remove html/php tags.
$mixOption = \strip_tags($mixOption);
$mixOption = \trim($mixOption);
if ($mixOption === '' || $mixOption === null) {
unset($arrOptions[$mixKeyOption]);
}
}
return $arrOptions;
}
|
php
|
protected function prepareWidgetOptions($arrIds, $objAttribute)
{
$arrOptions = $objAttribute->getFilterOptions(
($this->get('onlypossible') ? $arrIds : null),
(bool) $this->get('onlyused')
);
// Remove empty values from list.
foreach ($arrOptions as $mixKeyOption => $mixOption) {
// Remove html/php tags.
$mixOption = \strip_tags($mixOption);
$mixOption = \trim($mixOption);
if ($mixOption === '' || $mixOption === null) {
unset($arrOptions[$mixKeyOption]);
}
}
return $arrOptions;
}
|
[
"protected",
"function",
"prepareWidgetOptions",
"(",
"$",
"arrIds",
",",
"$",
"objAttribute",
")",
"{",
"$",
"arrOptions",
"=",
"$",
"objAttribute",
"->",
"getFilterOptions",
"(",
"(",
"$",
"this",
"->",
"get",
"(",
"'onlypossible'",
")",
"?",
"$",
"arrIds",
":",
"null",
")",
",",
"(",
"bool",
")",
"$",
"this",
"->",
"get",
"(",
"'onlyused'",
")",
")",
";",
"// Remove empty values from list.",
"foreach",
"(",
"$",
"arrOptions",
"as",
"$",
"mixKeyOption",
"=>",
"$",
"mixOption",
")",
"{",
"// Remove html/php tags.",
"$",
"mixOption",
"=",
"\\",
"strip_tags",
"(",
"$",
"mixOption",
")",
";",
"$",
"mixOption",
"=",
"\\",
"trim",
"(",
"$",
"mixOption",
")",
";",
"if",
"(",
"$",
"mixOption",
"===",
"''",
"||",
"$",
"mixOption",
"===",
"null",
")",
"{",
"unset",
"(",
"$",
"arrOptions",
"[",
"$",
"mixKeyOption",
"]",
")",
";",
"}",
"}",
"return",
"$",
"arrOptions",
";",
"}"
] |
Prepare options for the widget.
@param array $arrIds List of ids.
@param IAttribute $objAttribute The metamodel attribute.
@return array
|
[
"Prepare",
"options",
"for",
"the",
"widget",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterSetting/AbstractFromTo.php#L180-L199
|
27,526
|
MetaModels/filter_fromto
|
src/FilterSetting/AbstractFromTo.php
|
AbstractFromTo.prepareWidgetParamAndFilterUrl
|
protected function prepareWidgetParamAndFilterUrl($arrFilterUrl)
{
// Split up our param so the widgets can use it again.
$parameterName = $this->getParamName();
$privateFilterUrl = $arrFilterUrl;
$parameterValue = null;
// If we have a value, we have to explode it by double underscore to have a valid value which the active checks
// may cope with.
if (\array_key_exists($parameterName, $arrFilterUrl) && !empty($arrFilterUrl[$parameterName])) {
if (\is_array($arrFilterUrl[$parameterName])) {
$parameterValue = $arrFilterUrl[$parameterName];
} else {
$parameterValue = \explode(',', $arrFilterUrl[$parameterName], 2);
}
if ($parameterValue && ($parameterValue[0] || $parameterValue[1])) {
$privateFilterUrl[$parameterName] = $parameterValue;
return [$privateFilterUrl, $parameterValue];
} else {
// No values given, clear the array.
$parameterValue = null;
return [$privateFilterUrl, $parameterValue];
}
}
return [$privateFilterUrl, $parameterValue];
}
|
php
|
protected function prepareWidgetParamAndFilterUrl($arrFilterUrl)
{
// Split up our param so the widgets can use it again.
$parameterName = $this->getParamName();
$privateFilterUrl = $arrFilterUrl;
$parameterValue = null;
// If we have a value, we have to explode it by double underscore to have a valid value which the active checks
// may cope with.
if (\array_key_exists($parameterName, $arrFilterUrl) && !empty($arrFilterUrl[$parameterName])) {
if (\is_array($arrFilterUrl[$parameterName])) {
$parameterValue = $arrFilterUrl[$parameterName];
} else {
$parameterValue = \explode(',', $arrFilterUrl[$parameterName], 2);
}
if ($parameterValue && ($parameterValue[0] || $parameterValue[1])) {
$privateFilterUrl[$parameterName] = $parameterValue;
return [$privateFilterUrl, $parameterValue];
} else {
// No values given, clear the array.
$parameterValue = null;
return [$privateFilterUrl, $parameterValue];
}
}
return [$privateFilterUrl, $parameterValue];
}
|
[
"protected",
"function",
"prepareWidgetParamAndFilterUrl",
"(",
"$",
"arrFilterUrl",
")",
"{",
"// Split up our param so the widgets can use it again.",
"$",
"parameterName",
"=",
"$",
"this",
"->",
"getParamName",
"(",
")",
";",
"$",
"privateFilterUrl",
"=",
"$",
"arrFilterUrl",
";",
"$",
"parameterValue",
"=",
"null",
";",
"// If we have a value, we have to explode it by double underscore to have a valid value which the active checks",
"// may cope with.",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"parameterName",
",",
"$",
"arrFilterUrl",
")",
"&&",
"!",
"empty",
"(",
"$",
"arrFilterUrl",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"arrFilterUrl",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"$",
"parameterValue",
"=",
"$",
"arrFilterUrl",
"[",
"$",
"parameterName",
"]",
";",
"}",
"else",
"{",
"$",
"parameterValue",
"=",
"\\",
"explode",
"(",
"','",
",",
"$",
"arrFilterUrl",
"[",
"$",
"parameterName",
"]",
",",
"2",
")",
";",
"}",
"if",
"(",
"$",
"parameterValue",
"&&",
"(",
"$",
"parameterValue",
"[",
"0",
"]",
"||",
"$",
"parameterValue",
"[",
"1",
"]",
")",
")",
"{",
"$",
"privateFilterUrl",
"[",
"$",
"parameterName",
"]",
"=",
"$",
"parameterValue",
";",
"return",
"[",
"$",
"privateFilterUrl",
",",
"$",
"parameterValue",
"]",
";",
"}",
"else",
"{",
"// No values given, clear the array.",
"$",
"parameterValue",
"=",
"null",
";",
"return",
"[",
"$",
"privateFilterUrl",
",",
"$",
"parameterValue",
"]",
";",
"}",
"}",
"return",
"[",
"$",
"privateFilterUrl",
",",
"$",
"parameterValue",
"]",
";",
"}"
] |
Prepare the widget Param and filter url.
@param array $arrFilterUrl The filter url.
@return array
|
[
"Prepare",
"the",
"widget",
"Param",
"and",
"filter",
"url",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterSetting/AbstractFromTo.php#L208-L237
|
27,527
|
MetaModels/filter_fromto
|
src/FilterSetting/AbstractFromTo.php
|
AbstractFromTo.formatEmpty
|
private function formatEmpty($value)
{
if (empty($value = \trim($value))) {
return $value;
}
return $this->formatValue($value);
}
|
php
|
private function formatEmpty($value)
{
if (empty($value = \trim($value))) {
return $value;
}
return $this->formatValue($value);
}
|
[
"private",
"function",
"formatEmpty",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
"=",
"\\",
"trim",
"(",
"$",
"value",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"formatValue",
"(",
"$",
"value",
")",
";",
"}"
] |
Format the value but return empty if it is empty.
@param string $value The value to format.
@return bool|string
|
[
"Format",
"the",
"value",
"but",
"return",
"empty",
"if",
"it",
"is",
"empty",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterSetting/AbstractFromTo.php#L351-L358
|
27,528
|
MetaModels/filter_fromto
|
src/FilterSetting/AbstractFromTo.php
|
AbstractFromTo.createFromToRule
|
private function createFromToRule(IAttribute $attribute, $formattedValueZero, $formattedValueOne)
{
// If something went wrong return an empty list.
if ($formattedValueZero === false || $formattedValueOne === false) {
return new StaticIdList([]);
}
// Add rule to the filter.
$rule = $this->buildFromToRule($attribute);
if (null !== $formattedValueOne) {
$rule->setLowerBound($formattedValueZero, $this->get('moreequal'))
->setUpperBound($formattedValueOne, $this->get('lessequal'));
return $rule;
}
if ($this->get('fromfield')) {
$rule->setLowerBound($formattedValueZero, $this->get('moreequal'));
return $rule;
}
$rule->setUpperBound($formattedValueZero, $this->get('lessequal'));
return $rule;
}
|
php
|
private function createFromToRule(IAttribute $attribute, $formattedValueZero, $formattedValueOne)
{
// If something went wrong return an empty list.
if ($formattedValueZero === false || $formattedValueOne === false) {
return new StaticIdList([]);
}
// Add rule to the filter.
$rule = $this->buildFromToRule($attribute);
if (null !== $formattedValueOne) {
$rule->setLowerBound($formattedValueZero, $this->get('moreequal'))
->setUpperBound($formattedValueOne, $this->get('lessequal'));
return $rule;
}
if ($this->get('fromfield')) {
$rule->setLowerBound($formattedValueZero, $this->get('moreequal'));
return $rule;
}
$rule->setUpperBound($formattedValueZero, $this->get('lessequal'));
return $rule;
}
|
[
"private",
"function",
"createFromToRule",
"(",
"IAttribute",
"$",
"attribute",
",",
"$",
"formattedValueZero",
",",
"$",
"formattedValueOne",
")",
"{",
"// If something went wrong return an empty list.",
"if",
"(",
"$",
"formattedValueZero",
"===",
"false",
"||",
"$",
"formattedValueOne",
"===",
"false",
")",
"{",
"return",
"new",
"StaticIdList",
"(",
"[",
"]",
")",
";",
"}",
"// Add rule to the filter.",
"$",
"rule",
"=",
"$",
"this",
"->",
"buildFromToRule",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"formattedValueOne",
")",
"{",
"$",
"rule",
"->",
"setLowerBound",
"(",
"$",
"formattedValueZero",
",",
"$",
"this",
"->",
"get",
"(",
"'moreequal'",
")",
")",
"->",
"setUpperBound",
"(",
"$",
"formattedValueOne",
",",
"$",
"this",
"->",
"get",
"(",
"'lessequal'",
")",
")",
";",
"return",
"$",
"rule",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'fromfield'",
")",
")",
"{",
"$",
"rule",
"->",
"setLowerBound",
"(",
"$",
"formattedValueZero",
",",
"$",
"this",
"->",
"get",
"(",
"'moreequal'",
")",
")",
";",
"return",
"$",
"rule",
";",
"}",
"$",
"rule",
"->",
"setUpperBound",
"(",
"$",
"formattedValueZero",
",",
"$",
"this",
"->",
"get",
"(",
"'lessequal'",
")",
")",
";",
"return",
"$",
"rule",
";",
"}"
] |
Create and populate a rule instance.
@param IAttribute $attribute The attribute to filter on.
@param string $formattedValueZero The formatted first value.
@param string $formattedValueOne The formatted second value.
@return \MetaModels\FilterFromToBundle\FilterRule\FromTo|StaticIdList
|
[
"Create",
"and",
"populate",
"a",
"rule",
"instance",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterSetting/AbstractFromTo.php#L369-L391
|
27,529
|
nglasl/silverstripe-mediawesome
|
src/controllers/MediaHolderController.php
|
MediaHolderController.index
|
public function index() {
// Use a custom media type holder template if one exists.
$type = $this->data()->MediaType();
$templates = array();
if($type->exists()) {
$templates[] = 'MediaHolder_' . str_replace(' ', '', $type->Title);
}
$templates[] = 'MediaHolder';
$templates[] = 'Page';
$this->extend('updateTemplates', $templates);
return $this->renderWith($templates);
}
|
php
|
public function index() {
// Use a custom media type holder template if one exists.
$type = $this->data()->MediaType();
$templates = array();
if($type->exists()) {
$templates[] = 'MediaHolder_' . str_replace(' ', '', $type->Title);
}
$templates[] = 'MediaHolder';
$templates[] = 'Page';
$this->extend('updateTemplates', $templates);
return $this->renderWith($templates);
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"// Use a custom media type holder template if one exists.",
"$",
"type",
"=",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"MediaType",
"(",
")",
";",
"$",
"templates",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"type",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"templates",
"[",
"]",
"=",
"'MediaHolder_'",
".",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"type",
"->",
"Title",
")",
";",
"}",
"$",
"templates",
"[",
"]",
"=",
"'MediaHolder'",
";",
"$",
"templates",
"[",
"]",
"=",
"'Page'",
";",
"$",
"this",
"->",
"extend",
"(",
"'updateTemplates'",
",",
"$",
"templates",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"$",
"templates",
")",
";",
"}"
] |
Determine the template for this media holder.
|
[
"Determine",
"the",
"template",
"for",
"this",
"media",
"holder",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/controllers/MediaHolderController.php#L36-L49
|
27,530
|
nglasl/silverstripe-mediawesome
|
src/controllers/MediaHolderController.php
|
MediaHolderController.resolveURL
|
private function resolveURL() {
// Retrieve the current request URL segments.
$request = $this->getRequest();
$URL = $request->getURL();
$holder = substr($URL, 0, strpos($URL, '/'));
$page = substr($URL, strrpos($URL, '/') + 1);
// Determine whether a media page child once existed.
$resolution = self::find_old_page(array(
$holder,
$page
));
$comparison = trim($resolution, '/');
// Make sure the current request URL doesn't match the resolution.
if($resolution && ($page !== substr($comparison, strrpos($comparison, '/') + 1))) {
// Retrieve the current request parameters.
$parameters = $request->getVars();
unset($parameters['url']);
// Appropriately redirect towards the updated media page URL.
$response = new HTTPResponse();
return $response->redirect(self::join_links($resolution, !empty($parameters) ? '?' . http_build_query($parameters) : null), 301);
}
else {
// The media page child doesn't resolve.
return null;
}
}
|
php
|
private function resolveURL() {
// Retrieve the current request URL segments.
$request = $this->getRequest();
$URL = $request->getURL();
$holder = substr($URL, 0, strpos($URL, '/'));
$page = substr($URL, strrpos($URL, '/') + 1);
// Determine whether a media page child once existed.
$resolution = self::find_old_page(array(
$holder,
$page
));
$comparison = trim($resolution, '/');
// Make sure the current request URL doesn't match the resolution.
if($resolution && ($page !== substr($comparison, strrpos($comparison, '/') + 1))) {
// Retrieve the current request parameters.
$parameters = $request->getVars();
unset($parameters['url']);
// Appropriately redirect towards the updated media page URL.
$response = new HTTPResponse();
return $response->redirect(self::join_links($resolution, !empty($parameters) ? '?' . http_build_query($parameters) : null), 301);
}
else {
// The media page child doesn't resolve.
return null;
}
}
|
[
"private",
"function",
"resolveURL",
"(",
")",
"{",
"// Retrieve the current request URL segments.",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"URL",
"=",
"$",
"request",
"->",
"getURL",
"(",
")",
";",
"$",
"holder",
"=",
"substr",
"(",
"$",
"URL",
",",
"0",
",",
"strpos",
"(",
"$",
"URL",
",",
"'/'",
")",
")",
";",
"$",
"page",
"=",
"substr",
"(",
"$",
"URL",
",",
"strrpos",
"(",
"$",
"URL",
",",
"'/'",
")",
"+",
"1",
")",
";",
"// Determine whether a media page child once existed.",
"$",
"resolution",
"=",
"self",
"::",
"find_old_page",
"(",
"array",
"(",
"$",
"holder",
",",
"$",
"page",
")",
")",
";",
"$",
"comparison",
"=",
"trim",
"(",
"$",
"resolution",
",",
"'/'",
")",
";",
"// Make sure the current request URL doesn't match the resolution.",
"if",
"(",
"$",
"resolution",
"&&",
"(",
"$",
"page",
"!==",
"substr",
"(",
"$",
"comparison",
",",
"strrpos",
"(",
"$",
"comparison",
",",
"'/'",
")",
"+",
"1",
")",
")",
")",
"{",
"// Retrieve the current request parameters.",
"$",
"parameters",
"=",
"$",
"request",
"->",
"getVars",
"(",
")",
";",
"unset",
"(",
"$",
"parameters",
"[",
"'url'",
"]",
")",
";",
"// Appropriately redirect towards the updated media page URL.",
"$",
"response",
"=",
"new",
"HTTPResponse",
"(",
")",
";",
"return",
"$",
"response",
"->",
"redirect",
"(",
"self",
"::",
"join_links",
"(",
"$",
"resolution",
",",
"!",
"empty",
"(",
"$",
"parameters",
")",
"?",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
":",
"null",
")",
",",
"301",
")",
";",
"}",
"else",
"{",
"// The media page child doesn't resolve.",
"return",
"null",
";",
"}",
"}"
] |
Determine whether a media page child once existed for the current request, and redirect appropriately.
@return http response
|
[
"Determine",
"whether",
"a",
"media",
"page",
"child",
"once",
"existed",
"for",
"the",
"current",
"request",
"and",
"redirect",
"appropriately",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/controllers/MediaHolderController.php#L353-L390
|
27,531
|
nglasl/silverstripe-mediawesome
|
src/controllers/MediaHolderController.php
|
MediaHolderController.getDateFilterForm
|
public function getDateFilterForm() {
// Display a form that allows filtering from a specified date.
$children = MediaPage::get()->filter('ParentID', $this->data()->ID);
$form = Form::create(
$this,
'getDateFilterForm',
FieldList::create(
$date = DateField::create(
'from',
'From'
)->setMinDate($children->min('Date'))->setMaxDate($children->max('Date')),
HiddenField::create(
'category'
),
HiddenField::create(
'tag'
)
),
FieldList::create(
FormAction::create(
'dateFilter',
'Filter'
),
FormAction::create(
'clearFilters',
'Clear'
)
)
);
$form->setFormMethod('get');
// Remove validation if clear has been triggered.
$request = $this->getRequest();
if($request->getVar('action_clearFilters')) {
$form->unsetValidator();
}
// Allow extension customisation.
$this->extend('updateFilterForm', $form);
// Display existing request filters.
$form->loadDataFrom($request->getVars());
return $form;
}
|
php
|
public function getDateFilterForm() {
// Display a form that allows filtering from a specified date.
$children = MediaPage::get()->filter('ParentID', $this->data()->ID);
$form = Form::create(
$this,
'getDateFilterForm',
FieldList::create(
$date = DateField::create(
'from',
'From'
)->setMinDate($children->min('Date'))->setMaxDate($children->max('Date')),
HiddenField::create(
'category'
),
HiddenField::create(
'tag'
)
),
FieldList::create(
FormAction::create(
'dateFilter',
'Filter'
),
FormAction::create(
'clearFilters',
'Clear'
)
)
);
$form->setFormMethod('get');
// Remove validation if clear has been triggered.
$request = $this->getRequest();
if($request->getVar('action_clearFilters')) {
$form->unsetValidator();
}
// Allow extension customisation.
$this->extend('updateFilterForm', $form);
// Display existing request filters.
$form->loadDataFrom($request->getVars());
return $form;
}
|
[
"public",
"function",
"getDateFilterForm",
"(",
")",
"{",
"// Display a form that allows filtering from a specified date.",
"$",
"children",
"=",
"MediaPage",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'ParentID'",
",",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"ID",
")",
";",
"$",
"form",
"=",
"Form",
"::",
"create",
"(",
"$",
"this",
",",
"'getDateFilterForm'",
",",
"FieldList",
"::",
"create",
"(",
"$",
"date",
"=",
"DateField",
"::",
"create",
"(",
"'from'",
",",
"'From'",
")",
"->",
"setMinDate",
"(",
"$",
"children",
"->",
"min",
"(",
"'Date'",
")",
")",
"->",
"setMaxDate",
"(",
"$",
"children",
"->",
"max",
"(",
"'Date'",
")",
")",
",",
"HiddenField",
"::",
"create",
"(",
"'category'",
")",
",",
"HiddenField",
"::",
"create",
"(",
"'tag'",
")",
")",
",",
"FieldList",
"::",
"create",
"(",
"FormAction",
"::",
"create",
"(",
"'dateFilter'",
",",
"'Filter'",
")",
",",
"FormAction",
"::",
"create",
"(",
"'clearFilters'",
",",
"'Clear'",
")",
")",
")",
";",
"$",
"form",
"->",
"setFormMethod",
"(",
"'get'",
")",
";",
"// Remove validation if clear has been triggered.",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getVar",
"(",
"'action_clearFilters'",
")",
")",
"{",
"$",
"form",
"->",
"unsetValidator",
"(",
")",
";",
"}",
"// Allow extension customisation.",
"$",
"this",
"->",
"extend",
"(",
"'updateFilterForm'",
",",
"$",
"form",
")",
";",
"// Display existing request filters.",
"$",
"form",
"->",
"loadDataFrom",
"(",
"$",
"request",
"->",
"getVars",
"(",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] |
Retrieve a simple date filter form.
@return form
|
[
"Retrieve",
"a",
"simple",
"date",
"filter",
"form",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/controllers/MediaHolderController.php#L398-L446
|
27,532
|
nglasl/silverstripe-mediawesome
|
src/controllers/MediaHolderController.php
|
MediaHolderController.dateFilter
|
public function dateFilter() {
// Apply the from date filter.
$request = $this->getRequest();
$from = $request->getVar('from');
$link = $this->Link();
$separator = '?';
if($from) {
// Determine the formatted URL to represent the request filter.
$date = DBDate::create()->setValue($from);
$link .= $date->Format('y/MM/dd/');
}
// Preserve the category/tag filters if they exist.
$category = $request->getVar('category');
$tag = $request->getVar('tag');
if($category) {
$link = HTTP::setGetVar('category', $category, $link, $separator);
$separator = '&';
}
if($tag) {
$link = HTTP::setGetVar('tag', $tag, $link, $separator);
}
// Allow extension customisation.
$this->extend('updateFilter', $link);
// Request the filtered paginated children.
return $this->redirect($link);
}
|
php
|
public function dateFilter() {
// Apply the from date filter.
$request = $this->getRequest();
$from = $request->getVar('from');
$link = $this->Link();
$separator = '?';
if($from) {
// Determine the formatted URL to represent the request filter.
$date = DBDate::create()->setValue($from);
$link .= $date->Format('y/MM/dd/');
}
// Preserve the category/tag filters if they exist.
$category = $request->getVar('category');
$tag = $request->getVar('tag');
if($category) {
$link = HTTP::setGetVar('category', $category, $link, $separator);
$separator = '&';
}
if($tag) {
$link = HTTP::setGetVar('tag', $tag, $link, $separator);
}
// Allow extension customisation.
$this->extend('updateFilter', $link);
// Request the filtered paginated children.
return $this->redirect($link);
}
|
[
"public",
"function",
"dateFilter",
"(",
")",
"{",
"// Apply the from date filter.",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"from",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'from'",
")",
";",
"$",
"link",
"=",
"$",
"this",
"->",
"Link",
"(",
")",
";",
"$",
"separator",
"=",
"'?'",
";",
"if",
"(",
"$",
"from",
")",
"{",
"// Determine the formatted URL to represent the request filter.",
"$",
"date",
"=",
"DBDate",
"::",
"create",
"(",
")",
"->",
"setValue",
"(",
"$",
"from",
")",
";",
"$",
"link",
".=",
"$",
"date",
"->",
"Format",
"(",
"'y/MM/dd/'",
")",
";",
"}",
"// Preserve the category/tag filters if they exist.",
"$",
"category",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'category'",
")",
";",
"$",
"tag",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'tag'",
")",
";",
"if",
"(",
"$",
"category",
")",
"{",
"$",
"link",
"=",
"HTTP",
"::",
"setGetVar",
"(",
"'category'",
",",
"$",
"category",
",",
"$",
"link",
",",
"$",
"separator",
")",
";",
"$",
"separator",
"=",
"'&'",
";",
"}",
"if",
"(",
"$",
"tag",
")",
"{",
"$",
"link",
"=",
"HTTP",
"::",
"setGetVar",
"(",
"'tag'",
",",
"$",
"tag",
",",
"$",
"link",
",",
"$",
"separator",
")",
";",
"}",
"// Allow extension customisation.",
"$",
"this",
"->",
"extend",
"(",
"'updateFilter'",
",",
"$",
"link",
")",
";",
"// Request the filtered paginated children.",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"link",
")",
";",
"}"
] |
Request media page children from the filtered date.
|
[
"Request",
"media",
"page",
"children",
"from",
"the",
"filtered",
"date",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/controllers/MediaHolderController.php#L452-L487
|
27,533
|
nglasl/silverstripe-mediawesome
|
src/objects/MediaAttribute.php
|
MediaAttribute.checkPermissions
|
public function checkPermissions($member = null) {
// Retrieve the current site configuration permissions for customisation of media.
$configuration = SiteConfig::current_site_config();
return Permission::check($configuration->MediaPermission, 'any', $member);
}
|
php
|
public function checkPermissions($member = null) {
// Retrieve the current site configuration permissions for customisation of media.
$configuration = SiteConfig::current_site_config();
return Permission::check($configuration->MediaPermission, 'any', $member);
}
|
[
"public",
"function",
"checkPermissions",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"// Retrieve the current site configuration permissions for customisation of media.",
"$",
"configuration",
"=",
"SiteConfig",
"::",
"current_site_config",
"(",
")",
";",
"return",
"Permission",
"::",
"check",
"(",
"$",
"configuration",
"->",
"MediaPermission",
",",
"'any'",
",",
"$",
"member",
")",
";",
"}"
] |
Determine access for the current CMS user from the site configuration permissions.
@parameter <{CURRENT_MEMBER}> member
@return boolean
|
[
"Determine",
"access",
"for",
"the",
"current",
"CMS",
"user",
"from",
"the",
"site",
"configuration",
"permissions",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/objects/MediaAttribute.php#L74-L80
|
27,534
|
nglasl/silverstripe-mediawesome
|
src/objects/MediaAttribute.php
|
MediaAttribute.validate
|
public function validate() {
$result = parent::validate();
// Confirm that the current attribute has been given a title.
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
// Allow extension customisation.
$this->extend('validateMediaAttribute', $result);
return $result;
}
|
php
|
public function validate() {
$result = parent::validate();
// Confirm that the current attribute has been given a title.
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
// Allow extension customisation.
$this->extend('validateMediaAttribute', $result);
return $result;
}
|
[
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"validate",
"(",
")",
";",
"// Confirm that the current attribute has been given a title.",
"if",
"(",
"$",
"result",
"->",
"isValid",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"Title",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"'\"Title\" required!'",
")",
";",
"}",
"// Allow extension customisation.",
"$",
"this",
"->",
"extend",
"(",
"'validateMediaAttribute'",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Confirm that the current attribute is valid.
|
[
"Confirm",
"that",
"the",
"current",
"attribute",
"is",
"valid",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/objects/MediaAttribute.php#L99-L113
|
27,535
|
jonnitto/Jonnitto.PrettyEmbedYoutube
|
Classes/Eel/YoutubeHelper.php
|
YoutubeHelper.parseID
|
function parseID($url) {
if (!$url) {
return false;
}
$regs = array();
if (preg_match('/(?<=(?:(?<=v)|(?<=i)|(?<=list))=)[a-zA-Z0-9-]+(?=&)|(?<=(?:(?<=v)|(?<=i)|(?<=list))\/)[^&\n]+|(?<=embed\/)[^"&\n]+|(?<=(?:(?<=v)|(?<=i)|(?<=list))=)[^&\n]+|(?<=youtu.be\/)[^&\n]+/im', $url, $regs)) {
return $regs[0];
}
return $url;
}
|
php
|
function parseID($url) {
if (!$url) {
return false;
}
$regs = array();
if (preg_match('/(?<=(?:(?<=v)|(?<=i)|(?<=list))=)[a-zA-Z0-9-]+(?=&)|(?<=(?:(?<=v)|(?<=i)|(?<=list))\/)[^&\n]+|(?<=embed\/)[^"&\n]+|(?<=(?:(?<=v)|(?<=i)|(?<=list))=)[^&\n]+|(?<=youtu.be\/)[^&\n]+/im', $url, $regs)) {
return $regs[0];
}
return $url;
}
|
[
"function",
"parseID",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"$",
"url",
")",
"{",
"return",
"false",
";",
"}",
"$",
"regs",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/(?<=(?:(?<=v)|(?<=i)|(?<=list))=)[a-zA-Z0-9-]+(?=&)|(?<=(?:(?<=v)|(?<=i)|(?<=list))\\/)[^&\\n]+|(?<=embed\\/)[^\"&\\n]+|(?<=(?:(?<=v)|(?<=i)|(?<=list))=)[^&\\n]+|(?<=youtu.be\\/)[^&\\n]+/im'",
",",
"$",
"url",
",",
"$",
"regs",
")",
")",
"{",
"return",
"$",
"regs",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Get Youtube video id from url
@param string $url The URL
@return string the video id extracted from url
|
[
"Get",
"Youtube",
"video",
"id",
"from",
"url"
] |
2df6d1ced7fce9fd1cea327bc6cb617a25e714d0
|
https://github.com/jonnitto/Jonnitto.PrettyEmbedYoutube/blob/2df6d1ced7fce9fd1cea327bc6cb617a25e714d0/Classes/Eel/YoutubeHelper.php#L23-L32
|
27,536
|
jonnitto/Jonnitto.PrettyEmbedYoutube
|
Classes/Eel/YoutubeHelper.php
|
YoutubeHelper.data
|
function data($id)
{
if (!$id) {
return false;
}
$data = json_decode(@file_get_contents('https://www.youtube.com/oembed?url=https%3A//youtube.com/watch%3Fv%3D' . $id));
if (!$data) {
return false;
}
return $data;
}
|
php
|
function data($id)
{
if (!$id) {
return false;
}
$data = json_decode(@file_get_contents('https://www.youtube.com/oembed?url=https%3A//youtube.com/watch%3Fv%3D' . $id));
if (!$data) {
return false;
}
return $data;
}
|
[
"function",
"data",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"json_decode",
"(",
"@",
"file_get_contents",
"(",
"'https://www.youtube.com/oembed?url=https%3A//youtube.com/watch%3Fv%3D'",
".",
"$",
"id",
")",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Grab the data of a publicly embeddable video hosted on youtube
@param string $id The "id" of a video
@return mixed The data or false if there's an error
|
[
"Grab",
"the",
"data",
"of",
"a",
"publicly",
"embeddable",
"video",
"hosted",
"on",
"youtube"
] |
2df6d1ced7fce9fd1cea327bc6cb617a25e714d0
|
https://github.com/jonnitto/Jonnitto.PrettyEmbedYoutube/blob/2df6d1ced7fce9fd1cea327bc6cb617a25e714d0/Classes/Eel/YoutubeHelper.php#L39-L49
|
27,537
|
jonnitto/Jonnitto.PrettyEmbedYoutube
|
Classes/Eel/YoutubeHelper.php
|
YoutubeHelper.title
|
function title($id) {
$data = $this->data($id);
if (!$data) {
return false;
}
return $data->title;
}
|
php
|
function title($id) {
$data = $this->data($id);
if (!$data) {
return false;
}
return $data->title;
}
|
[
"function",
"title",
"(",
"$",
"id",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"data",
"->",
"title",
";",
"}"
] |
Grab the title of a publicly embeddable video hosted on youtube
@param string $id The "id" of a video
@return mixed The title or false if there's an error
|
[
"Grab",
"the",
"title",
"of",
"a",
"publicly",
"embeddable",
"video",
"hosted",
"on",
"youtube"
] |
2df6d1ced7fce9fd1cea327bc6cb617a25e714d0
|
https://github.com/jonnitto/Jonnitto.PrettyEmbedYoutube/blob/2df6d1ced7fce9fd1cea327bc6cb617a25e714d0/Classes/Eel/YoutubeHelper.php#L56-L62
|
27,538
|
nglasl/silverstripe-mediawesome
|
src/extensions/SiteConfigMediaPermissionExtension.php
|
SiteConfigMediaPermissionExtension.updateCMSFields
|
public function updateCMSFields(FieldList $fields) {
$permissions = array(
'ADMIN' => 'Administrators and developers',
'SITETREE_EDIT_ALL' => 'Content authors'
);
// Confirm that the current CMS user has permission.
if(Permission::check('EDIT_SITECONFIG') === false) {
$fields->addFieldToTab('Root.Access', $options = ReadonlyField::create(
'Media',
'Who can customise media?',
$permissions[$this->owner->MediaPermission]
));
}
else {
// Display the permission configuration.
$fields->addFieldToTab('Root.Access', $options = OptionsetField::create(
'MediaPermission',
'Who can customise media?',
$permissions
));
}
// Allow extension customisation.
$this->owner->extend('updateSiteConfigMediaPermissionExtensionCMSFields', $fields);
}
|
php
|
public function updateCMSFields(FieldList $fields) {
$permissions = array(
'ADMIN' => 'Administrators and developers',
'SITETREE_EDIT_ALL' => 'Content authors'
);
// Confirm that the current CMS user has permission.
if(Permission::check('EDIT_SITECONFIG') === false) {
$fields->addFieldToTab('Root.Access', $options = ReadonlyField::create(
'Media',
'Who can customise media?',
$permissions[$this->owner->MediaPermission]
));
}
else {
// Display the permission configuration.
$fields->addFieldToTab('Root.Access', $options = OptionsetField::create(
'MediaPermission',
'Who can customise media?',
$permissions
));
}
// Allow extension customisation.
$this->owner->extend('updateSiteConfigMediaPermissionExtensionCMSFields', $fields);
}
|
[
"public",
"function",
"updateCMSFields",
"(",
"FieldList",
"$",
"fields",
")",
"{",
"$",
"permissions",
"=",
"array",
"(",
"'ADMIN'",
"=>",
"'Administrators and developers'",
",",
"'SITETREE_EDIT_ALL'",
"=>",
"'Content authors'",
")",
";",
"// Confirm that the current CMS user has permission.",
"if",
"(",
"Permission",
"::",
"check",
"(",
"'EDIT_SITECONFIG'",
")",
"===",
"false",
")",
"{",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.Access'",
",",
"$",
"options",
"=",
"ReadonlyField",
"::",
"create",
"(",
"'Media'",
",",
"'Who can customise media?'",
",",
"$",
"permissions",
"[",
"$",
"this",
"->",
"owner",
"->",
"MediaPermission",
"]",
")",
")",
";",
"}",
"else",
"{",
"// Display the permission configuration.",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.Access'",
",",
"$",
"options",
"=",
"OptionsetField",
"::",
"create",
"(",
"'MediaPermission'",
",",
"'Who can customise media?'",
",",
"$",
"permissions",
")",
")",
";",
"}",
"// Allow extension customisation.",
"$",
"this",
"->",
"owner",
"->",
"extend",
"(",
"'updateSiteConfigMediaPermissionExtensionCMSFields'",
",",
"$",
"fields",
")",
";",
"}"
] |
Allow permission configuration for customisation of media.
|
[
"Allow",
"permission",
"configuration",
"for",
"customisation",
"of",
"media",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/extensions/SiteConfigMediaPermissionExtension.php#L30-L60
|
27,539
|
MetaModels/filter_fromto
|
src/FilterRule/FromToDate.php
|
FromToDate.runSimpleQuery
|
private function runSimpleQuery($operation, $value)
{
$attribute = $this->getAttribute();
if (!$attribute instanceof ISimple) {
throw new \RuntimeException('Filtering for time ranges is only possible on simple attributes.');
}
return $this->executeRule(new SimpleQuery(
\sprintf(
'SELECT id FROM %s WHERE TIME(FROM_UNIXTIME(%s)) %s ?)',
$attribute->getMetaModel()->getTableName(),
$attribute->getColName(),
$operation
),
[$value],
'id',
$this->connection
));
}
|
php
|
private function runSimpleQuery($operation, $value)
{
$attribute = $this->getAttribute();
if (!$attribute instanceof ISimple) {
throw new \RuntimeException('Filtering for time ranges is only possible on simple attributes.');
}
return $this->executeRule(new SimpleQuery(
\sprintf(
'SELECT id FROM %s WHERE TIME(FROM_UNIXTIME(%s)) %s ?)',
$attribute->getMetaModel()->getTableName(),
$attribute->getColName(),
$operation
),
[$value],
'id',
$this->connection
));
}
|
[
"private",
"function",
"runSimpleQuery",
"(",
"$",
"operation",
",",
"$",
"value",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
")",
";",
"if",
"(",
"!",
"$",
"attribute",
"instanceof",
"ISimple",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Filtering for time ranges is only possible on simple attributes.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"executeRule",
"(",
"new",
"SimpleQuery",
"(",
"\\",
"sprintf",
"(",
"'SELECT id FROM %s WHERE TIME(FROM_UNIXTIME(%s)) %s ?)'",
",",
"$",
"attribute",
"->",
"getMetaModel",
"(",
")",
"->",
"getTableName",
"(",
")",
",",
"$",
"attribute",
"->",
"getColName",
"(",
")",
",",
"$",
"operation",
")",
",",
"[",
"$",
"value",
"]",
",",
"'id'",
",",
"$",
"this",
"->",
"connection",
")",
")",
";",
"}"
] |
Run a simple query against the attribute when using time only filtering.
@param string $operation The mathematical operation to use for evaluating.
@param string $value The value to match against.
@return array|null
@throws \RuntimeException When the attribute is not a simple one.
|
[
"Run",
"a",
"simple",
"query",
"against",
"the",
"attribute",
"when",
"using",
"time",
"only",
"filtering",
"."
] |
0d65f4b14f3eceab9e022c79388fbced5e47ed9d
|
https://github.com/MetaModels/filter_fromto/blob/0d65f4b14f3eceab9e022c79388fbced5e47ed9d/src/FilterRule/FromToDate.php#L99-L118
|
27,540
|
cssjanus/php-cssjanus
|
src/CSSJanus.php
|
CSSJanus.buildPatterns
|
private static function buildPatterns() {
if (!is_null(self::$patterns['escape'])) {
// Patterns have already been built
return;
}
// @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong
$patterns =& self::$patterns;
$patterns['escape'] = "(?:{$patterns['unicode']}|\\[^\r\n\f0-9a-f])";
$patterns['nmstart'] = "(?:[_a-z]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['nmchar'] = "(?:[_a-z0-9-]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['ident'] = "-?{$patterns['nmstart']}{$patterns['nmchar']}*";
$patterns['quantity'] = "{$patterns['num']}(?:\s*{$patterns['unit']}|{$patterns['ident']})?";
$patterns['possibly_negative_quantity'] = "((?:-?{$patterns['quantity']})|(?:inherit|auto))";
$patterns['color'] = "(#?{$patterns['nmchar']}+|(?:rgba?|hsla?)\([ \d.,%-]+\))";
$patterns['url_chars'] = "(?:{$patterns['url_special_chars']}|{$patterns['nonAscii']}|{$patterns['escape']})*";
$patterns['lookahead_not_open_brace'] = "(?!({$patterns['nmchar']}|\r?\n|\s|#|\:|\.|\,|\+|>|\(|\)|\[|\]|=|\*=|~=|\^=|'[^']*'])*?{)";
$patterns['lookahead_not_closing_paren'] = "(?!{$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['lookahead_for_closing_paren'] = "(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['noflip_single'] = "/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i";
$patterns['noflip_class'] = "/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i";
$patterns['direction_ltr'] = "/({$patterns['direction']})ltr/i";
$patterns['direction_rtl'] = "/({$patterns['direction']})rtl/i";
$patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i";
$patterns['right_in_url'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_for_closing_paren']}/i";
$patterns['ltr_in_url'] = "/{$patterns['lookbehind_not_letter']}(ltr){$patterns['lookahead_for_closing_paren']}/i";
$patterns['rtl_in_url'] = "/{$patterns['lookbehind_not_letter']}(rtl){$patterns['lookahead_for_closing_paren']}/i";
$patterns['cursor_east'] = "/{$patterns['lookbehind_not_letter']}([ns]?)e-resize/";
$patterns['cursor_west'] = "/{$patterns['lookbehind_not_letter']}([ns]?)w-resize/";
$patterns['four_notation_quantity_props'] = "((?:margin|padding|border-width)\s*:\s*)";
$patterns['four_notation_quantity'] = "/{$patterns['four_notation_quantity_props']}{$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}{$patterns['suffix']}/i";
$patterns['four_notation_color'] = "/((?:-color|border-style)\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}{$patterns['suffix']}/i";
// border-radius: <length or percentage>{1,4} [optional: / <length or percentage>{1,4} ]
$patterns['border_radius'] = '/(border-radius\s*:\s*)' . $patterns['possibly_negative_quantity']
. '(?:(?:\s+' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?'
. '(?:(?:(?:\s*\/\s*)' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?' . $patterns['suffix']
. '/i';
$patterns['box_shadow'] = "/(box-shadow\s*:\s*(?:inset\s*)?){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow1'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}(\s*){$patterns['color']}/i";
$patterns['text_shadow2'] = "/(text-shadow\s*:\s*){$patterns['color']}(\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow3'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['bg_horizontal_percentage'] = "/(background(?:-position)?\s*:\s*(?:[^:;}\s]+\s+)*?)({$patterns['quantity']})/i";
$patterns['bg_horizontal_percentage_x'] = "/(background-position-x\s*:\s*)(-?{$patterns['num']}%)/i";
$patterns['translate_x'] = "/(transform\s*:[^;]*)(translateX\s*\(\s*){$patterns['possibly_negative_quantity']}(\s*\))/i";
$patterns['translate'] = "/(transform\s*:[^;]*)(translate\s*\(\s*){$patterns['possibly_negative_quantity']}((?:\s*,\s*{$patterns['possibly_negative_quantity']}){0,2}\s*\))/i";
// @codingStandardsIgnoreEnd
}
|
php
|
private static function buildPatterns() {
if (!is_null(self::$patterns['escape'])) {
// Patterns have already been built
return;
}
// @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong
$patterns =& self::$patterns;
$patterns['escape'] = "(?:{$patterns['unicode']}|\\[^\r\n\f0-9a-f])";
$patterns['nmstart'] = "(?:[_a-z]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['nmchar'] = "(?:[_a-z0-9-]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['ident'] = "-?{$patterns['nmstart']}{$patterns['nmchar']}*";
$patterns['quantity'] = "{$patterns['num']}(?:\s*{$patterns['unit']}|{$patterns['ident']})?";
$patterns['possibly_negative_quantity'] = "((?:-?{$patterns['quantity']})|(?:inherit|auto))";
$patterns['color'] = "(#?{$patterns['nmchar']}+|(?:rgba?|hsla?)\([ \d.,%-]+\))";
$patterns['url_chars'] = "(?:{$patterns['url_special_chars']}|{$patterns['nonAscii']}|{$patterns['escape']})*";
$patterns['lookahead_not_open_brace'] = "(?!({$patterns['nmchar']}|\r?\n|\s|#|\:|\.|\,|\+|>|\(|\)|\[|\]|=|\*=|~=|\^=|'[^']*'])*?{)";
$patterns['lookahead_not_closing_paren'] = "(?!{$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['lookahead_for_closing_paren'] = "(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['noflip_single'] = "/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i";
$patterns['noflip_class'] = "/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i";
$patterns['direction_ltr'] = "/({$patterns['direction']})ltr/i";
$patterns['direction_rtl'] = "/({$patterns['direction']})rtl/i";
$patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i";
$patterns['right_in_url'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_for_closing_paren']}/i";
$patterns['ltr_in_url'] = "/{$patterns['lookbehind_not_letter']}(ltr){$patterns['lookahead_for_closing_paren']}/i";
$patterns['rtl_in_url'] = "/{$patterns['lookbehind_not_letter']}(rtl){$patterns['lookahead_for_closing_paren']}/i";
$patterns['cursor_east'] = "/{$patterns['lookbehind_not_letter']}([ns]?)e-resize/";
$patterns['cursor_west'] = "/{$patterns['lookbehind_not_letter']}([ns]?)w-resize/";
$patterns['four_notation_quantity_props'] = "((?:margin|padding|border-width)\s*:\s*)";
$patterns['four_notation_quantity'] = "/{$patterns['four_notation_quantity_props']}{$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}{$patterns['suffix']}/i";
$patterns['four_notation_color'] = "/((?:-color|border-style)\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}{$patterns['suffix']}/i";
// border-radius: <length or percentage>{1,4} [optional: / <length or percentage>{1,4} ]
$patterns['border_radius'] = '/(border-radius\s*:\s*)' . $patterns['possibly_negative_quantity']
. '(?:(?:\s+' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?'
. '(?:(?:(?:\s*\/\s*)' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?' . $patterns['suffix']
. '/i';
$patterns['box_shadow'] = "/(box-shadow\s*:\s*(?:inset\s*)?){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow1'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}(\s*){$patterns['color']}/i";
$patterns['text_shadow2'] = "/(text-shadow\s*:\s*){$patterns['color']}(\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow3'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['bg_horizontal_percentage'] = "/(background(?:-position)?\s*:\s*(?:[^:;}\s]+\s+)*?)({$patterns['quantity']})/i";
$patterns['bg_horizontal_percentage_x'] = "/(background-position-x\s*:\s*)(-?{$patterns['num']}%)/i";
$patterns['translate_x'] = "/(transform\s*:[^;]*)(translateX\s*\(\s*){$patterns['possibly_negative_quantity']}(\s*\))/i";
$patterns['translate'] = "/(transform\s*:[^;]*)(translate\s*\(\s*){$patterns['possibly_negative_quantity']}((?:\s*,\s*{$patterns['possibly_negative_quantity']}){0,2}\s*\))/i";
// @codingStandardsIgnoreEnd
}
|
[
"private",
"static",
"function",
"buildPatterns",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'escape'",
"]",
")",
")",
"{",
"// Patterns have already been built",
"return",
";",
"}",
"// @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong",
"$",
"patterns",
"=",
"&",
"self",
"::",
"$",
"patterns",
";",
"$",
"patterns",
"[",
"'escape'",
"]",
"=",
"\"(?:{$patterns['unicode']}|\\\\[^\\r\\n\\f0-9a-f])\"",
";",
"$",
"patterns",
"[",
"'nmstart'",
"]",
"=",
"\"(?:[_a-z]|{$patterns['nonAscii']}|{$patterns['escape']})\"",
";",
"$",
"patterns",
"[",
"'nmchar'",
"]",
"=",
"\"(?:[_a-z0-9-]|{$patterns['nonAscii']}|{$patterns['escape']})\"",
";",
"$",
"patterns",
"[",
"'ident'",
"]",
"=",
"\"-?{$patterns['nmstart']}{$patterns['nmchar']}*\"",
";",
"$",
"patterns",
"[",
"'quantity'",
"]",
"=",
"\"{$patterns['num']}(?:\\s*{$patterns['unit']}|{$patterns['ident']})?\"",
";",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
"=",
"\"((?:-?{$patterns['quantity']})|(?:inherit|auto))\"",
";",
"$",
"patterns",
"[",
"'color'",
"]",
"=",
"\"(#?{$patterns['nmchar']}+|(?:rgba?|hsla?)\\([ \\d.,%-]+\\))\"",
";",
"$",
"patterns",
"[",
"'url_chars'",
"]",
"=",
"\"(?:{$patterns['url_special_chars']}|{$patterns['nonAscii']}|{$patterns['escape']})*\"",
";",
"$",
"patterns",
"[",
"'lookahead_not_open_brace'",
"]",
"=",
"\"(?!({$patterns['nmchar']}|\\r?\\n|\\s|#|\\:|\\.|\\,|\\+|>|\\(|\\)|\\[|\\]|=|\\*=|~=|\\^=|'[^']*'])*?{)\"",
";",
"$",
"patterns",
"[",
"'lookahead_not_closing_paren'",
"]",
"=",
"\"(?!{$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\\))\"",
";",
"$",
"patterns",
"[",
"'lookahead_for_closing_paren'",
"]",
"=",
"\"(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\\))\"",
";",
"$",
"patterns",
"[",
"'noflip_single'",
"]",
"=",
"\"/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i\"",
";",
"$",
"patterns",
"[",
"'noflip_class'",
"]",
"=",
"\"/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i\"",
";",
"$",
"patterns",
"[",
"'direction_ltr'",
"]",
"=",
"\"/({$patterns['direction']})ltr/i\"",
";",
"$",
"patterns",
"[",
"'direction_rtl'",
"]",
"=",
"\"/({$patterns['direction']})rtl/i\"",
";",
"$",
"patterns",
"[",
"'left'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i\"",
";",
"$",
"patterns",
"[",
"'right'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i\"",
";",
"$",
"patterns",
"[",
"'left_in_url'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i\"",
";",
"$",
"patterns",
"[",
"'right_in_url'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_for_closing_paren']}/i\"",
";",
"$",
"patterns",
"[",
"'ltr_in_url'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}(ltr){$patterns['lookahead_for_closing_paren']}/i\"",
";",
"$",
"patterns",
"[",
"'rtl_in_url'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}(rtl){$patterns['lookahead_for_closing_paren']}/i\"",
";",
"$",
"patterns",
"[",
"'cursor_east'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}([ns]?)e-resize/\"",
";",
"$",
"patterns",
"[",
"'cursor_west'",
"]",
"=",
"\"/{$patterns['lookbehind_not_letter']}([ns]?)w-resize/\"",
";",
"$",
"patterns",
"[",
"'four_notation_quantity_props'",
"]",
"=",
"\"((?:margin|padding|border-width)\\s*:\\s*)\"",
";",
"$",
"patterns",
"[",
"'four_notation_quantity'",
"]",
"=",
"\"/{$patterns['four_notation_quantity_props']}{$patterns['possibly_negative_quantity']}(\\s+){$patterns['possibly_negative_quantity']}(\\s+){$patterns['possibly_negative_quantity']}(\\s+){$patterns['possibly_negative_quantity']}{$patterns['suffix']}/i\"",
";",
"$",
"patterns",
"[",
"'four_notation_color'",
"]",
"=",
"\"/((?:-color|border-style)\\s*:\\s*){$patterns['color']}(\\s+){$patterns['color']}(\\s+){$patterns['color']}(\\s+){$patterns['color']}{$patterns['suffix']}/i\"",
";",
"// border-radius: <length or percentage>{1,4} [optional: / <length or percentage>{1,4} ]",
"$",
"patterns",
"[",
"'border_radius'",
"]",
"=",
"'/(border-radius\\s*:\\s*)'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"'(?:(?:\\s+'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')(?:\\s+'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')?(?:\\s+'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')?)?'",
".",
"'(?:(?:(?:\\s*\\/\\s*)'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')(?:\\s+'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')?(?:\\s+'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')?(?:\\s+'",
".",
"$",
"patterns",
"[",
"'possibly_negative_quantity'",
"]",
".",
"')?)?'",
".",
"$",
"patterns",
"[",
"'suffix'",
"]",
".",
"'/i'",
";",
"$",
"patterns",
"[",
"'box_shadow'",
"]",
"=",
"\"/(box-shadow\\s*:\\s*(?:inset\\s*)?){$patterns['possibly_negative_quantity']}/i\"",
";",
"$",
"patterns",
"[",
"'text_shadow1'",
"]",
"=",
"\"/(text-shadow\\s*:\\s*){$patterns['possibly_negative_quantity']}(\\s*){$patterns['color']}/i\"",
";",
"$",
"patterns",
"[",
"'text_shadow2'",
"]",
"=",
"\"/(text-shadow\\s*:\\s*){$patterns['color']}(\\s*){$patterns['possibly_negative_quantity']}/i\"",
";",
"$",
"patterns",
"[",
"'text_shadow3'",
"]",
"=",
"\"/(text-shadow\\s*:\\s*){$patterns['possibly_negative_quantity']}/i\"",
";",
"$",
"patterns",
"[",
"'bg_horizontal_percentage'",
"]",
"=",
"\"/(background(?:-position)?\\s*:\\s*(?:[^:;}\\s]+\\s+)*?)({$patterns['quantity']})/i\"",
";",
"$",
"patterns",
"[",
"'bg_horizontal_percentage_x'",
"]",
"=",
"\"/(background-position-x\\s*:\\s*)(-?{$patterns['num']}%)/i\"",
";",
"$",
"patterns",
"[",
"'translate_x'",
"]",
"=",
"\"/(transform\\s*:[^;]*)(translateX\\s*\\(\\s*){$patterns['possibly_negative_quantity']}(\\s*\\))/i\"",
";",
"$",
"patterns",
"[",
"'translate'",
"]",
"=",
"\"/(transform\\s*:[^;]*)(translate\\s*\\(\\s*){$patterns['possibly_negative_quantity']}((?:\\s*,\\s*{$patterns['possibly_negative_quantity']}){0,2}\\s*\\))/i\"",
";",
"// @codingStandardsIgnoreEnd",
"}"
] |
Build patterns we can't define above because they depend on other patterns.
|
[
"Build",
"patterns",
"we",
"can",
"t",
"define",
"above",
"because",
"they",
"depend",
"on",
"other",
"patterns",
"."
] |
44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6
|
https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L87-L135
|
27,541
|
cssjanus/php-cssjanus
|
src/CSSJanus.php
|
CSSJanus.transform
|
public static function transform($css, $options = array(), $transformEdgeInUrl = false) {
if (!is_array($options)) {
$options = array(
'transformDirInUrl' => (bool)$options,
'transformEdgeInUrl' => (bool)$transformEdgeInUrl,
);
}
// Defaults
$options += array(
'transformDirInUrl' => false,
'transformEdgeInUrl' => false,
);
// We wrap tokens in ` , not ~ like the original implementation does.
// This was done because ` is not a legal character in CSS and can only
// occur in URLs, where we escape it to %60 before inserting our tokens.
$css = str_replace('`', '%60', $css);
self::buildPatterns();
// Tokenize single line rules with /* @noflip */
$noFlipSingle = new CSSJanusTokenizer(self::$patterns['noflip_single'], '`NOFLIP_SINGLE`');
$css = $noFlipSingle->tokenize($css);
// Tokenize class rules with /* @noflip */
$noFlipClass = new CSSJanusTokenizer(self::$patterns['noflip_class'], '`NOFLIP_CLASS`');
$css = $noFlipClass->tokenize($css);
// Tokenize comments
$comments = new CSSJanusTokenizer(self::$patterns['comment'], '`C`');
$css = $comments->tokenize($css);
// LTR->RTL fixes start here
$css = self::fixDirection($css);
if ($options['transformDirInUrl']) {
$css = self::fixLtrRtlInURL($css);
}
if ($options['transformEdgeInUrl']) {
$css = self::fixLeftRightInURL($css);
}
$css = self::fixLeftAndRight($css);
$css = self::fixCursorProperties($css);
$css = self::fixFourPartNotation($css);
$css = self::fixBorderRadius($css);
$css = self::fixBackgroundPosition($css);
$css = self::fixShadows($css);
$css = self::fixTranslate($css);
// Detokenize stuff we tokenized before
$css = $comments->detokenize($css);
$css = $noFlipClass->detokenize($css);
$css = $noFlipSingle->detokenize($css);
return $css;
}
|
php
|
public static function transform($css, $options = array(), $transformEdgeInUrl = false) {
if (!is_array($options)) {
$options = array(
'transformDirInUrl' => (bool)$options,
'transformEdgeInUrl' => (bool)$transformEdgeInUrl,
);
}
// Defaults
$options += array(
'transformDirInUrl' => false,
'transformEdgeInUrl' => false,
);
// We wrap tokens in ` , not ~ like the original implementation does.
// This was done because ` is not a legal character in CSS and can only
// occur in URLs, where we escape it to %60 before inserting our tokens.
$css = str_replace('`', '%60', $css);
self::buildPatterns();
// Tokenize single line rules with /* @noflip */
$noFlipSingle = new CSSJanusTokenizer(self::$patterns['noflip_single'], '`NOFLIP_SINGLE`');
$css = $noFlipSingle->tokenize($css);
// Tokenize class rules with /* @noflip */
$noFlipClass = new CSSJanusTokenizer(self::$patterns['noflip_class'], '`NOFLIP_CLASS`');
$css = $noFlipClass->tokenize($css);
// Tokenize comments
$comments = new CSSJanusTokenizer(self::$patterns['comment'], '`C`');
$css = $comments->tokenize($css);
// LTR->RTL fixes start here
$css = self::fixDirection($css);
if ($options['transformDirInUrl']) {
$css = self::fixLtrRtlInURL($css);
}
if ($options['transformEdgeInUrl']) {
$css = self::fixLeftRightInURL($css);
}
$css = self::fixLeftAndRight($css);
$css = self::fixCursorProperties($css);
$css = self::fixFourPartNotation($css);
$css = self::fixBorderRadius($css);
$css = self::fixBackgroundPosition($css);
$css = self::fixShadows($css);
$css = self::fixTranslate($css);
// Detokenize stuff we tokenized before
$css = $comments->detokenize($css);
$css = $noFlipClass->detokenize($css);
$css = $noFlipSingle->detokenize($css);
return $css;
}
|
[
"public",
"static",
"function",
"transform",
"(",
"$",
"css",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"transformEdgeInUrl",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'transformDirInUrl'",
"=>",
"(",
"bool",
")",
"$",
"options",
",",
"'transformEdgeInUrl'",
"=>",
"(",
"bool",
")",
"$",
"transformEdgeInUrl",
",",
")",
";",
"}",
"// Defaults",
"$",
"options",
"+=",
"array",
"(",
"'transformDirInUrl'",
"=>",
"false",
",",
"'transformEdgeInUrl'",
"=>",
"false",
",",
")",
";",
"// We wrap tokens in ` , not ~ like the original implementation does.",
"// This was done because ` is not a legal character in CSS and can only",
"// occur in URLs, where we escape it to %60 before inserting our tokens.",
"$",
"css",
"=",
"str_replace",
"(",
"'`'",
",",
"'%60'",
",",
"$",
"css",
")",
";",
"self",
"::",
"buildPatterns",
"(",
")",
";",
"// Tokenize single line rules with /* @noflip */",
"$",
"noFlipSingle",
"=",
"new",
"CSSJanusTokenizer",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'noflip_single'",
"]",
",",
"'`NOFLIP_SINGLE`'",
")",
";",
"$",
"css",
"=",
"$",
"noFlipSingle",
"->",
"tokenize",
"(",
"$",
"css",
")",
";",
"// Tokenize class rules with /* @noflip */",
"$",
"noFlipClass",
"=",
"new",
"CSSJanusTokenizer",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'noflip_class'",
"]",
",",
"'`NOFLIP_CLASS`'",
")",
";",
"$",
"css",
"=",
"$",
"noFlipClass",
"->",
"tokenize",
"(",
"$",
"css",
")",
";",
"// Tokenize comments",
"$",
"comments",
"=",
"new",
"CSSJanusTokenizer",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'comment'",
"]",
",",
"'`C`'",
")",
";",
"$",
"css",
"=",
"$",
"comments",
"->",
"tokenize",
"(",
"$",
"css",
")",
";",
"// LTR->RTL fixes start here",
"$",
"css",
"=",
"self",
"::",
"fixDirection",
"(",
"$",
"css",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'transformDirInUrl'",
"]",
")",
"{",
"$",
"css",
"=",
"self",
"::",
"fixLtrRtlInURL",
"(",
"$",
"css",
")",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'transformEdgeInUrl'",
"]",
")",
"{",
"$",
"css",
"=",
"self",
"::",
"fixLeftRightInURL",
"(",
"$",
"css",
")",
";",
"}",
"$",
"css",
"=",
"self",
"::",
"fixLeftAndRight",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"self",
"::",
"fixCursorProperties",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"self",
"::",
"fixFourPartNotation",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"self",
"::",
"fixBorderRadius",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"self",
"::",
"fixBackgroundPosition",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"self",
"::",
"fixShadows",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"self",
"::",
"fixTranslate",
"(",
"$",
"css",
")",
";",
"// Detokenize stuff we tokenized before",
"$",
"css",
"=",
"$",
"comments",
"->",
"detokenize",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"$",
"noFlipClass",
"->",
"detokenize",
"(",
"$",
"css",
")",
";",
"$",
"css",
"=",
"$",
"noFlipSingle",
"->",
"detokenize",
"(",
"$",
"css",
")",
";",
"return",
"$",
"css",
";",
"}"
] |
Transform an LTR stylesheet to RTL
@param string $css Stylesheet to transform
@param array|bool $options Options array or value of transformDirInUrl option (back-compat)
@param bool $options['transformDirInUrl'] Transform directions in URLs (ltr/rtl). Default: false.
@param bool $options['transformEdgeInUrl'] Transform edges in URLs (left/right). Default: false.
@param bool $transformEdgeInUrl [optional] For back-compat
@return string Transformed stylesheet
|
[
"Transform",
"an",
"LTR",
"stylesheet",
"to",
"RTL"
] |
44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6
|
https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L146-L202
|
27,542
|
cssjanus/php-cssjanus
|
src/CSSJanus.php
|
CSSJanus.fixLtrRtlInURL
|
private static function fixLtrRtlInURL($css) {
$css = preg_replace(self::$patterns['ltr_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['rtl_in_url'], 'ltr', $css);
$css = str_replace(self::$patterns['tmpToken'], 'rtl', $css);
return $css;
}
|
php
|
private static function fixLtrRtlInURL($css) {
$css = preg_replace(self::$patterns['ltr_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['rtl_in_url'], 'ltr', $css);
$css = str_replace(self::$patterns['tmpToken'], 'rtl', $css);
return $css;
}
|
[
"private",
"static",
"function",
"fixLtrRtlInURL",
"(",
"$",
"css",
")",
"{",
"$",
"css",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'ltr_in_url'",
"]",
",",
"self",
"::",
"$",
"patterns",
"[",
"'tmpToken'",
"]",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'rtl_in_url'",
"]",
",",
"'ltr'",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'tmpToken'",
"]",
",",
"'rtl'",
",",
"$",
"css",
")",
";",
"return",
"$",
"css",
";",
"}"
] |
Replace 'ltr' with 'rtl' and vice versa in background URLs
@param $css string
@return string
|
[
"Replace",
"ltr",
"with",
"rtl",
"and",
"vice",
"versa",
"in",
"background",
"URLs"
] |
44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6
|
https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L233-L239
|
27,543
|
cssjanus/php-cssjanus
|
src/CSSJanus.php
|
CSSJanus.fixLeftRightInURL
|
private static function fixLeftRightInURL($css) {
$css = preg_replace(self::$patterns['left_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['right_in_url'], 'left', $css);
$css = str_replace(self::$patterns['tmpToken'], 'right', $css);
return $css;
}
|
php
|
private static function fixLeftRightInURL($css) {
$css = preg_replace(self::$patterns['left_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['right_in_url'], 'left', $css);
$css = str_replace(self::$patterns['tmpToken'], 'right', $css);
return $css;
}
|
[
"private",
"static",
"function",
"fixLeftRightInURL",
"(",
"$",
"css",
")",
"{",
"$",
"css",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'left_in_url'",
"]",
",",
"self",
"::",
"$",
"patterns",
"[",
"'tmpToken'",
"]",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'right_in_url'",
"]",
",",
"'left'",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'tmpToken'",
"]",
",",
"'right'",
",",
"$",
"css",
")",
";",
"return",
"$",
"css",
";",
"}"
] |
Replace 'left' with 'right' and vice versa in background URLs
@param $css string
@return string
|
[
"Replace",
"left",
"with",
"right",
"and",
"vice",
"versa",
"in",
"background",
"URLs"
] |
44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6
|
https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L246-L252
|
27,544
|
cssjanus/php-cssjanus
|
src/CSSJanus.php
|
CSSJanus.fixShadows
|
private static function fixShadows($css) {
$css = preg_replace_callback(self::$patterns['box_shadow'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow1'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow2'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow3'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
return $css;
}
|
php
|
private static function fixShadows($css) {
$css = preg_replace_callback(self::$patterns['box_shadow'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow1'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow2'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow3'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
return $css;
}
|
[
"private",
"static",
"function",
"fixShadows",
"(",
"$",
"css",
")",
"{",
"$",
"css",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'box_shadow'",
"]",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
".",
"self",
"::",
"flipSign",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"}",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'text_shadow1'",
"]",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
".",
"$",
"matches",
"[",
"2",
"]",
".",
"$",
"matches",
"[",
"3",
"]",
".",
"self",
"::",
"flipSign",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
";",
"}",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'text_shadow2'",
"]",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
".",
"$",
"matches",
"[",
"2",
"]",
".",
"$",
"matches",
"[",
"3",
"]",
".",
"self",
"::",
"flipSign",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
";",
"}",
",",
"$",
"css",
")",
";",
"$",
"css",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'text_shadow3'",
"]",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
".",
"self",
"::",
"flipSign",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"}",
",",
"$",
"css",
")",
";",
"return",
"$",
"css",
";",
"}"
] |
Negates horizontal offset in box-shadow and text-shadow rules.
@param $css string
@return string
|
[
"Negates",
"horizontal",
"offset",
"in",
"box",
"-",
"shadow",
"and",
"text",
"-",
"shadow",
"rules",
"."
] |
44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6
|
https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L389-L407
|
27,545
|
cssjanus/php-cssjanus
|
src/CSSJanus.php
|
CSSJanus.fixBackgroundPosition
|
private static function fixBackgroundPosition($css) {
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
// preg_replace_callback() sometimes returns null
$css = $replaced;
}
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage_x'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
$css = $replaced;
}
return $css;
}
|
php
|
private static function fixBackgroundPosition($css) {
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
// preg_replace_callback() sometimes returns null
$css = $replaced;
}
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage_x'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
$css = $replaced;
}
return $css;
}
|
[
"private",
"static",
"function",
"fixBackgroundPosition",
"(",
"$",
"css",
")",
"{",
"$",
"replaced",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'bg_horizontal_percentage'",
"]",
",",
"array",
"(",
"'self'",
",",
"'calculateNewBackgroundPosition'",
")",
",",
"$",
"css",
")",
";",
"if",
"(",
"$",
"replaced",
"!==",
"null",
")",
"{",
"// preg_replace_callback() sometimes returns null",
"$",
"css",
"=",
"$",
"replaced",
";",
"}",
"$",
"replaced",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'bg_horizontal_percentage_x'",
"]",
",",
"array",
"(",
"'self'",
",",
"'calculateNewBackgroundPosition'",
")",
",",
"$",
"css",
")",
";",
"if",
"(",
"$",
"replaced",
"!==",
"null",
")",
"{",
"$",
"css",
"=",
"$",
"replaced",
";",
"}",
"return",
"$",
"css",
";",
"}"
] |
Flip horizontal background percentages.
@param $css string
@return string
|
[
"Flip",
"horizontal",
"background",
"percentages",
"."
] |
44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6
|
https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L432-L452
|
27,546
|
nglasl/silverstripe-mediawesome
|
src/objects/MediaType.php
|
MediaType.validate
|
public function validate() {
$result = parent::validate();
// Confirm that the current type has been given a title and doesn't already exist.
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
else if($result->isValid() && MediaType::get_one(MediaType::class, array(
'ID != ?' => $this->ID,
'Title = ?' => $this->Title
))) {
$result->addError('Type already exists!');
}
// Allow extension customisation.
$this->extend('validateMediaType', $result);
return $result;
}
|
php
|
public function validate() {
$result = parent::validate();
// Confirm that the current type has been given a title and doesn't already exist.
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
else if($result->isValid() && MediaType::get_one(MediaType::class, array(
'ID != ?' => $this->ID,
'Title = ?' => $this->Title
))) {
$result->addError('Type already exists!');
}
// Allow extension customisation.
$this->extend('validateMediaType', $result);
return $result;
}
|
[
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"validate",
"(",
")",
";",
"// Confirm that the current type has been given a title and doesn't already exist.",
"if",
"(",
"$",
"result",
"->",
"isValid",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"Title",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"'\"Title\" required!'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"result",
"->",
"isValid",
"(",
")",
"&&",
"MediaType",
"::",
"get_one",
"(",
"MediaType",
"::",
"class",
",",
"array",
"(",
"'ID != ?'",
"=>",
"$",
"this",
"->",
"ID",
",",
"'Title = ?'",
"=>",
"$",
"this",
"->",
"Title",
")",
")",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"'Type already exists!'",
")",
";",
"}",
"// Allow extension customisation.",
"$",
"this",
"->",
"extend",
"(",
"'validateMediaType'",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Confirm that the current type is valid.
|
[
"Confirm",
"that",
"the",
"current",
"type",
"is",
"valid",
"."
] |
0537ad9934f69a680cd20115269efed13e082abf
|
https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/objects/MediaType.php#L105-L125
|
27,547
|
dreamfactorysoftware/df-sqldb
|
src/Resources/StoredFunction.php
|
StoredFunction.describeFunctions
|
protected function describeFunctions($names, $refresh = false)
{
$names = static::validateAsArray(
$names,
',',
true,
'The request contains no valid function names or properties.'
);
$out = [];
foreach ($names as $name) {
$out[] = $this->describeFunction($name, $refresh);
}
return $out;
}
|
php
|
protected function describeFunctions($names, $refresh = false)
{
$names = static::validateAsArray(
$names,
',',
true,
'The request contains no valid function names or properties.'
);
$out = [];
foreach ($names as $name) {
$out[] = $this->describeFunction($name, $refresh);
}
return $out;
}
|
[
"protected",
"function",
"describeFunctions",
"(",
"$",
"names",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"names",
"=",
"static",
"::",
"validateAsArray",
"(",
"$",
"names",
",",
"','",
",",
"true",
",",
"'The request contains no valid function names or properties.'",
")",
";",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"this",
"->",
"describeFunction",
"(",
"$",
"name",
",",
"$",
"refresh",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Get multiple functions and their properties
@param string | array $names Function names comma-delimited string or array
@param bool $refresh Force a refresh of the schema from the database
@return array
@throws \Exception
|
[
"Get",
"multiple",
"functions",
"and",
"their",
"properties"
] |
f5b6c45fae068db5043419405299bfbc928fa90b
|
https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Resources/StoredFunction.php#L270-L285
|
27,548
|
dreamfactorysoftware/df-sqldb
|
src/Resources/StoredFunction.php
|
StoredFunction.describeFunction
|
protected function describeFunction($name, $refresh = false)
{
$name = (is_array($name) ? array_get($name, 'name') : $name);
if (empty($name)) {
throw new BadRequestException('Function name can not be empty.');
}
$this->checkPermission(Verbs::GET, $name);
try {
$function = $this->getFunction($name, $refresh);
$result = $function->toArray();
$result['access'] = $this->getPermissions($name);
return $result;
} catch (RestException $ex) {
throw $ex;
} catch (\Exception $ex) {
throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
}
}
|
php
|
protected function describeFunction($name, $refresh = false)
{
$name = (is_array($name) ? array_get($name, 'name') : $name);
if (empty($name)) {
throw new BadRequestException('Function name can not be empty.');
}
$this->checkPermission(Verbs::GET, $name);
try {
$function = $this->getFunction($name, $refresh);
$result = $function->toArray();
$result['access'] = $this->getPermissions($name);
return $result;
} catch (RestException $ex) {
throw $ex;
} catch (\Exception $ex) {
throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
}
}
|
[
"protected",
"function",
"describeFunction",
"(",
"$",
"name",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"(",
"is_array",
"(",
"$",
"name",
")",
"?",
"array_get",
"(",
"$",
"name",
",",
"'name'",
")",
":",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"'Function name can not be empty.'",
")",
";",
"}",
"$",
"this",
"->",
"checkPermission",
"(",
"Verbs",
"::",
"GET",
",",
"$",
"name",
")",
";",
"try",
"{",
"$",
"function",
"=",
"$",
"this",
"->",
"getFunction",
"(",
"$",
"name",
",",
"$",
"refresh",
")",
";",
"$",
"result",
"=",
"$",
"function",
"->",
"toArray",
"(",
")",
";",
"$",
"result",
"[",
"'access'",
"]",
"=",
"$",
"this",
"->",
"getPermissions",
"(",
"$",
"name",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"RestException",
"$",
"ex",
")",
"{",
"throw",
"$",
"ex",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"InternalServerErrorException",
"(",
"\"Failed to query database schema.\\n{$ex->getMessage()}\"",
")",
";",
"}",
"}"
] |
Get any properties related to the function
@param string | array $name Function name or defining properties
@param bool $refresh Force a refresh of the schema from the database
@return array
@throws \Exception
|
[
"Get",
"any",
"properties",
"related",
"to",
"the",
"function"
] |
f5b6c45fae068db5043419405299bfbc928fa90b
|
https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Resources/StoredFunction.php#L296-L316
|
27,549
|
rtconner/laravel-likeable
|
src/LikeCounter.php
|
LikeCounter.rebuild
|
public static function rebuild($modelClass)
{
if(empty($modelClass)) {
throw new \Exception('$modelClass cannot be empty/null. Maybe set the $morphClass variable on your model.');
}
$builder = Like::query()
->select(\DB::raw('count(*) as count, likeable_type, likeable_id'))
->where('likeable_type', $modelClass)
->groupBy('likeable_id');
$results = $builder->get();
$inserts = $results->toArray();
\DB::table((new static)->table)->insert($inserts);
}
|
php
|
public static function rebuild($modelClass)
{
if(empty($modelClass)) {
throw new \Exception('$modelClass cannot be empty/null. Maybe set the $morphClass variable on your model.');
}
$builder = Like::query()
->select(\DB::raw('count(*) as count, likeable_type, likeable_id'))
->where('likeable_type', $modelClass)
->groupBy('likeable_id');
$results = $builder->get();
$inserts = $results->toArray();
\DB::table((new static)->table)->insert($inserts);
}
|
[
"public",
"static",
"function",
"rebuild",
"(",
"$",
"modelClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"modelClass",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'$modelClass cannot be empty/null. Maybe set the $morphClass variable on your model.'",
")",
";",
"}",
"$",
"builder",
"=",
"Like",
"::",
"query",
"(",
")",
"->",
"select",
"(",
"\\",
"DB",
"::",
"raw",
"(",
"'count(*) as count, likeable_type, likeable_id'",
")",
")",
"->",
"where",
"(",
"'likeable_type'",
",",
"$",
"modelClass",
")",
"->",
"groupBy",
"(",
"'likeable_id'",
")",
";",
"$",
"results",
"=",
"$",
"builder",
"->",
"get",
"(",
")",
";",
"$",
"inserts",
"=",
"$",
"results",
"->",
"toArray",
"(",
")",
";",
"\\",
"DB",
"::",
"table",
"(",
"(",
"new",
"static",
")",
"->",
"table",
")",
"->",
"insert",
"(",
"$",
"inserts",
")",
";",
"}"
] |
Delete all counts of the given model, and recount them and insert new counts
@param string $model (should match Model::$morphClass)
|
[
"Delete",
"all",
"counts",
"of",
"the",
"given",
"model",
"and",
"recount",
"them",
"and",
"insert",
"new",
"counts"
] |
d3b61686703a23a4aa61f593e55bc10b87f60621
|
https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/LikeCounter.php#L23-L39
|
27,550
|
rtconner/laravel-likeable
|
src/Likeable.php
|
Likeable.like
|
public function like($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
if($userId) {
$like = $this->likes()
->where('user_id', '=', $userId)
->first();
if($like) return;
$like = new Like();
$like->user_id = $userId;
$this->likes()->save($like);
}
$this->incrementLikeCount();
}
|
php
|
public function like($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
if($userId) {
$like = $this->likes()
->where('user_id', '=', $userId)
->first();
if($like) return;
$like = new Like();
$like->user_id = $userId;
$this->likes()->save($like);
}
$this->incrementLikeCount();
}
|
[
"public",
"function",
"like",
"(",
"$",
"userId",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"userId",
")",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"loggedInUserId",
"(",
")",
";",
"}",
"if",
"(",
"$",
"userId",
")",
"{",
"$",
"like",
"=",
"$",
"this",
"->",
"likes",
"(",
")",
"->",
"where",
"(",
"'user_id'",
",",
"'='",
",",
"$",
"userId",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"like",
")",
"return",
";",
"$",
"like",
"=",
"new",
"Like",
"(",
")",
";",
"$",
"like",
"->",
"user_id",
"=",
"$",
"userId",
";",
"$",
"this",
"->",
"likes",
"(",
")",
"->",
"save",
"(",
"$",
"like",
")",
";",
"}",
"$",
"this",
"->",
"incrementLikeCount",
"(",
")",
";",
"}"
] |
Add a like for this record by the given user.
@param $userId mixed - If null will use currently logged in user.
|
[
"Add",
"a",
"like",
"for",
"this",
"record",
"by",
"the",
"given",
"user",
"."
] |
d3b61686703a23a4aa61f593e55bc10b87f60621
|
https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L69-L88
|
27,551
|
rtconner/laravel-likeable
|
src/Likeable.php
|
Likeable.liked
|
public function liked($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
return (bool) $this->likes()
->where('user_id', '=', $userId)
->count();
}
|
php
|
public function liked($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
return (bool) $this->likes()
->where('user_id', '=', $userId)
->count();
}
|
[
"public",
"function",
"liked",
"(",
"$",
"userId",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"userId",
")",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"loggedInUserId",
"(",
")",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"likes",
"(",
")",
"->",
"where",
"(",
"'user_id'",
",",
"'='",
",",
"$",
"userId",
")",
"->",
"count",
"(",
")",
";",
"}"
] |
Has the currently logged in user already "liked" the current object
@param string $userId
@return boolean
|
[
"Has",
"the",
"currently",
"logged",
"in",
"user",
"already",
"liked",
"the",
"current",
"object"
] |
d3b61686703a23a4aa61f593e55bc10b87f60621
|
https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L119-L128
|
27,552
|
rtconner/laravel-likeable
|
src/Likeable.php
|
Likeable.incrementLikeCount
|
private function incrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count++;
$counter->save();
} else {
$counter = new LikeCounter;
$counter->count = 1;
$this->likeCounter()->save($counter);
}
}
|
php
|
private function incrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count++;
$counter->save();
} else {
$counter = new LikeCounter;
$counter->count = 1;
$this->likeCounter()->save($counter);
}
}
|
[
"private",
"function",
"incrementLikeCount",
"(",
")",
"{",
"$",
"counter",
"=",
"$",
"this",
"->",
"likeCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"counter",
")",
"{",
"$",
"counter",
"->",
"count",
"++",
";",
"$",
"counter",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"$",
"counter",
"=",
"new",
"LikeCounter",
";",
"$",
"counter",
"->",
"count",
"=",
"1",
";",
"$",
"this",
"->",
"likeCounter",
"(",
")",
"->",
"save",
"(",
"$",
"counter",
")",
";",
"}",
"}"
] |
Private. Increment the total like count stored in the counter
|
[
"Private",
".",
"Increment",
"the",
"total",
"like",
"count",
"stored",
"in",
"the",
"counter"
] |
d3b61686703a23a4aa61f593e55bc10b87f60621
|
https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L133-L145
|
27,553
|
rtconner/laravel-likeable
|
src/Likeable.php
|
Likeable.decrementLikeCount
|
private function decrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count--;
if($counter->count) {
$counter->save();
} else {
$counter->delete();
}
}
}
|
php
|
private function decrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count--;
if($counter->count) {
$counter->save();
} else {
$counter->delete();
}
}
}
|
[
"private",
"function",
"decrementLikeCount",
"(",
")",
"{",
"$",
"counter",
"=",
"$",
"this",
"->",
"likeCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"counter",
")",
"{",
"$",
"counter",
"->",
"count",
"--",
";",
"if",
"(",
"$",
"counter",
"->",
"count",
")",
"{",
"$",
"counter",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"$",
"counter",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"}"
] |
Private. Decrement the total like count stored in the counter
|
[
"Private",
".",
"Decrement",
"the",
"total",
"like",
"count",
"stored",
"in",
"the",
"counter"
] |
d3b61686703a23a4aa61f593e55bc10b87f60621
|
https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L150-L162
|
27,554
|
rtconner/laravel-likeable
|
src/Likeable.php
|
Likeable.removeLikes
|
public function removeLikes()
{
Like::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
LikeCounter::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
}
|
php
|
public function removeLikes()
{
Like::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
LikeCounter::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
}
|
[
"public",
"function",
"removeLikes",
"(",
")",
"{",
"Like",
"::",
"where",
"(",
"'likeable_type'",
",",
"$",
"this",
"->",
"morphClass",
")",
"->",
"where",
"(",
"'likeable_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"delete",
"(",
")",
";",
"LikeCounter",
"::",
"where",
"(",
"'likeable_type'",
",",
"$",
"this",
"->",
"morphClass",
")",
"->",
"where",
"(",
"'likeable_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"delete",
"(",
")",
";",
"}"
] |
Delete likes related to the current record
|
[
"Delete",
"likes",
"related",
"to",
"the",
"current",
"record"
] |
d3b61686703a23a4aa61f593e55bc10b87f60621
|
https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L197-L202
|
27,555
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Managerarea/ManagersController.php
|
ManagersController.import
|
public function import(Manager $manager, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $manager,
'tabs' => 'managerarea.attributes.tabs',
'url' => route('managerarea.attributes.stash'),
'id' => "managerarea-attributes-{$manager->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
}
|
php
|
public function import(Manager $manager, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $manager,
'tabs' => 'managerarea.attributes.tabs',
'url' => route('managerarea.attributes.stash'),
'id' => "managerarea-attributes-{$manager->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
}
|
[
"public",
"function",
"import",
"(",
"Manager",
"$",
"manager",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"manager",
",",
"'tabs'",
"=>",
"'managerarea.attributes.tabs'",
",",
"'url'",
"=>",
"route",
"(",
"'managerarea.attributes.stash'",
")",
",",
"'id'",
"=>",
"\"managerarea-attributes-{$manager->getRouteKey()}-import-table\"",
",",
"]",
")",
"->",
"render",
"(",
"'cortex/foundation::managerarea.pages.datatable-dropzone'",
")",
";",
"}"
] |
Import managers.
@param \Cortex\Auth\Models\Manager $manager
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View
|
[
"Import",
"managers",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/ManagersController.php#L119-L127
|
27,556
|
laravie/codex
|
src/Support/Versioning.php
|
Versioning.proxyRequestViaVersion
|
protected function proxyRequestViaVersion(string $swapVersion, callable $callback): Response
{
$version = $this->version;
try {
$this->version = $swapVersion;
return \call_user_func($callback);
} finally {
$this->version = $version;
}
}
|
php
|
protected function proxyRequestViaVersion(string $swapVersion, callable $callback): Response
{
$version = $this->version;
try {
$this->version = $swapVersion;
return \call_user_func($callback);
} finally {
$this->version = $version;
}
}
|
[
"protected",
"function",
"proxyRequestViaVersion",
"(",
"string",
"$",
"swapVersion",
",",
"callable",
"$",
"callback",
")",
":",
"Response",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"version",
";",
"try",
"{",
"$",
"this",
"->",
"version",
"=",
"$",
"swapVersion",
";",
"return",
"\\",
"call_user_func",
"(",
"$",
"callback",
")",
";",
"}",
"finally",
"{",
"$",
"this",
"->",
"version",
"=",
"$",
"version",
";",
"}",
"}"
] |
Proxy route to response via other version.
@param string $swapVersion
@param callable $callback
@return \Laravie\Codex\Contracts\Response
|
[
"Proxy",
"route",
"to",
"response",
"via",
"other",
"version",
"."
] |
4d813bcbe20e7cf0b6c0cb98d3b077a070285709
|
https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Support/Versioning.php#L27-L38
|
27,557
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Frontarea/PhoneVerificationController.php
|
PhoneVerificationController.send
|
public function send(PhoneVerificationSendRequest $request)
{
$user = $request->user($this->getGuard())
?? $request->attemptUser($this->getGuard())
?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->input('phone'))->first();
$user->sendPhoneVerificationNotification($request->get('method'), true);
return intend([
'url' => route('frontarea.verification.phone.verify', ['phone' => $user->phone]),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.sent')],
]);
}
|
php
|
public function send(PhoneVerificationSendRequest $request)
{
$user = $request->user($this->getGuard())
?? $request->attemptUser($this->getGuard())
?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->input('phone'))->first();
$user->sendPhoneVerificationNotification($request->get('method'), true);
return intend([
'url' => route('frontarea.verification.phone.verify', ['phone' => $user->phone]),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.sent')],
]);
}
|
[
"public",
"function",
"send",
"(",
"PhoneVerificationSendRequest",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"request",
"->",
"user",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"??",
"$",
"request",
"->",
"attemptUser",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"??",
"app",
"(",
"'cortex.auth.member'",
")",
"->",
"whereNotNull",
"(",
"'phone'",
")",
"->",
"where",
"(",
"'phone'",
",",
"$",
"request",
"->",
"input",
"(",
"'phone'",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"user",
"->",
"sendPhoneVerificationNotification",
"(",
"$",
"request",
"->",
"get",
"(",
"'method'",
")",
",",
"true",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'frontarea.verification.phone.verify'",
",",
"[",
"'phone'",
"=>",
"$",
"user",
"->",
"phone",
"]",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"'cortex/auth::messages.verification.phone.sent'",
")",
"]",
",",
"]",
")",
";",
"}"
] |
Process the phone verification request form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Frontarea\PhoneVerificationSendRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Process",
"the",
"phone",
"verification",
"request",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Frontarea/PhoneVerificationController.php#L37-L49
|
27,558
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Frontarea/PhoneVerificationController.php
|
PhoneVerificationController.process
|
public function process(PhoneVerificationProcessRequest $request)
{
// Guest trying to authenticate through TwoFactor
if (($attemptUser = $request->attemptUser($this->getGuard())) && $this->attemptTwoFactor($attemptUser, $request->get('token'))) {
auth()->guard($this->getGuard())->login($attemptUser, $request->session()->get('cortex.auth.twofactor.remember'));
$request->session()->forget('cortex.auth.twofactor'); // @TODO: Do we need to forget session, or it's already gone after login?
return intend([
'intended' => route('frontarea.home'),
'with' => ['success' => trans('cortex/auth::messages.auth.login')],
]);
}
// Logged in user OR A GUEST trying to verify phone
if (($user = $request->user($this->getGuard()) ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->get('phone'))->first()) && $this->isValidTwoFactorPhone($user, $request->get('token'))) {
// Profile update
$user->fill([
'phone_verified_at' => now(),
])->forceSave();
return intend([
'url' => route('frontarea.account.settings'),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.verified')],
]);
}
return intend([
'back' => true,
'withErrors' => ['token' => trans('cortex/auth::messages.verification.twofactor.invalid_token')],
]);
}
|
php
|
public function process(PhoneVerificationProcessRequest $request)
{
// Guest trying to authenticate through TwoFactor
if (($attemptUser = $request->attemptUser($this->getGuard())) && $this->attemptTwoFactor($attemptUser, $request->get('token'))) {
auth()->guard($this->getGuard())->login($attemptUser, $request->session()->get('cortex.auth.twofactor.remember'));
$request->session()->forget('cortex.auth.twofactor'); // @TODO: Do we need to forget session, or it's already gone after login?
return intend([
'intended' => route('frontarea.home'),
'with' => ['success' => trans('cortex/auth::messages.auth.login')],
]);
}
// Logged in user OR A GUEST trying to verify phone
if (($user = $request->user($this->getGuard()) ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->get('phone'))->first()) && $this->isValidTwoFactorPhone($user, $request->get('token'))) {
// Profile update
$user->fill([
'phone_verified_at' => now(),
])->forceSave();
return intend([
'url' => route('frontarea.account.settings'),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.verified')],
]);
}
return intend([
'back' => true,
'withErrors' => ['token' => trans('cortex/auth::messages.verification.twofactor.invalid_token')],
]);
}
|
[
"public",
"function",
"process",
"(",
"PhoneVerificationProcessRequest",
"$",
"request",
")",
"{",
"// Guest trying to authenticate through TwoFactor",
"if",
"(",
"(",
"$",
"attemptUser",
"=",
"$",
"request",
"->",
"attemptUser",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
")",
"&&",
"$",
"this",
"->",
"attemptTwoFactor",
"(",
"$",
"attemptUser",
",",
"$",
"request",
"->",
"get",
"(",
"'token'",
")",
")",
")",
"{",
"auth",
"(",
")",
"->",
"guard",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"->",
"login",
"(",
"$",
"attemptUser",
",",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"get",
"(",
"'cortex.auth.twofactor.remember'",
")",
")",
";",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"forget",
"(",
"'cortex.auth.twofactor'",
")",
";",
"// @TODO: Do we need to forget session, or it's already gone after login?",
"return",
"intend",
"(",
"[",
"'intended'",
"=>",
"route",
"(",
"'frontarea.home'",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"'cortex/auth::messages.auth.login'",
")",
"]",
",",
"]",
")",
";",
"}",
"// Logged in user OR A GUEST trying to verify phone",
"if",
"(",
"(",
"$",
"user",
"=",
"$",
"request",
"->",
"user",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"??",
"app",
"(",
"'cortex.auth.member'",
")",
"->",
"whereNotNull",
"(",
"'phone'",
")",
"->",
"where",
"(",
"'phone'",
",",
"$",
"request",
"->",
"get",
"(",
"'phone'",
")",
")",
"->",
"first",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"isValidTwoFactorPhone",
"(",
"$",
"user",
",",
"$",
"request",
"->",
"get",
"(",
"'token'",
")",
")",
")",
"{",
"// Profile update",
"$",
"user",
"->",
"fill",
"(",
"[",
"'phone_verified_at'",
"=>",
"now",
"(",
")",
",",
"]",
")",
"->",
"forceSave",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'frontarea.account.settings'",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"'cortex/auth::messages.verification.phone.verified'",
")",
"]",
",",
"]",
")",
";",
"}",
"return",
"intend",
"(",
"[",
"'back'",
"=>",
"true",
",",
"'withErrors'",
"=>",
"[",
"'token'",
"=>",
"trans",
"(",
"'cortex/auth::messages.verification.twofactor.invalid_token'",
")",
"]",
",",
"]",
")",
";",
"}"
] |
Process the phone verification form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Frontarea\PhoneVerificationProcessRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Process",
"the",
"phone",
"verification",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Frontarea/PhoneVerificationController.php#L70-L100
|
27,559
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Tenantarea/AccountMediaController.php
|
AccountMediaController.destroy
|
public function destroy(Member $member, Media $media)
{
$member->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('frontarea.account.settings'),
'with' => [
'warning' => trans('cortex/foundation::messages.resource_deleted', [
'resource' => trans('cortex/foundation::common.media'),
'identifier' => $media->getRouteKey(),
]),
],
]);
}
|
php
|
public function destroy(Member $member, Media $media)
{
$member->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('frontarea.account.settings'),
'with' => [
'warning' => trans('cortex/foundation::messages.resource_deleted', [
'resource' => trans('cortex/foundation::common.media'),
'identifier' => $media->getRouteKey(),
]),
],
]);
}
|
[
"public",
"function",
"destroy",
"(",
"Member",
"$",
"member",
",",
"Media",
"$",
"media",
")",
"{",
"$",
"member",
"->",
"media",
"(",
")",
"->",
"where",
"(",
"$",
"media",
"->",
"getKeyName",
"(",
")",
",",
"$",
"media",
"->",
"getKey",
"(",
")",
")",
"->",
"first",
"(",
")",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'frontarea.account.settings'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/foundation::common.media'",
")",
",",
"'identifier'",
"=>",
"$",
"media",
"->",
"getRouteKey",
"(",
")",
",",
"]",
")",
",",
"]",
",",
"]",
")",
";",
"}"
] |
Destroy given member media.
@param \Cortex\Auth\Models\Member $member
@param \Spatie\MediaLibrary\Models\Media $media
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Destroy",
"given",
"member",
"media",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/AccountMediaController.php#L21-L34
|
27,560
|
laravie/codex
|
src/Client.php
|
Client.useVersion
|
public function useVersion(string $version)
{
if (! \array_key_exists($version, $this->supportedVersions)) {
throw new InvalidArgumentException("API version [{$version}] is not supported.");
}
$this->defaultVersion = $version;
return $this;
}
|
php
|
public function useVersion(string $version)
{
if (! \array_key_exists($version, $this->supportedVersions)) {
throw new InvalidArgumentException("API version [{$version}] is not supported.");
}
$this->defaultVersion = $version;
return $this;
}
|
[
"public",
"function",
"useVersion",
"(",
"string",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"\\",
"array_key_exists",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"supportedVersions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"API version [{$version}] is not supported.\"",
")",
";",
"}",
"$",
"this",
"->",
"defaultVersion",
"=",
"$",
"version",
";",
"return",
"$",
"this",
";",
"}"
] |
Use different API version.
@param string $version
@throws \InvalidArgumentException
@return $this
|
[
"Use",
"different",
"API",
"version",
"."
] |
4d813bcbe20e7cf0b6c0cb98d3b077a070285709
|
https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Client.php#L65-L74
|
27,561
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Tenantarea/EmailVerificationController.php
|
EmailVerificationController.send
|
public function send(EmailVerificationSendRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->sendVerificationLink($request->only(['email']));
switch ($result) {
case EmailVerificationBrokerContract::LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
}
|
php
|
public function send(EmailVerificationSendRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->sendVerificationLink($request->only(['email']));
switch ($result) {
case EmailVerificationBrokerContract::LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
}
|
[
"public",
"function",
"send",
"(",
"EmailVerificationSendRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'rinvex.auth.emailverification'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getEmailVerificationBroker",
"(",
")",
")",
"->",
"sendVerificationLink",
"(",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
"]",
")",
")",
";",
"switch",
"(",
"$",
"result",
")",
"{",
"case",
"EmailVerificationBrokerContract",
"::",
"LINK_SENT",
":",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'tenantarea.home'",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"'cortex/auth::'",
".",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"case",
"EmailVerificationBrokerContract",
"::",
"INVALID_USER",
":",
"default",
":",
"return",
"intend",
"(",
"[",
"'back'",
"=>",
"true",
",",
"'withInput'",
"=>",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
"]",
")",
",",
"'withErrors'",
"=>",
"[",
"'email'",
"=>",
"trans",
"(",
"'cortex/auth::'",
".",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"}",
"}"
] |
Process the email verification request form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\EmailVerificationSendRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Process",
"the",
"email",
"verification",
"request",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/EmailVerificationController.php#L34-L55
|
27,562
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Tenantarea/EmailVerificationController.php
|
EmailVerificationController.verify
|
public function verify(EmailVerificationProcessRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->verify($request->only(['email', 'expiration', 'token']), function ($user) {
$user->fill([
'email_verified_at' => now(),
])->forceSave();
});
switch ($result) {
case EmailVerificationBrokerContract::EMAIL_VERIFIED:
return intend([
'url' => route('tenantarea.account.settings'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
case EmailVerificationBrokerContract::INVALID_TOKEN:
case EmailVerificationBrokerContract::EXPIRED_TOKEN:
default:
return intend([
'url' => route('tenantarea.verification.email.request'),
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
}
|
php
|
public function verify(EmailVerificationProcessRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->verify($request->only(['email', 'expiration', 'token']), function ($user) {
$user->fill([
'email_verified_at' => now(),
])->forceSave();
});
switch ($result) {
case EmailVerificationBrokerContract::EMAIL_VERIFIED:
return intend([
'url' => route('tenantarea.account.settings'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
case EmailVerificationBrokerContract::INVALID_TOKEN:
case EmailVerificationBrokerContract::EXPIRED_TOKEN:
default:
return intend([
'url' => route('tenantarea.verification.email.request'),
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
}
|
[
"public",
"function",
"verify",
"(",
"EmailVerificationProcessRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'rinvex.auth.emailverification'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getEmailVerificationBroker",
"(",
")",
")",
"->",
"verify",
"(",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
",",
"'expiration'",
",",
"'token'",
"]",
")",
",",
"function",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"->",
"fill",
"(",
"[",
"'email_verified_at'",
"=>",
"now",
"(",
")",
",",
"]",
")",
"->",
"forceSave",
"(",
")",
";",
"}",
")",
";",
"switch",
"(",
"$",
"result",
")",
"{",
"case",
"EmailVerificationBrokerContract",
"::",
"EMAIL_VERIFIED",
":",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'tenantarea.account.settings'",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"'cortex/auth::'",
".",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"case",
"EmailVerificationBrokerContract",
"::",
"INVALID_USER",
":",
"case",
"EmailVerificationBrokerContract",
"::",
"INVALID_TOKEN",
":",
"case",
"EmailVerificationBrokerContract",
"::",
"EXPIRED_TOKEN",
":",
"default",
":",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'tenantarea.verification.email.request'",
")",
",",
"'withInput'",
"=>",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
"]",
")",
",",
"'withErrors'",
"=>",
"[",
"'email'",
"=>",
"trans",
"(",
"'cortex/auth::'",
".",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"}",
"}"
] |
Process the email verification.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\EmailVerificationProcessRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Process",
"the",
"email",
"verification",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/EmailVerificationController.php#L64-L91
|
27,563
|
contributte/cache
|
src/Storages/MemoryAdapterStorage.php
|
MemoryAdapterStorage.read
|
public function read($key)
{
// Get data from memory storage
$data = $this->memoryStorage->read($key);
if ($data !== null) {
return $data;
}
// Get data from cached storage and write them to memory storage
$data = $this->cachedStorage->read($key);
if ($data !== null) {
$this->memoryStorage->write($key, $data, []);
}
return $data;
}
|
php
|
public function read($key)
{
// Get data from memory storage
$data = $this->memoryStorage->read($key);
if ($data !== null) {
return $data;
}
// Get data from cached storage and write them to memory storage
$data = $this->cachedStorage->read($key);
if ($data !== null) {
$this->memoryStorage->write($key, $data, []);
}
return $data;
}
|
[
"public",
"function",
"read",
"(",
"$",
"key",
")",
"{",
"// Get data from memory storage",
"$",
"data",
"=",
"$",
"this",
"->",
"memoryStorage",
"->",
"read",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"return",
"$",
"data",
";",
"}",
"// Get data from cached storage and write them to memory storage",
"$",
"data",
"=",
"$",
"this",
"->",
"cachedStorage",
"->",
"read",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"memoryStorage",
"->",
"write",
"(",
"$",
"key",
",",
"$",
"data",
",",
"[",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Read from cache.
@param string $key
@return mixed|null
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
|
[
"Read",
"from",
"cache",
"."
] |
ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e
|
https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L30-L45
|
27,564
|
contributte/cache
|
src/Storages/MemoryAdapterStorage.php
|
MemoryAdapterStorage.write
|
public function write($key, $data, array $dependencies): void
{
$this->cachedStorage->write($key, $data, $dependencies);
$this->memoryStorage->write($key, $data, $dependencies);
}
|
php
|
public function write($key, $data, array $dependencies): void
{
$this->cachedStorage->write($key, $data, $dependencies);
$this->memoryStorage->write($key, $data, $dependencies);
}
|
[
"public",
"function",
"write",
"(",
"$",
"key",
",",
"$",
"data",
",",
"array",
"$",
"dependencies",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cachedStorage",
"->",
"write",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"dependencies",
")",
";",
"$",
"this",
"->",
"memoryStorage",
"->",
"write",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"dependencies",
")",
";",
"}"
] |
Writes item into the cache.
@param string $key
@param mixed $data
@param mixed[] $dependencies
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
|
[
"Writes",
"item",
"into",
"the",
"cache",
"."
] |
ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e
|
https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L67-L71
|
27,565
|
contributte/cache
|
src/Storages/MemoryAdapterStorage.php
|
MemoryAdapterStorage.remove
|
public function remove($key): void
{
$this->cachedStorage->remove($key);
$this->memoryStorage->remove($key);
}
|
php
|
public function remove($key): void
{
$this->cachedStorage->remove($key);
$this->memoryStorage->remove($key);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cachedStorage",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"memoryStorage",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}"
] |
Removes item from the cache.
@param string $key
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
|
[
"Removes",
"item",
"from",
"the",
"cache",
"."
] |
ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e
|
https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L79-L83
|
27,566
|
contributte/cache
|
src/Storages/MemoryAdapterStorage.php
|
MemoryAdapterStorage.clean
|
public function clean(array $conditions): void
{
$this->cachedStorage->clean($conditions);
$this->memoryStorage->clean($conditions);
}
|
php
|
public function clean(array $conditions): void
{
$this->cachedStorage->clean($conditions);
$this->memoryStorage->clean($conditions);
}
|
[
"public",
"function",
"clean",
"(",
"array",
"$",
"conditions",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cachedStorage",
"->",
"clean",
"(",
"$",
"conditions",
")",
";",
"$",
"this",
"->",
"memoryStorage",
"->",
"clean",
"(",
"$",
"conditions",
")",
";",
"}"
] |
Removes items from the cache by conditions.
@param mixed[] $conditions
|
[
"Removes",
"items",
"from",
"the",
"cache",
"by",
"conditions",
"."
] |
ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e
|
https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L90-L94
|
27,567
|
swoft-cloud/swoft-rpc-client
|
src/Service/ServiceProxy.php
|
ServiceProxy.getMethodsTemplate
|
private static function getMethodsTemplate(array $reflectionMethods): string
{
$template = "";
foreach ($reflectionMethods as $reflectionMethod) {
$methodName = $reflectionMethod->getName();
// not to overrided method
if ($reflectionMethod->isConstructor() || $reflectionMethod->isStatic() || strpos($methodName, '__') !== false) {
continue;
}
// the template of parameter
$template .= " public function $methodName (";
$template .= self::getParameterTemplate($reflectionMethod);
$template .= ' ) ';
// the template of return type
$reflectionMethodReturn = $reflectionMethod->getReturnType();
if ($reflectionMethodReturn !== null) {
$returnType = $reflectionMethodReturn->__toString();
$returnType = ($returnType == 'self') ? $reflectionMethod->getDeclaringClass()->getName() : $returnType;
$template .= " : $returnType";
}
// overrided method
$template
.= "{
\$params = func_get_args();
return \$this->call('{$methodName}', \$params);
}
";
}
return $template;
}
|
php
|
private static function getMethodsTemplate(array $reflectionMethods): string
{
$template = "";
foreach ($reflectionMethods as $reflectionMethod) {
$methodName = $reflectionMethod->getName();
// not to overrided method
if ($reflectionMethod->isConstructor() || $reflectionMethod->isStatic() || strpos($methodName, '__') !== false) {
continue;
}
// the template of parameter
$template .= " public function $methodName (";
$template .= self::getParameterTemplate($reflectionMethod);
$template .= ' ) ';
// the template of return type
$reflectionMethodReturn = $reflectionMethod->getReturnType();
if ($reflectionMethodReturn !== null) {
$returnType = $reflectionMethodReturn->__toString();
$returnType = ($returnType == 'self') ? $reflectionMethod->getDeclaringClass()->getName() : $returnType;
$template .= " : $returnType";
}
// overrided method
$template
.= "{
\$params = func_get_args();
return \$this->call('{$methodName}', \$params);
}
";
}
return $template;
}
|
[
"private",
"static",
"function",
"getMethodsTemplate",
"(",
"array",
"$",
"reflectionMethods",
")",
":",
"string",
"{",
"$",
"template",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"reflectionMethods",
"as",
"$",
"reflectionMethod",
")",
"{",
"$",
"methodName",
"=",
"$",
"reflectionMethod",
"->",
"getName",
"(",
")",
";",
"// not to overrided method",
"if",
"(",
"$",
"reflectionMethod",
"->",
"isConstructor",
"(",
")",
"||",
"$",
"reflectionMethod",
"->",
"isStatic",
"(",
")",
"||",
"strpos",
"(",
"$",
"methodName",
",",
"'__'",
")",
"!==",
"false",
")",
"{",
"continue",
";",
"}",
"// the template of parameter",
"$",
"template",
".=",
"\" public function $methodName (\"",
";",
"$",
"template",
".=",
"self",
"::",
"getParameterTemplate",
"(",
"$",
"reflectionMethod",
")",
";",
"$",
"template",
".=",
"' ) '",
";",
"// the template of return type",
"$",
"reflectionMethodReturn",
"=",
"$",
"reflectionMethod",
"->",
"getReturnType",
"(",
")",
";",
"if",
"(",
"$",
"reflectionMethodReturn",
"!==",
"null",
")",
"{",
"$",
"returnType",
"=",
"$",
"reflectionMethodReturn",
"->",
"__toString",
"(",
")",
";",
"$",
"returnType",
"=",
"(",
"$",
"returnType",
"==",
"'self'",
")",
"?",
"$",
"reflectionMethod",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
":",
"$",
"returnType",
";",
"$",
"template",
".=",
"\" : $returnType\"",
";",
"}",
"// overrided method",
"$",
"template",
".=",
"\"{\n \\$params = func_get_args();\n return \\$this->call('{$methodName}', \\$params);\n }\n \"",
";",
"}",
"return",
"$",
"template",
";",
"}"
] |
return template of method
@param \ReflectionMethod[] $reflectionMethods
@return string
|
[
"return",
"template",
"of",
"method"
] |
f163834c9db7c1d45643347a49232152e42cd64a
|
https://github.com/swoft-cloud/swoft-rpc-client/blob/f163834c9db7c1d45643347a49232152e42cd64a/src/Service/ServiceProxy.php#L37-L71
|
27,568
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Tenantarea/SocialAuthenticationController.php
|
SocialAuthenticationController.createLocalUser
|
protected function createLocalUser(string $provider, array $attributes)
{
$localUser = app('cortex.auth.member');
$attributes['password'] = str_random();
$attributes['email_verified_at'] = now();
$attributes['is_active'] = ! config('cortex.auth.registration.moderated');
$localUser->fill($attributes)->save();
// Fire the register success event
event(new Registered($localUser));
$localUser->socialites()->create([
'provider' => $provider,
'provider_uid' => $attributes['id'],
]);
return $localUser;
}
|
php
|
protected function createLocalUser(string $provider, array $attributes)
{
$localUser = app('cortex.auth.member');
$attributes['password'] = str_random();
$attributes['email_verified_at'] = now();
$attributes['is_active'] = ! config('cortex.auth.registration.moderated');
$localUser->fill($attributes)->save();
// Fire the register success event
event(new Registered($localUser));
$localUser->socialites()->create([
'provider' => $provider,
'provider_uid' => $attributes['id'],
]);
return $localUser;
}
|
[
"protected",
"function",
"createLocalUser",
"(",
"string",
"$",
"provider",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"localUser",
"=",
"app",
"(",
"'cortex.auth.member'",
")",
";",
"$",
"attributes",
"[",
"'password'",
"]",
"=",
"str_random",
"(",
")",
";",
"$",
"attributes",
"[",
"'email_verified_at'",
"]",
"=",
"now",
"(",
")",
";",
"$",
"attributes",
"[",
"'is_active'",
"]",
"=",
"!",
"config",
"(",
"'cortex.auth.registration.moderated'",
")",
";",
"$",
"localUser",
"->",
"fill",
"(",
"$",
"attributes",
")",
"->",
"save",
"(",
")",
";",
"// Fire the register success event",
"event",
"(",
"new",
"Registered",
"(",
"$",
"localUser",
")",
")",
";",
"$",
"localUser",
"->",
"socialites",
"(",
")",
"->",
"create",
"(",
"[",
"'provider'",
"=>",
"$",
"provider",
",",
"'provider_uid'",
"=>",
"$",
"attributes",
"[",
"'id'",
"]",
",",
"]",
")",
";",
"return",
"$",
"localUser",
";",
"}"
] |
Create local user for the given provider.
@param string $provider
@param array $attributes
@return \Illuminate\Database\Eloquent\Model|null
|
[
"Create",
"local",
"user",
"for",
"the",
"given",
"provider",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/SocialAuthenticationController.php#L106-L125
|
27,569
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Managerarea/RolesController.php
|
RolesController.import
|
public function import(Role $role, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $role,
'tabs' => 'managerarea.roles.tabs',
'url' => route('managerarea.roles.stash'),
'id' => "managerarea-roles-{$role->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
}
|
php
|
public function import(Role $role, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $role,
'tabs' => 'managerarea.roles.tabs',
'url' => route('managerarea.roles.stash'),
'id' => "managerarea-roles-{$role->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
}
|
[
"public",
"function",
"import",
"(",
"Role",
"$",
"role",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"role",
",",
"'tabs'",
"=>",
"'managerarea.roles.tabs'",
",",
"'url'",
"=>",
"route",
"(",
"'managerarea.roles.stash'",
")",
",",
"'id'",
"=>",
"\"managerarea-roles-{$role->getRouteKey()}-import-table\"",
",",
"]",
")",
"->",
"render",
"(",
"'cortex/foundation::managerarea.pages.datatable-dropzone'",
")",
";",
"}"
] |
Import roles.
@param \Cortex\Auth\Models\Role $role
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View
|
[
"Import",
"roles",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/RolesController.php#L67-L75
|
27,570
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Managerarea/RolesController.php
|
RolesController.destroy
|
public function destroy(Role $role)
{
$role->delete();
return intend([
'url' => route('managerarea.roles.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.role'), 'identifier' => $role->title])],
]);
}
|
php
|
public function destroy(Role $role)
{
$role->delete();
return intend([
'url' => route('managerarea.roles.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.role'), 'identifier' => $role->title])],
]);
}
|
[
"public",
"function",
"destroy",
"(",
"Role",
"$",
"role",
")",
"{",
"$",
"role",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'managerarea.roles.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/auth::common.role'",
")",
",",
"'identifier'",
"=>",
"$",
"role",
"->",
"title",
"]",
")",
"]",
",",
"]",
")",
";",
"}"
] |
Destroy given role.
@param \Cortex\Auth\Models\Role $role
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Destroy",
"given",
"role",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/RolesController.php#L237-L245
|
27,571
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Tenantarea/PasswordResetController.php
|
PasswordResetController.send
|
public function send(PasswordResetSendRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->sendResetLink($request->only(['email']));
switch ($result) {
case PasswordResetBrokerContract::RESET_LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
}
|
php
|
public function send(PasswordResetSendRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->sendResetLink($request->only(['email']));
switch ($result) {
case PasswordResetBrokerContract::RESET_LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
}
|
[
"public",
"function",
"send",
"(",
"PasswordResetSendRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'auth.password'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getPasswordResetBroker",
"(",
")",
")",
"->",
"sendResetLink",
"(",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
"]",
")",
")",
";",
"switch",
"(",
"$",
"result",
")",
"{",
"case",
"PasswordResetBrokerContract",
"::",
"RESET_LINK_SENT",
":",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'tenantarea.home'",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"case",
"PasswordResetBrokerContract",
"::",
"INVALID_USER",
":",
"default",
":",
"return",
"intend",
"(",
"[",
"'back'",
"=>",
"true",
",",
"'withInput'",
"=>",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
"]",
")",
",",
"'withErrors'",
"=>",
"[",
"'email'",
"=>",
"trans",
"(",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"}",
"}"
] |
Process the password reset request form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\PasswordResetSendRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Process",
"the",
"password",
"reset",
"request",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/PasswordResetController.php#L35-L56
|
27,572
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Tenantarea/PasswordResetController.php
|
PasswordResetController.process
|
public function process(PasswordResetPostProcessRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->reset($request->only(['email', 'expiration', 'token', 'password', 'password_confirmation']), function ($user, $password) {
$user->fill([
'password' => $password,
'remember_token' => str_random(60),
])->forceSave();
});
switch ($result) {
case PasswordResetBrokerContract::PASSWORD_RESET:
return intend([
'url' => route('tenantarea.login'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
case PasswordResetBrokerContract::INVALID_TOKEN:
case PasswordResetBrokerContract::EXPIRED_TOKEN:
case PasswordResetBrokerContract::INVALID_PASSWORD:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
}
|
php
|
public function process(PasswordResetPostProcessRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->reset($request->only(['email', 'expiration', 'token', 'password', 'password_confirmation']), function ($user, $password) {
$user->fill([
'password' => $password,
'remember_token' => str_random(60),
])->forceSave();
});
switch ($result) {
case PasswordResetBrokerContract::PASSWORD_RESET:
return intend([
'url' => route('tenantarea.login'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
case PasswordResetBrokerContract::INVALID_TOKEN:
case PasswordResetBrokerContract::EXPIRED_TOKEN:
case PasswordResetBrokerContract::INVALID_PASSWORD:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
}
|
[
"public",
"function",
"process",
"(",
"PasswordResetPostProcessRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'auth.password'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getPasswordResetBroker",
"(",
")",
")",
"->",
"reset",
"(",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
",",
"'expiration'",
",",
"'token'",
",",
"'password'",
",",
"'password_confirmation'",
"]",
")",
",",
"function",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"$",
"user",
"->",
"fill",
"(",
"[",
"'password'",
"=>",
"$",
"password",
",",
"'remember_token'",
"=>",
"str_random",
"(",
"60",
")",
",",
"]",
")",
"->",
"forceSave",
"(",
")",
";",
"}",
")",
";",
"switch",
"(",
"$",
"result",
")",
"{",
"case",
"PasswordResetBrokerContract",
"::",
"PASSWORD_RESET",
":",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'tenantarea.login'",
")",
",",
"'with'",
"=>",
"[",
"'success'",
"=>",
"trans",
"(",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"case",
"PasswordResetBrokerContract",
"::",
"INVALID_USER",
":",
"case",
"PasswordResetBrokerContract",
"::",
"INVALID_TOKEN",
":",
"case",
"PasswordResetBrokerContract",
"::",
"EXPIRED_TOKEN",
":",
"case",
"PasswordResetBrokerContract",
"::",
"INVALID_PASSWORD",
":",
"default",
":",
"return",
"intend",
"(",
"[",
"'back'",
"=>",
"true",
",",
"'withInput'",
"=>",
"$",
"request",
"->",
"only",
"(",
"[",
"'email'",
"]",
")",
",",
"'withErrors'",
"=>",
"[",
"'email'",
"=>",
"trans",
"(",
"$",
"result",
")",
"]",
",",
"]",
")",
";",
"}",
"}"
] |
Process the password reset form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\PasswordResetPostProcessRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Process",
"the",
"password",
"reset",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/PasswordResetController.php#L79-L108
|
27,573
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Adminarea/MembersController.php
|
MembersController.import
|
public function import(Member $member, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $member,
'tabs' => 'adminarea.attributes.tabs',
'url' => route('adminarea.members.stash'),
'id' => "adminarea-attributes-{$member->getRouteKey()}-import-table",
])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
}
|
php
|
public function import(Member $member, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $member,
'tabs' => 'adminarea.attributes.tabs',
'url' => route('adminarea.members.stash'),
'id' => "adminarea-attributes-{$member->getRouteKey()}-import-table",
])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
}
|
[
"public",
"function",
"import",
"(",
"Member",
"$",
"member",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"member",
",",
"'tabs'",
"=>",
"'adminarea.attributes.tabs'",
",",
"'url'",
"=>",
"route",
"(",
"'adminarea.members.stash'",
")",
",",
"'id'",
"=>",
"\"adminarea-attributes-{$member->getRouteKey()}-import-table\"",
",",
"]",
")",
"->",
"render",
"(",
"'cortex/foundation::adminarea.pages.datatable-dropzone'",
")",
";",
"}"
] |
Import members.
@param \Cortex\Auth\Models\Member $member
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View
|
[
"Import",
"members",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Adminarea/MembersController.php#L119-L127
|
27,574
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Managerarea/MembersController.php
|
MembersController.destroy
|
public function destroy(Member $member)
{
$member->delete();
return intend([
'url' => route('managerarea.members.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.member'), 'identifier' => $member->username])],
]);
}
|
php
|
public function destroy(Member $member)
{
$member->delete();
return intend([
'url' => route('managerarea.members.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.member'), 'identifier' => $member->username])],
]);
}
|
[
"public",
"function",
"destroy",
"(",
"Member",
"$",
"member",
")",
"{",
"$",
"member",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'managerarea.members.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/auth::common.member'",
")",
",",
"'identifier'",
"=>",
"$",
"member",
"->",
"username",
"]",
")",
"]",
",",
"]",
")",
";",
"}"
] |
Destroy given member.
@param \Cortex\Auth\Models\Member $member
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Destroy",
"given",
"member",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/MembersController.php#L290-L298
|
27,575
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Managerarea/AccountTwoFactorController.php
|
AccountTwoFactorController.index
|
public function index(Request $request)
{
$twoFactor = $request->user($this->getGuard())->getTwoFactor();
return view('cortex/auth::managerarea.pages.account-twofactor', compact('twoFactor'));
}
|
php
|
public function index(Request $request)
{
$twoFactor = $request->user($this->getGuard())->getTwoFactor();
return view('cortex/auth::managerarea.pages.account-twofactor', compact('twoFactor'));
}
|
[
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"twoFactor",
"=",
"$",
"request",
"->",
"user",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"->",
"getTwoFactor",
"(",
")",
";",
"return",
"view",
"(",
"'cortex/auth::managerarea.pages.account-twofactor'",
",",
"compact",
"(",
"'twoFactor'",
")",
")",
";",
"}"
] |
Show the account security form.
@param \Illuminate\Http\Request $request
@return \Illuminate\View\View
|
[
"Show",
"the",
"account",
"security",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/AccountTwoFactorController.php#L23-L28
|
27,576
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Adminarea/ManagersMediaController.php
|
ManagersMediaController.destroy
|
public function destroy(Manager $manager, Media $media)
{
$manager->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('adminarea.managers.edit', ['manager' => $manager]),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])],
]);
}
|
php
|
public function destroy(Manager $manager, Media $media)
{
$manager->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('adminarea.managers.edit', ['manager' => $manager]),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])],
]);
}
|
[
"public",
"function",
"destroy",
"(",
"Manager",
"$",
"manager",
",",
"Media",
"$",
"media",
")",
"{",
"$",
"manager",
"->",
"media",
"(",
")",
"->",
"where",
"(",
"$",
"media",
"->",
"getKeyName",
"(",
")",
",",
"$",
"media",
"->",
"getKey",
"(",
")",
")",
"->",
"first",
"(",
")",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'adminarea.managers.edit'",
",",
"[",
"'manager'",
"=>",
"$",
"manager",
"]",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/foundation::common.media'",
")",
",",
"'identifier'",
"=>",
"$",
"media",
"->",
"getRouteKey",
"(",
")",
"]",
")",
"]",
",",
"]",
")",
";",
"}"
] |
Destroy given manager media.
@param \Cortex\Auth\Models\Manager $manager
@param \Spatie\MediaLibrary\Models\Media $media
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Destroy",
"given",
"manager",
"media",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Adminarea/ManagersMediaController.php#L46-L54
|
27,577
|
laravie/codex
|
src/Support/Responsable.php
|
Responsable.interactsWithResponse
|
protected function interactsWithResponse(Response $response): Response
{
if ($response instanceof Filterable && $this instanceof Filterable) {
$response->setFilterable($this->getFilterable());
}
if ($this->validateResponseAutomatically === true) {
$response->validate();
}
return $response;
}
|
php
|
protected function interactsWithResponse(Response $response): Response
{
if ($response instanceof Filterable && $this instanceof Filterable) {
$response->setFilterable($this->getFilterable());
}
if ($this->validateResponseAutomatically === true) {
$response->validate();
}
return $response;
}
|
[
"protected",
"function",
"interactsWithResponse",
"(",
"Response",
"$",
"response",
")",
":",
"Response",
"{",
"if",
"(",
"$",
"response",
"instanceof",
"Filterable",
"&&",
"$",
"this",
"instanceof",
"Filterable",
")",
"{",
"$",
"response",
"->",
"setFilterable",
"(",
"$",
"this",
"->",
"getFilterable",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"validateResponseAutomatically",
"===",
"true",
")",
"{",
"$",
"response",
"->",
"validate",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Interacts with Response.
@param \Laravie\Codex\Contracts\Response $response
@return \Laravie\Codex\Contracts\Response
|
[
"Interacts",
"with",
"Response",
"."
] |
4d813bcbe20e7cf0b6c0cb98d3b077a070285709
|
https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Support/Responsable.php#L18-L29
|
27,578
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Adminarea/ManagersController.php
|
ManagersController.destroy
|
public function destroy(Manager $manager)
{
$manager->delete();
return intend([
'url' => route('adminarea.managers.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.manager'), 'identifier' => $manager->username])],
]);
}
|
php
|
public function destroy(Manager $manager)
{
$manager->delete();
return intend([
'url' => route('adminarea.managers.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.manager'), 'identifier' => $manager->username])],
]);
}
|
[
"public",
"function",
"destroy",
"(",
"Manager",
"$",
"manager",
")",
"{",
"$",
"manager",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'adminarea.managers.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/auth::common.manager'",
")",
",",
"'identifier'",
"=>",
"$",
"manager",
"->",
"username",
"]",
")",
"]",
",",
"]",
")",
";",
"}"
] |
Destroy given manager.
@param \Cortex\Auth\Models\Manager $manager
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
[
"Destroy",
"given",
"manager",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Adminarea/ManagersController.php#L294-L302
|
27,579
|
rinvex/cortex-auth-b2b2c2
|
src/Http/Controllers/Frontarea/TenantRegistrationController.php
|
TenantRegistrationController.form
|
public function form(TenantRegistrationRequest $request)
{
$countries = collect(countries())->map(function ($country, $code) {
return [
'id' => $code,
'text' => $country['name'],
'emoji' => $country['emoji'],
];
})->values();
$languages = collect(languages())->pluck('name', 'iso_639_1');
return view('cortex/auth::frontarea.pages.tenant-registration', compact('countries', 'languages'));
}
|
php
|
public function form(TenantRegistrationRequest $request)
{
$countries = collect(countries())->map(function ($country, $code) {
return [
'id' => $code,
'text' => $country['name'],
'emoji' => $country['emoji'],
];
})->values();
$languages = collect(languages())->pluck('name', 'iso_639_1');
return view('cortex/auth::frontarea.pages.tenant-registration', compact('countries', 'languages'));
}
|
[
"public",
"function",
"form",
"(",
"TenantRegistrationRequest",
"$",
"request",
")",
"{",
"$",
"countries",
"=",
"collect",
"(",
"countries",
"(",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"country",
",",
"$",
"code",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"code",
",",
"'text'",
"=>",
"$",
"country",
"[",
"'name'",
"]",
",",
"'emoji'",
"=>",
"$",
"country",
"[",
"'emoji'",
"]",
",",
"]",
";",
"}",
")",
"->",
"values",
"(",
")",
";",
"$",
"languages",
"=",
"collect",
"(",
"languages",
"(",
")",
")",
"->",
"pluck",
"(",
"'name'",
",",
"'iso_639_1'",
")",
";",
"return",
"view",
"(",
"'cortex/auth::frontarea.pages.tenant-registration'",
",",
"compact",
"(",
"'countries'",
",",
"'languages'",
")",
")",
";",
"}"
] |
Show the registration form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Frontarea\TenantRegistrationRequest $request
@return \Illuminate\View\View
|
[
"Show",
"the",
"registration",
"form",
"."
] |
3152b5314f77910656ddaddfd1bf7aa8e2517905
|
https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Frontarea/TenantRegistrationController.php#L22-L34
|
27,580
|
laravie/codex
|
src/Concerns/Request/Multipart.php
|
Multipart.prepareMultipartRequestPayloads
|
final public function prepareMultipartRequestPayloads(array $headers = [], array $body = [], array $files = []): array
{
$multipart = (($headers['Content-Type'] ?? null) == 'multipart/form-data');
if (empty($files) && ! $multipart) {
return [$headers, $body];
}
$builder = new Builder(StreamFactoryDiscovery::find());
$this->addFilesToMultipartBuilder($builder, $files);
$this->addBodyToMultipartBuilder(
$builder, $this instanceof Filterable ? $this->filterRequest($body) : $body
);
$headers['Content-Type'] = 'multipart/form-data; boundary='.$builder->getBoundary();
return [$headers, $builder->build()];
}
|
php
|
final public function prepareMultipartRequestPayloads(array $headers = [], array $body = [], array $files = []): array
{
$multipart = (($headers['Content-Type'] ?? null) == 'multipart/form-data');
if (empty($files) && ! $multipart) {
return [$headers, $body];
}
$builder = new Builder(StreamFactoryDiscovery::find());
$this->addFilesToMultipartBuilder($builder, $files);
$this->addBodyToMultipartBuilder(
$builder, $this instanceof Filterable ? $this->filterRequest($body) : $body
);
$headers['Content-Type'] = 'multipart/form-data; boundary='.$builder->getBoundary();
return [$headers, $builder->build()];
}
|
[
"final",
"public",
"function",
"prepareMultipartRequestPayloads",
"(",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"files",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"multipart",
"=",
"(",
"(",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"??",
"null",
")",
"==",
"'multipart/form-data'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"files",
")",
"&&",
"!",
"$",
"multipart",
")",
"{",
"return",
"[",
"$",
"headers",
",",
"$",
"body",
"]",
";",
"}",
"$",
"builder",
"=",
"new",
"Builder",
"(",
"StreamFactoryDiscovery",
"::",
"find",
"(",
")",
")",
";",
"$",
"this",
"->",
"addFilesToMultipartBuilder",
"(",
"$",
"builder",
",",
"$",
"files",
")",
";",
"$",
"this",
"->",
"addBodyToMultipartBuilder",
"(",
"$",
"builder",
",",
"$",
"this",
"instanceof",
"Filterable",
"?",
"$",
"this",
"->",
"filterRequest",
"(",
"$",
"body",
")",
":",
"$",
"body",
")",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'multipart/form-data; boundary='",
".",
"$",
"builder",
"->",
"getBoundary",
"(",
")",
";",
"return",
"[",
"$",
"headers",
",",
"$",
"builder",
"->",
"build",
"(",
")",
"]",
";",
"}"
] |
Prepare multipart request payloads.
@param array $headers
@param array $body
@param array $files
@return array
|
[
"Prepare",
"multipart",
"request",
"payloads",
"."
] |
4d813bcbe20e7cf0b6c0cb98d3b077a070285709
|
https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Concerns/Request/Multipart.php#L56-L74
|
27,581
|
laravie/codex
|
src/Concerns/Request/Multipart.php
|
Multipart.addBodyToMultipartBuilder
|
final protected function addBodyToMultipartBuilder(Builder $builder, array $body, ?string $prefix = null): void
{
foreach ($body as $key => $value) {
$name = $key;
if (! \is_null($prefix)) {
$name = "{$prefix}[{$key}]";
}
if (\is_array($value)) {
$this->addBodyToMultipartBuilder($builder, $value, $name);
continue;
}
$builder->addResource($name, $value, ['Content-Type' => 'text/plain']);
}
}
|
php
|
final protected function addBodyToMultipartBuilder(Builder $builder, array $body, ?string $prefix = null): void
{
foreach ($body as $key => $value) {
$name = $key;
if (! \is_null($prefix)) {
$name = "{$prefix}[{$key}]";
}
if (\is_array($value)) {
$this->addBodyToMultipartBuilder($builder, $value, $name);
continue;
}
$builder->addResource($name, $value, ['Content-Type' => 'text/plain']);
}
}
|
[
"final",
"protected",
"function",
"addBodyToMultipartBuilder",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"body",
",",
"?",
"string",
"$",
"prefix",
"=",
"null",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"body",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"$",
"key",
";",
"if",
"(",
"!",
"\\",
"is_null",
"(",
"$",
"prefix",
")",
")",
"{",
"$",
"name",
"=",
"\"{$prefix}[{$key}]\"",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"addBodyToMultipartBuilder",
"(",
"$",
"builder",
",",
"$",
"value",
",",
"$",
"name",
")",
";",
"continue",
";",
"}",
"$",
"builder",
"->",
"addResource",
"(",
"$",
"name",
",",
"$",
"value",
",",
"[",
"'Content-Type'",
"=>",
"'text/plain'",
"]",
")",
";",
"}",
"}"
] |
Add body to multipart stream builder.
@param \Http\Message\MultipartStream\MultipartStreamBuilder $builder
@param array $body
@param string|null $prefix
@return void
|
[
"Add",
"body",
"to",
"multipart",
"stream",
"builder",
"."
] |
4d813bcbe20e7cf0b6c0cb98d3b077a070285709
|
https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Concerns/Request/Multipart.php#L85-L101
|
27,582
|
laravie/codex
|
src/Concerns/Request/Multipart.php
|
Multipart.addFilesToMultipartBuilder
|
final protected function addFilesToMultipartBuilder(Builder $builder, array $files = []): void
{
foreach ($files as $key => $file) {
if (! \is_null($file)) {
$builder->addResource($key, fopen($file, 'r'));
}
}
}
|
php
|
final protected function addFilesToMultipartBuilder(Builder $builder, array $files = []): void
{
foreach ($files as $key => $file) {
if (! \is_null($file)) {
$builder->addResource($key, fopen($file, 'r'));
}
}
}
|
[
"final",
"protected",
"function",
"addFilesToMultipartBuilder",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"files",
"=",
"[",
"]",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"\\",
"is_null",
"(",
"$",
"file",
")",
")",
"{",
"$",
"builder",
"->",
"addResource",
"(",
"$",
"key",
",",
"fopen",
"(",
"$",
"file",
",",
"'r'",
")",
")",
";",
"}",
"}",
"}"
] |
Add files to multipart stream builder.
@param \Http\Message\MultipartStream\MultipartStreamBuilder $builder
@param array $files
@return void
|
[
"Add",
"files",
"to",
"multipart",
"stream",
"builder",
"."
] |
4d813bcbe20e7cf0b6c0cb98d3b077a070285709
|
https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Concerns/Request/Multipart.php#L111-L118
|
27,583
|
byTestGear/laravel-accountable
|
src/Traits/Accountable.php
|
Accountable.updatedBy
|
public function updatedBy()
{
$relation = $this->belongsTo(
AccountableServiceProvider::userModel(),
config('accountable.column_names.updated_by')
);
return $this->userModelUsesSoftDeletes() ? $relation->withTrashed() : $relation;
}
|
php
|
public function updatedBy()
{
$relation = $this->belongsTo(
AccountableServiceProvider::userModel(),
config('accountable.column_names.updated_by')
);
return $this->userModelUsesSoftDeletes() ? $relation->withTrashed() : $relation;
}
|
[
"public",
"function",
"updatedBy",
"(",
")",
"{",
"$",
"relation",
"=",
"$",
"this",
"->",
"belongsTo",
"(",
"AccountableServiceProvider",
"::",
"userModel",
"(",
")",
",",
"config",
"(",
"'accountable.column_names.updated_by'",
")",
")",
";",
"return",
"$",
"this",
"->",
"userModelUsesSoftDeletes",
"(",
")",
"?",
"$",
"relation",
"->",
"withTrashed",
"(",
")",
":",
"$",
"relation",
";",
"}"
] |
Define the updated by relationship.
@return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
[
"Define",
"the",
"updated",
"by",
"relationship",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L94-L102
|
27,584
|
byTestGear/laravel-accountable
|
src/Traits/Accountable.php
|
Accountable.scopeOnlyCreatedBy
|
public function scopeOnlyCreatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.created_by'), $user->getKey());
}
|
php
|
public function scopeOnlyCreatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.created_by'), $user->getKey());
}
|
[
"public",
"function",
"scopeOnlyCreatedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"user",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"config",
"(",
"'accountable.column_names.created_by'",
")",
",",
"$",
"user",
"->",
"getKey",
"(",
")",
")",
";",
"}"
] |
Scope a query to only include records created by a given user.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder
|
[
"Scope",
"a",
"query",
"to",
"only",
"include",
"records",
"created",
"by",
"a",
"given",
"user",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L127-L130
|
27,585
|
byTestGear/laravel-accountable
|
src/Traits/Accountable.php
|
Accountable.scopeOnlyUpdatedBy
|
public function scopeOnlyUpdatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.updated_by'), $user->getKey());
}
|
php
|
public function scopeOnlyUpdatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.updated_by'), $user->getKey());
}
|
[
"public",
"function",
"scopeOnlyUpdatedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"user",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"config",
"(",
"'accountable.column_names.updated_by'",
")",
",",
"$",
"user",
"->",
"getKey",
"(",
")",
")",
";",
"}"
] |
Scope a query to only include records updated by a given user.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder
|
[
"Scope",
"a",
"query",
"to",
"only",
"include",
"records",
"updated",
"by",
"a",
"given",
"user",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L152-L155
|
27,586
|
byTestGear/laravel-accountable
|
src/Traits/Accountable.php
|
Accountable.scopeOnlyDeletedBy
|
public function scopeOnlyDeletedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.deleted_by'), $user->getKey());
}
|
php
|
public function scopeOnlyDeletedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.deleted_by'), $user->getKey());
}
|
[
"public",
"function",
"scopeOnlyDeletedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"user",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"config",
"(",
"'accountable.column_names.deleted_by'",
")",
",",
"$",
"user",
"->",
"getKey",
"(",
")",
")",
";",
"}"
] |
Scope a query to only include records deleted by a given user.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder
|
[
"Scope",
"a",
"query",
"to",
"only",
"include",
"records",
"deleted",
"by",
"a",
"given",
"user",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L165-L168
|
27,587
|
byTestGear/laravel-accountable
|
src/AccountableServiceProvider.php
|
AccountableServiceProvider.userModel
|
public static function userModel()
{
$guard = self::authDriver();
return collect(config('auth.guards'))
->map(function ($guard) {
return config("auth.providers.{$guard['provider']}.model");
})->get($guard);
}
|
php
|
public static function userModel()
{
$guard = self::authDriver();
return collect(config('auth.guards'))
->map(function ($guard) {
return config("auth.providers.{$guard['provider']}.model");
})->get($guard);
}
|
[
"public",
"static",
"function",
"userModel",
"(",
")",
"{",
"$",
"guard",
"=",
"self",
"::",
"authDriver",
"(",
")",
";",
"return",
"collect",
"(",
"config",
"(",
"'auth.guards'",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"guard",
")",
"{",
"return",
"config",
"(",
"\"auth.providers.{$guard['provider']}.model\"",
")",
";",
"}",
")",
"->",
"get",
"(",
"$",
"guard",
")",
";",
"}"
] |
Returns the user model, based on the configured authentication driver.
@return string
|
[
"Returns",
"the",
"user",
"model",
"based",
"on",
"the",
"configured",
"authentication",
"driver",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/AccountableServiceProvider.php#L52-L60
|
27,588
|
byTestGear/laravel-accountable
|
src/Observer/AccountableObserver.php
|
AccountableObserver.creating
|
public function creating($model)
{
if ($model->accountableEnabled()) {
$model->{$this->config['column_names']['created_by']} = $this->accountableUserId();
$model->{$this->config['column_names']['updated_by']} = $this->accountableUserId();
}
}
|
php
|
public function creating($model)
{
if ($model->accountableEnabled()) {
$model->{$this->config['column_names']['created_by']} = $this->accountableUserId();
$model->{$this->config['column_names']['updated_by']} = $this->accountableUserId();
}
}
|
[
"public",
"function",
"creating",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"accountableEnabled",
"(",
")",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"config",
"[",
"'column_names'",
"]",
"[",
"'created_by'",
"]",
"}",
"=",
"$",
"this",
"->",
"accountableUserId",
"(",
")",
";",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"config",
"[",
"'column_names'",
"]",
"[",
"'updated_by'",
"]",
"}",
"=",
"$",
"this",
"->",
"accountableUserId",
"(",
")",
";",
"}",
"}"
] |
Store the user creating a record.
@param \Illuminate\Database\Eloquent\Model $model
|
[
"Store",
"the",
"user",
"creating",
"a",
"record",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Observer/AccountableObserver.php#L38-L44
|
27,589
|
byTestGear/laravel-accountable
|
src/Observer/AccountableObserver.php
|
AccountableObserver.deleting
|
public function deleting($model)
{
if ($model->accountableEnabled() &&
collect(class_uses($model))->contains(SoftDeletes::class)) {
$model->{$this->config['column_names']['deleted_by']} = $this->accountableUserId();
$model->save();
}
}
|
php
|
public function deleting($model)
{
if ($model->accountableEnabled() &&
collect(class_uses($model))->contains(SoftDeletes::class)) {
$model->{$this->config['column_names']['deleted_by']} = $this->accountableUserId();
$model->save();
}
}
|
[
"public",
"function",
"deleting",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"accountableEnabled",
"(",
")",
"&&",
"collect",
"(",
"class_uses",
"(",
"$",
"model",
")",
")",
"->",
"contains",
"(",
"SoftDeletes",
"::",
"class",
")",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"config",
"[",
"'column_names'",
"]",
"[",
"'deleted_by'",
"]",
"}",
"=",
"$",
"this",
"->",
"accountableUserId",
"(",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"}",
"}"
] |
Store the user deleting a record.
@param \Illuminate\Database\Eloquent\Model $model
|
[
"Store",
"the",
"user",
"deleting",
"a",
"record",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Observer/AccountableObserver.php#L63-L71
|
27,590
|
byTestGear/laravel-accountable
|
src/Accountable.php
|
Accountable.columns
|
public static function columns(Blueprint $table, $usesSoftDeletes = true)
{
self::addColumn($table, config('accountable.column_names.created_by'));
self::addColumn($table, config('accountable.column_names.updated_by'));
if ($usesSoftDeletes) {
self::addColumn($table, config('accountable.column_names.deleted_by'));
}
}
|
php
|
public static function columns(Blueprint $table, $usesSoftDeletes = true)
{
self::addColumn($table, config('accountable.column_names.created_by'));
self::addColumn($table, config('accountable.column_names.updated_by'));
if ($usesSoftDeletes) {
self::addColumn($table, config('accountable.column_names.deleted_by'));
}
}
|
[
"public",
"static",
"function",
"columns",
"(",
"Blueprint",
"$",
"table",
",",
"$",
"usesSoftDeletes",
"=",
"true",
")",
"{",
"self",
"::",
"addColumn",
"(",
"$",
"table",
",",
"config",
"(",
"'accountable.column_names.created_by'",
")",
")",
";",
"self",
"::",
"addColumn",
"(",
"$",
"table",
",",
"config",
"(",
"'accountable.column_names.updated_by'",
")",
")",
";",
"if",
"(",
"$",
"usesSoftDeletes",
")",
"{",
"self",
"::",
"addColumn",
"(",
"$",
"table",
",",
"config",
"(",
"'accountable.column_names.deleted_by'",
")",
")",
";",
"}",
"}"
] |
Add accountable.column_names to the table, including indexes.
@param \Illuminate\Database\Schema\Blueprint $table
@param bool $usesSoftDeletes
|
[
"Add",
"accountable",
".",
"column_names",
"to",
"the",
"table",
"including",
"indexes",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Accountable.php#L15-L23
|
27,591
|
byTestGear/laravel-accountable
|
src/Accountable.php
|
Accountable.addColumn
|
public static function addColumn(Blueprint $table, string $name)
{
$table->unsignedInteger($name)->nullable();
$table->index($name);
}
|
php
|
public static function addColumn(Blueprint $table, string $name)
{
$table->unsignedInteger($name)->nullable();
$table->index($name);
}
|
[
"public",
"static",
"function",
"addColumn",
"(",
"Blueprint",
"$",
"table",
",",
"string",
"$",
"name",
")",
"{",
"$",
"table",
"->",
"unsignedInteger",
"(",
"$",
"name",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"index",
"(",
"$",
"name",
")",
";",
"}"
] |
Add a single Accountable column to the table. Also creates an index.
@param \Illuminate\Database\Schema\Blueprint $table
@param string $name
|
[
"Add",
"a",
"single",
"Accountable",
"column",
"to",
"the",
"table",
".",
"Also",
"creates",
"an",
"index",
"."
] |
17a4d45de255b0106c1e51ae8974dd83301b4aff
|
https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Accountable.php#L31-L35
|
27,592
|
techdivision/import-product
|
src/Observers/UrlKeyObserver.php
|
UrlKeyObserver.makeUrlKeyUnique
|
protected function makeUrlKeyUnique($urlKey)
{
// initialize the entity type ID
$entityType = $this->getEntityType();
$entityTypeId = (integer) $entityType[MemberNames::ENTITY_TYPE_ID];
// initialize the store view ID, use the admin store view if no store view has
// been set, because the default url_key value has been set in admin store view
$storeId = $this->getSubject()->getRowStoreId(StoreViewCodes::ADMIN);
// initialize the counter
$counter = 0;
// initialize the counters
$matchingCounters = array();
$notMatchingCounters = array();
// pre-initialze the URL key to query for
$value = $urlKey;
do {
// try to load the attribute
$productVarcharAttribute = $this->getProductBunchProcessor()
->loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue(
MemberNames::URL_KEY,
$entityTypeId,
$storeId,
$value
);
// try to load the product's URL key
if ($productVarcharAttribute) {
// this IS the URL key of the passed entity
if ($this->isUrlKeyOf($productVarcharAttribute)) {
$matchingCounters[] = $counter;
} else {
$notMatchingCounters[] = $counter;
}
// prepare the next URL key to query for
$value = sprintf('%s-%d', $urlKey, ++$counter);
}
} while ($productVarcharAttribute);
// sort the array ascending according to the counter
asort($matchingCounters);
asort($notMatchingCounters);
// this IS the URL key of the passed entity => we've an UPDATE
if (sizeof($matchingCounters) > 0) {
// load highest counter
$counter = end($matchingCounters);
// if the counter is > 0, we've to append it to the new URL key
if ($counter > 0) {
$urlKey = sprintf('%s-%d', $urlKey, $counter);
}
} elseif (sizeof($notMatchingCounters) > 0) {
// create a new URL key by raising the counter
$newCounter = end($notMatchingCounters);
$urlKey = sprintf('%s-%d', $urlKey, ++$newCounter);
}
// return the passed URL key, if NOT
return $urlKey;
}
|
php
|
protected function makeUrlKeyUnique($urlKey)
{
// initialize the entity type ID
$entityType = $this->getEntityType();
$entityTypeId = (integer) $entityType[MemberNames::ENTITY_TYPE_ID];
// initialize the store view ID, use the admin store view if no store view has
// been set, because the default url_key value has been set in admin store view
$storeId = $this->getSubject()->getRowStoreId(StoreViewCodes::ADMIN);
// initialize the counter
$counter = 0;
// initialize the counters
$matchingCounters = array();
$notMatchingCounters = array();
// pre-initialze the URL key to query for
$value = $urlKey;
do {
// try to load the attribute
$productVarcharAttribute = $this->getProductBunchProcessor()
->loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue(
MemberNames::URL_KEY,
$entityTypeId,
$storeId,
$value
);
// try to load the product's URL key
if ($productVarcharAttribute) {
// this IS the URL key of the passed entity
if ($this->isUrlKeyOf($productVarcharAttribute)) {
$matchingCounters[] = $counter;
} else {
$notMatchingCounters[] = $counter;
}
// prepare the next URL key to query for
$value = sprintf('%s-%d', $urlKey, ++$counter);
}
} while ($productVarcharAttribute);
// sort the array ascending according to the counter
asort($matchingCounters);
asort($notMatchingCounters);
// this IS the URL key of the passed entity => we've an UPDATE
if (sizeof($matchingCounters) > 0) {
// load highest counter
$counter = end($matchingCounters);
// if the counter is > 0, we've to append it to the new URL key
if ($counter > 0) {
$urlKey = sprintf('%s-%d', $urlKey, $counter);
}
} elseif (sizeof($notMatchingCounters) > 0) {
// create a new URL key by raising the counter
$newCounter = end($notMatchingCounters);
$urlKey = sprintf('%s-%d', $urlKey, ++$newCounter);
}
// return the passed URL key, if NOT
return $urlKey;
}
|
[
"protected",
"function",
"makeUrlKeyUnique",
"(",
"$",
"urlKey",
")",
"{",
"// initialize the entity type ID",
"$",
"entityType",
"=",
"$",
"this",
"->",
"getEntityType",
"(",
")",
";",
"$",
"entityTypeId",
"=",
"(",
"integer",
")",
"$",
"entityType",
"[",
"MemberNames",
"::",
"ENTITY_TYPE_ID",
"]",
";",
"// initialize the store view ID, use the admin store view if no store view has",
"// been set, because the default url_key value has been set in admin store view",
"$",
"storeId",
"=",
"$",
"this",
"->",
"getSubject",
"(",
")",
"->",
"getRowStoreId",
"(",
"StoreViewCodes",
"::",
"ADMIN",
")",
";",
"// initialize the counter",
"$",
"counter",
"=",
"0",
";",
"// initialize the counters",
"$",
"matchingCounters",
"=",
"array",
"(",
")",
";",
"$",
"notMatchingCounters",
"=",
"array",
"(",
")",
";",
"// pre-initialze the URL key to query for",
"$",
"value",
"=",
"$",
"urlKey",
";",
"do",
"{",
"// try to load the attribute",
"$",
"productVarcharAttribute",
"=",
"$",
"this",
"->",
"getProductBunchProcessor",
"(",
")",
"->",
"loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue",
"(",
"MemberNames",
"::",
"URL_KEY",
",",
"$",
"entityTypeId",
",",
"$",
"storeId",
",",
"$",
"value",
")",
";",
"// try to load the product's URL key",
"if",
"(",
"$",
"productVarcharAttribute",
")",
"{",
"// this IS the URL key of the passed entity",
"if",
"(",
"$",
"this",
"->",
"isUrlKeyOf",
"(",
"$",
"productVarcharAttribute",
")",
")",
"{",
"$",
"matchingCounters",
"[",
"]",
"=",
"$",
"counter",
";",
"}",
"else",
"{",
"$",
"notMatchingCounters",
"[",
"]",
"=",
"$",
"counter",
";",
"}",
"// prepare the next URL key to query for",
"$",
"value",
"=",
"sprintf",
"(",
"'%s-%d'",
",",
"$",
"urlKey",
",",
"++",
"$",
"counter",
")",
";",
"}",
"}",
"while",
"(",
"$",
"productVarcharAttribute",
")",
";",
"// sort the array ascending according to the counter",
"asort",
"(",
"$",
"matchingCounters",
")",
";",
"asort",
"(",
"$",
"notMatchingCounters",
")",
";",
"// this IS the URL key of the passed entity => we've an UPDATE",
"if",
"(",
"sizeof",
"(",
"$",
"matchingCounters",
")",
">",
"0",
")",
"{",
"// load highest counter",
"$",
"counter",
"=",
"end",
"(",
"$",
"matchingCounters",
")",
";",
"// if the counter is > 0, we've to append it to the new URL key",
"if",
"(",
"$",
"counter",
">",
"0",
")",
"{",
"$",
"urlKey",
"=",
"sprintf",
"(",
"'%s-%d'",
",",
"$",
"urlKey",
",",
"$",
"counter",
")",
";",
"}",
"}",
"elseif",
"(",
"sizeof",
"(",
"$",
"notMatchingCounters",
")",
">",
"0",
")",
"{",
"// create a new URL key by raising the counter",
"$",
"newCounter",
"=",
"end",
"(",
"$",
"notMatchingCounters",
")",
";",
"$",
"urlKey",
"=",
"sprintf",
"(",
"'%s-%d'",
",",
"$",
"urlKey",
",",
"++",
"$",
"newCounter",
")",
";",
"}",
"// return the passed URL key, if NOT",
"return",
"$",
"urlKey",
";",
"}"
] |
Make's the passed URL key unique by adding the next number to the end.
@param string $urlKey The URL key to make unique
@return string The unique URL key
|
[
"Make",
"s",
"the",
"passed",
"URL",
"key",
"unique",
"by",
"adding",
"the",
"next",
"number",
"to",
"the",
"end",
"."
] |
a596e0c4b0495c918139935a709815c739d61e95
|
https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Observers/UrlKeyObserver.php#L159-L224
|
27,593
|
techdivision/import-product
|
src/Repositories/ProductWebsiteRepository.php
|
ProductWebsiteRepository.findOneByProductIdAndWebsite
|
public function findOneByProductIdAndWebsite($productId, $websiteId)
{
// prepare the params
$params = array(
MemberNames::PRODUCT_ID => $productId,
MemberNames::WEBSITE_ID => $websiteId
);
// load and return the product with the passed product/website ID
$this->productWebsiteStmt->execute($params);
return $this->productWebsiteStmt->fetch(\PDO::FETCH_ASSOC);
}
|
php
|
public function findOneByProductIdAndWebsite($productId, $websiteId)
{
// prepare the params
$params = array(
MemberNames::PRODUCT_ID => $productId,
MemberNames::WEBSITE_ID => $websiteId
);
// load and return the product with the passed product/website ID
$this->productWebsiteStmt->execute($params);
return $this->productWebsiteStmt->fetch(\PDO::FETCH_ASSOC);
}
|
[
"public",
"function",
"findOneByProductIdAndWebsite",
"(",
"$",
"productId",
",",
"$",
"websiteId",
")",
"{",
"// prepare the params",
"$",
"params",
"=",
"array",
"(",
"MemberNames",
"::",
"PRODUCT_ID",
"=>",
"$",
"productId",
",",
"MemberNames",
"::",
"WEBSITE_ID",
"=>",
"$",
"websiteId",
")",
";",
"// load and return the product with the passed product/website ID",
"$",
"this",
"->",
"productWebsiteStmt",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"productWebsiteStmt",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}"
] |
Load's and return's the product website relation with the passed product and website ID.
@param string $productId The product ID of the relation
@param string $websiteId The website ID of the relation
@return array The product website
|
[
"Load",
"s",
"and",
"return",
"s",
"the",
"product",
"website",
"relation",
"with",
"the",
"passed",
"product",
"and",
"website",
"ID",
"."
] |
a596e0c4b0495c918139935a709815c739d61e95
|
https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Repositories/ProductWebsiteRepository.php#L67-L79
|
27,594
|
contributte/thepay-api
|
src/DataApi/Processors/Digester.php
|
Digester.processItem
|
protected function processItem($value): string
{
if (Utils::isList($value)) {
return $this->processList($value);
}
return $this->processHash($value);
}
|
php
|
protected function processItem($value): string
{
if (Utils::isList($value)) {
return $this->processList($value);
}
return $this->processHash($value);
}
|
[
"protected",
"function",
"processItem",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"Utils",
"::",
"isList",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processList",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"processHash",
"(",
"$",
"value",
")",
";",
"}"
] |
Hashes, lists and booleans are treated specially. Other values are simply
converted to strings, strings are left untouched.
@param mixed $value
|
[
"Hashes",
"lists",
"and",
"booleans",
"are",
"treated",
"specially",
".",
"Other",
"values",
"are",
"simply",
"converted",
"to",
"strings",
"strings",
"are",
"left",
"untouched",
"."
] |
7e28eaf30ad1880533add93cf9e7296e61c09b8e
|
https://github.com/contributte/thepay-api/blob/7e28eaf30ad1880533add93cf9e7296e61c09b8e/src/DataApi/Processors/Digester.php#L69-L76
|
27,595
|
contributte/thepay-api
|
src/ReturnedPayment.php
|
ReturnedPayment.verifySignature
|
public function verifySignature(?string $signature = null): bool
{
// check merchantId and accountId from request
if (
$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
) {
throw new InvalidSignatureException();
}
if ($signature === null) {
$signature = $this->signature;
}
// Compute the signature for specified arguments, and compare it to the specified signature.
$out = [];
$out[] = 'merchantId=' . $this->getRequestMerchantId();
$out[] = 'accountId=' . $this->getRequestAccountId();
foreach (array_merge(self::$REQUIRED_ARGS, self::$OPTIONAL_ARGS) as $property) {
if ($this->{$property} !== null) {
$value = $this->{$property};
if (in_array($property, self::$FLOAT_ARGS, true)) {
$value = number_format($value, 2, '.', '');
} elseif (in_array($property, self::$BOOL_ARGS, true)) {
$value = $value ? '1' : '0';
}
$out[] = sprintf('%s=%s', $property, $value);
}
}
$out[] = 'password=' . $this->getMerchantConfig()->password;
$sig = $this->hashFunction(implode('&', $out));
if ($sig === $signature) {
return true;
}
throw new InvalidSignatureException();
}
|
php
|
public function verifySignature(?string $signature = null): bool
{
// check merchantId and accountId from request
if (
$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
) {
throw new InvalidSignatureException();
}
if ($signature === null) {
$signature = $this->signature;
}
// Compute the signature for specified arguments, and compare it to the specified signature.
$out = [];
$out[] = 'merchantId=' . $this->getRequestMerchantId();
$out[] = 'accountId=' . $this->getRequestAccountId();
foreach (array_merge(self::$REQUIRED_ARGS, self::$OPTIONAL_ARGS) as $property) {
if ($this->{$property} !== null) {
$value = $this->{$property};
if (in_array($property, self::$FLOAT_ARGS, true)) {
$value = number_format($value, 2, '.', '');
} elseif (in_array($property, self::$BOOL_ARGS, true)) {
$value = $value ? '1' : '0';
}
$out[] = sprintf('%s=%s', $property, $value);
}
}
$out[] = 'password=' . $this->getMerchantConfig()->password;
$sig = $this->hashFunction(implode('&', $out));
if ($sig === $signature) {
return true;
}
throw new InvalidSignatureException();
}
|
[
"public",
"function",
"verifySignature",
"(",
"?",
"string",
"$",
"signature",
"=",
"null",
")",
":",
"bool",
"{",
"// check merchantId and accountId from request",
"if",
"(",
"$",
"this",
"->",
"getRequestMerchantId",
"(",
")",
"!==",
"$",
"this",
"->",
"getMerchantConfig",
"(",
")",
"->",
"merchantId",
"||",
"$",
"this",
"->",
"getRequestAccountId",
"(",
")",
"!==",
"$",
"this",
"->",
"getMerchantConfig",
"(",
")",
"->",
"accountId",
")",
"{",
"throw",
"new",
"InvalidSignatureException",
"(",
")",
";",
"}",
"if",
"(",
"$",
"signature",
"===",
"null",
")",
"{",
"$",
"signature",
"=",
"$",
"this",
"->",
"signature",
";",
"}",
"// Compute the signature for specified arguments, and compare it to the specified signature.",
"$",
"out",
"=",
"[",
"]",
";",
"$",
"out",
"[",
"]",
"=",
"'merchantId='",
".",
"$",
"this",
"->",
"getRequestMerchantId",
"(",
")",
";",
"$",
"out",
"[",
"]",
"=",
"'accountId='",
".",
"$",
"this",
"->",
"getRequestAccountId",
"(",
")",
";",
"foreach",
"(",
"array_merge",
"(",
"self",
"::",
"$",
"REQUIRED_ARGS",
",",
"self",
"::",
"$",
"OPTIONAL_ARGS",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"{",
"$",
"property",
"}",
"!==",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"{",
"$",
"property",
"}",
";",
"if",
"(",
"in_array",
"(",
"$",
"property",
",",
"self",
"::",
"$",
"FLOAT_ARGS",
",",
"true",
")",
")",
"{",
"$",
"value",
"=",
"number_format",
"(",
"$",
"value",
",",
"2",
",",
"'.'",
",",
"''",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"property",
",",
"self",
"::",
"$",
"BOOL_ARGS",
",",
"true",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
"'1'",
":",
"'0'",
";",
"}",
"$",
"out",
"[",
"]",
"=",
"sprintf",
"(",
"'%s=%s'",
",",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"out",
"[",
"]",
"=",
"'password='",
".",
"$",
"this",
"->",
"getMerchantConfig",
"(",
")",
"->",
"password",
";",
"$",
"sig",
"=",
"$",
"this",
"->",
"hashFunction",
"(",
"implode",
"(",
"'&'",
",",
"$",
"out",
")",
")",
";",
"if",
"(",
"$",
"sig",
"===",
"$",
"signature",
")",
"{",
"return",
"true",
";",
"}",
"throw",
"new",
"InvalidSignatureException",
"(",
")",
";",
"}"
] |
Use this call to verify signature of the payment.
this method is called automatically.
@return true if signature is valid, otherwise throws
a Tp\TpInvalidSignatureException.
@throws InvalidSignatureException , when signature isinvalid.
|
[
"Use",
"this",
"call",
"to",
"verify",
"signature",
"of",
"the",
"payment",
".",
"this",
"method",
"is",
"called",
"automatically",
"."
] |
7e28eaf30ad1880533add93cf9e7296e61c09b8e
|
https://github.com/contributte/thepay-api/blob/7e28eaf30ad1880533add93cf9e7296e61c09b8e/src/ReturnedPayment.php#L219-L261
|
27,596
|
OXID-eSales/paymorrow-module
|
core/oxpspaymorrowlogger.php
|
OxpsPaymorrowLogger.log
|
public function log( array $aInfo )
{
/** @var $oPmSettings OxpsPaymorrowSettings */
$oPmSettings = oxNew( 'OxpsPaymorrowSettings' );
return $oPmSettings->isLoggingEnabled()
? $this->_saveToFile( $this->_toConvertToString( $aInfo ) )
: false;
}
|
php
|
public function log( array $aInfo )
{
/** @var $oPmSettings OxpsPaymorrowSettings */
$oPmSettings = oxNew( 'OxpsPaymorrowSettings' );
return $oPmSettings->isLoggingEnabled()
? $this->_saveToFile( $this->_toConvertToString( $aInfo ) )
: false;
}
|
[
"public",
"function",
"log",
"(",
"array",
"$",
"aInfo",
")",
"{",
"/** @var $oPmSettings OxpsPaymorrowSettings */",
"$",
"oPmSettings",
"=",
"oxNew",
"(",
"'OxpsPaymorrowSettings'",
")",
";",
"return",
"$",
"oPmSettings",
"->",
"isLoggingEnabled",
"(",
")",
"?",
"$",
"this",
"->",
"_saveToFile",
"(",
"$",
"this",
"->",
"_toConvertToString",
"(",
"$",
"aInfo",
")",
")",
":",
"false",
";",
"}"
] |
Method that writes the given info to the log.
@param array $aInfo
@return bool|string
|
[
"Method",
"that",
"writes",
"the",
"given",
"info",
"to",
"the",
"log",
"."
] |
adb5d7f50c2fa5b566abd262161c483c42847b42
|
https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L89-L97
|
27,597
|
OXID-eSales/paymorrow-module
|
core/oxpspaymorrowlogger.php
|
OxpsPaymorrowLogger.logWithType
|
public function logWithType( array $aInfo, $sType = '' )
{
$this->setFileName( sprintf( "oxpspaymorrow_%s_data-%s_log.txt", $sType, date( 'Y-m-d' ) ) );
$this->log( $aInfo );
}
|
php
|
public function logWithType( array $aInfo, $sType = '' )
{
$this->setFileName( sprintf( "oxpspaymorrow_%s_data-%s_log.txt", $sType, date( 'Y-m-d' ) ) );
$this->log( $aInfo );
}
|
[
"public",
"function",
"logWithType",
"(",
"array",
"$",
"aInfo",
",",
"$",
"sType",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"setFileName",
"(",
"sprintf",
"(",
"\"oxpspaymorrow_%s_data-%s_log.txt\"",
",",
"$",
"sType",
",",
"date",
"(",
"'Y-m-d'",
")",
")",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"aInfo",
")",
";",
"}"
] |
Logs Paymorrow to file with type and date appended.
@param array $aInfo
@param string $sType
|
[
"Logs",
"Paymorrow",
"to",
"file",
"with",
"type",
"and",
"date",
"appended",
"."
] |
adb5d7f50c2fa5b566abd262161c483c42847b42
|
https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L105-L109
|
27,598
|
OXID-eSales/paymorrow-module
|
core/oxpspaymorrowlogger.php
|
OxpsPaymorrowLogger.getContents
|
public function getContents()
{
$sErrorLogPath = $this->getErrorLogPathWithName();
$sLog = '';
if ( is_file( $sErrorLogPath ) ) {
$fErrorLog = fopen( $sErrorLogPath, "r" );
while ( !feof( $fErrorLog ) ) {
$sLog .= trim( fgets( $fErrorLog, 4096 ) ) . PHP_EOL;
}
fclose( $fErrorLog );
}
return $sLog;
}
|
php
|
public function getContents()
{
$sErrorLogPath = $this->getErrorLogPathWithName();
$sLog = '';
if ( is_file( $sErrorLogPath ) ) {
$fErrorLog = fopen( $sErrorLogPath, "r" );
while ( !feof( $fErrorLog ) ) {
$sLog .= trim( fgets( $fErrorLog, 4096 ) ) . PHP_EOL;
}
fclose( $fErrorLog );
}
return $sLog;
}
|
[
"public",
"function",
"getContents",
"(",
")",
"{",
"$",
"sErrorLogPath",
"=",
"$",
"this",
"->",
"getErrorLogPathWithName",
"(",
")",
";",
"$",
"sLog",
"=",
"''",
";",
"if",
"(",
"is_file",
"(",
"$",
"sErrorLogPath",
")",
")",
"{",
"$",
"fErrorLog",
"=",
"fopen",
"(",
"$",
"sErrorLogPath",
",",
"\"r\"",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"fErrorLog",
")",
")",
"{",
"$",
"sLog",
".=",
"trim",
"(",
"fgets",
"(",
"$",
"fErrorLog",
",",
"4096",
")",
")",
".",
"PHP_EOL",
";",
"}",
"fclose",
"(",
"$",
"fErrorLog",
")",
";",
"}",
"return",
"$",
"sLog",
";",
"}"
] |
Get error log file contents.
@return string
|
[
"Get",
"error",
"log",
"file",
"contents",
"."
] |
adb5d7f50c2fa5b566abd262161c483c42847b42
|
https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L116-L133
|
27,599
|
OXID-eSales/paymorrow-module
|
core/oxpspaymorrowlogger.php
|
OxpsPaymorrowLogger.getAllContents
|
public function getAllContents()
{
$sLog = '';
$sFormat = "----------------------------------------------------------------------\n" .
"%s\n" .
"----------------------------------------------------------------------\n\n" .
"%s\n\n";
$sLogDirectoryPath = $this->getErrorLogPath();
$hDir = @opendir( $sLogDirectoryPath );
if ( !empty( $hDir ) ) {
while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
$sLog .= $this->_getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat );
}
}
return $sLog;
}
|
php
|
public function getAllContents()
{
$sLog = '';
$sFormat = "----------------------------------------------------------------------\n" .
"%s\n" .
"----------------------------------------------------------------------\n\n" .
"%s\n\n";
$sLogDirectoryPath = $this->getErrorLogPath();
$hDir = @opendir( $sLogDirectoryPath );
if ( !empty( $hDir ) ) {
while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
$sLog .= $this->_getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat );
}
}
return $sLog;
}
|
[
"public",
"function",
"getAllContents",
"(",
")",
"{",
"$",
"sLog",
"=",
"''",
";",
"$",
"sFormat",
"=",
"\"----------------------------------------------------------------------\\n\"",
".",
"\"%s\\n\"",
".",
"\"----------------------------------------------------------------------\\n\\n\"",
".",
"\"%s\\n\\n\"",
";",
"$",
"sLogDirectoryPath",
"=",
"$",
"this",
"->",
"getErrorLogPath",
"(",
")",
";",
"$",
"hDir",
"=",
"@",
"opendir",
"(",
"$",
"sLogDirectoryPath",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"hDir",
")",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"sFileName",
"=",
"readdir",
"(",
"$",
"hDir",
")",
")",
")",
"{",
"$",
"sLog",
".=",
"$",
"this",
"->",
"_getFormattedContents",
"(",
"$",
"sLogDirectoryPath",
",",
"$",
"sFileName",
",",
"$",
"sFormat",
")",
";",
"}",
"}",
"return",
"$",
"sLog",
";",
"}"
] |
Get all error log files contents.
@return string
|
[
"Get",
"all",
"error",
"log",
"files",
"contents",
"."
] |
adb5d7f50c2fa5b566abd262161c483c42847b42
|
https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L140-L158
|
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.