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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,500
|
liftkit/document
|
src/Document/Html.php
|
Html.addScript
|
public function addScript ($src, $prepend = false)
{
if ($prepend) {
array_unshift($this->scriptUrls, $src);
} else {
$this->scriptUrls[] = $src;
}
$html = '<script type="text/javascript" src="' . $this->sanitize($src) . '"></script>';
$this->addHeader($html, $prepend);
}
|
php
|
public function addScript ($src, $prepend = false)
{
if ($prepend) {
array_unshift($this->scriptUrls, $src);
} else {
$this->scriptUrls[] = $src;
}
$html = '<script type="text/javascript" src="' . $this->sanitize($src) . '"></script>';
$this->addHeader($html, $prepend);
}
|
[
"public",
"function",
"addScript",
"(",
"$",
"src",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"scriptUrls",
",",
"$",
"src",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"scriptUrls",
"[",
"]",
"=",
"$",
"src",
";",
"}",
"$",
"html",
"=",
"'<script type=\"text/javascript\" src=\"'",
".",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"src",
")",
".",
"'\"></script>'",
";",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"html",
",",
"$",
"prepend",
")",
";",
"}"
] |
addScript function.
Adds scripts to head.
@access public
@param string $src
@param bool $prepend (default: false)
@return void
|
[
"addScript",
"function",
"."
] |
1f6d409c780e42f1c1d177e70039b039e28e2c53
|
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L119-L130
|
235,501
|
liftkit/document
|
src/Document/Html.php
|
Html.addStylesheet
|
public function addStylesheet ($src, $prepend = false)
{
if ($prepend) {
array_unshift($this->stylesheetUrls, $src);
} else {
$this->stylesheetUrls[] = $src;
}
$html = '<link rel="stylesheet" type="text/css" href="' . $this->sanitize($src) . '" />';
$this->addHeader($html, $prepend);
}
|
php
|
public function addStylesheet ($src, $prepend = false)
{
if ($prepend) {
array_unshift($this->stylesheetUrls, $src);
} else {
$this->stylesheetUrls[] = $src;
}
$html = '<link rel="stylesheet" type="text/css" href="' . $this->sanitize($src) . '" />';
$this->addHeader($html, $prepend);
}
|
[
"public",
"function",
"addStylesheet",
"(",
"$",
"src",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"stylesheetUrls",
",",
"$",
"src",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"stylesheetUrls",
"[",
"]",
"=",
"$",
"src",
";",
"}",
"$",
"html",
"=",
"'<link rel=\"stylesheet\" type=\"text/css\" href=\"'",
".",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"src",
")",
".",
"'\" />'",
";",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"html",
",",
"$",
"prepend",
")",
";",
"}"
] |
addStylesheet function.
Addes stylesheets to head.
@access public
@param string $src
@param bool $prepend (default: false)
@return void
|
[
"addStylesheet",
"function",
"."
] |
1f6d409c780e42f1c1d177e70039b039e28e2c53
|
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L145-L156
|
235,502
|
MESD/JasperReportViewerBundle
|
Controller/ReportViewerController.php
|
ReportViewerController.historyAction
|
public function historyAction($reportUri = null) {
//Determine whether to show or hide the report home button
$hideHome = $this->container->get('request')->query->get('hideHome') ?: 'false';
//Render and return
$response = new Response($this->container->get('templating')->render(
'MesdJasperReportViewerBundle:ReportViewer:reportHistory.html.twig', array(
'reportUri' => $reportUri,
'hideHome' => $hideHome
)
)
);
return $response;
}
|
php
|
public function historyAction($reportUri = null) {
//Determine whether to show or hide the report home button
$hideHome = $this->container->get('request')->query->get('hideHome') ?: 'false';
//Render and return
$response = new Response($this->container->get('templating')->render(
'MesdJasperReportViewerBundle:ReportViewer:reportHistory.html.twig', array(
'reportUri' => $reportUri,
'hideHome' => $hideHome
)
)
);
return $response;
}
|
[
"public",
"function",
"historyAction",
"(",
"$",
"reportUri",
"=",
"null",
")",
"{",
"//Determine whether to show or hide the report home button",
"$",
"hideHome",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request'",
")",
"->",
"query",
"->",
"get",
"(",
"'hideHome'",
")",
"?",
":",
"'false'",
";",
"//Render and return",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"render",
"(",
"'MesdJasperReportViewerBundle:ReportViewer:reportHistory.html.twig'",
",",
"array",
"(",
"'reportUri'",
"=>",
"$",
"reportUri",
",",
"'hideHome'",
"=>",
"$",
"hideHome",
")",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Display information and history for a given report
@param string $reportUri The url encoded uri of the report to show info for
@return Response Rendered page
|
[
"Display",
"information",
"and",
"history",
"for",
"a",
"given",
"report"
] |
d51ff079ba79b35c549a7ac472a305d416060d86
|
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L105-L118
|
235,503
|
MESD/JasperReportViewerBundle
|
Controller/ReportViewerController.php
|
ReportViewerController.loadPage
|
protected function loadPage($requestId, $page) {
//Create an array that will be converted into the json response
$response = array('success' => true, 'output' => '');
//Load the report
$rl = $this->container->get('mesd.jasper.report.loader')->getReportLoader();
try {
$report = $rl->getCachedReport($requestId, 'html', array('page' => $page));
} catch(\Exception $e) {
$response['success'] = false;
$response['output'] = 'An error occured trying to load the report';
$response['totalPages'] = 0;
$response['page'] = 0;
}
if ($response['success']) {
$response['success'] = !$report->getError();
$response['output'] = $report->getOutput();
$response['totalPages'] = $report->getTotalPages();
$response['page'] = $report->getPage();
}
//return the response array
return $response;
}
|
php
|
protected function loadPage($requestId, $page) {
//Create an array that will be converted into the json response
$response = array('success' => true, 'output' => '');
//Load the report
$rl = $this->container->get('mesd.jasper.report.loader')->getReportLoader();
try {
$report = $rl->getCachedReport($requestId, 'html', array('page' => $page));
} catch(\Exception $e) {
$response['success'] = false;
$response['output'] = 'An error occured trying to load the report';
$response['totalPages'] = 0;
$response['page'] = 0;
}
if ($response['success']) {
$response['success'] = !$report->getError();
$response['output'] = $report->getOutput();
$response['totalPages'] = $report->getTotalPages();
$response['page'] = $report->getPage();
}
//return the response array
return $response;
}
|
[
"protected",
"function",
"loadPage",
"(",
"$",
"requestId",
",",
"$",
"page",
")",
"{",
"//Create an array that will be converted into the json response",
"$",
"response",
"=",
"array",
"(",
"'success'",
"=>",
"true",
",",
"'output'",
"=>",
"''",
")",
";",
"//Load the report",
"$",
"rl",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.loader'",
")",
"->",
"getReportLoader",
"(",
")",
";",
"try",
"{",
"$",
"report",
"=",
"$",
"rl",
"->",
"getCachedReport",
"(",
"$",
"requestId",
",",
"'html'",
",",
"array",
"(",
"'page'",
"=>",
"$",
"page",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"response",
"[",
"'success'",
"]",
"=",
"false",
";",
"$",
"response",
"[",
"'output'",
"]",
"=",
"'An error occured trying to load the report'",
";",
"$",
"response",
"[",
"'totalPages'",
"]",
"=",
"0",
";",
"$",
"response",
"[",
"'page'",
"]",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"response",
"[",
"'success'",
"]",
")",
"{",
"$",
"response",
"[",
"'success'",
"]",
"=",
"!",
"$",
"report",
"->",
"getError",
"(",
")",
";",
"$",
"response",
"[",
"'output'",
"]",
"=",
"$",
"report",
"->",
"getOutput",
"(",
")",
";",
"$",
"response",
"[",
"'totalPages'",
"]",
"=",
"$",
"report",
"->",
"getTotalPages",
"(",
")",
";",
"$",
"response",
"[",
"'page'",
"]",
"=",
"$",
"report",
"->",
"getPage",
"(",
")",
";",
"}",
"//return the response array",
"return",
"$",
"response",
";",
"}"
] |
Loads a page from the report store
@param string $requestId The request id of the cached report
@param string $page The page number to display
@return array The response array
|
[
"Loads",
"a",
"page",
"from",
"the",
"report",
"store"
] |
d51ff079ba79b35c549a7ac472a305d416060d86
|
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L151-L175
|
235,504
|
MESD/JasperReportViewerBundle
|
Controller/ReportViewerController.php
|
ReportViewerController.executeAction
|
public function executeAction($reportUri, Request $request) {
//Decode the report uri
$decodedReportUri = urldecode($reportUri);
//Get the form again
$form = $this->container->get('mesd.jasper.report.client')->buildReportInputForm(
$decodedReportUri, null, array('data' => $request->request->get('form')));
//Process the form
$form->handleRequest($request);
//If any errors
if (!$form->isValid()) {
//Get form errors
$errors = FormErrorConverter::convertToArray($form);
return new JsonResponse(array('success' => false, 'errors' => $errors));
}
//Build the report
$rb = $this->container->get('mesd.jasper.report.client')->createReportBuilder($decodedReportUri);
$rb->setInputParametersArray($form->getData());
$rb->setFormat('html');
$rb->setPage(1);
//Run the report and get the request id back
$requestId = $rb->runReport();
//Load the first page of the report for the output
$response = $this->loadPage($requestId, 1);
//Setup the links for the toolbar
$response['toolbar'] = $this->container->get('mesd.jasper.reportviewer.linkhelper')->generateToolbarLinks(
$requestId, $response['page'], $response['totalPages']);
//Return the json response
return new JsonResponse($response);
}
|
php
|
public function executeAction($reportUri, Request $request) {
//Decode the report uri
$decodedReportUri = urldecode($reportUri);
//Get the form again
$form = $this->container->get('mesd.jasper.report.client')->buildReportInputForm(
$decodedReportUri, null, array('data' => $request->request->get('form')));
//Process the form
$form->handleRequest($request);
//If any errors
if (!$form->isValid()) {
//Get form errors
$errors = FormErrorConverter::convertToArray($form);
return new JsonResponse(array('success' => false, 'errors' => $errors));
}
//Build the report
$rb = $this->container->get('mesd.jasper.report.client')->createReportBuilder($decodedReportUri);
$rb->setInputParametersArray($form->getData());
$rb->setFormat('html');
$rb->setPage(1);
//Run the report and get the request id back
$requestId = $rb->runReport();
//Load the first page of the report for the output
$response = $this->loadPage($requestId, 1);
//Setup the links for the toolbar
$response['toolbar'] = $this->container->get('mesd.jasper.reportviewer.linkhelper')->generateToolbarLinks(
$requestId, $response['page'], $response['totalPages']);
//Return the json response
return new JsonResponse($response);
}
|
[
"public",
"function",
"executeAction",
"(",
"$",
"reportUri",
",",
"Request",
"$",
"request",
")",
"{",
"//Decode the report uri",
"$",
"decodedReportUri",
"=",
"urldecode",
"(",
"$",
"reportUri",
")",
";",
"//Get the form again",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.client'",
")",
"->",
"buildReportInputForm",
"(",
"$",
"decodedReportUri",
",",
"null",
",",
"array",
"(",
"'data'",
"=>",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'form'",
")",
")",
")",
";",
"//Process the form",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"//If any errors",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"//Get form errors",
"$",
"errors",
"=",
"FormErrorConverter",
"::",
"convertToArray",
"(",
"$",
"form",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'success'",
"=>",
"false",
",",
"'errors'",
"=>",
"$",
"errors",
")",
")",
";",
"}",
"//Build the report",
"$",
"rb",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.client'",
")",
"->",
"createReportBuilder",
"(",
"$",
"decodedReportUri",
")",
";",
"$",
"rb",
"->",
"setInputParametersArray",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
";",
"$",
"rb",
"->",
"setFormat",
"(",
"'html'",
")",
";",
"$",
"rb",
"->",
"setPage",
"(",
"1",
")",
";",
"//Run the report and get the request id back",
"$",
"requestId",
"=",
"$",
"rb",
"->",
"runReport",
"(",
")",
";",
"//Load the first page of the report for the output",
"$",
"response",
"=",
"$",
"this",
"->",
"loadPage",
"(",
"$",
"requestId",
",",
"1",
")",
";",
"//Setup the links for the toolbar",
"$",
"response",
"[",
"'toolbar'",
"]",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.reportviewer.linkhelper'",
")",
"->",
"generateToolbarLinks",
"(",
"$",
"requestId",
",",
"$",
"response",
"[",
"'page'",
"]",
",",
"$",
"response",
"[",
"'totalPages'",
"]",
")",
";",
"//Return the json response",
"return",
"new",
"JsonResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Runs a report
@param string $reportUri The jasper server uri for the report
@param Request $request The request from the submitted request input form
@return JsonResponse Json Response giving links to the output or what errors occured
|
[
"Runs",
"a",
"report"
] |
d51ff079ba79b35c549a7ac472a305d416060d86
|
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L186-L221
|
235,505
|
MESD/JasperReportViewerBundle
|
Controller/ReportViewerController.php
|
ReportViewerController.listJsonAction
|
public function listJsonAction() {
//Get the folder
$folderUri = $this->container->get('request')->query->get('id');
//Set folder uri to null to use the default if the root is requested ('#')
if ('#' === $folderUri) {
$folder = null;
} else {
$folder = $folderUri;
}
//Get the resource descriptors (not recursively)
$resources = $this->container->get('mesd.jasper.report.client')->getResourceList($folder, false);
//Convert the resources into an array to encode in json in the way jstree can read them
$response = array();
foreach($resources as $resource) {
$data = array();
$data['id'] = $resource->getUriString();
$data['parent'] = $folderUri;
$data['icon'] = false;
if ('reportUnit' === $resource->getWsType()) {
//Report object specific settings
$data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-file"></i> ' . $resource->getLabel();
$data['children'] = false;
//Set the href to the report input form
$data['a_attr'] = array('href' => $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_report_viewer', array('reportUri' => rawurlencode($resource->getUriString()))));
$data['dump'] = $resource->getUriString();
} elseif ('folder' === $resource->getWsType()) {
//Folder object specific settings
$data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-folder-close"></i> ' . $resource->getLabel();
$data['children'] = true;
}
$response[] = $data;
}
//Get the resources
return new JsonResponse($response);
}
|
php
|
public function listJsonAction() {
//Get the folder
$folderUri = $this->container->get('request')->query->get('id');
//Set folder uri to null to use the default if the root is requested ('#')
if ('#' === $folderUri) {
$folder = null;
} else {
$folder = $folderUri;
}
//Get the resource descriptors (not recursively)
$resources = $this->container->get('mesd.jasper.report.client')->getResourceList($folder, false);
//Convert the resources into an array to encode in json in the way jstree can read them
$response = array();
foreach($resources as $resource) {
$data = array();
$data['id'] = $resource->getUriString();
$data['parent'] = $folderUri;
$data['icon'] = false;
if ('reportUnit' === $resource->getWsType()) {
//Report object specific settings
$data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-file"></i> ' . $resource->getLabel();
$data['children'] = false;
//Set the href to the report input form
$data['a_attr'] = array('href' => $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_report_viewer', array('reportUri' => rawurlencode($resource->getUriString()))));
$data['dump'] = $resource->getUriString();
} elseif ('folder' === $resource->getWsType()) {
//Folder object specific settings
$data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-folder-close"></i> ' . $resource->getLabel();
$data['children'] = true;
}
$response[] = $data;
}
//Get the resources
return new JsonResponse($response);
}
|
[
"public",
"function",
"listJsonAction",
"(",
")",
"{",
"//Get the folder",
"$",
"folderUri",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request'",
")",
"->",
"query",
"->",
"get",
"(",
"'id'",
")",
";",
"//Set folder uri to null to use the default if the root is requested ('#')",
"if",
"(",
"'#'",
"===",
"$",
"folderUri",
")",
"{",
"$",
"folder",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"folder",
"=",
"$",
"folderUri",
";",
"}",
"//Get the resource descriptors (not recursively)",
"$",
"resources",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.client'",
")",
"->",
"getResourceList",
"(",
"$",
"folder",
",",
"false",
")",
";",
"//Convert the resources into an array to encode in json in the way jstree can read them",
"$",
"response",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"resource",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"resource",
"->",
"getUriString",
"(",
")",
";",
"$",
"data",
"[",
"'parent'",
"]",
"=",
"$",
"folderUri",
";",
"$",
"data",
"[",
"'icon'",
"]",
"=",
"false",
";",
"if",
"(",
"'reportUnit'",
"===",
"$",
"resource",
"->",
"getWsType",
"(",
")",
")",
"{",
"//Report object specific settings",
"$",
"data",
"[",
"'text'",
"]",
"=",
"'<i id=\"'",
".",
"$",
"data",
"[",
"'id'",
"]",
".",
"'-icon\" class=\"icon-file\"></i> '",
".",
"$",
"resource",
"->",
"getLabel",
"(",
")",
";",
"$",
"data",
"[",
"'children'",
"]",
"=",
"false",
";",
"//Set the href to the report input form",
"$",
"data",
"[",
"'a_attr'",
"]",
"=",
"array",
"(",
"'href'",
"=>",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'MesdJasperReportViewerBundle_display_report_viewer'",
",",
"array",
"(",
"'reportUri'",
"=>",
"rawurlencode",
"(",
"$",
"resource",
"->",
"getUriString",
"(",
")",
")",
")",
")",
")",
";",
"$",
"data",
"[",
"'dump'",
"]",
"=",
"$",
"resource",
"->",
"getUriString",
"(",
")",
";",
"}",
"elseif",
"(",
"'folder'",
"===",
"$",
"resource",
"->",
"getWsType",
"(",
")",
")",
"{",
"//Folder object specific settings",
"$",
"data",
"[",
"'text'",
"]",
"=",
"'<i id=\"'",
".",
"$",
"data",
"[",
"'id'",
"]",
".",
"'-icon\" class=\"icon-folder-close\"></i> '",
".",
"$",
"resource",
"->",
"getLabel",
"(",
")",
";",
"$",
"data",
"[",
"'children'",
"]",
"=",
"true",
";",
"}",
"$",
"response",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"//Get the resources",
"return",
"new",
"JsonResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Gets the resources contained in the requested folder
Folder name comes in via a query string parameter ('#' to use the default)
@return JsonResponse The Json Object of the returned resources
|
[
"Gets",
"the",
"resources",
"contained",
"in",
"the",
"requested",
"folder"
] |
d51ff079ba79b35c549a7ac472a305d416060d86
|
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L231-L271
|
235,506
|
MESD/JasperReportViewerBundle
|
Controller/ReportViewerController.php
|
ReportViewerController.reportHistoryJsonAction
|
public function reportHistoryJsonAction($reportUri = null) {
//Get the sent parameters from datatables
$limit = $this->container->get('request')->query->get('length');
$offset = $this->container->get('request')->query->get('start');
//Create a new repsonse array that will be converted to json
$response = array();
//Get the history for the given report from the report history
$records = $this->container->get('mesd.jasper.report.history')->getReportHistoryDisplay(
urldecode($reportUri), true, array('limit' => $limit, 'offset' => $offset));
if ($reportUri) {
//Get the count of records
$count = $this->container->get('mesd.jasper.report.history')->loadHistoryForReport(
urldecode($reportUri), true, array('count' => true));
} else {
//Get the count of records
$count = $this->container->get('mesd.jasper.report.history')->loadRecentHistory(
true, array('count' => true));
}
$response['recordsTotal'] = $count;
$response['recordsFiltered'] = $count;
//Convert the records to an array
$response['data'] = array();
foreach($records as $record) {
//Create the links
$links = array();
foreach(json_decode($record['formats']) as $format) {
//If html handle it differently, else export like usual
if ('html' === $format) {
$href = $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_history_report_viewer', array(
'reportUri' => urlencode($record['report']),
'existing' => $record['requestId']
)
);
} else {
$href = $this->container->get('router')->generate('MesdJasperReportBundle_export_cached_report', array(
'requestId' => $record['requestId'],
'format' => $format
)
);
}
$links[] = '<a href="' . $href . '">' . $format . '</a>';
}
//Convert to the format that datatables can read
$response['data'][] = array(
$record['report'],
$record['date']->format('Y-m-d H:i:s'),
$record['parameters'],
implode(' ', $links)
);
}
//Send back the Json
return new JsonResponse($response);
}
|
php
|
public function reportHistoryJsonAction($reportUri = null) {
//Get the sent parameters from datatables
$limit = $this->container->get('request')->query->get('length');
$offset = $this->container->get('request')->query->get('start');
//Create a new repsonse array that will be converted to json
$response = array();
//Get the history for the given report from the report history
$records = $this->container->get('mesd.jasper.report.history')->getReportHistoryDisplay(
urldecode($reportUri), true, array('limit' => $limit, 'offset' => $offset));
if ($reportUri) {
//Get the count of records
$count = $this->container->get('mesd.jasper.report.history')->loadHistoryForReport(
urldecode($reportUri), true, array('count' => true));
} else {
//Get the count of records
$count = $this->container->get('mesd.jasper.report.history')->loadRecentHistory(
true, array('count' => true));
}
$response['recordsTotal'] = $count;
$response['recordsFiltered'] = $count;
//Convert the records to an array
$response['data'] = array();
foreach($records as $record) {
//Create the links
$links = array();
foreach(json_decode($record['formats']) as $format) {
//If html handle it differently, else export like usual
if ('html' === $format) {
$href = $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_history_report_viewer', array(
'reportUri' => urlencode($record['report']),
'existing' => $record['requestId']
)
);
} else {
$href = $this->container->get('router')->generate('MesdJasperReportBundle_export_cached_report', array(
'requestId' => $record['requestId'],
'format' => $format
)
);
}
$links[] = '<a href="' . $href . '">' . $format . '</a>';
}
//Convert to the format that datatables can read
$response['data'][] = array(
$record['report'],
$record['date']->format('Y-m-d H:i:s'),
$record['parameters'],
implode(' ', $links)
);
}
//Send back the Json
return new JsonResponse($response);
}
|
[
"public",
"function",
"reportHistoryJsonAction",
"(",
"$",
"reportUri",
"=",
"null",
")",
"{",
"//Get the sent parameters from datatables",
"$",
"limit",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request'",
")",
"->",
"query",
"->",
"get",
"(",
"'length'",
")",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request'",
")",
"->",
"query",
"->",
"get",
"(",
"'start'",
")",
";",
"//Create a new repsonse array that will be converted to json",
"$",
"response",
"=",
"array",
"(",
")",
";",
"//Get the history for the given report from the report history",
"$",
"records",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.history'",
")",
"->",
"getReportHistoryDisplay",
"(",
"urldecode",
"(",
"$",
"reportUri",
")",
",",
"true",
",",
"array",
"(",
"'limit'",
"=>",
"$",
"limit",
",",
"'offset'",
"=>",
"$",
"offset",
")",
")",
";",
"if",
"(",
"$",
"reportUri",
")",
"{",
"//Get the count of records",
"$",
"count",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.history'",
")",
"->",
"loadHistoryForReport",
"(",
"urldecode",
"(",
"$",
"reportUri",
")",
",",
"true",
",",
"array",
"(",
"'count'",
"=>",
"true",
")",
")",
";",
"}",
"else",
"{",
"//Get the count of records",
"$",
"count",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mesd.jasper.report.history'",
")",
"->",
"loadRecentHistory",
"(",
"true",
",",
"array",
"(",
"'count'",
"=>",
"true",
")",
")",
";",
"}",
"$",
"response",
"[",
"'recordsTotal'",
"]",
"=",
"$",
"count",
";",
"$",
"response",
"[",
"'recordsFiltered'",
"]",
"=",
"$",
"count",
";",
"//Convert the records to an array",
"$",
"response",
"[",
"'data'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"//Create the links",
"$",
"links",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"json_decode",
"(",
"$",
"record",
"[",
"'formats'",
"]",
")",
"as",
"$",
"format",
")",
"{",
"//If html handle it differently, else export like usual",
"if",
"(",
"'html'",
"===",
"$",
"format",
")",
"{",
"$",
"href",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'MesdJasperReportViewerBundle_display_history_report_viewer'",
",",
"array",
"(",
"'reportUri'",
"=>",
"urlencode",
"(",
"$",
"record",
"[",
"'report'",
"]",
")",
",",
"'existing'",
"=>",
"$",
"record",
"[",
"'requestId'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"href",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'MesdJasperReportBundle_export_cached_report'",
",",
"array",
"(",
"'requestId'",
"=>",
"$",
"record",
"[",
"'requestId'",
"]",
",",
"'format'",
"=>",
"$",
"format",
")",
")",
";",
"}",
"$",
"links",
"[",
"]",
"=",
"'<a href=\"'",
".",
"$",
"href",
".",
"'\">'",
".",
"$",
"format",
".",
"'</a>'",
";",
"}",
"//Convert to the format that datatables can read",
"$",
"response",
"[",
"'data'",
"]",
"[",
"]",
"=",
"array",
"(",
"$",
"record",
"[",
"'report'",
"]",
",",
"$",
"record",
"[",
"'date'",
"]",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
",",
"$",
"record",
"[",
"'parameters'",
"]",
",",
"implode",
"(",
"' '",
",",
"$",
"links",
")",
")",
";",
"}",
"//Send back the Json",
"return",
"new",
"JsonResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Returns the json of a
@param string $reportUri Url encoded report uri
@return Response The json representation of this reports history table
|
[
"Returns",
"the",
"json",
"of",
"a"
] |
d51ff079ba79b35c549a7ac472a305d416060d86
|
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L281-L340
|
235,507
|
FiveLab/ResourceBundle
|
src/EventListener/ValidateResourceListener.php
|
ValidateResourceListener.onKernelControllerArguments
|
public function onKernelControllerArguments(FilterControllerArgumentsEvent $event): void
{
$arguments = $event->getArguments();
foreach ($arguments as $argument) {
if ($argument instanceof ResourceInterface) {
$violationList = $this->validator->validate($argument);
if (count($violationList)) {
throw ViolationListException::create($violationList);
}
}
}
}
|
php
|
public function onKernelControllerArguments(FilterControllerArgumentsEvent $event): void
{
$arguments = $event->getArguments();
foreach ($arguments as $argument) {
if ($argument instanceof ResourceInterface) {
$violationList = $this->validator->validate($argument);
if (count($violationList)) {
throw ViolationListException::create($violationList);
}
}
}
}
|
[
"public",
"function",
"onKernelControllerArguments",
"(",
"FilterControllerArgumentsEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"arguments",
"=",
"$",
"event",
"->",
"getArguments",
"(",
")",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"argument",
")",
"{",
"if",
"(",
"$",
"argument",
"instanceof",
"ResourceInterface",
")",
"{",
"$",
"violationList",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"argument",
")",
";",
"if",
"(",
"count",
"(",
"$",
"violationList",
")",
")",
"{",
"throw",
"ViolationListException",
"::",
"create",
"(",
"$",
"violationList",
")",
";",
"}",
"}",
"}",
"}"
] |
Listen kernel.controller_arguments event for validate input resources
@param FilterControllerArgumentsEvent $event
@throws ViolationListException
|
[
"Listen",
"kernel",
".",
"controller_arguments",
"event",
"for",
"validate",
"input",
"resources"
] |
048fce7be5357dc23fef1402ef8ca213489e8154
|
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/EventListener/ValidateResourceListener.php#L50-L63
|
235,508
|
metashock/Jm_Autoloader
|
lib/php/Jm/Autoloader.php
|
Jm_Autoloader.addPath
|
public function addPath($path, $namespace = '', $prepend = FALSE) {
if ($prepend === TRUE) {
return $this->prependPath($path, $namespace);
} else {
if (!empty($namespace)) {
$path = array (
$path, str_replace('_', '/', $namespace)
);
}
$this->paths []= $path;
}
return $this;
}
|
php
|
public function addPath($path, $namespace = '', $prepend = FALSE) {
if ($prepend === TRUE) {
return $this->prependPath($path, $namespace);
} else {
if (!empty($namespace)) {
$path = array (
$path, str_replace('_', '/', $namespace)
);
}
$this->paths []= $path;
}
return $this;
}
|
[
"public",
"function",
"addPath",
"(",
"$",
"path",
",",
"$",
"namespace",
"=",
"''",
",",
"$",
"prepend",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"prepend",
"===",
"TRUE",
")",
"{",
"return",
"$",
"this",
"->",
"prependPath",
"(",
"$",
"path",
",",
"$",
"namespace",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"path",
"=",
"array",
"(",
"$",
"path",
",",
"str_replace",
"(",
"'_'",
",",
"'/'",
",",
"$",
"namespace",
")",
")",
";",
"}",
"$",
"this",
"->",
"paths",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds a path to the search path array
@param string $path A classpath
@param string $namespace The root namespace of $path. If not empty or
omitted Jm_Autoloader expects that classes in
the path are named like $namespace_Class_Name
@param boolean $prepend If set to true the path will be prepended
instead of being appended. defaults to false
@return Jm_Autoloader
|
[
"Adds",
"a",
"path",
"to",
"the",
"search",
"path",
"array"
] |
0173dcef12a7f988985518685407ed33ede149a9
|
https://github.com/metashock/Jm_Autoloader/blob/0173dcef12a7f988985518685407ed33ede149a9/lib/php/Jm/Autoloader.php#L126-L138
|
235,509
|
bishopb/vanilla
|
library/core/class.router.php
|
Gdn_Router.SetRoute
|
public function SetRoute($Route, $Destination, $Type, $Save = TRUE) {
$Key = $this->_EncodeRouteKey($Route);
SaveToConfig('Routes.'.$Key, array($Destination, $Type), $Save);
$this->_LoadRoutes();
}
|
php
|
public function SetRoute($Route, $Destination, $Type, $Save = TRUE) {
$Key = $this->_EncodeRouteKey($Route);
SaveToConfig('Routes.'.$Key, array($Destination, $Type), $Save);
$this->_LoadRoutes();
}
|
[
"public",
"function",
"SetRoute",
"(",
"$",
"Route",
",",
"$",
"Destination",
",",
"$",
"Type",
",",
"$",
"Save",
"=",
"TRUE",
")",
"{",
"$",
"Key",
"=",
"$",
"this",
"->",
"_EncodeRouteKey",
"(",
"$",
"Route",
")",
";",
"SaveToConfig",
"(",
"'Routes.'",
".",
"$",
"Key",
",",
"array",
"(",
"$",
"Destination",
",",
"$",
"Type",
")",
",",
"$",
"Save",
")",
";",
"$",
"this",
"->",
"_LoadRoutes",
"(",
")",
";",
"}"
] |
Update or add a route to the config table
@param string $Route
@param string $Destination
@param string $Type
@param bool $Save Optional. Save this to the config or just in memory?
|
[
"Update",
"or",
"add",
"a",
"route",
"to",
"the",
"config",
"table"
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.router.php#L75-L79
|
235,510
|
wasabi-cms/cms
|
src/Model/Table/PagesTable.php
|
PagesTable.getForFrontend
|
public function getForFrontend($pageId)
{
return $this->find()
->contain(['Current', 'Attributes'])
->formatResults([$this, 'formatAttributes'])
->where([$this->aliasField('id') => $pageId])
->first();
}
|
php
|
public function getForFrontend($pageId)
{
return $this->find()
->contain(['Current', 'Attributes'])
->formatResults([$this, 'formatAttributes'])
->where([$this->aliasField('id') => $pageId])
->first();
}
|
[
"public",
"function",
"getForFrontend",
"(",
"$",
"pageId",
")",
"{",
"return",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"contain",
"(",
"[",
"'Current'",
",",
"'Attributes'",
"]",
")",
"->",
"formatResults",
"(",
"[",
"$",
"this",
",",
"'formatAttributes'",
"]",
")",
"->",
"where",
"(",
"[",
"$",
"this",
"->",
"aliasField",
"(",
"'id'",
")",
"=>",
"$",
"pageId",
"]",
")",
"->",
"first",
"(",
")",
";",
"}"
] |
Find a single page including content and attributes for output in the frontend.
@param int $pageId The page id.
@return Page|null
|
[
"Find",
"a",
"single",
"page",
"including",
"content",
"and",
"attributes",
"for",
"output",
"in",
"the",
"frontend",
"."
] |
2787b6422ea1d719cf49951b3253fd0ac31d22ca
|
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Model/Table/PagesTable.php#L181-L188
|
235,511
|
znframework/package-security
|
Injection.php
|
Injection.encode
|
public static function encode(String $string) : String
{
$secBadChars = Properties::$injectionBadChars;
if( ! empty($secBadChars) )
{
foreach( $secBadChars as $badChar => $changeChar )
{
if( is_numeric($badChar) )
{
$badChar = $changeChar;
$changeChar = '';
}
$badChar = trim($badChar, '/');
$string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
}
}
return addslashes(trim($string));
}
|
php
|
public static function encode(String $string) : String
{
$secBadChars = Properties::$injectionBadChars;
if( ! empty($secBadChars) )
{
foreach( $secBadChars as $badChar => $changeChar )
{
if( is_numeric($badChar) )
{
$badChar = $changeChar;
$changeChar = '';
}
$badChar = trim($badChar, '/');
$string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
}
}
return addslashes(trim($string));
}
|
[
"public",
"static",
"function",
"encode",
"(",
"String",
"$",
"string",
")",
":",
"String",
"{",
"$",
"secBadChars",
"=",
"Properties",
"::",
"$",
"injectionBadChars",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"secBadChars",
")",
")",
"{",
"foreach",
"(",
"$",
"secBadChars",
"as",
"$",
"badChar",
"=>",
"$",
"changeChar",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"badChar",
")",
")",
"{",
"$",
"badChar",
"=",
"$",
"changeChar",
";",
"$",
"changeChar",
"=",
"''",
";",
"}",
"$",
"badChar",
"=",
"trim",
"(",
"$",
"badChar",
",",
"'/'",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/'",
".",
"$",
"badChar",
".",
"'/xi'",
",",
"$",
"changeChar",
",",
"$",
"string",
")",
";",
"}",
"}",
"return",
"addslashes",
"(",
"trim",
"(",
"$",
"string",
")",
")",
";",
"}"
] |
Encode Injection Chars
@param string $string
@return string
|
[
"Encode",
"Injection",
"Chars"
] |
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
|
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Injection.php#L32-L52
|
235,512
|
znframework/package-security
|
Injection.php
|
Injection.nailEncode
|
public static function nailEncode(String $str) : String
{
$str = str_replace(array_keys(self::$nailChars), array_values(self::$nailChars), $str);
return $str;
}
|
php
|
public static function nailEncode(String $str) : String
{
$str = str_replace(array_keys(self::$nailChars), array_values(self::$nailChars), $str);
return $str;
}
|
[
"public",
"static",
"function",
"nailEncode",
"(",
"String",
"$",
"str",
")",
":",
"String",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"nailChars",
")",
",",
"array_values",
"(",
"self",
"::",
"$",
"nailChars",
")",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Encode Nail Chars
@param string $string
@return string
|
[
"Encode",
"Nail",
"Chars"
] |
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
|
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Injection.php#L73-L78
|
235,513
|
znframework/package-security
|
Injection.php
|
Injection.nailDecode
|
public static function nailDecode(String $str) : String
{
$str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str);
return $str;
}
|
php
|
public static function nailDecode(String $str) : String
{
$str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str);
return $str;
}
|
[
"public",
"static",
"function",
"nailDecode",
"(",
"String",
"$",
"str",
")",
":",
"String",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"array_values",
"(",
"self",
"::",
"$",
"nailChars",
")",
",",
"array_keys",
"(",
"self",
"::",
"$",
"nailChars",
")",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Decode Nail Chars
@param string $string
@return string
|
[
"Decode",
"Nail",
"Chars"
] |
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
|
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Injection.php#L87-L92
|
235,514
|
webriq/core
|
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
|
Mapper.parseProxyData
|
protected function parseProxyData( & $data )
{
if ( empty( $data ) )
{
return array();
}
$result = array();
foreach ( json_decode( $data, true ) as $field )
{
if ( empty( $field['name'] ) )
{
continue;
}
$name = (string) $field['name'];
$parts = explode( '.', $name, 2 );
$value = isset( $field['value'] ) ? $field['value'] : null;
if ( count( $parts ) > 1 )
{
list( $name, $sub ) = $parts;
if ( isset( $result[$name] ) )
{
if ( ! is_array( $result[$name] ) )
{
$result[$name] = (array) $result[$name];
}
}
else
{
$result[$name] = array();
}
$result[$name][$sub] = $value;
}
else
{
$result[$name] = $value;
}
}
foreach ( $result as & $value )
{
if ( is_array( $value ) )
{
uksort( $value, 'strnatcmp' );
}
}
return $result;
}
|
php
|
protected function parseProxyData( & $data )
{
if ( empty( $data ) )
{
return array();
}
$result = array();
foreach ( json_decode( $data, true ) as $field )
{
if ( empty( $field['name'] ) )
{
continue;
}
$name = (string) $field['name'];
$parts = explode( '.', $name, 2 );
$value = isset( $field['value'] ) ? $field['value'] : null;
if ( count( $parts ) > 1 )
{
list( $name, $sub ) = $parts;
if ( isset( $result[$name] ) )
{
if ( ! is_array( $result[$name] ) )
{
$result[$name] = (array) $result[$name];
}
}
else
{
$result[$name] = array();
}
$result[$name][$sub] = $value;
}
else
{
$result[$name] = $value;
}
}
foreach ( $result as & $value )
{
if ( is_array( $value ) )
{
uksort( $value, 'strnatcmp' );
}
}
return $result;
}
|
[
"protected",
"function",
"parseProxyData",
"(",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"field",
"[",
"'name'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"name",
"=",
"(",
"string",
")",
"$",
"field",
"[",
"'name'",
"]",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
",",
"2",
")",
";",
"$",
"value",
"=",
"isset",
"(",
"$",
"field",
"[",
"'value'",
"]",
")",
"?",
"$",
"field",
"[",
"'value'",
"]",
":",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"1",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"sub",
")",
"=",
"$",
"parts",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"(",
"array",
")",
"$",
"result",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"result",
"[",
"$",
"name",
"]",
"[",
"$",
"sub",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"foreach",
"(",
"$",
"result",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"uksort",
"(",
"$",
"value",
",",
"'strnatcmp'",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Parse proxy-data
Like:
<pre>
<struct>
[{"name":"{key}","value":"{value}"}]
...
</struct>
</pre>
@param string $data
@return array
|
[
"Parse",
"proxy",
"-",
"data"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L367-L419
|
235,515
|
webriq/core
|
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
|
Mapper.findRenderList
|
public function findRenderList( $id = null )
{
$platform = $this->getDbAdapter()
->getPlatform();
$columns = $this->getSelectColumns();
$columns['_depth'] = new Sql\Expression( '(' .
$this->sql( null )
->select( array( 'parent' => static::$tableName ) )
->columns( array(
new Sql\Expression( 'COUNT(*)' )
) )
->where( array(
new Sql\Predicate\Expression(
$platform->quoteIdentifierChain( array( static::$tableName, 'left' ) ) .
' BETWEEN ' . $platform->quoteIdentifierChain( array( 'parent', 'left' ) ) .
' AND ' . $platform->quoteIdentifierChain( array( 'parent', 'right' ) )
),
) )
->getSqlString( $platform ) .
')' );
$select = $this->select( $columns )
->order( 'left' );
if ( null !== $id )
{
$select->join( array( 'parent' => self::$tableName ),
'( ' . self::$tableName . '.left BETWEEN parent.left AND parent.right ) ',
array() )
->where( array( 'parent.id' => $id ) );
}
/* @var $result \Zend\Db\Adapter\Driver\ResultInterface */
$return = array();
$result = $this->sql()
->prepareStatementForSqlObject( $select )
->execute();
foreach ( $result as $row )
{
$depth = (int) $row['_depth'];
unset( $row['_depth'] );
$return[] = array( $depth, $this->selected( $row ) );
}
return $return;
}
|
php
|
public function findRenderList( $id = null )
{
$platform = $this->getDbAdapter()
->getPlatform();
$columns = $this->getSelectColumns();
$columns['_depth'] = new Sql\Expression( '(' .
$this->sql( null )
->select( array( 'parent' => static::$tableName ) )
->columns( array(
new Sql\Expression( 'COUNT(*)' )
) )
->where( array(
new Sql\Predicate\Expression(
$platform->quoteIdentifierChain( array( static::$tableName, 'left' ) ) .
' BETWEEN ' . $platform->quoteIdentifierChain( array( 'parent', 'left' ) ) .
' AND ' . $platform->quoteIdentifierChain( array( 'parent', 'right' ) )
),
) )
->getSqlString( $platform ) .
')' );
$select = $this->select( $columns )
->order( 'left' );
if ( null !== $id )
{
$select->join( array( 'parent' => self::$tableName ),
'( ' . self::$tableName . '.left BETWEEN parent.left AND parent.right ) ',
array() )
->where( array( 'parent.id' => $id ) );
}
/* @var $result \Zend\Db\Adapter\Driver\ResultInterface */
$return = array();
$result = $this->sql()
->prepareStatementForSqlObject( $select )
->execute();
foreach ( $result as $row )
{
$depth = (int) $row['_depth'];
unset( $row['_depth'] );
$return[] = array( $depth, $this->selected( $row ) );
}
return $return;
}
|
[
"public",
"function",
"findRenderList",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"platform",
"=",
"$",
"this",
"->",
"getDbAdapter",
"(",
")",
"->",
"getPlatform",
"(",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"getSelectColumns",
"(",
")",
";",
"$",
"columns",
"[",
"'_depth'",
"]",
"=",
"new",
"Sql",
"\\",
"Expression",
"(",
"'('",
".",
"$",
"this",
"->",
"sql",
"(",
"null",
")",
"->",
"select",
"(",
"array",
"(",
"'parent'",
"=>",
"static",
"::",
"$",
"tableName",
")",
")",
"->",
"columns",
"(",
"array",
"(",
"new",
"Sql",
"\\",
"Expression",
"(",
"'COUNT(*)'",
")",
")",
")",
"->",
"where",
"(",
"array",
"(",
"new",
"Sql",
"\\",
"Predicate",
"\\",
"Expression",
"(",
"$",
"platform",
"->",
"quoteIdentifierChain",
"(",
"array",
"(",
"static",
"::",
"$",
"tableName",
",",
"'left'",
")",
")",
".",
"' BETWEEN '",
".",
"$",
"platform",
"->",
"quoteIdentifierChain",
"(",
"array",
"(",
"'parent'",
",",
"'left'",
")",
")",
".",
"' AND '",
".",
"$",
"platform",
"->",
"quoteIdentifierChain",
"(",
"array",
"(",
"'parent'",
",",
"'right'",
")",
")",
")",
",",
")",
")",
"->",
"getSqlString",
"(",
"$",
"platform",
")",
".",
"')'",
")",
";",
"$",
"select",
"=",
"$",
"this",
"->",
"select",
"(",
"$",
"columns",
")",
"->",
"order",
"(",
"'left'",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"id",
")",
"{",
"$",
"select",
"->",
"join",
"(",
"array",
"(",
"'parent'",
"=>",
"self",
"::",
"$",
"tableName",
")",
",",
"'( '",
".",
"self",
"::",
"$",
"tableName",
".",
"'.left BETWEEN parent.left AND parent.right ) '",
",",
"array",
"(",
")",
")",
"->",
"where",
"(",
"array",
"(",
"'parent.id'",
"=>",
"$",
"id",
")",
")",
";",
"}",
"/* @var $result \\Zend\\Db\\Adapter\\Driver\\ResultInterface */",
"$",
"return",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"sql",
"(",
")",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"select",
")",
"->",
"execute",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"$",
"depth",
"=",
"(",
"int",
")",
"$",
"row",
"[",
"'_depth'",
"]",
";",
"unset",
"(",
"$",
"row",
"[",
"'_depth'",
"]",
")",
";",
"$",
"return",
"[",
"]",
"=",
"array",
"(",
"$",
"depth",
",",
"$",
"this",
"->",
"selected",
"(",
"$",
"row",
")",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Find render-list
@param int|null $id
@return \Menu\Model\Menu\StructureInterface[]
|
[
"Find",
"render",
"-",
"list"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L455-L503
|
235,516
|
webriq/core
|
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
|
Mapper.saveSingleProperty
|
private function saveSingleProperty( $id, $name, $value )
{
$sql = $this->sql( $this->getTableInSchema(
static::$propertyTableName
) );
$update = $sql->update()
->set( array(
'value' => $value,
) )
->where( array(
'menuId' => $id,
'name' => $name,
) );
$affected = $sql->prepareStatementForSqlObject( $update )
->execute()
->getAffectedRows();
if ( $affected < 1 )
{
$insert = $sql->insert()
->values( array(
'menuId' => $id,
'name' => $name,
'value' => $value,
) );
$affected = $sql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
}
return $affected;
}
|
php
|
private function saveSingleProperty( $id, $name, $value )
{
$sql = $this->sql( $this->getTableInSchema(
static::$propertyTableName
) );
$update = $sql->update()
->set( array(
'value' => $value,
) )
->where( array(
'menuId' => $id,
'name' => $name,
) );
$affected = $sql->prepareStatementForSqlObject( $update )
->execute()
->getAffectedRows();
if ( $affected < 1 )
{
$insert = $sql->insert()
->values( array(
'menuId' => $id,
'name' => $name,
'value' => $value,
) );
$affected = $sql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
}
return $affected;
}
|
[
"private",
"function",
"saveSingleProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"getTableInSchema",
"(",
"static",
"::",
"$",
"propertyTableName",
")",
")",
";",
"$",
"update",
"=",
"$",
"sql",
"->",
"update",
"(",
")",
"->",
"set",
"(",
"array",
"(",
"'value'",
"=>",
"$",
"value",
",",
")",
")",
"->",
"where",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"name",
",",
")",
")",
";",
"$",
"affected",
"=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"update",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"if",
"(",
"$",
"affected",
"<",
"1",
")",
"{",
"$",
"insert",
"=",
"$",
"sql",
"->",
"insert",
"(",
")",
"->",
"values",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"name",
",",
"'value'",
"=>",
"$",
"value",
",",
")",
")",
";",
"$",
"affected",
"=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"insert",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"}",
"return",
"$",
"affected",
";",
"}"
] |
Save a single property
@param int $id
@param string $name
@param mixed $value
@return int
|
[
"Save",
"a",
"single",
"property"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L513-L547
|
235,517
|
webriq/core
|
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
|
Mapper.saveProperty
|
protected function saveProperty( $id, $name, $value )
{
$rows = 0;
$sql = $this->sql( $this->getTableInSchema(
static::$propertyTableName
) );
$like = strtr( $name, array(
'\\' => '\\\\',
'%' => '\%',
'_' => '\_',
) ) . '.%';
if ( is_array( $value ) )
{
$nameLikeOrEq = new Sql\Predicate\PredicateSet( array(
new Sql\Predicate\Like( 'name', $like ),
new Sql\Predicate\Operator( 'name', Sql\Predicate\Operator::OP_EQ, $name )
), Sql\Predicate\PredicateSet::OP_OR );
if ( empty( $value ) )
{
$delete = $sql->delete()
->where( array(
'menuId' => $id,
$nameLikeOrEq,
) );
$rows += $sql->prepareStatementForSqlObject( $delete )
->execute()
->getAffectedRows();
}
else
{
$keys = array();
foreach ( $value as $idx => $val )
{
$keys[] = $key = $name . '.' . $idx;
$rows += $this->saveSingleProperty( $id, $key, $val );
}
$delete = $sql->delete()
->where( array(
'menuId' => $id,
$nameLikeOrEq,
new NotIn( 'name', $keys ),
) );
$rows += $sql->prepareStatementForSqlObject( $delete )
->execute()
->getAffectedRows();
}
}
else
{
$rows += $this->saveSingleProperty( $id, $name, $value );
$delete = $sql->delete()
->where( array(
'menuId' => $id,
new Sql\Predicate\Like( 'name', $like ),
) );
$rows += $sql->prepareStatementForSqlObject( $delete )
->execute()
->getAffectedRows();
}
return $rows;
}
|
php
|
protected function saveProperty( $id, $name, $value )
{
$rows = 0;
$sql = $this->sql( $this->getTableInSchema(
static::$propertyTableName
) );
$like = strtr( $name, array(
'\\' => '\\\\',
'%' => '\%',
'_' => '\_',
) ) . '.%';
if ( is_array( $value ) )
{
$nameLikeOrEq = new Sql\Predicate\PredicateSet( array(
new Sql\Predicate\Like( 'name', $like ),
new Sql\Predicate\Operator( 'name', Sql\Predicate\Operator::OP_EQ, $name )
), Sql\Predicate\PredicateSet::OP_OR );
if ( empty( $value ) )
{
$delete = $sql->delete()
->where( array(
'menuId' => $id,
$nameLikeOrEq,
) );
$rows += $sql->prepareStatementForSqlObject( $delete )
->execute()
->getAffectedRows();
}
else
{
$keys = array();
foreach ( $value as $idx => $val )
{
$keys[] = $key = $name . '.' . $idx;
$rows += $this->saveSingleProperty( $id, $key, $val );
}
$delete = $sql->delete()
->where( array(
'menuId' => $id,
$nameLikeOrEq,
new NotIn( 'name', $keys ),
) );
$rows += $sql->prepareStatementForSqlObject( $delete )
->execute()
->getAffectedRows();
}
}
else
{
$rows += $this->saveSingleProperty( $id, $name, $value );
$delete = $sql->delete()
->where( array(
'menuId' => $id,
new Sql\Predicate\Like( 'name', $like ),
) );
$rows += $sql->prepareStatementForSqlObject( $delete )
->execute()
->getAffectedRows();
}
return $rows;
}
|
[
"protected",
"function",
"saveProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"rows",
"=",
"0",
";",
"$",
"sql",
"=",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"getTableInSchema",
"(",
"static",
"::",
"$",
"propertyTableName",
")",
")",
";",
"$",
"like",
"=",
"strtr",
"(",
"$",
"name",
",",
"array",
"(",
"'\\\\'",
"=>",
"'\\\\\\\\'",
",",
"'%'",
"=>",
"'\\%'",
",",
"'_'",
"=>",
"'\\_'",
",",
")",
")",
".",
"'.%'",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"nameLikeOrEq",
"=",
"new",
"Sql",
"\\",
"Predicate",
"\\",
"PredicateSet",
"(",
"array",
"(",
"new",
"Sql",
"\\",
"Predicate",
"\\",
"Like",
"(",
"'name'",
",",
"$",
"like",
")",
",",
"new",
"Sql",
"\\",
"Predicate",
"\\",
"Operator",
"(",
"'name'",
",",
"Sql",
"\\",
"Predicate",
"\\",
"Operator",
"::",
"OP_EQ",
",",
"$",
"name",
")",
")",
",",
"Sql",
"\\",
"Predicate",
"\\",
"PredicateSet",
"::",
"OP_OR",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"delete",
"=",
"$",
"sql",
"->",
"delete",
"(",
")",
"->",
"where",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"$",
"nameLikeOrEq",
",",
")",
")",
";",
"$",
"rows",
"+=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"delete",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"}",
"else",
"{",
"$",
"keys",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"idx",
"=>",
"$",
"val",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"$",
"key",
"=",
"$",
"name",
".",
"'.'",
".",
"$",
"idx",
";",
"$",
"rows",
"+=",
"$",
"this",
"->",
"saveSingleProperty",
"(",
"$",
"id",
",",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"$",
"delete",
"=",
"$",
"sql",
"->",
"delete",
"(",
")",
"->",
"where",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"$",
"nameLikeOrEq",
",",
"new",
"NotIn",
"(",
"'name'",
",",
"$",
"keys",
")",
",",
")",
")",
";",
"$",
"rows",
"+=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"delete",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"rows",
"+=",
"$",
"this",
"->",
"saveSingleProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"delete",
"=",
"$",
"sql",
"->",
"delete",
"(",
")",
"->",
"where",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"new",
"Sql",
"\\",
"Predicate",
"\\",
"Like",
"(",
"'name'",
",",
"$",
"like",
")",
",",
")",
")",
";",
"$",
"rows",
"+=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"delete",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"}",
"return",
"$",
"rows",
";",
"}"
] |
Save a property
@param int $id
@param string $name
@param mixed $value
@return int
|
[
"Save",
"a",
"property"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L557-L627
|
235,518
|
webriq/core
|
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
|
Mapper.saveLabel
|
protected function saveLabel( $id, $label )
{
$locale = $this->getLocale();
$sql = $this->sql( $this->getTableInSchema(
static::$labelTableName
) );
$update = $sql->update()
->set( array(
'label' => $label,
) )
->where( array(
'menuId' => $id,
'locale' => $locale,
) );
$affected = $sql->prepareStatementForSqlObject( $update )
->execute()
->getAffectedRows();
if ( $affected < 1 )
{
$insert = $sql->insert()
->values( array(
'menuId' => $id,
'locale' => $locale,
'label' => $label,
) );
$affected = $sql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
}
return $affected;
}
|
php
|
protected function saveLabel( $id, $label )
{
$locale = $this->getLocale();
$sql = $this->sql( $this->getTableInSchema(
static::$labelTableName
) );
$update = $sql->update()
->set( array(
'label' => $label,
) )
->where( array(
'menuId' => $id,
'locale' => $locale,
) );
$affected = $sql->prepareStatementForSqlObject( $update )
->execute()
->getAffectedRows();
if ( $affected < 1 )
{
$insert = $sql->insert()
->values( array(
'menuId' => $id,
'locale' => $locale,
'label' => $label,
) );
$affected = $sql->prepareStatementForSqlObject( $insert )
->execute()
->getAffectedRows();
}
return $affected;
}
|
[
"protected",
"function",
"saveLabel",
"(",
"$",
"id",
",",
"$",
"label",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"getLocale",
"(",
")",
";",
"$",
"sql",
"=",
"$",
"this",
"->",
"sql",
"(",
"$",
"this",
"->",
"getTableInSchema",
"(",
"static",
"::",
"$",
"labelTableName",
")",
")",
";",
"$",
"update",
"=",
"$",
"sql",
"->",
"update",
"(",
")",
"->",
"set",
"(",
"array",
"(",
"'label'",
"=>",
"$",
"label",
",",
")",
")",
"->",
"where",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"'locale'",
"=>",
"$",
"locale",
",",
")",
")",
";",
"$",
"affected",
"=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"update",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"if",
"(",
"$",
"affected",
"<",
"1",
")",
"{",
"$",
"insert",
"=",
"$",
"sql",
"->",
"insert",
"(",
")",
"->",
"values",
"(",
"array",
"(",
"'menuId'",
"=>",
"$",
"id",
",",
"'locale'",
"=>",
"$",
"locale",
",",
"'label'",
"=>",
"$",
"label",
",",
")",
")",
";",
"$",
"affected",
"=",
"$",
"sql",
"->",
"prepareStatementForSqlObject",
"(",
"$",
"insert",
")",
"->",
"execute",
"(",
")",
"->",
"getAffectedRows",
"(",
")",
";",
"}",
"return",
"$",
"affected",
";",
"}"
] |
Save a label
@param int $id
@param string $label
@return int
|
[
"Save",
"a",
"label"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L636-L671
|
235,519
|
webriq/core
|
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
|
Mapper.interleaveParagraphs
|
public function interleaveParagraphs( $updateNode, $likeNode )
{
return $this->sql()
->menu_interleave_paragraph( (int) $updateNode,
(int) $likeNode );
}
|
php
|
public function interleaveParagraphs( $updateNode, $likeNode )
{
return $this->sql()
->menu_interleave_paragraph( (int) $updateNode,
(int) $likeNode );
}
|
[
"public",
"function",
"interleaveParagraphs",
"(",
"$",
"updateNode",
",",
"$",
"likeNode",
")",
"{",
"return",
"$",
"this",
"->",
"sql",
"(",
")",
"->",
"menu_interleave_paragraph",
"(",
"(",
"int",
")",
"$",
"updateNode",
",",
"(",
"int",
")",
"$",
"likeNode",
")",
";",
"}"
] |
Interleave paragraph-nodes
Update $updateNode's descendant menu-paragraphs
to be more like in $likeNode's.
@param int $updateNode
@param int $likeNode
@return bool
|
[
"Interleave",
"paragraph",
"-",
"nodes"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L739-L744
|
235,520
|
mchorse/crystal-edge.php
|
src/FileSystemExport.php
|
FileSystemExport.export
|
public function export(Logger $logger = null)
{
foreach ($this->site->process() as $path => $content)
{
$dest = "{$this->path}/$path";
$folder = substr($dest, 0, strrpos($dest, '/'));
if (!is_dir($folder))
{
mkdir($folder, 0777, true);
}
if (file_put_contents($dest, $content['output']) && $logger)
{
$logger->log(Logger::INFO, 'Web page %s was compiled at %s', [$path, $dest]);
}
}
return true;
}
|
php
|
public function export(Logger $logger = null)
{
foreach ($this->site->process() as $path => $content)
{
$dest = "{$this->path}/$path";
$folder = substr($dest, 0, strrpos($dest, '/'));
if (!is_dir($folder))
{
mkdir($folder, 0777, true);
}
if (file_put_contents($dest, $content['output']) && $logger)
{
$logger->log(Logger::INFO, 'Web page %s was compiled at %s', [$path, $dest]);
}
}
return true;
}
|
[
"public",
"function",
"export",
"(",
"Logger",
"$",
"logger",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"site",
"->",
"process",
"(",
")",
"as",
"$",
"path",
"=>",
"$",
"content",
")",
"{",
"$",
"dest",
"=",
"\"{$this->path}/$path\"",
";",
"$",
"folder",
"=",
"substr",
"(",
"$",
"dest",
",",
"0",
",",
"strrpos",
"(",
"$",
"dest",
",",
"'/'",
")",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"folder",
")",
")",
"{",
"mkdir",
"(",
"$",
"folder",
",",
"0777",
",",
"true",
")",
";",
"}",
"if",
"(",
"file_put_contents",
"(",
"$",
"dest",
",",
"$",
"content",
"[",
"'output'",
"]",
")",
"&&",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"log",
"(",
"Logger",
"::",
"INFO",
",",
"'Web page %s was compiled at %s'",
",",
"[",
"$",
"path",
",",
"$",
"dest",
"]",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Export a site to build folder
|
[
"Export",
"a",
"site",
"to",
"build",
"folder"
] |
b030f3a124be9ac0b76ed180ca31035180ab9321
|
https://github.com/mchorse/crystal-edge.php/blob/b030f3a124be9ac0b76ed180ca31035180ab9321/src/FileSystemExport.php#L35-L54
|
235,521
|
SergioMadness/framework
|
framework/components/i18n/Fabric.php
|
Fabric.getTranslator
|
public function getTranslator($type, array $params = [])
{
$result = null;
if (!isset($params['language'])) {
throw new \Exception('Need \'language\' param');
}
switch ($type) {
case interfaces\Translator::TRANSLATOR_FILE:
$result = new FileTranslator();
if (!isset($params['dir'])) {
throw new \Exception('Need \'dir\' param');
}
$result->setDir($params['dir']);
$result->setLanguage($params['language']);
break;
case interfaces\Translator::TRANSLATOR_ARRAY:
$result = new ArrayTranslator();
if (!isset($params['map'])) {
throw new \Exception('Need \'map\' param');
}
$result->setMap($params['map']);
$result->setLanguage($params['language']);
break;
case interfaces\Translator::TRANSLATOR_DB:
$result = new DBTranslator();
if (!isset($params['aliasFieldName'])) {
throw new \Exception('Need \'aliasFieldName\' param');
}
if (!isset($params['languageFieldName'])) {
throw new \Exception('Need \'languageFieldName\' param');
}
if (!isset($params['resultFieldName'])) {
throw new \Exception('Need \'resultFieldName\' param');
}
if (!isset($params['table'])) {
throw new \Exception('Need \'table\' param');
}
if (!isset($params['connection'])) {
throw new \Exception('Need \'connection\' param');
}
$result->setAliasFieldName($params['aliasFieldName']);
$result->setResultFieldName($params['resultFieldName']);
$result->setTableName($params['table']);
$result->setLanguageFieldName($params['languageFieldName']);
$result->setQueryBuilder(\pwf\basic\db\QueryBuilder::select()
->setConditionBuilder(\pwf\basic\db\QueryBuilder::getConditionBuilder()));
$result->setConnection(is_string($params['connection']) ? \pwf\basic\Application::$instance->getComponent($params['connection'])
: $params['connection']);
$result->setLanguage($params['language']);
break;
}
return $result;
}
|
php
|
public function getTranslator($type, array $params = [])
{
$result = null;
if (!isset($params['language'])) {
throw new \Exception('Need \'language\' param');
}
switch ($type) {
case interfaces\Translator::TRANSLATOR_FILE:
$result = new FileTranslator();
if (!isset($params['dir'])) {
throw new \Exception('Need \'dir\' param');
}
$result->setDir($params['dir']);
$result->setLanguage($params['language']);
break;
case interfaces\Translator::TRANSLATOR_ARRAY:
$result = new ArrayTranslator();
if (!isset($params['map'])) {
throw new \Exception('Need \'map\' param');
}
$result->setMap($params['map']);
$result->setLanguage($params['language']);
break;
case interfaces\Translator::TRANSLATOR_DB:
$result = new DBTranslator();
if (!isset($params['aliasFieldName'])) {
throw new \Exception('Need \'aliasFieldName\' param');
}
if (!isset($params['languageFieldName'])) {
throw new \Exception('Need \'languageFieldName\' param');
}
if (!isset($params['resultFieldName'])) {
throw new \Exception('Need \'resultFieldName\' param');
}
if (!isset($params['table'])) {
throw new \Exception('Need \'table\' param');
}
if (!isset($params['connection'])) {
throw new \Exception('Need \'connection\' param');
}
$result->setAliasFieldName($params['aliasFieldName']);
$result->setResultFieldName($params['resultFieldName']);
$result->setTableName($params['table']);
$result->setLanguageFieldName($params['languageFieldName']);
$result->setQueryBuilder(\pwf\basic\db\QueryBuilder::select()
->setConditionBuilder(\pwf\basic\db\QueryBuilder::getConditionBuilder()));
$result->setConnection(is_string($params['connection']) ? \pwf\basic\Application::$instance->getComponent($params['connection'])
: $params['connection']);
$result->setLanguage($params['language']);
break;
}
return $result;
}
|
[
"public",
"function",
"getTranslator",
"(",
"$",
"type",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'language'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'language\\' param'",
")",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"interfaces",
"\\",
"Translator",
"::",
"TRANSLATOR_FILE",
":",
"$",
"result",
"=",
"new",
"FileTranslator",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'dir'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'dir\\' param'",
")",
";",
"}",
"$",
"result",
"->",
"setDir",
"(",
"$",
"params",
"[",
"'dir'",
"]",
")",
";",
"$",
"result",
"->",
"setLanguage",
"(",
"$",
"params",
"[",
"'language'",
"]",
")",
";",
"break",
";",
"case",
"interfaces",
"\\",
"Translator",
"::",
"TRANSLATOR_ARRAY",
":",
"$",
"result",
"=",
"new",
"ArrayTranslator",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'map'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'map\\' param'",
")",
";",
"}",
"$",
"result",
"->",
"setMap",
"(",
"$",
"params",
"[",
"'map'",
"]",
")",
";",
"$",
"result",
"->",
"setLanguage",
"(",
"$",
"params",
"[",
"'language'",
"]",
")",
";",
"break",
";",
"case",
"interfaces",
"\\",
"Translator",
"::",
"TRANSLATOR_DB",
":",
"$",
"result",
"=",
"new",
"DBTranslator",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'aliasFieldName'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'aliasFieldName\\' param'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'languageFieldName'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'languageFieldName\\' param'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'resultFieldName'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'resultFieldName\\' param'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'table'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'table\\' param'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'connection'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Need \\'connection\\' param'",
")",
";",
"}",
"$",
"result",
"->",
"setAliasFieldName",
"(",
"$",
"params",
"[",
"'aliasFieldName'",
"]",
")",
";",
"$",
"result",
"->",
"setResultFieldName",
"(",
"$",
"params",
"[",
"'resultFieldName'",
"]",
")",
";",
"$",
"result",
"->",
"setTableName",
"(",
"$",
"params",
"[",
"'table'",
"]",
")",
";",
"$",
"result",
"->",
"setLanguageFieldName",
"(",
"$",
"params",
"[",
"'languageFieldName'",
"]",
")",
";",
"$",
"result",
"->",
"setQueryBuilder",
"(",
"\\",
"pwf",
"\\",
"basic",
"\\",
"db",
"\\",
"QueryBuilder",
"::",
"select",
"(",
")",
"->",
"setConditionBuilder",
"(",
"\\",
"pwf",
"\\",
"basic",
"\\",
"db",
"\\",
"QueryBuilder",
"::",
"getConditionBuilder",
"(",
")",
")",
")",
";",
"$",
"result",
"->",
"setConnection",
"(",
"is_string",
"(",
"$",
"params",
"[",
"'connection'",
"]",
")",
"?",
"\\",
"pwf",
"\\",
"basic",
"\\",
"Application",
"::",
"$",
"instance",
"->",
"getComponent",
"(",
"$",
"params",
"[",
"'connection'",
"]",
")",
":",
"$",
"params",
"[",
"'connection'",
"]",
")",
";",
"$",
"result",
"->",
"setLanguage",
"(",
"$",
"params",
"[",
"'language'",
"]",
")",
";",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get translator by type
@param string $type
@param array $params
@return \pwf\components\i18n\interfaces\Translator
|
[
"Get",
"translator",
"by",
"type"
] |
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
|
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/i18n/Fabric.php#L15-L69
|
235,522
|
broeser/sanitor
|
src/SanitizableTrait.php
|
SanitizableTrait.getFilteredValue
|
public function getFilteredValue() {
if(!$this->getSanitizer() instanceof Sanitizer) {
throw new \Exception('You have to assign a sanitizer first!');
}
return $this->getSanitizer()->filter($this->getRawValue());
}
|
php
|
public function getFilteredValue() {
if(!$this->getSanitizer() instanceof Sanitizer) {
throw new \Exception('You have to assign a sanitizer first!');
}
return $this->getSanitizer()->filter($this->getRawValue());
}
|
[
"public",
"function",
"getFilteredValue",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getSanitizer",
"(",
")",
"instanceof",
"Sanitizer",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'You have to assign a sanitizer first!'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getSanitizer",
"(",
")",
"->",
"filter",
"(",
"$",
"this",
"->",
"getRawValue",
"(",
")",
")",
";",
"}"
] |
Returns the filtered value of this
@return mixed
@throws Exception
|
[
"Returns",
"the",
"filtered",
"value",
"of",
"this"
] |
580e539a2747e3d66527cbbde968004743481a5c
|
https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/SanitizableTrait.php#L39-L45
|
235,523
|
bearframework/emails-addon
|
classes/Emails.php
|
Emails.send
|
public function send(\BearFramework\Emails\Email $email): void
{
$app = App::get();
$email = clone($email);
if ($this->hasEventListeners('beforeSendEmail')) {
$eventDetails = new \BearFramework\Emails\BeforeSendEmailEventDetails($email);
$this->dispatchEvent('beforeSendEmail', $eventDetails);
if ($eventDetails->preventDefault) {
return;
}
}
if (empty($this->senders)) {
throw new \Exception('No email senders added.');
}
foreach ($this->senders as $sender) {
if (is_callable($sender)) {
$sender = call_user_func($sender);
}
if (is_string($sender)) {
$sender = new $sender();
}
if ($sender instanceof \BearFramework\Emails\ISender) {
if ($sender->send($email)) {
if ($this->hasEventListeners('sendEmail')) {
$eventDetails = new \BearFramework\Emails\SendEmailEventDetails($email);
$this->dispatchEvent('sendEmail', $eventDetails);
}
return;
}
}
}
throw new \Exception('No email sender is capable of sending the email provided.');
}
|
php
|
public function send(\BearFramework\Emails\Email $email): void
{
$app = App::get();
$email = clone($email);
if ($this->hasEventListeners('beforeSendEmail')) {
$eventDetails = new \BearFramework\Emails\BeforeSendEmailEventDetails($email);
$this->dispatchEvent('beforeSendEmail', $eventDetails);
if ($eventDetails->preventDefault) {
return;
}
}
if (empty($this->senders)) {
throw new \Exception('No email senders added.');
}
foreach ($this->senders as $sender) {
if (is_callable($sender)) {
$sender = call_user_func($sender);
}
if (is_string($sender)) {
$sender = new $sender();
}
if ($sender instanceof \BearFramework\Emails\ISender) {
if ($sender->send($email)) {
if ($this->hasEventListeners('sendEmail')) {
$eventDetails = new \BearFramework\Emails\SendEmailEventDetails($email);
$this->dispatchEvent('sendEmail', $eventDetails);
}
return;
}
}
}
throw new \Exception('No email sender is capable of sending the email provided.');
}
|
[
"public",
"function",
"send",
"(",
"\\",
"BearFramework",
"\\",
"Emails",
"\\",
"Email",
"$",
"email",
")",
":",
"void",
"{",
"$",
"app",
"=",
"App",
"::",
"get",
"(",
")",
";",
"$",
"email",
"=",
"clone",
"(",
"$",
"email",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasEventListeners",
"(",
"'beforeSendEmail'",
")",
")",
"{",
"$",
"eventDetails",
"=",
"new",
"\\",
"BearFramework",
"\\",
"Emails",
"\\",
"BeforeSendEmailEventDetails",
"(",
"$",
"email",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'beforeSendEmail'",
",",
"$",
"eventDetails",
")",
";",
"if",
"(",
"$",
"eventDetails",
"->",
"preventDefault",
")",
"{",
"return",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"senders",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No email senders added.'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"senders",
"as",
"$",
"sender",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"sender",
")",
")",
"{",
"$",
"sender",
"=",
"call_user_func",
"(",
"$",
"sender",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"sender",
")",
")",
"{",
"$",
"sender",
"=",
"new",
"$",
"sender",
"(",
")",
";",
"}",
"if",
"(",
"$",
"sender",
"instanceof",
"\\",
"BearFramework",
"\\",
"Emails",
"\\",
"ISender",
")",
"{",
"if",
"(",
"$",
"sender",
"->",
"send",
"(",
"$",
"email",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasEventListeners",
"(",
"'sendEmail'",
")",
")",
"{",
"$",
"eventDetails",
"=",
"new",
"\\",
"BearFramework",
"\\",
"Emails",
"\\",
"SendEmailEventDetails",
"(",
"$",
"email",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'sendEmail'",
",",
"$",
"eventDetails",
")",
";",
"}",
"return",
";",
"}",
"}",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'No email sender is capable of sending the email provided.'",
")",
";",
"}"
] |
Sends a email.
@param \BearFramework\Emails\Email $email The email to send.
@return void No value is returned.
@throws \Exception
|
[
"Sends",
"a",
"email",
"."
] |
43a68c47e2b1d231dc69a324249ff5f6827201ca
|
https://github.com/bearframework/emails-addon/blob/43a68c47e2b1d231dc69a324249ff5f6827201ca/classes/Emails.php#L73-L108
|
235,524
|
treehouselabs/domain
|
src/TreeHouse/Domain/AbstractAggregate.php
|
AbstractAggregate.mutate
|
private function mutate($event)
{
$method = 'on' . (string) new EventName($event);
if (method_exists($this, $method)) {
$this->$method($event);
} else {
throw new \RuntimeException(sprintf('Method %s does not exist on aggregate %s', $method, get_class($this)));
}
}
|
php
|
private function mutate($event)
{
$method = 'on' . (string) new EventName($event);
if (method_exists($this, $method)) {
$this->$method($event);
} else {
throw new \RuntimeException(sprintf('Method %s does not exist on aggregate %s', $method, get_class($this)));
}
}
|
[
"private",
"function",
"mutate",
"(",
"$",
"event",
")",
"{",
"$",
"method",
"=",
"'on'",
".",
"(",
"string",
")",
"new",
"EventName",
"(",
"$",
"event",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"event",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Method %s does not exist on aggregate %s'",
",",
"$",
"method",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"}"
] |
Update in-memory state.
@param object $event
|
[
"Update",
"in",
"-",
"memory",
"state",
"."
] |
e22b319307b985dcac94687b1c2b5418b41f1998
|
https://github.com/treehouselabs/domain/blob/e22b319307b985dcac94687b1c2b5418b41f1998/src/TreeHouse/Domain/AbstractAggregate.php#L14-L23
|
235,525
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.divide
|
public function divide($number): Utility
{
$divisible = new static($number);
if ($divisible->value() == 0 || $this->number == 0) {
throw new DivisionByZeroError();
}
$value = $this->number / $divisible->value();
return new static($value);
}
|
php
|
public function divide($number): Utility
{
$divisible = new static($number);
if ($divisible->value() == 0 || $this->number == 0) {
throw new DivisionByZeroError();
}
$value = $this->number / $divisible->value();
return new static($value);
}
|
[
"public",
"function",
"divide",
"(",
"$",
"number",
")",
":",
"Utility",
"{",
"$",
"divisible",
"=",
"new",
"static",
"(",
"$",
"number",
")",
";",
"if",
"(",
"$",
"divisible",
"->",
"value",
"(",
")",
"==",
"0",
"||",
"$",
"this",
"->",
"number",
"==",
"0",
")",
"{",
"throw",
"new",
"DivisionByZeroError",
"(",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"number",
"/",
"$",
"divisible",
"->",
"value",
"(",
")",
";",
"return",
"new",
"static",
"(",
"$",
"value",
")",
";",
"}"
] |
Divide the number by the number
@param $number
@return Utility
@throws NonNumericValueException
@throws \DivisionByZeroError
|
[
"Divide",
"the",
"number",
"by",
"the",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L95-L106
|
235,526
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.factors
|
public function factors(): array
{
// 0 has infinite factors
if ($this->number === 0 || !is_int($this->number)) {
throw new InvalidNumberException();
}
$x = abs($this->number);
$sqrx = floor(sqrt($x));
$factors = [];
for ($i = 1; $i <= $sqrx; $i++) {
if ($x % $i === 0) {
$factors[] = $i;
if ($i !== $sqrx) {
$factors[] = $x / $i;
}
}
}
sort($factors);
return $factors;
}
|
php
|
public function factors(): array
{
// 0 has infinite factors
if ($this->number === 0 || !is_int($this->number)) {
throw new InvalidNumberException();
}
$x = abs($this->number);
$sqrx = floor(sqrt($x));
$factors = [];
for ($i = 1; $i <= $sqrx; $i++) {
if ($x % $i === 0) {
$factors[] = $i;
if ($i !== $sqrx) {
$factors[] = $x / $i;
}
}
}
sort($factors);
return $factors;
}
|
[
"public",
"function",
"factors",
"(",
")",
":",
"array",
"{",
"// 0 has infinite factors",
"if",
"(",
"$",
"this",
"->",
"number",
"===",
"0",
"||",
"!",
"is_int",
"(",
"$",
"this",
"->",
"number",
")",
")",
"{",
"throw",
"new",
"InvalidNumberException",
"(",
")",
";",
"}",
"$",
"x",
"=",
"abs",
"(",
"$",
"this",
"->",
"number",
")",
";",
"$",
"sqrx",
"=",
"floor",
"(",
"sqrt",
"(",
"$",
"x",
")",
")",
";",
"$",
"factors",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"sqrx",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"x",
"%",
"$",
"i",
"===",
"0",
")",
"{",
"$",
"factors",
"[",
"]",
"=",
"$",
"i",
";",
"if",
"(",
"$",
"i",
"!==",
"$",
"sqrx",
")",
"{",
"$",
"factors",
"[",
"]",
"=",
"$",
"x",
"/",
"$",
"i",
";",
"}",
"}",
"}",
"sort",
"(",
"$",
"factors",
")",
";",
"return",
"$",
"factors",
";",
"}"
] |
Get the factors for the number
@return array
@throws InvalidNumberException
|
[
"Get",
"the",
"factors",
"for",
"the",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L114-L135
|
235,527
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.isNegative
|
public function isNegative(): bool
{
if ($this->number === 0 ){
throw new IsZeroException('0 is neither positive or negative');
}
return (!is_int($this->number) && $this->number < 0 || $this->number < 0);
}
|
php
|
public function isNegative(): bool
{
if ($this->number === 0 ){
throw new IsZeroException('0 is neither positive or negative');
}
return (!is_int($this->number) && $this->number < 0 || $this->number < 0);
}
|
[
"public",
"function",
"isNegative",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"number",
"===",
"0",
")",
"{",
"throw",
"new",
"IsZeroException",
"(",
"'0 is neither positive or negative'",
")",
";",
"}",
"return",
"(",
"!",
"is_int",
"(",
"$",
"this",
"->",
"number",
")",
"&&",
"$",
"this",
"->",
"number",
"<",
"0",
"||",
"$",
"this",
"->",
"number",
"<",
"0",
")",
";",
"}"
] |
Is the number negative
@return bool
@throws IsZeroException
|
[
"Is",
"the",
"number",
"negative"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L156-L162
|
235,528
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.magnitude
|
public function magnitude(): Utility
{
if ($this->number == 0) {
$magnitude = 0;
} else {
$magnitude = floor(log10(abs($this->number)));
}
return new static($magnitude);
}
|
php
|
public function magnitude(): Utility
{
if ($this->number == 0) {
$magnitude = 0;
} else {
$magnitude = floor(log10(abs($this->number)));
}
return new static($magnitude);
}
|
[
"public",
"function",
"magnitude",
"(",
")",
":",
"Utility",
"{",
"if",
"(",
"$",
"this",
"->",
"number",
"==",
"0",
")",
"{",
"$",
"magnitude",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"magnitude",
"=",
"floor",
"(",
"log10",
"(",
"abs",
"(",
"$",
"this",
"->",
"number",
")",
")",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"magnitude",
")",
";",
"}"
] |
Get the order of magnitude of the number
@return Utility
@throws NonNumericValueException
|
[
"Get",
"the",
"order",
"of",
"magnitude",
"of",
"the",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L183-L192
|
235,529
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.pad
|
private function pad($padding = 1, $direction = STR_PAD_BOTH): string
{
return str_pad($this->number, $padding, 0, $direction);
}
|
php
|
private function pad($padding = 1, $direction = STR_PAD_BOTH): string
{
return str_pad($this->number, $padding, 0, $direction);
}
|
[
"private",
"function",
"pad",
"(",
"$",
"padding",
"=",
"1",
",",
"$",
"direction",
"=",
"STR_PAD_BOTH",
")",
":",
"string",
"{",
"return",
"str_pad",
"(",
"$",
"this",
"->",
"number",
",",
"$",
"padding",
",",
"0",
",",
"$",
"direction",
")",
";",
"}"
] |
Add padding to the number
@param int $padding
@param int $direction
@return string
|
[
"Add",
"padding",
"to",
"the",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L259-L262
|
235,530
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.round
|
private function round($number, $precision, int $mode): Utility
{
if ($precision < 0) {
throw new InvalidNumberException('Precision value should be greater or equal to zero');
}
$value = round($number, $precision, $mode);
return new static($value);
}
|
php
|
private function round($number, $precision, int $mode): Utility
{
if ($precision < 0) {
throw new InvalidNumberException('Precision value should be greater or equal to zero');
}
$value = round($number, $precision, $mode);
return new static($value);
}
|
[
"private",
"function",
"round",
"(",
"$",
"number",
",",
"$",
"precision",
",",
"int",
"$",
"mode",
")",
":",
"Utility",
"{",
"if",
"(",
"$",
"precision",
"<",
"0",
")",
"{",
"throw",
"new",
"InvalidNumberException",
"(",
"'Precision value should be greater or equal to zero'",
")",
";",
"}",
"$",
"value",
"=",
"round",
"(",
"$",
"number",
",",
"$",
"precision",
",",
"$",
"mode",
")",
";",
"return",
"new",
"static",
"(",
"$",
"value",
")",
";",
"}"
] |
Round a number
@param $number
@param int $precision
@param int $mode
@return Utility
@throws InvalidNumberException
@throws NonNumericValueException
|
[
"Round",
"a",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L310-L319
|
235,531
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.roundDown
|
public function roundDown(int $precision = 0): Utility
{
return $this->round($this->number, $precision, PHP_ROUND_HALF_DOWN);
}
|
php
|
public function roundDown(int $precision = 0): Utility
{
return $this->round($this->number, $precision, PHP_ROUND_HALF_DOWN);
}
|
[
"public",
"function",
"roundDown",
"(",
"int",
"$",
"precision",
"=",
"0",
")",
":",
"Utility",
"{",
"return",
"$",
"this",
"->",
"round",
"(",
"$",
"this",
"->",
"number",
",",
"$",
"precision",
",",
"PHP_ROUND_HALF_DOWN",
")",
";",
"}"
] |
Round down the number
@param int $precision
@return Utility
@throws InvalidNumberException
@throws NonNumericValueException
|
[
"Round",
"down",
"the",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L330-L333
|
235,532
|
myerscode/utilities-numbers
|
src/Utility.php
|
Utility.roundUp
|
public function roundUp(int $precision = 0): Utility
{
return $this->round($this->number, $precision, PHP_ROUND_HALF_UP);
}
|
php
|
public function roundUp(int $precision = 0): Utility
{
return $this->round($this->number, $precision, PHP_ROUND_HALF_UP);
}
|
[
"public",
"function",
"roundUp",
"(",
"int",
"$",
"precision",
"=",
"0",
")",
":",
"Utility",
"{",
"return",
"$",
"this",
"->",
"round",
"(",
"$",
"this",
"->",
"number",
",",
"$",
"precision",
",",
"PHP_ROUND_HALF_UP",
")",
";",
"}"
] |
Round up the number
@param int $precision
@return Utility
@throws InvalidNumberException
@throws NonNumericValueException
|
[
"Round",
"up",
"the",
"number"
] |
c2ee8bffcda5fda425572bc3e195e9afb795f843
|
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L344-L347
|
235,533
|
nattreid/security
|
src/Model/Users/User.php
|
User.setUsername
|
public function setUsername(string $username): void
{
if (Strings::match($username, '/[^A-Za-z0-9_]/')) {
throw new InvalidArgumentException('Username contains invalid characters');
}
/* @var $repository UsersRepository */
$repository = $this->getRepository();
$user = $repository->getByUsername($username);
if ($user !== null && $user !== $this) {
throw new UniqueConstraintViolationException("Username '$username' exists");
}
$this->username = $username;
}
|
php
|
public function setUsername(string $username): void
{
if (Strings::match($username, '/[^A-Za-z0-9_]/')) {
throw new InvalidArgumentException('Username contains invalid characters');
}
/* @var $repository UsersRepository */
$repository = $this->getRepository();
$user = $repository->getByUsername($username);
if ($user !== null && $user !== $this) {
throw new UniqueConstraintViolationException("Username '$username' exists");
}
$this->username = $username;
}
|
[
"public",
"function",
"setUsername",
"(",
"string",
"$",
"username",
")",
":",
"void",
"{",
"if",
"(",
"Strings",
"::",
"match",
"(",
"$",
"username",
",",
"'/[^A-Za-z0-9_]/'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Username contains invalid characters'",
")",
";",
"}",
"/* @var $repository UsersRepository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"user",
"=",
"$",
"repository",
"->",
"getByUsername",
"(",
"$",
"username",
")",
";",
"if",
"(",
"$",
"user",
"!==",
"null",
"&&",
"$",
"user",
"!==",
"$",
"this",
")",
"{",
"throw",
"new",
"UniqueConstraintViolationException",
"(",
"\"Username '$username' exists\"",
")",
";",
"}",
"$",
"this",
"->",
"username",
"=",
"$",
"username",
";",
"}"
] |
Ulozi uzivatelske jmeno
@param string $username
@throws UniqueConstraintViolationException
@throws InvalidArgumentException
|
[
"Ulozi",
"uzivatelske",
"jmeno"
] |
ed649e5bdf453cea2d5352e643dbf201193de01d
|
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Model/Users/User.php#L65-L78
|
235,534
|
nattreid/security
|
src/Model/Users/User.php
|
User.getterRoleConstants
|
public function getterRoleConstants(): array
{
$result = [];
$roles = $this->roles->get();
/* @var $role AclRole */
foreach ($roles as $role) {
$result[] = $role->name;
}
return $result;
}
|
php
|
public function getterRoleConstants(): array
{
$result = [];
$roles = $this->roles->get();
/* @var $role AclRole */
foreach ($roles as $role) {
$result[] = $role->name;
}
return $result;
}
|
[
"public",
"function",
"getterRoleConstants",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"roles",
"=",
"$",
"this",
"->",
"roles",
"->",
"get",
"(",
")",
";",
"/* @var $role AclRole */",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"role",
"->",
"name",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Vrati jmena roli
@return array
|
[
"Vrati",
"jmena",
"roli"
] |
ed649e5bdf453cea2d5352e643dbf201193de01d
|
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Model/Users/User.php#L136-L145
|
235,535
|
nattreid/security
|
src/Model/Users/User.php
|
User.getterRoleTitles
|
protected function getterRoleTitles(): array
{
$result = [];
$roles = $this->roles->get();
/* @var $role AclRole */
foreach ($roles as $role) {
$result[] = $role->title;
}
return $result;
}
|
php
|
protected function getterRoleTitles(): array
{
$result = [];
$roles = $this->roles->get();
/* @var $role AclRole */
foreach ($roles as $role) {
$result[] = $role->title;
}
return $result;
}
|
[
"protected",
"function",
"getterRoleTitles",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"roles",
"=",
"$",
"this",
"->",
"roles",
"->",
"get",
"(",
")",
";",
"/* @var $role AclRole */",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"role",
"->",
"title",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Vrati nazvy roli
@return array
|
[
"Vrati",
"nazvy",
"roli"
] |
ed649e5bdf453cea2d5352e643dbf201193de01d
|
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Model/Users/User.php#L151-L160
|
235,536
|
jnjxp/html
|
src/Helper/Styles.php
|
Styles.inline
|
public function inline($style, array $attr = null)
{
$attr = $this->escaper->attr(
$this->fixInlineAttr($attr)
);
return "<style {$attr}>{$style}</style>";
}
|
php
|
public function inline($style, array $attr = null)
{
$attr = $this->escaper->attr(
$this->fixInlineAttr($attr)
);
return "<style {$attr}>{$style}</style>";
}
|
[
"public",
"function",
"inline",
"(",
"$",
"style",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"$",
"attr",
"=",
"$",
"this",
"->",
"escaper",
"->",
"attr",
"(",
"$",
"this",
"->",
"fixInlineAttr",
"(",
"$",
"attr",
")",
")",
";",
"return",
"\"<style {$attr}>{$style}</style>\"",
";",
"}"
] |
makes an internal style tag
@param string $style css snippet
@param null|array $attr attributes for style tag
@return string
@access public
|
[
"makes",
"an",
"internal",
"style",
"tag"
] |
a38f130c19ab0a60ea52bc1d2560a68d2048d292
|
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L67-L73
|
235,537
|
jnjxp/html
|
src/Helper/Styles.php
|
Styles.inlineCond
|
public function inlineCond($cond, $style, array $attr = null)
{
$style = $this->inline($style, $attr);
$cond = $this->escaper->html($cond);
return "<!--[if {$cond}]>{$style}<![endif]-->";
}
|
php
|
public function inlineCond($cond, $style, array $attr = null)
{
$style = $this->inline($style, $attr);
$cond = $this->escaper->html($cond);
return "<!--[if {$cond}]>{$style}<![endif]-->";
}
|
[
"public",
"function",
"inlineCond",
"(",
"$",
"cond",
",",
"$",
"style",
",",
"array",
"$",
"attr",
"=",
"null",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"inline",
"(",
"$",
"style",
",",
"$",
"attr",
")",
";",
"$",
"cond",
"=",
"$",
"this",
"->",
"escaper",
"->",
"html",
"(",
"$",
"cond",
")",
";",
"return",
"\"<!--[if {$cond}]>{$style}<![endif]-->\"",
";",
"}"
] |
add inline conditional style
@param string $cond ie condition
@param string $style css snippet
@param null|array $attr attributes for style tag
@return string
@access public
|
[
"add",
"inline",
"conditional",
"style"
] |
a38f130c19ab0a60ea52bc1d2560a68d2048d292
|
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L86-L91
|
235,538
|
jnjxp/html
|
src/Helper/Styles.php
|
Styles.addInline
|
public function addInline($style, array $attr = null, $position = 1000)
{
$this->addElement(
$position,
$this->inline($style, $attr)
);
return $this;
}
|
php
|
public function addInline($style, array $attr = null, $position = 1000)
{
$this->addElement(
$position,
$this->inline($style, $attr)
);
return $this;
}
|
[
"public",
"function",
"addInline",
"(",
"$",
"style",
",",
"array",
"$",
"attr",
"=",
"null",
",",
"$",
"position",
"=",
"1000",
")",
"{",
"$",
"this",
"->",
"addElement",
"(",
"$",
"position",
",",
"$",
"this",
"->",
"inline",
"(",
"$",
"style",
",",
"$",
"attr",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
add inline css
@param string $style css snippet
@param null|array $attr attributes for style tag
@param int $position sort
@return Styles
@access public
|
[
"add",
"inline",
"css"
] |
a38f130c19ab0a60ea52bc1d2560a68d2048d292
|
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L104-L111
|
235,539
|
jnjxp/html
|
src/Helper/Styles.php
|
Styles.addInlineCond
|
public function addInlineCond(
$cond,
$style,
array $attr = null,
$position = 1000
) {
$this->addElement(
$position,
$this->inlineCond($cond, $style, $attr)
);
return $this;
}
|
php
|
public function addInlineCond(
$cond,
$style,
array $attr = null,
$position = 1000
) {
$this->addElement(
$position,
$this->inlineCond($cond, $style, $attr)
);
return $this;
}
|
[
"public",
"function",
"addInlineCond",
"(",
"$",
"cond",
",",
"$",
"style",
",",
"array",
"$",
"attr",
"=",
"null",
",",
"$",
"position",
"=",
"1000",
")",
"{",
"$",
"this",
"->",
"addElement",
"(",
"$",
"position",
",",
"$",
"this",
"->",
"inlineCond",
"(",
"$",
"cond",
",",
"$",
"style",
",",
"$",
"attr",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
add inline conditional css
@param string $cond ie condition
@param string $style css snippet
@param null|array $attr attributes for style tag
@param int $position sort
@return Styles
@access public
|
[
"add",
"inline",
"conditional",
"css"
] |
a38f130c19ab0a60ea52bc1d2560a68d2048d292
|
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L125-L136
|
235,540
|
jnjxp/html
|
src/Helper/Styles.php
|
Styles.inlineCaptureStart
|
public function inlineCaptureStart(array $attr = null, $position = 1000)
{
$this->capture[] = [
'func' => 'addInline',
'args' => [
'style' => '',
$attr,
$position
]
];
ob_start();
return $this;
}
|
php
|
public function inlineCaptureStart(array $attr = null, $position = 1000)
{
$this->capture[] = [
'func' => 'addInline',
'args' => [
'style' => '',
$attr,
$position
]
];
ob_start();
return $this;
}
|
[
"public",
"function",
"inlineCaptureStart",
"(",
"array",
"$",
"attr",
"=",
"null",
",",
"$",
"position",
"=",
"1000",
")",
"{",
"$",
"this",
"->",
"capture",
"[",
"]",
"=",
"[",
"'func'",
"=>",
"'addInline'",
",",
"'args'",
"=>",
"[",
"'style'",
"=>",
"''",
",",
"$",
"attr",
",",
"$",
"position",
"]",
"]",
";",
"ob_start",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
capture inline snippet
@param null|array $attr attributes for style tag
@param int $position sort
@return Styles
@access public
|
[
"capture",
"inline",
"snippet"
] |
a38f130c19ab0a60ea52bc1d2560a68d2048d292
|
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L148-L161
|
235,541
|
jnjxp/html
|
src/Helper/Styles.php
|
Styles.inlineCondCaptureStart
|
public function inlineCondCaptureStart(
$cond,
array $attr = null,
$position = 1000
) {
$this->capture[] = [
'func' => 'addInlineCond',
'args' => [
$cond,
'style' => '',
$attr,
$position
]
];
ob_start();
return $this;
}
|
php
|
public function inlineCondCaptureStart(
$cond,
array $attr = null,
$position = 1000
) {
$this->capture[] = [
'func' => 'addInlineCond',
'args' => [
$cond,
'style' => '',
$attr,
$position
]
];
ob_start();
return $this;
}
|
[
"public",
"function",
"inlineCondCaptureStart",
"(",
"$",
"cond",
",",
"array",
"$",
"attr",
"=",
"null",
",",
"$",
"position",
"=",
"1000",
")",
"{",
"$",
"this",
"->",
"capture",
"[",
"]",
"=",
"[",
"'func'",
"=>",
"'addInlineCond'",
",",
"'args'",
"=>",
"[",
"$",
"cond",
",",
"'style'",
"=>",
"''",
",",
"$",
"attr",
",",
"$",
"position",
"]",
"]",
";",
"ob_start",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
capture inline conditional style
@param mixed $cond ie condition
@param null|array $attr attributes for style tag
@param int $position sort
@return Styles
@access public
|
[
"capture",
"inline",
"conditional",
"style"
] |
a38f130c19ab0a60ea52bc1d2560a68d2048d292
|
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L174-L191
|
235,542
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.init
|
public static function init(AdminStore $admin_store) {
self::$admin_store = $admin_store;
self::$sql = $admin_store->store;
self::$logger = $admin_store->logger;
}
|
php
|
public static function init(AdminStore $admin_store) {
self::$admin_store = $admin_store;
self::$sql = $admin_store->store;
self::$logger = $admin_store->logger;
}
|
[
"public",
"static",
"function",
"init",
"(",
"AdminStore",
"$",
"admin_store",
")",
"{",
"self",
"::",
"$",
"admin_store",
"=",
"$",
"admin_store",
";",
"self",
"::",
"$",
"sql",
"=",
"$",
"admin_store",
"->",
"store",
";",
"self",
"::",
"$",
"logger",
"=",
"$",
"admin_store",
"->",
"logger",
";",
"}"
] |
Initialize object.
@param AdminStore $admin_store An instance of AdminStore.
|
[
"Initialize",
"object",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L29-L33
|
235,543
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.drop
|
public static function drop() {
foreach([
"DROP VIEW IF EXISTS v_usess",
"DROP TABLE IF EXISTS usess",
"DROP TABLE IF EXISTS udata",
"DROP TABLE IF EXISTS meta",
] as $drop) {
// @codeCoverageIgnoreStart
try {
self::$sql->query_raw($drop);
} catch(SQLError $e) {
$msg = "Cannot drop data:" . $e->getMessage();
self::$logger->error("Zapmin: sql error: $msg");
throw new AdminStoreError($msg);
}
// @codeCoverageIgnoreEnd
}
}
|
php
|
public static function drop() {
foreach([
"DROP VIEW IF EXISTS v_usess",
"DROP TABLE IF EXISTS usess",
"DROP TABLE IF EXISTS udata",
"DROP TABLE IF EXISTS meta",
] as $drop) {
// @codeCoverageIgnoreStart
try {
self::$sql->query_raw($drop);
} catch(SQLError $e) {
$msg = "Cannot drop data:" . $e->getMessage();
self::$logger->error("Zapmin: sql error: $msg");
throw new AdminStoreError($msg);
}
// @codeCoverageIgnoreEnd
}
}
|
[
"public",
"static",
"function",
"drop",
"(",
")",
"{",
"foreach",
"(",
"[",
"\"DROP VIEW IF EXISTS v_usess\"",
",",
"\"DROP TABLE IF EXISTS usess\"",
",",
"\"DROP TABLE IF EXISTS udata\"",
",",
"\"DROP TABLE IF EXISTS meta\"",
",",
"]",
"as",
"$",
"drop",
")",
"{",
"// @codeCoverageIgnoreStart",
"try",
"{",
"self",
"::",
"$",
"sql",
"->",
"query_raw",
"(",
"$",
"drop",
")",
";",
"}",
"catch",
"(",
"SQLError",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"Cannot drop data:\"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"\"Zapmin: sql error: $msg\"",
")",
";",
"throw",
"new",
"AdminStoreError",
"(",
"$",
"msg",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"}",
"}"
] |
Drop existing tables.
|
[
"Drop",
"existing",
"tables",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L45-L62
|
235,544
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.exists
|
public static function exists($force_create_table=null) {
$sql = self::$sql;
$sql::$logger->deactivate();
try {
$sql->query("SELECT 1 FROM udata LIMIT 1");
$sql::$logger->activate();
if ($force_create_table) {
self::drop();
self::$logger->info("Zapmin: Recreating tables.");
return false;
}
return true;
} catch (SQLError $e) {
}
$sql::$logger->activate();
return false;
}
|
php
|
public static function exists($force_create_table=null) {
$sql = self::$sql;
$sql::$logger->deactivate();
try {
$sql->query("SELECT 1 FROM udata LIMIT 1");
$sql::$logger->activate();
if ($force_create_table) {
self::drop();
self::$logger->info("Zapmin: Recreating tables.");
return false;
}
return true;
} catch (SQLError $e) {
}
$sql::$logger->activate();
return false;
}
|
[
"public",
"static",
"function",
"exists",
"(",
"$",
"force_create_table",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
"self",
"::",
"$",
"sql",
";",
"$",
"sql",
"::",
"$",
"logger",
"->",
"deactivate",
"(",
")",
";",
"try",
"{",
"$",
"sql",
"->",
"query",
"(",
"\"SELECT 1 FROM udata LIMIT 1\"",
")",
";",
"$",
"sql",
"::",
"$",
"logger",
"->",
"activate",
"(",
")",
";",
"if",
"(",
"$",
"force_create_table",
")",
"{",
"self",
"::",
"drop",
"(",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"info",
"(",
"\"Zapmin: Recreating tables.\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"SQLError",
"$",
"e",
")",
"{",
"}",
"$",
"sql",
"::",
"$",
"logger",
"->",
"activate",
"(",
")",
";",
"return",
"false",
";",
"}"
] |
Check if tables exist.
@param bool $force_create_table Recreate tables if true.
@return bool True if tables exist.
|
[
"Check",
"if",
"tables",
"exist",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L70-L86
|
235,545
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.fragments
|
public static function fragments($expiration=7200) {
$sql = self::$sql;
$args = [];
$args['index'] = $sql->stmt_fragment('index');
$args['engine'] = $sql->stmt_fragment('engine');
$args['dtnow'] = $sql->stmt_fragment('datetime');
$args['expire'] = $sql->stmt_fragment(
'datetime', ['delta' => $expiration]);
if ($sql->get_connection_params()['dbtype'] == 'mysql')
$args['dtnow'] = $args['expire'] = 'CURRENT_TIMESTAMP';
return $args;
}
|
php
|
public static function fragments($expiration=7200) {
$sql = self::$sql;
$args = [];
$args['index'] = $sql->stmt_fragment('index');
$args['engine'] = $sql->stmt_fragment('engine');
$args['dtnow'] = $sql->stmt_fragment('datetime');
$args['expire'] = $sql->stmt_fragment(
'datetime', ['delta' => $expiration]);
if ($sql->get_connection_params()['dbtype'] == 'mysql')
$args['dtnow'] = $args['expire'] = 'CURRENT_TIMESTAMP';
return $args;
}
|
[
"public",
"static",
"function",
"fragments",
"(",
"$",
"expiration",
"=",
"7200",
")",
"{",
"$",
"sql",
"=",
"self",
"::",
"$",
"sql",
";",
"$",
"args",
"=",
"[",
"]",
";",
"$",
"args",
"[",
"'index'",
"]",
"=",
"$",
"sql",
"->",
"stmt_fragment",
"(",
"'index'",
")",
";",
"$",
"args",
"[",
"'engine'",
"]",
"=",
"$",
"sql",
"->",
"stmt_fragment",
"(",
"'engine'",
")",
";",
"$",
"args",
"[",
"'dtnow'",
"]",
"=",
"$",
"sql",
"->",
"stmt_fragment",
"(",
"'datetime'",
")",
";",
"$",
"args",
"[",
"'expire'",
"]",
"=",
"$",
"sql",
"->",
"stmt_fragment",
"(",
"'datetime'",
",",
"[",
"'delta'",
"=>",
"$",
"expiration",
"]",
")",
";",
"if",
"(",
"$",
"sql",
"->",
"get_connection_params",
"(",
")",
"[",
"'dbtype'",
"]",
"==",
"'mysql'",
")",
"$",
"args",
"[",
"'dtnow'",
"]",
"=",
"$",
"args",
"[",
"'expire'",
"]",
"=",
"'CURRENT_TIMESTAMP'",
";",
"return",
"$",
"args",
";",
"}"
] |
SQL statement fragments.
@param int $expiration Regular session expiration duration,
in second.
|
[
"SQL",
"statement",
"fragments",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L94-L105
|
235,546
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.install
|
public static function install($expiration=7200) {
$dtnow = $expire = null;
extract(self::fragments($expiration));
$sql = self::$sql;
# user table
$user_table = ("
CREATE TABLE udata (
uid %s,
uname VARCHAR(64) UNIQUE,
upass VARCHAR(64),
usalt VARCHAR(16),
since TIMESTAMP NOT NULL DEFAULT %s,
email VARCHAR(64),
email_verified INT NOT NULL DEFAULT 0,
fname VARCHAR(128),
site VARCHAR(128)
) %s;
");
$user_table = sprintf($user_table, $index, $dtnow, $engine);
$sql->query_raw($user_table);
# default user
$root_salt = self::$admin_store->generate_secret(
'root', null, 16);
$root_pass = self::$admin_store->hash_password(
'root', 'admin', $root_salt);
$sql->insert('udata', [
'uid' => 1,
'uname' => 'root',
'upass' => $root_pass,
'usalt' => $root_salt,
]);
# session table
$session_table = ("
CREATE TABLE usess (
sid %s,
uid INTEGER REFERENCES udata(uid) ON DELETE CASCADE,
token VARCHAR(64),
expire TIMESTAMP NOT NULL DEFAULT %s
) %s;
");
$session_table = sprintf(
$session_table, $index, $expire, $engine);
$sql->query_raw($session_table);
# session view
$user_session_view = ("
CREATE VIEW v_usess AS
SELECT
udata.*,
usess.sid,
usess.token,
usess.expire
FROM udata, usess
WHERE
udata.uid=usess.uid;
");
$sql->query_raw($user_session_view);
# metadata
$sql->query_raw(sprintf("
CREATE TABLE meta (
version VARCHAR(24) NOT NULL DEFAULT '0.0'
);
", $engine));
$sql->insert('meta', [
'version' => self::TABLE_VERSION,
]);
}
|
php
|
public static function install($expiration=7200) {
$dtnow = $expire = null;
extract(self::fragments($expiration));
$sql = self::$sql;
# user table
$user_table = ("
CREATE TABLE udata (
uid %s,
uname VARCHAR(64) UNIQUE,
upass VARCHAR(64),
usalt VARCHAR(16),
since TIMESTAMP NOT NULL DEFAULT %s,
email VARCHAR(64),
email_verified INT NOT NULL DEFAULT 0,
fname VARCHAR(128),
site VARCHAR(128)
) %s;
");
$user_table = sprintf($user_table, $index, $dtnow, $engine);
$sql->query_raw($user_table);
# default user
$root_salt = self::$admin_store->generate_secret(
'root', null, 16);
$root_pass = self::$admin_store->hash_password(
'root', 'admin', $root_salt);
$sql->insert('udata', [
'uid' => 1,
'uname' => 'root',
'upass' => $root_pass,
'usalt' => $root_salt,
]);
# session table
$session_table = ("
CREATE TABLE usess (
sid %s,
uid INTEGER REFERENCES udata(uid) ON DELETE CASCADE,
token VARCHAR(64),
expire TIMESTAMP NOT NULL DEFAULT %s
) %s;
");
$session_table = sprintf(
$session_table, $index, $expire, $engine);
$sql->query_raw($session_table);
# session view
$user_session_view = ("
CREATE VIEW v_usess AS
SELECT
udata.*,
usess.sid,
usess.token,
usess.expire
FROM udata, usess
WHERE
udata.uid=usess.uid;
");
$sql->query_raw($user_session_view);
# metadata
$sql->query_raw(sprintf("
CREATE TABLE meta (
version VARCHAR(24) NOT NULL DEFAULT '0.0'
);
", $engine));
$sql->insert('meta', [
'version' => self::TABLE_VERSION,
]);
}
|
[
"public",
"static",
"function",
"install",
"(",
"$",
"expiration",
"=",
"7200",
")",
"{",
"$",
"dtnow",
"=",
"$",
"expire",
"=",
"null",
";",
"extract",
"(",
"self",
"::",
"fragments",
"(",
"$",
"expiration",
")",
")",
";",
"$",
"sql",
"=",
"self",
"::",
"$",
"sql",
";",
"# user table",
"$",
"user_table",
"=",
"(",
"\"\n\t\t\tCREATE TABLE udata (\n\t\t\t\tuid %s,\n\t\t\t\tuname VARCHAR(64) UNIQUE,\n\t\t\t\tupass VARCHAR(64),\n\t\t\t\tusalt VARCHAR(16),\n\t\t\t\tsince TIMESTAMP NOT NULL DEFAULT %s,\n\t\t\t\temail VARCHAR(64),\n\t\t\t\temail_verified INT NOT NULL DEFAULT 0,\n\t\t\t\tfname VARCHAR(128),\n\t\t\t\tsite VARCHAR(128)\n\t\t\t) %s;\n\t\t\"",
")",
";",
"$",
"user_table",
"=",
"sprintf",
"(",
"$",
"user_table",
",",
"$",
"index",
",",
"$",
"dtnow",
",",
"$",
"engine",
")",
";",
"$",
"sql",
"->",
"query_raw",
"(",
"$",
"user_table",
")",
";",
"# default user",
"$",
"root_salt",
"=",
"self",
"::",
"$",
"admin_store",
"->",
"generate_secret",
"(",
"'root'",
",",
"null",
",",
"16",
")",
";",
"$",
"root_pass",
"=",
"self",
"::",
"$",
"admin_store",
"->",
"hash_password",
"(",
"'root'",
",",
"'admin'",
",",
"$",
"root_salt",
")",
";",
"$",
"sql",
"->",
"insert",
"(",
"'udata'",
",",
"[",
"'uid'",
"=>",
"1",
",",
"'uname'",
"=>",
"'root'",
",",
"'upass'",
"=>",
"$",
"root_pass",
",",
"'usalt'",
"=>",
"$",
"root_salt",
",",
"]",
")",
";",
"# session table",
"$",
"session_table",
"=",
"(",
"\"\n\t\t\tCREATE TABLE usess (\n\t\t\t\tsid %s,\n\t\t\t\tuid INTEGER REFERENCES udata(uid) ON DELETE CASCADE,\n\t\t\t\ttoken VARCHAR(64),\n\t\t\t\texpire TIMESTAMP NOT NULL DEFAULT %s\n\t\t\t) %s;\n\t\t\"",
")",
";",
"$",
"session_table",
"=",
"sprintf",
"(",
"$",
"session_table",
",",
"$",
"index",
",",
"$",
"expire",
",",
"$",
"engine",
")",
";",
"$",
"sql",
"->",
"query_raw",
"(",
"$",
"session_table",
")",
";",
"# session view",
"$",
"user_session_view",
"=",
"(",
"\"\n\t\t\tCREATE VIEW v_usess AS\n\t\t\t\tSELECT\n\t\t\t\t\tudata.*,\n\t\t\t\t\tusess.sid,\n\t\t\t\t\tusess.token,\n\t\t\t\t\tusess.expire\n\t\t\t\tFROM udata, usess\n\t\t\t\tWHERE\n\t\t\t\t\tudata.uid=usess.uid;\n\t\t\"",
")",
";",
"$",
"sql",
"->",
"query_raw",
"(",
"$",
"user_session_view",
")",
";",
"# metadata",
"$",
"sql",
"->",
"query_raw",
"(",
"sprintf",
"(",
"\"\n\t\t\tCREATE TABLE meta (\n\t\t\t\tversion VARCHAR(24) NOT NULL DEFAULT '0.0'\n\t\t\t);\n\t\t\"",
",",
"$",
"engine",
")",
")",
";",
"$",
"sql",
"->",
"insert",
"(",
"'meta'",
",",
"[",
"'version'",
"=>",
"self",
"::",
"TABLE_VERSION",
",",
"]",
")",
";",
"}"
] |
Install tables.
@param int $expiration Regular session expiration duration,
in second.
@note In case of email addresses:
- Unique and null in one column is not portable. Must check
email uniqueness manually.
- Email verification must be held separately. Table only
reserves a column for it.
|
[
"Install",
"tables",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L118-L194
|
235,547
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.upgrade
|
public static function upgrade() {
$sql = self::$sql;
$sql::$logger->deactivate();
try {
$version = $sql->query(
"SELECT version FROM meta LIMIT 1")['version'];
} catch(SQLError $e) {
$sql::$logger->activate();
return self::upgrade_tables();
}
$sql::$logger->activate();
if (0 <= version_compare($version, self::TABLE_VERSION))
return self::$logger->debug(
"Zapmin: Tables are up-to-date.");
return self::upgrade_tables($version);
}
|
php
|
public static function upgrade() {
$sql = self::$sql;
$sql::$logger->deactivate();
try {
$version = $sql->query(
"SELECT version FROM meta LIMIT 1")['version'];
} catch(SQLError $e) {
$sql::$logger->activate();
return self::upgrade_tables();
}
$sql::$logger->activate();
if (0 <= version_compare($version, self::TABLE_VERSION))
return self::$logger->debug(
"Zapmin: Tables are up-to-date.");
return self::upgrade_tables($version);
}
|
[
"public",
"static",
"function",
"upgrade",
"(",
")",
"{",
"$",
"sql",
"=",
"self",
"::",
"$",
"sql",
";",
"$",
"sql",
"::",
"$",
"logger",
"->",
"deactivate",
"(",
")",
";",
"try",
"{",
"$",
"version",
"=",
"$",
"sql",
"->",
"query",
"(",
"\"SELECT version FROM meta LIMIT 1\"",
")",
"[",
"'version'",
"]",
";",
"}",
"catch",
"(",
"SQLError",
"$",
"e",
")",
"{",
"$",
"sql",
"::",
"$",
"logger",
"->",
"activate",
"(",
")",
";",
"return",
"self",
"::",
"upgrade_tables",
"(",
")",
";",
"}",
"$",
"sql",
"::",
"$",
"logger",
"->",
"activate",
"(",
")",
";",
"if",
"(",
"0",
"<=",
"version_compare",
"(",
"$",
"version",
",",
"self",
"::",
"TABLE_VERSION",
")",
")",
"return",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Zapmin: Tables are up-to-date.\"",
")",
";",
"return",
"self",
"::",
"upgrade_tables",
"(",
"$",
"version",
")",
";",
"}"
] |
Check if tables need upgrade.
|
[
"Check",
"if",
"tables",
"need",
"upgrade",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L199-L217
|
235,548
|
bfitech/zapmin
|
src/AdminStoreTables.php
|
AdminStoreTables.upgrade_tables
|
private static function upgrade_tables($from_version=null) {
$sql = self::$sql;
if (!$from_version) {
$from_version = '0.0';
$sql->query_raw("
CREATE TABLE meta (
version VARCHAR(24) NOT NULL DEFAULT '0.0'
);
");
$sql->insert('meta', [
'version' => self::TABLE_VERSION,
]);
} else {
$sql->update('meta', [
'version' => self::TABLE_VERSION,
]);
}
self::$logger->info(sprintf(
"Zapmin: Upgrading tables: '%s' -> '%s'.",
$from_version, self::TABLE_VERSION));
# other upgrade actions here ...
}
|
php
|
private static function upgrade_tables($from_version=null) {
$sql = self::$sql;
if (!$from_version) {
$from_version = '0.0';
$sql->query_raw("
CREATE TABLE meta (
version VARCHAR(24) NOT NULL DEFAULT '0.0'
);
");
$sql->insert('meta', [
'version' => self::TABLE_VERSION,
]);
} else {
$sql->update('meta', [
'version' => self::TABLE_VERSION,
]);
}
self::$logger->info(sprintf(
"Zapmin: Upgrading tables: '%s' -> '%s'.",
$from_version, self::TABLE_VERSION));
# other upgrade actions here ...
}
|
[
"private",
"static",
"function",
"upgrade_tables",
"(",
"$",
"from_version",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
"self",
"::",
"$",
"sql",
";",
"if",
"(",
"!",
"$",
"from_version",
")",
"{",
"$",
"from_version",
"=",
"'0.0'",
";",
"$",
"sql",
"->",
"query_raw",
"(",
"\"\n\t\t\t\tCREATE TABLE meta (\n\t\t\t\t\tversion VARCHAR(24) NOT NULL DEFAULT '0.0'\n\t\t\t\t);\n\t\t\t\"",
")",
";",
"$",
"sql",
"->",
"insert",
"(",
"'meta'",
",",
"[",
"'version'",
"=>",
"self",
"::",
"TABLE_VERSION",
",",
"]",
")",
";",
"}",
"else",
"{",
"$",
"sql",
"->",
"update",
"(",
"'meta'",
",",
"[",
"'version'",
"=>",
"self",
"::",
"TABLE_VERSION",
",",
"]",
")",
";",
"}",
"self",
"::",
"$",
"logger",
"->",
"info",
"(",
"sprintf",
"(",
"\"Zapmin: Upgrading tables: '%s' -> '%s'.\"",
",",
"$",
"from_version",
",",
"self",
"::",
"TABLE_VERSION",
")",
")",
";",
"# other upgrade actions here ...",
"}"
] |
Upgrade tables.
|
[
"Upgrade",
"tables",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L222-L247
|
235,549
|
affinity4/config
|
src/Loader/Json.php
|
Json.input
|
public function input($file_content)
{
$this->file_content = $file_content;
$this->parsed_content = json_decode($this->file_content, true);
}
|
php
|
public function input($file_content)
{
$this->file_content = $file_content;
$this->parsed_content = json_decode($this->file_content, true);
}
|
[
"public",
"function",
"input",
"(",
"$",
"file_content",
")",
"{",
"$",
"this",
"->",
"file_content",
"=",
"$",
"file_content",
";",
"$",
"this",
"->",
"parsed_content",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"file_content",
",",
"true",
")",
";",
"}"
] |
Get raw JSON content and convert to array using json_decode
@author Luke Watts <luke@affinity4.ie>
@since 1.1.0
@param $file_content string
@return void
|
[
"Get",
"raw",
"JSON",
"content",
"and",
"convert",
"to",
"array",
"using",
"json_decode"
] |
df25bbf0839626af9b70b885e28bf32b1ad8d94a
|
https://github.com/affinity4/config/blob/df25bbf0839626af9b70b885e28bf32b1ad8d94a/src/Loader/Json.php#L59-L64
|
235,550
|
routegroup/native-media
|
src/Traits/Fileable.php
|
Fileable.files
|
public function files()
{
return $this->morphToMany(
config('media.model', \Routegroup\Media\File::class),
'mediables',
null,
null,
'media_id'
)
->withPivot('type')
->whereNotNull('mediables.type')
->withTimestamps();
}
|
php
|
public function files()
{
return $this->morphToMany(
config('media.model', \Routegroup\Media\File::class),
'mediables',
null,
null,
'media_id'
)
->withPivot('type')
->whereNotNull('mediables.type')
->withTimestamps();
}
|
[
"public",
"function",
"files",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"morphToMany",
"(",
"config",
"(",
"'media.model'",
",",
"\\",
"Routegroup",
"\\",
"Media",
"\\",
"File",
"::",
"class",
")",
",",
"'mediables'",
",",
"null",
",",
"null",
",",
"'media_id'",
")",
"->",
"withPivot",
"(",
"'type'",
")",
"->",
"whereNotNull",
"(",
"'mediables.type'",
")",
"->",
"withTimestamps",
"(",
")",
";",
"}"
] |
Has many files.
@return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
[
"Has",
"many",
"files",
"."
] |
5ea35c46c2ac1019e277ec4fe698f17581524631
|
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Traits/Fileable.php#L32-L44
|
235,551
|
asbsoft/yii2module-users_0_170112
|
models/User.php
|
User.profileRules
|
public function profileRules()
{
return [
[['username', 'password', 'email'], 'required', 'on' => self::SCENARIO_CREATE],
['username', 'match', 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i',
'message' => Yii::t($this->tcModule, 'Only latin letters, digits, hyphen, points and blanks begin with letter')
],
['username', 'string', 'min' => $this->minUsernameLength, 'max' => $this->maxUsernameLength],
['password', 'string', 'min' => $this->minPasswordLength, 'max' => $this->maxPasswordLength],
['email', 'string', 'max' => 255],
['email', 'email'],
];
}
|
php
|
public function profileRules()
{
return [
[['username', 'password', 'email'], 'required', 'on' => self::SCENARIO_CREATE],
['username', 'match', 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i',
'message' => Yii::t($this->tcModule, 'Only latin letters, digits, hyphen, points and blanks begin with letter')
],
['username', 'string', 'min' => $this->minUsernameLength, 'max' => $this->maxUsernameLength],
['password', 'string', 'min' => $this->minPasswordLength, 'max' => $this->maxPasswordLength],
['email', 'string', 'max' => 255],
['email', 'email'],
];
}
|
[
"public",
"function",
"profileRules",
"(",
")",
"{",
"return",
"[",
"[",
"[",
"'username'",
",",
"'password'",
",",
"'email'",
"]",
",",
"'required'",
",",
"'on'",
"=>",
"self",
"::",
"SCENARIO_CREATE",
"]",
",",
"[",
"'username'",
",",
"'match'",
",",
"'pattern'",
"=>",
"'/^[A-Za-z][A-Za-z0-9\\-\\.\\ ]+$/i'",
",",
"'message'",
"=>",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tcModule",
",",
"'Only latin letters, digits, hyphen, points and blanks begin with letter'",
")",
"]",
",",
"[",
"'username'",
",",
"'string'",
",",
"'min'",
"=>",
"$",
"this",
"->",
"minUsernameLength",
",",
"'max'",
"=>",
"$",
"this",
"->",
"maxUsernameLength",
"]",
",",
"[",
"'password'",
",",
"'string'",
",",
"'min'",
"=>",
"$",
"this",
"->",
"minPasswordLength",
",",
"'max'",
"=>",
"$",
"this",
"->",
"maxPasswordLength",
"]",
",",
"[",
"'email'",
",",
"'string'",
",",
"'max'",
"=>",
"255",
"]",
",",
"[",
"'email'",
",",
"'email'",
"]",
",",
"]",
";",
"}"
] |
Part of rules for common use with ProfileForm.
Rules with fields length, patterns be best in single place.
|
[
"Part",
"of",
"rules",
"for",
"common",
"use",
"with",
"ProfileForm",
".",
"Rules",
"with",
"fields",
"length",
"patterns",
"be",
"best",
"in",
"single",
"place",
"."
] |
3906fdde2d5fdd54637f2b5246d52fe91ec5f648
|
https://github.com/asbsoft/yii2module-users_0_170112/blob/3906fdde2d5fdd54637f2b5246d52fe91ec5f648/models/User.php#L107-L122
|
235,552
|
bytorsten/graphql-subscriptions
|
src/Rules/SingleFieldSubscriptions.php
|
SingleFieldSubscriptions.getVisitor
|
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) {
if ($node->operation === 'subscription') {
if (count($node->selectionSet->selections) !== 1) {
$context->reportError(
new Error(
$this->singleFieldOnlyMessage($node->name ? $node->name->value : null),
array_slice($node->selectionSet->selections, 1)
)
);
}
}
}
];
}
|
php
|
public function getVisitor(ValidationContext $context)
{
return [
NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) {
if ($node->operation === 'subscription') {
if (count($node->selectionSet->selections) !== 1) {
$context->reportError(
new Error(
$this->singleFieldOnlyMessage($node->name ? $node->name->value : null),
array_slice($node->selectionSet->selections, 1)
)
);
}
}
}
];
}
|
[
"public",
"function",
"getVisitor",
"(",
"ValidationContext",
"$",
"context",
")",
"{",
"return",
"[",
"NodeKind",
"::",
"OPERATION_DEFINITION",
"=>",
"function",
"(",
"OperationDefinitionNode",
"$",
"node",
")",
"use",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"operation",
"===",
"'subscription'",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"node",
"->",
"selectionSet",
"->",
"selections",
")",
"!==",
"1",
")",
"{",
"$",
"context",
"->",
"reportError",
"(",
"new",
"Error",
"(",
"$",
"this",
"->",
"singleFieldOnlyMessage",
"(",
"$",
"node",
"->",
"name",
"?",
"$",
"node",
"->",
"name",
"->",
"value",
":",
"null",
")",
",",
"array_slice",
"(",
"$",
"node",
"->",
"selectionSet",
"->",
"selections",
",",
"1",
")",
")",
")",
";",
"}",
"}",
"}",
"]",
";",
"}"
] |
Returns structure suitable for GraphQL\Language\Visitor
@see \GraphQL\Language\Visitor
@param ValidationContext $context
@return array
|
[
"Returns",
"structure",
"suitable",
"for",
"GraphQL",
"\\",
"Language",
"\\",
"Visitor"
] |
c47b40c0c1762439573029cfef49fee5a6ca7a08
|
https://github.com/bytorsten/graphql-subscriptions/blob/c47b40c0c1762439573029cfef49fee5a6ca7a08/src/Rules/SingleFieldSubscriptions.php#L28-L44
|
235,553
|
gossi/trixionary
|
src/TrixionaryModule.php
|
TrixionaryModule.getSkillsPath
|
public function getSkillsPath(Sport $sport) {
return $this->getSportPath($sport)->append($this->getSkillsSegment($sport));
}
|
php
|
public function getSkillsPath(Sport $sport) {
return $this->getSportPath($sport)->append($this->getSkillsSegment($sport));
}
|
[
"public",
"function",
"getSkillsPath",
"(",
"Sport",
"$",
"sport",
")",
"{",
"return",
"$",
"this",
"->",
"getSportPath",
"(",
"$",
"sport",
")",
"->",
"append",
"(",
"$",
"this",
"->",
"getSkillsSegment",
"(",
"$",
"sport",
")",
")",
";",
"}"
] |
Returns the path for skills for the given sport
@param Sport $sport
@return Path
|
[
"Returns",
"the",
"path",
"for",
"skills",
"for",
"the",
"given",
"sport"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/TrixionaryModule.php#L150-L152
|
235,554
|
gossi/trixionary
|
src/TrixionaryModule.php
|
TrixionaryModule.getSkillPath
|
public function getSkillPath(Skill $skill) {
return $this->getSkillsPath($skill->getSport())->append($this->getSkillSegment($skill));
}
|
php
|
public function getSkillPath(Skill $skill) {
return $this->getSkillsPath($skill->getSport())->append($this->getSkillSegment($skill));
}
|
[
"public",
"function",
"getSkillPath",
"(",
"Skill",
"$",
"skill",
")",
"{",
"return",
"$",
"this",
"->",
"getSkillsPath",
"(",
"$",
"skill",
"->",
"getSport",
"(",
")",
")",
"->",
"append",
"(",
"$",
"this",
"->",
"getSkillSegment",
"(",
"$",
"skill",
")",
")",
";",
"}"
] |
Returns the path for the given skill
@param Skill $skill
@return Path
|
[
"Returns",
"the",
"path",
"for",
"the",
"given",
"skill"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/TrixionaryModule.php#L178-L180
|
235,555
|
gossi/trixionary
|
src/TrixionaryModule.php
|
TrixionaryModule.getSkillUrl
|
public function getSkillUrl(Skill $skill) {
return $this->getSkillsUrl($skill->getSport()) . '/' . $this->getSkillSegment($skill);
}
|
php
|
public function getSkillUrl(Skill $skill) {
return $this->getSkillsUrl($skill->getSport()) . '/' . $this->getSkillSegment($skill);
}
|
[
"public",
"function",
"getSkillUrl",
"(",
"Skill",
"$",
"skill",
")",
"{",
"return",
"$",
"this",
"->",
"getSkillsUrl",
"(",
"$",
"skill",
"->",
"getSport",
"(",
")",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getSkillSegment",
"(",
"$",
"skill",
")",
";",
"}"
] |
Returns the url for the given skill
@param Skill $skill
@return string
|
[
"Returns",
"the",
"url",
"for",
"the",
"given",
"skill"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/TrixionaryModule.php#L187-L189
|
235,556
|
samurai-fw/samurai
|
src/Console/Controller/UtilityController.php
|
UtilityController.locatorAction
|
public function locatorAction()
{
$arg = $this->request->get('args');
// task execute.
if (($task = $this->request->get('tasks')) || ($task = $this->request->get('option.T'))) {
return [self::FORWARD_ACTION, 'task.list'];
} elseif ($this->isTask($arg)) {
return [self::FORWARD_ACTION, 'task.execute'];
}
// start server.
if ($arg === 's') {
return [self::FORWARD_ACTION, 'utility.server'];
}
// show version.
if ($arg === null && ($this->request->get('option.v') || $this->request->get('version'))) {
return [self::FORWARD_ACTION, 'utility.version'];
}
// show usage.
if ($arg === null) {
return [self::FORWARD_ACTION, 'utility.usage'];
}
// action execute.
// exclude first argument, because this is command name.
$args = $this->request->getAsArray('args');
array_shift($args);
$this->request->set('args', $args);
return [self::FORWARD_ACTION, $this->completionActionArg($arg)];
}
|
php
|
public function locatorAction()
{
$arg = $this->request->get('args');
// task execute.
if (($task = $this->request->get('tasks')) || ($task = $this->request->get('option.T'))) {
return [self::FORWARD_ACTION, 'task.list'];
} elseif ($this->isTask($arg)) {
return [self::FORWARD_ACTION, 'task.execute'];
}
// start server.
if ($arg === 's') {
return [self::FORWARD_ACTION, 'utility.server'];
}
// show version.
if ($arg === null && ($this->request->get('option.v') || $this->request->get('version'))) {
return [self::FORWARD_ACTION, 'utility.version'];
}
// show usage.
if ($arg === null) {
return [self::FORWARD_ACTION, 'utility.usage'];
}
// action execute.
// exclude first argument, because this is command name.
$args = $this->request->getAsArray('args');
array_shift($args);
$this->request->set('args', $args);
return [self::FORWARD_ACTION, $this->completionActionArg($arg)];
}
|
[
"public",
"function",
"locatorAction",
"(",
")",
"{",
"$",
"arg",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'args'",
")",
";",
"// task execute.",
"if",
"(",
"(",
"$",
"task",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'tasks'",
")",
")",
"||",
"(",
"$",
"task",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'option.T'",
")",
")",
")",
"{",
"return",
"[",
"self",
"::",
"FORWARD_ACTION",
",",
"'task.list'",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isTask",
"(",
"$",
"arg",
")",
")",
"{",
"return",
"[",
"self",
"::",
"FORWARD_ACTION",
",",
"'task.execute'",
"]",
";",
"}",
"// start server.",
"if",
"(",
"$",
"arg",
"===",
"'s'",
")",
"{",
"return",
"[",
"self",
"::",
"FORWARD_ACTION",
",",
"'utility.server'",
"]",
";",
"}",
"// show version.",
"if",
"(",
"$",
"arg",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'option.v'",
")",
"||",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'version'",
")",
")",
")",
"{",
"return",
"[",
"self",
"::",
"FORWARD_ACTION",
",",
"'utility.version'",
"]",
";",
"}",
"// show usage.",
"if",
"(",
"$",
"arg",
"===",
"null",
")",
"{",
"return",
"[",
"self",
"::",
"FORWARD_ACTION",
",",
"'utility.usage'",
"]",
";",
"}",
"// action execute.",
"// exclude first argument, because this is command name.",
"$",
"args",
"=",
"$",
"this",
"->",
"request",
"->",
"getAsArray",
"(",
"'args'",
")",
";",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"request",
"->",
"set",
"(",
"'args'",
",",
"$",
"args",
")",
";",
"return",
"[",
"self",
"::",
"FORWARD_ACTION",
",",
"$",
"this",
"->",
"completionActionArg",
"(",
"$",
"arg",
")",
"]",
";",
"}"
] |
action locator action.
|
[
"action",
"locator",
"action",
"."
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L51-L83
|
235,557
|
samurai-fw/samurai
|
src/Console/Controller/UtilityController.php
|
UtilityController.versionAction
|
public function versionAction()
{
$this->assign('version', Samurai::getVersion());
$this->assign('state', Samurai::getState());
return self::VIEW_TEMPLATE;
}
|
php
|
public function versionAction()
{
$this->assign('version', Samurai::getVersion());
$this->assign('state', Samurai::getState());
return self::VIEW_TEMPLATE;
}
|
[
"public",
"function",
"versionAction",
"(",
")",
"{",
"$",
"this",
"->",
"assign",
"(",
"'version'",
",",
"Samurai",
"::",
"getVersion",
"(",
")",
")",
";",
"$",
"this",
"->",
"assign",
"(",
"'state'",
",",
"Samurai",
"::",
"getState",
"(",
")",
")",
";",
"return",
"self",
"::",
"VIEW_TEMPLATE",
";",
"}"
] |
show version action.
|
[
"show",
"version",
"action",
"."
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L90-L95
|
235,558
|
samurai-fw/samurai
|
src/Console/Controller/UtilityController.php
|
UtilityController.usageAction
|
public function usageAction()
{
$this->assign('version', Samurai::getVersion());
$this->assign('state', Samurai::getState());
$this->assign('script', './app'); // TODO: $this->request->getScript()
return self::VIEW_TEMPLATE;
}
|
php
|
public function usageAction()
{
$this->assign('version', Samurai::getVersion());
$this->assign('state', Samurai::getState());
$this->assign('script', './app'); // TODO: $this->request->getScript()
return self::VIEW_TEMPLATE;
}
|
[
"public",
"function",
"usageAction",
"(",
")",
"{",
"$",
"this",
"->",
"assign",
"(",
"'version'",
",",
"Samurai",
"::",
"getVersion",
"(",
")",
")",
";",
"$",
"this",
"->",
"assign",
"(",
"'state'",
",",
"Samurai",
"::",
"getState",
"(",
")",
")",
";",
"$",
"this",
"->",
"assign",
"(",
"'script'",
",",
"'./app'",
")",
";",
"// TODO: $this->request->getScript()",
"return",
"self",
"::",
"VIEW_TEMPLATE",
";",
"}"
] |
show usage action.
|
[
"show",
"usage",
"action",
"."
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L101-L107
|
235,559
|
samurai-fw/samurai
|
src/Console/Controller/UtilityController.php
|
UtilityController.serverAction
|
public function serverAction()
{
chdir($this->application->config('directory.document_root'));
$host = $this->request->get('host', 'localhost');
$port = $this->request->get('port', 8888);
passthru(sprintf('php -S %s:%s index.php', $host, $port));
}
|
php
|
public function serverAction()
{
chdir($this->application->config('directory.document_root'));
$host = $this->request->get('host', 'localhost');
$port = $this->request->get('port', 8888);
passthru(sprintf('php -S %s:%s index.php', $host, $port));
}
|
[
"public",
"function",
"serverAction",
"(",
")",
"{",
"chdir",
"(",
"$",
"this",
"->",
"application",
"->",
"config",
"(",
"'directory.document_root'",
")",
")",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'host'",
",",
"'localhost'",
")",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'port'",
",",
"8888",
")",
";",
"passthru",
"(",
"sprintf",
"(",
"'php -S %s:%s index.php'",
",",
"$",
"host",
",",
"$",
"port",
")",
")",
";",
"}"
] |
start server action.
|
[
"start",
"server",
"action",
"."
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L113-L119
|
235,560
|
JaredClemence/binn
|
src/builders/KeyValueByteGenerator.php
|
KeyValueByteGenerator.readNextKeyValuePair
|
public function readNextKeyValuePair( $truncatedString ) : ContainerElement {
$keyBytes = $this->extractKeyBytes( $truncatedString );
$remainingBytes = substr( $truncatedString, $keyBytes->getLength() );
$data = $this->readData( $remainingBytes );
return new ContainerElement($keyBytes, $data);
}
|
php
|
public function readNextKeyValuePair( $truncatedString ) : ContainerElement {
$keyBytes = $this->extractKeyBytes( $truncatedString );
$remainingBytes = substr( $truncatedString, $keyBytes->getLength() );
$data = $this->readData( $remainingBytes );
return new ContainerElement($keyBytes, $data);
}
|
[
"public",
"function",
"readNextKeyValuePair",
"(",
"$",
"truncatedString",
")",
":",
"ContainerElement",
"{",
"$",
"keyBytes",
"=",
"$",
"this",
"->",
"extractKeyBytes",
"(",
"$",
"truncatedString",
")",
";",
"$",
"remainingBytes",
"=",
"substr",
"(",
"$",
"truncatedString",
",",
"$",
"keyBytes",
"->",
"getLength",
"(",
")",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"readData",
"(",
"$",
"remainingBytes",
")",
";",
"return",
"new",
"ContainerElement",
"(",
"$",
"keyBytes",
",",
"$",
"data",
")",
";",
"}"
] |
This method receives a data string that is already truncated.
The expectation is that the first bytes will represent the key, then a series
of bytes will represent the value. That value will end either at the beginning of the
next data structure or the end of the data string.
@param type $truncatedString
|
[
"This",
"method",
"receives",
"a",
"data",
"string",
"that",
"is",
"already",
"truncated",
".",
"The",
"expectation",
"is",
"that",
"the",
"first",
"bytes",
"will",
"represent",
"the",
"key",
"then",
"a",
"series",
"of",
"bytes",
"will",
"represent",
"the",
"value",
".",
"That",
"value",
"will",
"end",
"either",
"at",
"the",
"beginning",
"of",
"the",
"next",
"data",
"structure",
"or",
"the",
"end",
"of",
"the",
"data",
"string",
"."
] |
838591e7a92c0f257c09a1df141d80737a20f7d9
|
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/KeyValueByteGenerator.php#L53-L58
|
235,561
|
romanmatyus/FileMailer
|
src/FileMailer/FileMailer.php
|
FileMailer.send
|
public function send(Message $message)
{
$content = $message->generateMessage();
preg_match('~Message-ID: <(?<message_id>\w+)[^>]+>~', $content, $matches);
$path = $this->tempDir . '/'. $this->prefix . $matches['message_id'] . '.' . self::FILE_EXTENSION;
if (($bytes = file_put_contents($path, $content)) === FALSE) {
throw new InvalidStateException("Unable to write email to '$path'.");
}
return $bytes;
}
|
php
|
public function send(Message $message)
{
$content = $message->generateMessage();
preg_match('~Message-ID: <(?<message_id>\w+)[^>]+>~', $content, $matches);
$path = $this->tempDir . '/'. $this->prefix . $matches['message_id'] . '.' . self::FILE_EXTENSION;
if (($bytes = file_put_contents($path, $content)) === FALSE) {
throw new InvalidStateException("Unable to write email to '$path'.");
}
return $bytes;
}
|
[
"public",
"function",
"send",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"content",
"=",
"$",
"message",
"->",
"generateMessage",
"(",
")",
";",
"preg_match",
"(",
"'~Message-ID: <(?<message_id>\\w+)[^>]+>~'",
",",
"$",
"content",
",",
"$",
"matches",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"tempDir",
".",
"'/'",
".",
"$",
"this",
"->",
"prefix",
".",
"$",
"matches",
"[",
"'message_id'",
"]",
".",
"'.'",
".",
"self",
"::",
"FILE_EXTENSION",
";",
"if",
"(",
"(",
"$",
"bytes",
"=",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"content",
")",
")",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"\"Unable to write email to '$path'.\"",
")",
";",
"}",
"return",
"$",
"bytes",
";",
"}"
] |
Store mail to file.
@param Message $message
@return int
|
[
"Store",
"mail",
"to",
"file",
"."
] |
732685f5505ea764fe76cc92bc4ffbc3b4ea917b
|
https://github.com/romanmatyus/FileMailer/blob/732685f5505ea764fe76cc92bc4ffbc3b4ea917b/src/FileMailer/FileMailer.php#L66-L78
|
235,562
|
ytubes/videos
|
controllers/CategoryController.php
|
CategoryController.actionIndex
|
public function actionIndex($slug, $page = 1, $sort = '')
{
$this->trigger(self::EVENT_BEFORE_CATEGORY_SHOW);
$data['slug'] = $slug;
$data['sort'] = $sort;
$data['page'] = (int) $page;
$data['route'] = '/' . $this->getRoute();
// Ищем категорию
$data['category'] = CategoryFinder::findBySlug($slug);//$categriesRepository->findBySlug($slug);
if (empty($data['category'])) {
throw new NotFoundHttpException('The requested page does not exist.');
}
$videoFinder = new VideoFinder();
$data['videos'] = $videoFinder->getVideosFromCategory($data['category'], $page);
$pagination = new Pagination([
'totalCount' => $videoFinder->totalCount(),
'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'pageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'route' => $data['route'],
'forcePageParam' => false,
]);
$settings = Yii::$app->settings->getAll();
$settings['videos'] = Module::getInstance()->settings->getAll();
Event::on(self::class, self::EVENT_AFTER_CATEGORY_SHOW, [\ytubes\videos\events\UpdateCountersEvent::class, 'onShowThumbs'], $data);
$this->trigger(self::EVENT_AFTER_CATEGORY_SHOW);
return $this->render('category_videos', [
'data' => $data,
'settings' => $settings,
'pagination' => $pagination,
]);
}
|
php
|
public function actionIndex($slug, $page = 1, $sort = '')
{
$this->trigger(self::EVENT_BEFORE_CATEGORY_SHOW);
$data['slug'] = $slug;
$data['sort'] = $sort;
$data['page'] = (int) $page;
$data['route'] = '/' . $this->getRoute();
// Ищем категорию
$data['category'] = CategoryFinder::findBySlug($slug);//$categriesRepository->findBySlug($slug);
if (empty($data['category'])) {
throw new NotFoundHttpException('The requested page does not exist.');
}
$videoFinder = new VideoFinder();
$data['videos'] = $videoFinder->getVideosFromCategory($data['category'], $page);
$pagination = new Pagination([
'totalCount' => $videoFinder->totalCount(),
'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'pageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'route' => $data['route'],
'forcePageParam' => false,
]);
$settings = Yii::$app->settings->getAll();
$settings['videos'] = Module::getInstance()->settings->getAll();
Event::on(self::class, self::EVENT_AFTER_CATEGORY_SHOW, [\ytubes\videos\events\UpdateCountersEvent::class, 'onShowThumbs'], $data);
$this->trigger(self::EVENT_AFTER_CATEGORY_SHOW);
return $this->render('category_videos', [
'data' => $data,
'settings' => $settings,
'pagination' => $pagination,
]);
}
|
[
"public",
"function",
"actionIndex",
"(",
"$",
"slug",
",",
"$",
"page",
"=",
"1",
",",
"$",
"sort",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_CATEGORY_SHOW",
")",
";",
"$",
"data",
"[",
"'slug'",
"]",
"=",
"$",
"slug",
";",
"$",
"data",
"[",
"'sort'",
"]",
"=",
"$",
"sort",
";",
"$",
"data",
"[",
"'page'",
"]",
"=",
"(",
"int",
")",
"$",
"page",
";",
"$",
"data",
"[",
"'route'",
"]",
"=",
"'/'",
".",
"$",
"this",
"->",
"getRoute",
"(",
")",
";",
"// Ищем категорию",
"$",
"data",
"[",
"'category'",
"]",
"=",
"CategoryFinder",
"::",
"findBySlug",
"(",
"$",
"slug",
")",
";",
"//$categriesRepository->findBySlug($slug);",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'category'",
"]",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The requested page does not exist.'",
")",
";",
"}",
"$",
"videoFinder",
"=",
"new",
"VideoFinder",
"(",
")",
";",
"$",
"data",
"[",
"'videos'",
"]",
"=",
"$",
"videoFinder",
"->",
"getVideosFromCategory",
"(",
"$",
"data",
"[",
"'category'",
"]",
",",
"$",
"page",
")",
";",
"$",
"pagination",
"=",
"new",
"Pagination",
"(",
"[",
"'totalCount'",
"=>",
"$",
"videoFinder",
"->",
"totalCount",
"(",
")",
",",
"'defaultPageSize'",
"=>",
"Module",
"::",
"getInstance",
"(",
")",
"->",
"settings",
"->",
"get",
"(",
"'items_per_page'",
",",
"20",
")",
",",
"'pageSize'",
"=>",
"Module",
"::",
"getInstance",
"(",
")",
"->",
"settings",
"->",
"get",
"(",
"'items_per_page'",
",",
"20",
")",
",",
"'route'",
"=>",
"$",
"data",
"[",
"'route'",
"]",
",",
"'forcePageParam'",
"=>",
"false",
",",
"]",
")",
";",
"$",
"settings",
"=",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"getAll",
"(",
")",
";",
"$",
"settings",
"[",
"'videos'",
"]",
"=",
"Module",
"::",
"getInstance",
"(",
")",
"->",
"settings",
"->",
"getAll",
"(",
")",
";",
"Event",
"::",
"on",
"(",
"self",
"::",
"class",
",",
"self",
"::",
"EVENT_AFTER_CATEGORY_SHOW",
",",
"[",
"\\",
"ytubes",
"\\",
"videos",
"\\",
"events",
"\\",
"UpdateCountersEvent",
"::",
"class",
",",
"'onShowThumbs'",
"]",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_CATEGORY_SHOW",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'category_videos'",
",",
"[",
"'data'",
"=>",
"$",
"data",
",",
"'settings'",
"=>",
"$",
"settings",
",",
"'pagination'",
"=>",
"$",
"pagination",
",",
"]",
")",
";",
"}"
] |
Lists categorized Videos models.
@return mixed
|
[
"Lists",
"categorized",
"Videos",
"models",
"."
] |
a35ecb1f8e38381063fbd757683a13df3a8cbc48
|
https://github.com/ytubes/videos/blob/a35ecb1f8e38381063fbd757683a13df3a8cbc48/controllers/CategoryController.php#L56-L95
|
235,563
|
khooz/commons
|
src/MrAudioGuy/Commons/Arr.php
|
Arr.pluck
|
public static function pluck (array $array, $keys)
{
if (!is_array($keys))
{
$keys = func_get_args();
array_shift($keys);
}
return array_intersect_key($array, array_flip($keys));
}
|
php
|
public static function pluck (array $array, $keys)
{
if (!is_array($keys))
{
$keys = func_get_args();
array_shift($keys);
}
return array_intersect_key($array, array_flip($keys));
}
|
[
"public",
"static",
"function",
"pluck",
"(",
"array",
"$",
"array",
",",
"$",
"keys",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"keys",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"keys",
")",
";",
"}",
"return",
"array_intersect_key",
"(",
"$",
"array",
",",
"array_flip",
"(",
"$",
"keys",
")",
")",
";",
"}"
] |
Plucks keys from an array
@param array $array
@param $keys
@return array
|
[
"Plucks",
"keys",
"from",
"an",
"array"
] |
d426df97075e66e19f7576e89bdd954c699914f4
|
https://github.com/khooz/commons/blob/d426df97075e66e19f7576e89bdd954c699914f4/src/MrAudioGuy/Commons/Arr.php#L20-L29
|
235,564
|
khooz/commons
|
src/MrAudioGuy/Commons/Arr.php
|
Arr.is_associative
|
public static function is_associative (array $array)
{
foreach ($array as $k => $v)
{
$t = str_replace((int)$k, '', $k);
if (!empty($t))
{
if (!static::is_int($k))
{
return true;
}
}
}
return false;
}
|
php
|
public static function is_associative (array $array)
{
foreach ($array as $k => $v)
{
$t = str_replace((int)$k, '', $k);
if (!empty($t))
{
if (!static::is_int($k))
{
return true;
}
}
}
return false;
}
|
[
"public",
"static",
"function",
"is_associative",
"(",
"array",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"t",
"=",
"str_replace",
"(",
"(",
"int",
")",
"$",
"k",
",",
"''",
",",
"$",
"k",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"t",
")",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is_int",
"(",
"$",
"k",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determines if an array is associative
@param array $array
@return bool
|
[
"Determines",
"if",
"an",
"array",
"is",
"associative"
] |
d426df97075e66e19f7576e89bdd954c699914f4
|
https://github.com/khooz/commons/blob/d426df97075e66e19f7576e89bdd954c699914f4/src/MrAudioGuy/Commons/Arr.php#L57-L72
|
235,565
|
jsiefer/class-mocker
|
src/ClassMocker.php
|
ClassMocker.enable
|
public function enable()
{
spl_autoload_register([$this, 'autoload'], true, true);
spl_autoload_register([$this, 'autoloadOptional'], true, false);
return $this;
}
|
php
|
public function enable()
{
spl_autoload_register([$this, 'autoload'], true, true);
spl_autoload_register([$this, 'autoloadOptional'], true, false);
return $this;
}
|
[
"public",
"function",
"enable",
"(",
")",
"{",
"spl_autoload_register",
"(",
"[",
"$",
"this",
",",
"'autoload'",
"]",
",",
"true",
",",
"true",
")",
";",
"spl_autoload_register",
"(",
"[",
"$",
"this",
",",
"'autoloadOptional'",
"]",
",",
"true",
",",
"false",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Enable class mocker by registering the auto loader
@return $this
|
[
"Enable",
"class",
"mocker",
"by",
"registering",
"the",
"auto",
"loader"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L68-L73
|
235,566
|
jsiefer/class-mocker
|
src/ClassMocker.php
|
ClassMocker.mock
|
public function mock($pattern, $ifNotExist = false)
{
if ($ifNotExist) {
$this->_optionalMockPatterns[] = $pattern;
} else {
$this->_mockPatterns[] = $pattern;
}
return $this;
}
|
php
|
public function mock($pattern, $ifNotExist = false)
{
if ($ifNotExist) {
$this->_optionalMockPatterns[] = $pattern;
} else {
$this->_mockPatterns[] = $pattern;
}
return $this;
}
|
[
"public",
"function",
"mock",
"(",
"$",
"pattern",
",",
"$",
"ifNotExist",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"ifNotExist",
")",
"{",
"$",
"this",
"->",
"_optionalMockPatterns",
"[",
"]",
"=",
"$",
"pattern",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_mockPatterns",
"[",
"]",
"=",
"$",
"pattern",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Mock any class matching the given pattern
e.g.
mock('Mage*')
mock('Mage*Collection')
mock('Foo\Bar\*')
@param string $pattern
@param bool $ifNotExist
@return $this
|
[
"Mock",
"any",
"class",
"matching",
"the",
"given",
"pattern"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L114-L123
|
235,567
|
jsiefer/class-mocker
|
src/ClassMocker.php
|
ClassMocker.generateAndLoadClass
|
public function generateAndLoadClass($className)
{
if (class_exists($className, false)) {
throw new \RuntimeException("Unable to generate and load already existing class '$className'");
}
$filename = $this->findFile($className);
if (!$filename || !file_exists($filename)) {
$classFileGenerator = $this->_builder->build($className);
if ($filename) {
file_put_contents($filename, $classFileGenerator->generate());
} else {
$this->evalContent($classFileGenerator);
}
}
if ($filename && file_exists($filename)) {
include $filename;
}
}
|
php
|
public function generateAndLoadClass($className)
{
if (class_exists($className, false)) {
throw new \RuntimeException("Unable to generate and load already existing class '$className'");
}
$filename = $this->findFile($className);
if (!$filename || !file_exists($filename)) {
$classFileGenerator = $this->_builder->build($className);
if ($filename) {
file_put_contents($filename, $classFileGenerator->generate());
} else {
$this->evalContent($classFileGenerator);
}
}
if ($filename && file_exists($filename)) {
include $filename;
}
}
|
[
"public",
"function",
"generateAndLoadClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Unable to generate and load already existing class '$className'\"",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"findFile",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"$",
"filename",
"||",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"classFileGenerator",
"=",
"$",
"this",
"->",
"_builder",
"->",
"build",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"filename",
")",
"{",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"classFileGenerator",
"->",
"generate",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"evalContent",
"(",
"$",
"classFileGenerator",
")",
";",
"}",
"}",
"if",
"(",
"$",
"filename",
"&&",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"include",
"$",
"filename",
";",
"}",
"}"
] |
Generate and load the given class
@param string $className
@throws \Exception
@return void
|
[
"Generate",
"and",
"load",
"the",
"given",
"class"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L215-L235
|
235,568
|
jsiefer/class-mocker
|
src/ClassMocker.php
|
ClassMocker._autoload
|
protected function _autoload($patterns, $className)
{
foreach ($patterns as $pattern) {
if (!fnmatch($pattern, $className, FNM_NOESCAPE)) {
continue;
}
$this->generateAndLoadClass($className);
return true;
}
return false;
}
|
php
|
protected function _autoload($patterns, $className)
{
foreach ($patterns as $pattern) {
if (!fnmatch($pattern, $className, FNM_NOESCAPE)) {
continue;
}
$this->generateAndLoadClass($className);
return true;
}
return false;
}
|
[
"protected",
"function",
"_autoload",
"(",
"$",
"patterns",
",",
"$",
"className",
")",
"{",
"foreach",
"(",
"$",
"patterns",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"fnmatch",
"(",
"$",
"pattern",
",",
"$",
"className",
",",
"FNM_NOESCAPE",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"generateAndLoadClass",
"(",
"$",
"className",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Autoload class if matching any of given patterns
@param string[] $patterns
@param string $className
@return bool
|
[
"Autoload",
"class",
"if",
"matching",
"any",
"of",
"given",
"patterns"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L245-L256
|
235,569
|
jsiefer/class-mocker
|
src/ClassMocker.php
|
ClassMocker.evalContent
|
private function evalContent(FileGenerator $classFileGenerator)
{
$code = $classFileGenerator->generate();
$code = substr($code, 6); // remove <?php
eval($code);
}
|
php
|
private function evalContent(FileGenerator $classFileGenerator)
{
$code = $classFileGenerator->generate();
$code = substr($code, 6); // remove <?php
eval($code);
}
|
[
"private",
"function",
"evalContent",
"(",
"FileGenerator",
"$",
"classFileGenerator",
")",
"{",
"$",
"code",
"=",
"$",
"classFileGenerator",
"->",
"generate",
"(",
")",
";",
"$",
"code",
"=",
"substr",
"(",
"$",
"code",
",",
"6",
")",
";",
"// remove <?php",
"eval",
"(",
"$",
"code",
")",
";",
"}"
] |
Eval file content
@param FileGenerator $classFileGenerator
|
[
"Eval",
"file",
"content"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L263-L269
|
235,570
|
jsiefer/class-mocker
|
src/ClassMocker.php
|
ClassMocker.findFile
|
protected function findFile($className)
{
$genDir = $this->getGenerationDir();
if (!$genDir) {
return null;
}
$path = [$genDir];
$path[] = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
$path = implode(DIRECTORY_SEPARATOR, $path);
$dir = dirname($path);
if (!is_dir($dir) && !@mkdir($dir, 0777, true)) {
$e = error_get_last();
throw new \RuntimeException(
"Failed to create class generation folder: " . $e['message']
);
}
return $path;
}
|
php
|
protected function findFile($className)
{
$genDir = $this->getGenerationDir();
if (!$genDir) {
return null;
}
$path = [$genDir];
$path[] = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
$path = implode(DIRECTORY_SEPARATOR, $path);
$dir = dirname($path);
if (!is_dir($dir) && !@mkdir($dir, 0777, true)) {
$e = error_get_last();
throw new \RuntimeException(
"Failed to create class generation folder: " . $e['message']
);
}
return $path;
}
|
[
"protected",
"function",
"findFile",
"(",
"$",
"className",
")",
"{",
"$",
"genDir",
"=",
"$",
"this",
"->",
"getGenerationDir",
"(",
")",
";",
"if",
"(",
"!",
"$",
"genDir",
")",
"{",
"return",
"null",
";",
"}",
"$",
"path",
"=",
"[",
"$",
"genDir",
"]",
";",
"$",
"path",
"[",
"]",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"className",
")",
".",
"'.php'",
";",
"$",
"path",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
"&&",
"!",
"@",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
")",
"{",
"$",
"e",
"=",
"error_get_last",
"(",
")",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Failed to create class generation folder: \"",
".",
"$",
"e",
"[",
"'message'",
"]",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Retrieve file for class name
@param string $className
@return string
@throws \Exception
|
[
"Retrieve",
"file",
"for",
"class",
"name"
] |
a355fc9bece8e6f27fbfd09b1631234f7d73a791
|
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L279-L302
|
235,571
|
geniv/nette-filters
|
src/FilterLatte.php
|
FilterLatte.addTag
|
public static function addTag(string $string, string $tag): string
{
$lastPoint = strrpos($string, '.');
return ($tag ? substr_replace($string, sprintf('.%s.', $tag), $lastPoint, 1) : $string);
}
|
php
|
public static function addTag(string $string, string $tag): string
{
$lastPoint = strrpos($string, '.');
return ($tag ? substr_replace($string, sprintf('.%s.', $tag), $lastPoint, 1) : $string);
}
|
[
"public",
"static",
"function",
"addTag",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"tag",
")",
":",
"string",
"{",
"$",
"lastPoint",
"=",
"strrpos",
"(",
"$",
"string",
",",
"'.'",
")",
";",
"return",
"(",
"$",
"tag",
"?",
"substr_replace",
"(",
"$",
"string",
",",
"sprintf",
"(",
"'.%s.'",
",",
"$",
"tag",
")",
",",
"$",
"lastPoint",
",",
"1",
")",
":",
"$",
"string",
")",
";",
"}"
] |
Add tag.
@param string $string
@param string $tag
@return string
|
[
"Add",
"tag",
"."
] |
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
|
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L47-L51
|
235,572
|
geniv/nette-filters
|
src/FilterLatte.php
|
FilterLatte.dateDiff
|
public static function dateDiff(DateTime $from = null, DateTime $to = null, string $format = 'Y-m-d H:i:s'): string
{
if (!$from) {
return '';
}
if (!$to) { // if not define to then to date is set today
$to = new DateTime();
}
return $from->diff($to)->format($format);
}
|
php
|
public static function dateDiff(DateTime $from = null, DateTime $to = null, string $format = 'Y-m-d H:i:s'): string
{
if (!$from) {
return '';
}
if (!$to) { // if not define to then to date is set today
$to = new DateTime();
}
return $from->diff($to)->format($format);
}
|
[
"public",
"static",
"function",
"dateDiff",
"(",
"DateTime",
"$",
"from",
"=",
"null",
",",
"DateTime",
"$",
"to",
"=",
"null",
",",
"string",
"$",
"format",
"=",
"'Y-m-d H:i:s'",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"from",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"!",
"$",
"to",
")",
"{",
"// if not define to then to date is set today",
"$",
"to",
"=",
"new",
"DateTime",
"(",
")",
";",
"}",
"return",
"$",
"from",
"->",
"diff",
"(",
"$",
"to",
")",
"->",
"format",
"(",
"$",
"format",
")",
";",
"}"
] |
Date diff.
@param DateTime|null $from
@param DateTime|null $to
@param string $format
@return string
@throws \Exception
|
[
"Date",
"diff",
"."
] |
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
|
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L75-L84
|
235,573
|
geniv/nette-filters
|
src/FilterLatte.php
|
FilterLatte.googleMapsLink
|
public static function googleMapsLink(string $query): string
{
$result = $query;
if ($query) {
$result = 'https://www.google.com/maps/search/?api=1&query=' . $query;
}
return $result;
}
|
php
|
public static function googleMapsLink(string $query): string
{
$result = $query;
if ($query) {
$result = 'https://www.google.com/maps/search/?api=1&query=' . $query;
}
return $result;
}
|
[
"public",
"static",
"function",
"googleMapsLink",
"(",
"string",
"$",
"query",
")",
":",
"string",
"{",
"$",
"result",
"=",
"$",
"query",
";",
"if",
"(",
"$",
"query",
")",
"{",
"$",
"result",
"=",
"'https://www.google.com/maps/search/?api=1&query='",
".",
"$",
"query",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Google maps link.
@see https://developers.google.com/maps/documentation/urls/guide
@param string $query
@return string
|
[
"Google",
"maps",
"link",
"."
] |
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
|
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L94-L101
|
235,574
|
geniv/nette-filters
|
src/FilterLatte.php
|
FilterLatte.toUrl
|
public static function toUrl(string $url, string $scheme = 'http://'): string
{
$http = preg_match('/^http[s]?:\/\//', $url);
return (!$http ? $scheme : '') . $url;
}
|
php
|
public static function toUrl(string $url, string $scheme = 'http://'): string
{
$http = preg_match('/^http[s]?:\/\//', $url);
return (!$http ? $scheme : '') . $url;
}
|
[
"public",
"static",
"function",
"toUrl",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"scheme",
"=",
"'http://'",
")",
":",
"string",
"{",
"$",
"http",
"=",
"preg_match",
"(",
"'/^http[s]?:\\/\\//'",
",",
"$",
"url",
")",
";",
"return",
"(",
"!",
"$",
"http",
"?",
"$",
"scheme",
":",
"''",
")",
".",
"$",
"url",
";",
"}"
] |
To url.
@param string $url
@param string $scheme
@return string
|
[
"To",
"url",
"."
] |
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
|
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L111-L115
|
235,575
|
geniv/nette-filters
|
src/FilterLatte.php
|
FilterLatte.realUrl
|
public static function realUrl(string $value)
{
list($scheme, $url) = explode('//', $value);
$reverse = explode('/', $url);
$arr = [];
foreach ($reverse as $item) {
$arr[] = $item;
if ($item == '..') {
array_pop($arr); // remove 2x from array stack
array_pop($arr);
}
}
return $scheme . '//' . implode('/', $arr);
}
|
php
|
public static function realUrl(string $value)
{
list($scheme, $url) = explode('//', $value);
$reverse = explode('/', $url);
$arr = [];
foreach ($reverse as $item) {
$arr[] = $item;
if ($item == '..') {
array_pop($arr); // remove 2x from array stack
array_pop($arr);
}
}
return $scheme . '//' . implode('/', $arr);
}
|
[
"public",
"static",
"function",
"realUrl",
"(",
"string",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"scheme",
",",
"$",
"url",
")",
"=",
"explode",
"(",
"'//'",
",",
"$",
"value",
")",
";",
"$",
"reverse",
"=",
"explode",
"(",
"'/'",
",",
"$",
"url",
")",
";",
"$",
"arr",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reverse",
"as",
"$",
"item",
")",
"{",
"$",
"arr",
"[",
"]",
"=",
"$",
"item",
";",
"if",
"(",
"$",
"item",
"==",
"'..'",
")",
"{",
"array_pop",
"(",
"$",
"arr",
")",
";",
"// remove 2x from array stack",
"array_pop",
"(",
"$",
"arr",
")",
";",
"}",
"}",
"return",
"$",
"scheme",
".",
"'//'",
".",
"implode",
"(",
"'/'",
",",
"$",
"arr",
")",
";",
"}"
] |
Real url.
@param string $value
@return string
|
[
"Real",
"url",
"."
] |
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
|
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L124-L137
|
235,576
|
rollun-com/rollun-permission
|
src/Permission/src/Authentication/AuthenticationChain.php
|
AuthenticationChain.authenticate
|
public function authenticate(ServerRequestInterface $request): ?UserInterface
{
foreach ($this->authenticationServices as $authenticationService) {
$user = $authenticationService->authenticate($request);
if ($user !== null) {
return $user;
}
}
return null;
}
|
php
|
public function authenticate(ServerRequestInterface $request): ?UserInterface
{
foreach ($this->authenticationServices as $authenticationService) {
$user = $authenticationService->authenticate($request);
if ($user !== null) {
return $user;
}
}
return null;
}
|
[
"public",
"function",
"authenticate",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"?",
"UserInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"authenticationServices",
"as",
"$",
"authenticationService",
")",
"{",
"$",
"user",
"=",
"$",
"authenticationService",
"->",
"authenticate",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"user",
"!==",
"null",
")",
"{",
"return",
"$",
"user",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Chain available authentication services and try authenticate using it
If no one authentication service can authenticate return null
Other way return user from first service that can authenticate
Last authentication service provide an unauthorized response if no one can authenticate
@param ServerRequestInterface $request
@return UserInterface
|
[
"Chain",
"available",
"authentication",
"services",
"and",
"try",
"authenticate",
"using",
"it",
"If",
"no",
"one",
"authentication",
"service",
"can",
"authenticate",
"return",
"null",
"Other",
"way",
"return",
"user",
"from",
"first",
"service",
"that",
"can",
"authenticate",
"Last",
"authentication",
"service",
"provide",
"an",
"unauthorized",
"response",
"if",
"no",
"one",
"can",
"authenticate"
] |
9f58c814337fcfd1e52ecfbf496f95d276d8217e
|
https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/Authentication/AuthenticationChain.php#L50-L61
|
235,577
|
AnonymPHP/Anonym-Library
|
src/Anonym/Application/ServiceProvider.php
|
ServiceProvider.registerProvider
|
public function registerProvider($provider){
$providers = (array) $provider;
foreach($providers as $provider){
$this->app()['config']->add('general.providers', $provider);
}
}
|
php
|
public function registerProvider($provider){
$providers = (array) $provider;
foreach($providers as $provider){
$this->app()['config']->add('general.providers', $provider);
}
}
|
[
"public",
"function",
"registerProvider",
"(",
"$",
"provider",
")",
"{",
"$",
"providers",
"=",
"(",
"array",
")",
"$",
"provider",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"app",
"(",
")",
"[",
"'config'",
"]",
"->",
"add",
"(",
"'general.providers'",
",",
"$",
"provider",
")",
";",
"}",
"}"
] |
You can register your providers with string or array data.
@param array|string $provider
@return $this
|
[
"You",
"can",
"register",
"your",
"providers",
"with",
"string",
"or",
"array",
"data",
"."
] |
c967ad804f84e8fb204593a0959cda2fed5ae075
|
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Application/ServiceProvider.php#L108-L114
|
235,578
|
marando/phpSOFA
|
src/Marando/IAU/iauApcs13.php
|
iauApcs13.Apcs13
|
public static function Apcs13($date1, $date2, array $pv, iauASTROM $astrom) {
$ehpv = [];
$ebpv = [];
/* Earth barycentric & heliocentric position/velocity (au, au/d). */
IAU::Epv00($date1, $date2, $ehpv, $ebpv);
/* Compute the star-independent astrometry parameters. */
IAU::Apcs($date1, $date2, $pv, $ebpv, $ehpv[0], $astrom);
/* Finished. */
}
|
php
|
public static function Apcs13($date1, $date2, array $pv, iauASTROM $astrom) {
$ehpv = [];
$ebpv = [];
/* Earth barycentric & heliocentric position/velocity (au, au/d). */
IAU::Epv00($date1, $date2, $ehpv, $ebpv);
/* Compute the star-independent astrometry parameters. */
IAU::Apcs($date1, $date2, $pv, $ebpv, $ehpv[0], $astrom);
/* Finished. */
}
|
[
"public",
"static",
"function",
"Apcs13",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"array",
"$",
"pv",
",",
"iauASTROM",
"$",
"astrom",
")",
"{",
"$",
"ehpv",
"=",
"[",
"]",
";",
"$",
"ebpv",
"=",
"[",
"]",
";",
"/* Earth barycentric & heliocentric position/velocity (au, au/d). */",
"IAU",
"::",
"Epv00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"ehpv",
",",
"$",
"ebpv",
")",
";",
"/* Compute the star-independent astrometry parameters. */",
"IAU",
"::",
"Apcs",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"pv",
",",
"$",
"ebpv",
",",
"$",
"ehpv",
"[",
"0",
"]",
",",
"$",
"astrom",
")",
";",
"/* Finished. */",
"}"
] |
- - - - - - - - - -
i a u A p c s 1 3
- - - - - - - - - -
For an observer whose geocentric position and velocity are known,
prepare star-independent astrometry parameters for transformations
between ICRS and GCRS. The Earth ephemeris is from SOFA models.
The parameters produced by this function are required in the space
motion, parallax, light deflection and aberration parts of the
astrometric transformation chain.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
date1 double TDB as a 2-part...
date2 double ...Julian Date (Note 1)
pv double[2][3] observer's geocentric pos/vel (Note 3)
Returned:
astrom iauASTROM* star-independent astrometry parameters:
pmt double PM time interval (SSB, Julian years)
eb double[3] SSB to observer (vector, au)
eh double[3] Sun to observer (unit vector)
em double distance from Sun to observer (au)
v double[3] barycentric observer velocity (vector, c)
bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor
bpn double[3][3] bias-precession-nutation matrix
along double unchanged
xpl double unchanged
ypl double unchanged
sphi double unchanged
cphi double unchanged
diurab double unchanged
eral double unchanged
refa double unchanged
refb double unchanged
Notes:
1) The TDB date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TDB)=2450123.7 could be expressed in any of these ways, among
others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in cases
where the loss of several decimal digits of resolution is
acceptable. The J2000 method is best matched to the way the
argument is handled internally and will deliver the optimum
resolution. The MJD method and the date & time methods are both
good compromises between resolution and convenience. For most
applications of this function the choice will not be at all
critical.
TT can be used instead of TDB without any significant impact on
accuracy.
2) All the vectors are with respect to BCRS axes.
3) The observer's position and velocity pv are geocentric but with
respect to BCRS axes, and in units of m and m/s. No assumptions
are made about proximity to the Earth, and the function can be
used for deep space applications as well as Earth orbit and
terrestrial.
4) In cases where the caller wishes to supply his own Earth
ephemeris, the function iauApcs can be used instead of the present
function.
5) This is one of several functions that inserts into the astrom
structure star-independent parameters needed for the chain of
astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed.
The various functions support different classes of observer and
portions of the transformation chain:
functions observer transformation
iauApcg iauApcg13 geocentric ICRS <-> GCRS
iauApci iauApci13 terrestrial ICRS <-> CIRS
iauApco iauApco13 terrestrial ICRS <-> observed
iauApcs iauApcs13 space ICRS <-> GCRS
iauAper iauAper13 terrestrial update Earth rotation
iauApio iauApio13 terrestrial CIRS <-> observed
Those with names ending in "13" use contemporary SOFA models to
compute the various ephemerides. The others accept ephemerides
supplied by the caller.
The transformation from ICRS to GCRS covers space motion,
parallax, light deflection, and aberration. From GCRS to CIRS
comprises frame bias and precession-nutation. From CIRS to
observed takes account of Earth rotation, polar motion, diurnal
aberration and parallax (unless subsumed into the ICRS <-> GCRS
transformation), and atmospheric refraction.
6) The context structure astrom produced by this function is used by
iauAtciq* and iauAticq*.
Called:
iauEpv00 Earth position and velocity
iauApcs astrometry parameters, ICRS-GCRS, space observer
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"A",
"p",
"c",
"s",
"1",
"3",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauApcs13.php#L127-L138
|
235,579
|
setrun/setrun-component-user
|
src/services/AuthService.php
|
AuthService.auth
|
public function auth(LoginForm $form): User
{
$this->checkFailure();
$user = $this->user->findByUsernameOrEmail($form->username);
if (!$user || !$user->validatePassword($form->password)) {
$this->setFailure();
throw new \DomainException($this->i18n->t('setrun/user', 'Wrong Username or Password'));
}
if ($user && $user->status == User::STATUS_BLOCKED) {
throw new \DomainException($this->i18n->t('setrun/user', 'Account temporarily blocked'));
}
if ($user && $user->status == User::STATUS_WAIT) {
throw new \DomainException($this->i18n->t('setrun/user', 'Account not confirmed'));
}
$this->removeFailure();
return $user;
}
|
php
|
public function auth(LoginForm $form): User
{
$this->checkFailure();
$user = $this->user->findByUsernameOrEmail($form->username);
if (!$user || !$user->validatePassword($form->password)) {
$this->setFailure();
throw new \DomainException($this->i18n->t('setrun/user', 'Wrong Username or Password'));
}
if ($user && $user->status == User::STATUS_BLOCKED) {
throw new \DomainException($this->i18n->t('setrun/user', 'Account temporarily blocked'));
}
if ($user && $user->status == User::STATUS_WAIT) {
throw new \DomainException($this->i18n->t('setrun/user', 'Account not confirmed'));
}
$this->removeFailure();
return $user;
}
|
[
"public",
"function",
"auth",
"(",
"LoginForm",
"$",
"form",
")",
":",
"User",
"{",
"$",
"this",
"->",
"checkFailure",
"(",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"user",
"->",
"findByUsernameOrEmail",
"(",
"$",
"form",
"->",
"username",
")",
";",
"if",
"(",
"!",
"$",
"user",
"||",
"!",
"$",
"user",
"->",
"validatePassword",
"(",
"$",
"form",
"->",
"password",
")",
")",
"{",
"$",
"this",
"->",
"setFailure",
"(",
")",
";",
"throw",
"new",
"\\",
"DomainException",
"(",
"$",
"this",
"->",
"i18n",
"->",
"t",
"(",
"'setrun/user'",
",",
"'Wrong Username or Password'",
")",
")",
";",
"}",
"if",
"(",
"$",
"user",
"&&",
"$",
"user",
"->",
"status",
"==",
"User",
"::",
"STATUS_BLOCKED",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"$",
"this",
"->",
"i18n",
"->",
"t",
"(",
"'setrun/user'",
",",
"'Account temporarily blocked'",
")",
")",
";",
"}",
"if",
"(",
"$",
"user",
"&&",
"$",
"user",
"->",
"status",
"==",
"User",
"::",
"STATUS_WAIT",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"$",
"this",
"->",
"i18n",
"->",
"t",
"(",
"'setrun/user'",
",",
"'Account not confirmed'",
")",
")",
";",
"}",
"$",
"this",
"->",
"removeFailure",
"(",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
User auth.
@param LoginForm $form
@return User
|
[
"User",
"auth",
"."
] |
6aca4c62f099918032b66da1f94d7565694a0735
|
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/services/AuthService.php#L57-L73
|
235,580
|
setrun/setrun-component-user
|
src/services/AuthService.php
|
AuthService.checkFailure
|
private function checkFailure() : void
{
$failure = (int) $this->session->get('failure', 0);
$time = (int) $this->session->get('failure_time', time());
if ($failure >= static::FAILURE) {
if ($time >= time()) {
throw new \DomainException($this->i18n->t(
'setrun/user',
'Form is blocked for {min} minutes',
['min' => static::FAILURE_TIME / 60])
);
}
$this->removeFailure();
}
}
|
php
|
private function checkFailure() : void
{
$failure = (int) $this->session->get('failure', 0);
$time = (int) $this->session->get('failure_time', time());
if ($failure >= static::FAILURE) {
if ($time >= time()) {
throw new \DomainException($this->i18n->t(
'setrun/user',
'Form is blocked for {min} minutes',
['min' => static::FAILURE_TIME / 60])
);
}
$this->removeFailure();
}
}
|
[
"private",
"function",
"checkFailure",
"(",
")",
":",
"void",
"{",
"$",
"failure",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'failure'",
",",
"0",
")",
";",
"$",
"time",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'failure_time'",
",",
"time",
"(",
")",
")",
";",
"if",
"(",
"$",
"failure",
">=",
"static",
"::",
"FAILURE",
")",
"{",
"if",
"(",
"$",
"time",
">=",
"time",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"$",
"this",
"->",
"i18n",
"->",
"t",
"(",
"'setrun/user'",
",",
"'Form is blocked for {min} minutes'",
",",
"[",
"'min'",
"=>",
"static",
"::",
"FAILURE_TIME",
"/",
"60",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"removeFailure",
"(",
")",
";",
"}",
"}"
] |
Check for failure of access.
@return void
|
[
"Check",
"for",
"failure",
"of",
"access",
"."
] |
6aca4c62f099918032b66da1f94d7565694a0735
|
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/services/AuthService.php#L79-L93
|
235,581
|
setrun/setrun-component-user
|
src/services/AuthService.php
|
AuthService.setFailure
|
private function setFailure() : void
{
$this->session->set('failure', $this->session->get('failure') + 1);
$this->session->set('failure_time', time() + (int) static::FAILURE_TIME);
}
|
php
|
private function setFailure() : void
{
$this->session->set('failure', $this->session->get('failure') + 1);
$this->session->set('failure_time', time() + (int) static::FAILURE_TIME);
}
|
[
"private",
"function",
"setFailure",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"'failure'",
",",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'failure'",
")",
"+",
"1",
")",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"'failure_time'",
",",
"time",
"(",
")",
"+",
"(",
"int",
")",
"static",
"::",
"FAILURE_TIME",
")",
";",
"}"
] |
Set a failure.
@return void
|
[
"Set",
"a",
"failure",
"."
] |
6aca4c62f099918032b66da1f94d7565694a0735
|
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/services/AuthService.php#L99-L103
|
235,582
|
okaufmann/google-movies-client
|
src/GoogleMoviesClient/HttpClient/Adapter/AbstractAdapter.php
|
AbstractAdapter.createApiException
|
protected function createApiException(Request $request, Response $response)
{
//$errors = json_decode((string) $response->getBody());
return new HttpRequestException(
$response->getCode(),
$response->getBody(),
$request,
$response
);
}
|
php
|
protected function createApiException(Request $request, Response $response)
{
//$errors = json_decode((string) $response->getBody());
return new HttpRequestException(
$response->getCode(),
$response->getBody(),
$request,
$response
);
}
|
[
"protected",
"function",
"createApiException",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"//$errors = json_decode((string) $response->getBody());",
"return",
"new",
"HttpRequestException",
"(",
"$",
"response",
"->",
"getCode",
"(",
")",
",",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}"
] |
Create the unified exception to throw.
@param Request $request
@param Response $response
@return HttpRequestException
|
[
"Create",
"the",
"unified",
"exception",
"to",
"throw",
"."
] |
70ad4d3c640016cf24a0fd45ed8509029a6c02c6
|
https://github.com/okaufmann/google-movies-client/blob/70ad4d3c640016cf24a0fd45ed8509029a6c02c6/src/GoogleMoviesClient/HttpClient/Adapter/AbstractAdapter.php#L33-L43
|
235,583
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.detachFromDuty
|
public function detachFromDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($duty_id)) $fields['duty_id'] = $duty_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'duty');
}
|
php
|
public function detachFromDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($duty_id)) $fields['duty_id'] = $duty_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'duty');
}
|
[
"public",
"function",
"detachFromDuty",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"duty_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"duty_id",
")",
")",
"$",
"fields",
"[",
"'duty_id'",
"]",
"=",
"$",
"duty_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_del",
"(",
"$",
"fields",
",",
"'duty'",
")",
";",
"}"
] |
Detach Account From Duty
Detach this account from a duty. Using either the account ID, identifier, or username with either the duty ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $duty_id
@param string $code
@return \Unirest\Response
|
[
"Detach",
"Account",
"From",
"Duty"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L307-L318
|
235,584
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.attachToDuty
|
public function attachToDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($duty_id)) $fields['duty_id'] = $duty_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'duty');
}
|
php
|
public function attachToDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($duty_id)) $fields['duty_id'] = $duty_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'duty');
}
|
[
"public",
"function",
"attachToDuty",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"duty_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"duty_id",
")",
")",
"$",
"fields",
"[",
"'duty_id'",
"]",
"=",
"$",
"duty_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_post",
"(",
"$",
"fields",
",",
"'duty'",
")",
";",
"}"
] |
Attach Account To Duty
Attach this account to a duty. Using either the account ID, identifier, or username with either the duty ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $duty_id
@param string $code
@return \Unirest\Response
|
[
"Attach",
"Account",
"To",
"Duty"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L332-L343
|
235,585
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.detachFromSchool
|
public function detachFromSchool($id = null, $identifier = null, $username = null, $school_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($school_id)) $fields['school_id'] = $school_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'school');
}
|
php
|
public function detachFromSchool($id = null, $identifier = null, $username = null, $school_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($school_id)) $fields['school_id'] = $school_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'school');
}
|
[
"public",
"function",
"detachFromSchool",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"school_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"school_id",
")",
")",
"$",
"fields",
"[",
"'school_id'",
"]",
"=",
"$",
"school_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_del",
"(",
"$",
"fields",
",",
"'school'",
")",
";",
"}"
] |
Detach Account From School
Detach this account from a school. Using either the account ID, identifier, or username with either the school ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $school_id
@param string $code
@return \Unirest\Response
|
[
"Detach",
"Account",
"From",
"School"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L357-L368
|
235,586
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.attachToSchool
|
public function attachToSchool($id = null, $identifier = null, $username = null, $school_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($school_id)) $fields['school_id'] = $school_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'school');
}
|
php
|
public function attachToSchool($id = null, $identifier = null, $username = null, $school_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($school_id)) $fields['school_id'] = $school_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'school');
}
|
[
"public",
"function",
"attachToSchool",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"school_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"school_id",
")",
")",
"$",
"fields",
"[",
"'school_id'",
"]",
"=",
"$",
"school_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_post",
"(",
"$",
"fields",
",",
"'school'",
")",
";",
"}"
] |
Attach Account To School
Attach this account to a school. Using either the account ID, identifier, or username with either the school ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $school_id
@param string $code
@return \Unirest\Response
|
[
"Attach",
"Account",
"To",
"School"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L382-L393
|
235,587
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.detachFromCourse
|
public function detachFromCourse($id = null, $identifier = null, $username = null, $course_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($course_id)) $fields['course_id'] = $course_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'course');
}
|
php
|
public function detachFromCourse($id = null, $identifier = null, $username = null, $course_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($course_id)) $fields['course_id'] = $course_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'course');
}
|
[
"public",
"function",
"detachFromCourse",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"course_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"course_id",
")",
")",
"$",
"fields",
"[",
"'course_id'",
"]",
"=",
"$",
"course_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_del",
"(",
"$",
"fields",
",",
"'course'",
")",
";",
"}"
] |
Detach Account From Course
Detach this account from a course. Using either the account ID, identifier, or username with either the course ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $course_id
@param string $code
@return \Unirest\Response
|
[
"Detach",
"Account",
"From",
"Course"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L407-L418
|
235,588
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.attachToCourse
|
public function attachToCourse($id = null, $identifier = null, $username = null, $course_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($course_id)) $fields['course_id'] = $course_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'course');
}
|
php
|
public function attachToCourse($id = null, $identifier = null, $username = null, $course_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($course_id)) $fields['course_id'] = $course_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'course');
}
|
[
"public",
"function",
"attachToCourse",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"course_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"course_id",
")",
")",
"$",
"fields",
"[",
"'course_id'",
"]",
"=",
"$",
"course_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_post",
"(",
"$",
"fields",
",",
"'course'",
")",
";",
"}"
] |
Attach Account To Course
Attach this account to a course. Using either the account ID, identifier, or username with either the course ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $course_id
@param string $code
@return \Unirest\Response
|
[
"Attach",
"Account",
"To",
"Course"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L432-L443
|
235,589
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.detachFromDepartment
|
public function detachFromDepartment($id = null, $identifier = null, $username = null, $department_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($department_id)) $fields['department_id'] = $department_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'department');
}
|
php
|
public function detachFromDepartment($id = null, $identifier = null, $username = null, $department_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($department_id)) $fields['department_id'] = $department_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'department');
}
|
[
"public",
"function",
"detachFromDepartment",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"department_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"department_id",
")",
")",
"$",
"fields",
"[",
"'department_id'",
"]",
"=",
"$",
"department_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_del",
"(",
"$",
"fields",
",",
"'department'",
")",
";",
"}"
] |
Detach Account From Department
Detach this account from a department. Using either the account ID, identifier, or username with either the department ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $department_id
@param string $code
@return \Unirest\Response
|
[
"Detach",
"Account",
"From",
"Department"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L457-L468
|
235,590
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.attachToDepartment
|
public function attachToDepartment($id = null, $identifier = null, $username = null, $department_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($department_id)) $fields['department_id'] = $department_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'department');
}
|
php
|
public function attachToDepartment($id = null, $identifier = null, $username = null, $department_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($department_id)) $fields['department_id'] = $department_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'department');
}
|
[
"public",
"function",
"attachToDepartment",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"department_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"department_id",
")",
")",
"$",
"fields",
"[",
"'department_id'",
"]",
"=",
"$",
"department_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_post",
"(",
"$",
"fields",
",",
"'department'",
")",
";",
"}"
] |
Attach Account To Department
Attach this account to a department. Using either the account ID, identifier, or username with either the department ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $department_id
@param string $code
@return \Unirest\Response
|
[
"Attach",
"Account",
"To",
"Department"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L482-L493
|
235,591
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.detachFromRoom
|
public function detachFromRoom($id = null, $identifier = null, $username = null, $room_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($room_id)) $fields['room_id'] = $room_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'room');
}
|
php
|
public function detachFromRoom($id = null, $identifier = null, $username = null, $room_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($room_id)) $fields['room_id'] = $room_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_del($fields, 'room');
}
|
[
"public",
"function",
"detachFromRoom",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"room_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"room_id",
")",
")",
"$",
"fields",
"[",
"'room_id'",
"]",
"=",
"$",
"room_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_del",
"(",
"$",
"fields",
",",
"'room'",
")",
";",
"}"
] |
Detach Account From Room
Detach this account from a room. Using either the account ID, identifier, or username with either the room ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $room_id
@param string $code
@return \Unirest\Response
|
[
"Detach",
"Account",
"From",
"Room"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L507-L518
|
235,592
|
OpenResourceManager/client-php
|
src/Client/Account.php
|
Account.attachToRoom
|
public function attachToRoom($id = null, $identifier = null, $username = null, $room_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($room_id)) $fields['room_id'] = $room_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'room');
}
|
php
|
public function attachToRoom($id = null, $identifier = null, $username = null, $room_id = null, $code = null)
{
$fields = [];
if (!is_null($id)) $fields['id'] = $id;
if (!is_null($identifier)) $fields['identifier'] = $identifier;
if (!is_null($username)) $fields['username'] = $username;
if (!is_null($room_id)) $fields['room_id'] = $room_id;
if (!is_null($code)) $fields['code'] = $code;
return $this->_post($fields, 'room');
}
|
[
"public",
"function",
"attachToRoom",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
",",
"$",
"username",
"=",
"null",
",",
"$",
"room_id",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"$",
"fields",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"identifier",
")",
")",
"$",
"fields",
"[",
"'identifier'",
"]",
"=",
"$",
"identifier",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"username",
")",
")",
"$",
"fields",
"[",
"'username'",
"]",
"=",
"$",
"username",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"room_id",
")",
")",
"$",
"fields",
"[",
"'room_id'",
"]",
"=",
"$",
"room_id",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"code",
")",
")",
"$",
"fields",
"[",
"'code'",
"]",
"=",
"$",
"code",
";",
"return",
"$",
"this",
"->",
"_post",
"(",
"$",
"fields",
",",
"'room'",
")",
";",
"}"
] |
Attach Account To Room
Attach this account to a room. Using either the account ID, identifier, or username with either the room ID or code.
@param int $id
@param string $identifier
@param string $username
@param int $room_id
@param string $code
@return \Unirest\Response
|
[
"Attach",
"Account",
"To",
"Room"
] |
fa468e3425d32f97294fefed77a7f096f3f8cc86
|
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L532-L543
|
235,593
|
wasabi-cms/core
|
src/Controller/BackendAppController.php
|
BackendAppController._allow
|
protected function _allow()
{
$url = Wasabi::getCurrentUrlArray();
if ($this->Guardian->isGuestAction($url)) {
$this->Auth->allow($this->request->params['action']);
}
}
|
php
|
protected function _allow()
{
$url = Wasabi::getCurrentUrlArray();
if ($this->Guardian->isGuestAction($url)) {
$this->Auth->allow($this->request->params['action']);
}
}
|
[
"protected",
"function",
"_allow",
"(",
")",
"{",
"$",
"url",
"=",
"Wasabi",
"::",
"getCurrentUrlArray",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"Guardian",
"->",
"isGuestAction",
"(",
"$",
"url",
")",
")",
"{",
"$",
"this",
"->",
"Auth",
"->",
"allow",
"(",
"$",
"this",
"->",
"request",
"->",
"params",
"[",
"'action'",
"]",
")",
";",
"}",
"}"
] |
Allow all guest actions.
@return void
|
[
"Allow",
"all",
"guest",
"actions",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/BackendAppController.php#L198-L204
|
235,594
|
covex-nn/vfs
|
src/Partition.php
|
Partition.getList
|
public function getList(string $path)
{
$entity = $this->getEntity($path);
if (null !== $entity && $entity->file_exists() && $entity->is_dir()) {
$files = [];
$changes = $this->getChanges();
$own = $changes->own($path);
if (!($entity instanceof VirtualInterface)) {
$directory = $this->getRoot();
$directoryPath = $directory->path().'/'.$path;
$dirHandler = opendir($directoryPath);
if ($dirHandler) {
while (true) {
$file = readdir($dirHandler);
if (false === $file) {
break;
} elseif ('.' == $file || '..' == $file) {
continue;
}
$changesKey = ($path ? $path.'/' : '').$file;
if (isset($own[$changesKey])) {
continue;
}
$files[$changesKey] = Entity::newInstance($changesKey);
}
closedir($dirHandler);
}
}
foreach ($own as $changesKey => $file) {
/* @var $file EntityInterface */
if ($file instanceof DeletedInterface) {
unset($own[$changesKey]);
}
}
$mergedFiles = array_merge($files, $own);
ksort($mergedFiles);
$result = array_values($mergedFiles);
} else {
$result = null;
}
return $result;
}
|
php
|
public function getList(string $path)
{
$entity = $this->getEntity($path);
if (null !== $entity && $entity->file_exists() && $entity->is_dir()) {
$files = [];
$changes = $this->getChanges();
$own = $changes->own($path);
if (!($entity instanceof VirtualInterface)) {
$directory = $this->getRoot();
$directoryPath = $directory->path().'/'.$path;
$dirHandler = opendir($directoryPath);
if ($dirHandler) {
while (true) {
$file = readdir($dirHandler);
if (false === $file) {
break;
} elseif ('.' == $file || '..' == $file) {
continue;
}
$changesKey = ($path ? $path.'/' : '').$file;
if (isset($own[$changesKey])) {
continue;
}
$files[$changesKey] = Entity::newInstance($changesKey);
}
closedir($dirHandler);
}
}
foreach ($own as $changesKey => $file) {
/* @var $file EntityInterface */
if ($file instanceof DeletedInterface) {
unset($own[$changesKey]);
}
}
$mergedFiles = array_merge($files, $own);
ksort($mergedFiles);
$result = array_values($mergedFiles);
} else {
$result = null;
}
return $result;
}
|
[
"public",
"function",
"getList",
"(",
"string",
"$",
"path",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getEntity",
"(",
"$",
"path",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"entity",
"&&",
"$",
"entity",
"->",
"file_exists",
"(",
")",
"&&",
"$",
"entity",
"->",
"is_dir",
"(",
")",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"$",
"changes",
"=",
"$",
"this",
"->",
"getChanges",
"(",
")",
";",
"$",
"own",
"=",
"$",
"changes",
"->",
"own",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"(",
"$",
"entity",
"instanceof",
"VirtualInterface",
")",
")",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"getRoot",
"(",
")",
";",
"$",
"directoryPath",
"=",
"$",
"directory",
"->",
"path",
"(",
")",
".",
"'/'",
".",
"$",
"path",
";",
"$",
"dirHandler",
"=",
"opendir",
"(",
"$",
"directoryPath",
")",
";",
"if",
"(",
"$",
"dirHandler",
")",
"{",
"while",
"(",
"true",
")",
"{",
"$",
"file",
"=",
"readdir",
"(",
"$",
"dirHandler",
")",
";",
"if",
"(",
"false",
"===",
"$",
"file",
")",
"{",
"break",
";",
"}",
"elseif",
"(",
"'.'",
"==",
"$",
"file",
"||",
"'..'",
"==",
"$",
"file",
")",
"{",
"continue",
";",
"}",
"$",
"changesKey",
"=",
"(",
"$",
"path",
"?",
"$",
"path",
".",
"'/'",
":",
"''",
")",
".",
"$",
"file",
";",
"if",
"(",
"isset",
"(",
"$",
"own",
"[",
"$",
"changesKey",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"files",
"[",
"$",
"changesKey",
"]",
"=",
"Entity",
"::",
"newInstance",
"(",
"$",
"changesKey",
")",
";",
"}",
"closedir",
"(",
"$",
"dirHandler",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"own",
"as",
"$",
"changesKey",
"=>",
"$",
"file",
")",
"{",
"/* @var $file EntityInterface */",
"if",
"(",
"$",
"file",
"instanceof",
"DeletedInterface",
")",
"{",
"unset",
"(",
"$",
"own",
"[",
"$",
"changesKey",
"]",
")",
";",
"}",
"}",
"$",
"mergedFiles",
"=",
"array_merge",
"(",
"$",
"files",
",",
"$",
"own",
")",
";",
"ksort",
"(",
"$",
"mergedFiles",
")",
";",
"$",
"result",
"=",
"array_values",
"(",
"$",
"mergedFiles",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"null",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get list of files inside directory path.
@return EntityInterface[]|null
|
[
"Get",
"list",
"of",
"files",
"inside",
"directory",
"path",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L145-L194
|
235,595
|
covex-nn/vfs
|
src/Partition.php
|
Partition.tempnam
|
public function tempnam(): string
{
$root = $this->getFsRoot();
do {
++$this->fsCounter;
$name = $root.'/'.$this->fsCounter;
} while (file_exists($name));
return $name;
}
|
php
|
public function tempnam(): string
{
$root = $this->getFsRoot();
do {
++$this->fsCounter;
$name = $root.'/'.$this->fsCounter;
} while (file_exists($name));
return $name;
}
|
[
"public",
"function",
"tempnam",
"(",
")",
":",
"string",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"getFsRoot",
"(",
")",
";",
"do",
"{",
"++",
"$",
"this",
"->",
"fsCounter",
";",
"$",
"name",
"=",
"$",
"root",
".",
"'/'",
".",
"$",
"this",
"->",
"fsCounter",
";",
"}",
"while",
"(",
"file_exists",
"(",
"$",
"name",
")",
")",
";",
"return",
"$",
"name",
";",
"}"
] |
Get unique filename.
|
[
"Get",
"unique",
"filename",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L384-L393
|
235,596
|
covex-nn/vfs
|
src/Partition.php
|
Partition.commit
|
public function commit(): void
{
if (null !== $this->changes) {
$this->commitInternal($this->changes);
$this->changes = null;
}
}
|
php
|
public function commit(): void
{
if (null !== $this->changes) {
$this->commitInternal($this->changes);
$this->changes = null;
}
}
|
[
"public",
"function",
"commit",
"(",
")",
":",
"void",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"changes",
")",
"{",
"$",
"this",
"->",
"commitInternal",
"(",
"$",
"this",
"->",
"changes",
")",
";",
"$",
"this",
"->",
"changes",
"=",
"null",
";",
"}",
"}"
] |
Commit changes to real FS.
|
[
"Commit",
"changes",
"to",
"real",
"FS",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L457-L464
|
235,597
|
covex-nn/vfs
|
src/Partition.php
|
Partition.setRoot
|
protected function setRoot(EntityInterface $entity): void
{
if (!$entity->file_exists() || !$entity->is_dir()) {
throw new Exception('Root directory is not valid');
}
$this->root = $entity;
}
|
php
|
protected function setRoot(EntityInterface $entity): void
{
if (!$entity->file_exists() || !$entity->is_dir()) {
throw new Exception('Root directory is not valid');
}
$this->root = $entity;
}
|
[
"protected",
"function",
"setRoot",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"entity",
"->",
"file_exists",
"(",
")",
"||",
"!",
"$",
"entity",
"->",
"is_dir",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Root directory is not valid'",
")",
";",
"}",
"$",
"this",
"->",
"root",
"=",
"$",
"entity",
";",
"}"
] |
Init root.
|
[
"Init",
"root",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L469-L476
|
235,598
|
covex-nn/vfs
|
src/Partition.php
|
Partition.getChanges
|
protected function getChanges(): Changes
{
if (null === $this->changes) {
$this->changes = new Changes();
}
return $this->changes;
}
|
php
|
protected function getChanges(): Changes
{
if (null === $this->changes) {
$this->changes = new Changes();
}
return $this->changes;
}
|
[
"protected",
"function",
"getChanges",
"(",
")",
":",
"Changes",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"changes",
")",
"{",
"$",
"this",
"->",
"changes",
"=",
"new",
"Changes",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"changes",
";",
"}"
] |
Get FS-changes object.
|
[
"Get",
"FS",
"-",
"changes",
"object",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L481-L488
|
235,599
|
covex-nn/vfs
|
src/Partition.php
|
Partition.commitInternal
|
private function commitInternal(Changes $changes, string $path = ''): void
{
$root = $this->getRoot();
$rootpath = $root->path();
if ($path) {
$path .= '/';
}
$own = $changes->own();
foreach ($own as $filename => $vEntity) {
$filepath = $path.$filename;
$rPath = $rootpath.'/'.$filepath;
/* @var EntityAbstract|VirtualInterface $vEntity */
$vExists = $vEntity->file_exists();
$rDeleted = false;
$rEntity = $vEntity;
do {
$rEntity = $rEntity->getRealEntity();
$rDeleted = $rDeleted || !$rEntity->file_exists();
} while ($rEntity instanceof VirtualInterface);
$rExists = $rEntity->file_exists();
if ($rExists && !$vExists) {
$rDeleted = true;
}
if (!$vExists && !$rExists) {
continue;
} elseif ($rDeleted) {
if ($rExists) {
$this->fs->remove($rPath);
}
if ($vExists) {
$this->copyChanges($filepath);
}
} else {
if ($vEntity->is_file()) {
unlink($rPath);
copy($vEntity->path(), $rPath);
}
}
}
$subtrees = $changes->sublists();
foreach ($subtrees as $filename => $tree) {
if (!isset($own[$filename])) {
$this->commitInternal($tree, $path.$filename);
}
}
}
|
php
|
private function commitInternal(Changes $changes, string $path = ''): void
{
$root = $this->getRoot();
$rootpath = $root->path();
if ($path) {
$path .= '/';
}
$own = $changes->own();
foreach ($own as $filename => $vEntity) {
$filepath = $path.$filename;
$rPath = $rootpath.'/'.$filepath;
/* @var EntityAbstract|VirtualInterface $vEntity */
$vExists = $vEntity->file_exists();
$rDeleted = false;
$rEntity = $vEntity;
do {
$rEntity = $rEntity->getRealEntity();
$rDeleted = $rDeleted || !$rEntity->file_exists();
} while ($rEntity instanceof VirtualInterface);
$rExists = $rEntity->file_exists();
if ($rExists && !$vExists) {
$rDeleted = true;
}
if (!$vExists && !$rExists) {
continue;
} elseif ($rDeleted) {
if ($rExists) {
$this->fs->remove($rPath);
}
if ($vExists) {
$this->copyChanges($filepath);
}
} else {
if ($vEntity->is_file()) {
unlink($rPath);
copy($vEntity->path(), $rPath);
}
}
}
$subtrees = $changes->sublists();
foreach ($subtrees as $filename => $tree) {
if (!isset($own[$filename])) {
$this->commitInternal($tree, $path.$filename);
}
}
}
|
[
"private",
"function",
"commitInternal",
"(",
"Changes",
"$",
"changes",
",",
"string",
"$",
"path",
"=",
"''",
")",
":",
"void",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"getRoot",
"(",
")",
";",
"$",
"rootpath",
"=",
"$",
"root",
"->",
"path",
"(",
")",
";",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"path",
".=",
"'/'",
";",
"}",
"$",
"own",
"=",
"$",
"changes",
"->",
"own",
"(",
")",
";",
"foreach",
"(",
"$",
"own",
"as",
"$",
"filename",
"=>",
"$",
"vEntity",
")",
"{",
"$",
"filepath",
"=",
"$",
"path",
".",
"$",
"filename",
";",
"$",
"rPath",
"=",
"$",
"rootpath",
".",
"'/'",
".",
"$",
"filepath",
";",
"/* @var EntityAbstract|VirtualInterface $vEntity */",
"$",
"vExists",
"=",
"$",
"vEntity",
"->",
"file_exists",
"(",
")",
";",
"$",
"rDeleted",
"=",
"false",
";",
"$",
"rEntity",
"=",
"$",
"vEntity",
";",
"do",
"{",
"$",
"rEntity",
"=",
"$",
"rEntity",
"->",
"getRealEntity",
"(",
")",
";",
"$",
"rDeleted",
"=",
"$",
"rDeleted",
"||",
"!",
"$",
"rEntity",
"->",
"file_exists",
"(",
")",
";",
"}",
"while",
"(",
"$",
"rEntity",
"instanceof",
"VirtualInterface",
")",
";",
"$",
"rExists",
"=",
"$",
"rEntity",
"->",
"file_exists",
"(",
")",
";",
"if",
"(",
"$",
"rExists",
"&&",
"!",
"$",
"vExists",
")",
"{",
"$",
"rDeleted",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"vExists",
"&&",
"!",
"$",
"rExists",
")",
"{",
"continue",
";",
"}",
"elseif",
"(",
"$",
"rDeleted",
")",
"{",
"if",
"(",
"$",
"rExists",
")",
"{",
"$",
"this",
"->",
"fs",
"->",
"remove",
"(",
"$",
"rPath",
")",
";",
"}",
"if",
"(",
"$",
"vExists",
")",
"{",
"$",
"this",
"->",
"copyChanges",
"(",
"$",
"filepath",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"vEntity",
"->",
"is_file",
"(",
")",
")",
"{",
"unlink",
"(",
"$",
"rPath",
")",
";",
"copy",
"(",
"$",
"vEntity",
"->",
"path",
"(",
")",
",",
"$",
"rPath",
")",
";",
"}",
"}",
"}",
"$",
"subtrees",
"=",
"$",
"changes",
"->",
"sublists",
"(",
")",
";",
"foreach",
"(",
"$",
"subtrees",
"as",
"$",
"filename",
"=>",
"$",
"tree",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"own",
"[",
"$",
"filename",
"]",
")",
")",
"{",
"$",
"this",
"->",
"commitInternal",
"(",
"$",
"tree",
",",
"$",
"path",
".",
"$",
"filename",
")",
";",
"}",
"}",
"}"
] |
Commit changes into real FS.
Если удалено и не существовало с самого начала
- ничего не делаем
Иначе если когда-то не существовало
- удаляем всё RДерево
- Если сейчас существует, то
- переносим всё VДерево
Иначе если это файл, то
- удаляем RФайл
- копируем VФайл на место RФайла
По всем subtree
- сделать тоже самое, если не было собственных изменений
|
[
"Commit",
"changes",
"into",
"real",
"FS",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L506-L558
|
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.